From patchwork Fri Jun 19 14:32:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 191206 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp591981ilo; Fri, 19 Jun 2020 07:43:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzua1k2moYRQ3hmPdAaD0hRptMAYnlA9DnCL3Zz8DhZjRwnz3DiSAtgw1QCNyH5bBhYeAoO X-Received: by 2002:a17:906:af84:: with SMTP id mj4mr3564031ejb.473.1592577810231; Fri, 19 Jun 2020 07:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592577810; cv=none; d=google.com; s=arc-20160816; b=i7JmxoagsL32Cql7U8abfR8O/pTmO3f0XBfL+U2WZN3aBsqeZsv7b5QYj/OT46c980 0YufqraHfvUBFkJr8xpFRUQuFgsioWsINamLJ8GSm0tiBc8i4nDf46c1WrlRGMKt97SH kicV/8tMHGLN934LATi10j38CP/Kgh4CfndADfxpCW6tph7bM86iXIi8fxu2g84lsfId GU1wDm4U1S8h0td1fDImv/9O4hNcmlzMYC1XbuLjLBqheyR2jt2AG5AXQyifOZutXtI1 b0mXNB+CIv4P45DiWaWe6pIGdp4KhJyFUBtP5AQhpck1IdfEhKROapYbNDHt8TY2CtVT uTDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hYcByPDFNPpIRNXhqhwRcHzHjZCwpeSbVfSQeWhfeZg=; b=JC0wOvTP63sXo3Tm1jCkq2Otui+9XrRguKmNDO9rJJqJs5Ml/RIh9rF+sykEL2kfyo +rW6PsYj7uxr4gbxl9adepLC+fImX14Gbu3NzA/+7dw3xTnj38/aaMbViF79uGLyHkR6 yBsikIjHMrn0UZzO4lyo0Q+WYP4hpEyhxnACnrCYeKpXNUgObZFhGiMqOfpF9hnOLuHV JlejevK+YIcl2WCazFUcqA8BHPuwFihIcfRL+AocQf6dveTQ2y2bTYRsMXrDIIiSCgZw Z/xUDumPBHaf2yN538BnMJK1aVYmmuh10htmTUZ5mqAHQtAjWLhTWs7YlXaeMR/tmaFq guNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="CiSYGn/3"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si3826706edr.130.2020.06.19.07.43.30; Fri, 19 Jun 2020 07:43:30 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="CiSYGn/3"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388096AbgFSOnZ (ORCPT + 15 others); Fri, 19 Jun 2020 10:43:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:34342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388466AbgFSOnS (ORCPT ); Fri, 19 Jun 2020 10:43:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8185020A8B; Fri, 19 Jun 2020 14:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592577798; bh=C2yTplfXnz0lDxjv2W+yY3SAan1E8kfM48w4mLwAyDU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CiSYGn/3c5plGQSjZeqUhTgLDMU+BeBRwbN80jce8NKrkDDV24s1udSftuUTjjD96 3keC2DQwUG5+1Y3BddVVyyUaeCSuVoePCCRbVNA8NcuPO80rBp6W+AdOnAblDgV8eq NZwrJtVnkm81KKwA8SVZLA4CdB1nZWKW9oVqqqLA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Florian Fainelli , Linus Walleij , Russell King , Sasha Levin Subject: [PATCH 4.9 064/128] ARM: 8978/1: mm: make act_mm() respect THREAD_SIZE Date: Fri, 19 Jun 2020 16:32:38 +0200 Message-Id: <20200619141623.596611139@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141620.148019466@linuxfoundation.org> References: <20200619141620.148019466@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Linus Walleij [ Upstream commit e1de94380af588bdf6ad6f0cc1f75004c35bc096 ] Recent work with KASan exposed the folling hard-coded bitmask in arch/arm/mm/proc-macros.S: bic rd, sp, #8128 bic rd, rd, #63 This forms the bitmask 0x1FFF that is coinciding with (PAGE_SIZE << THREAD_SIZE_ORDER) - 1, this code was assuming that THREAD_SIZE is always 8K (8192). As KASan was increasing THREAD_SIZE_ORDER to 2, I ran into this bug. Fix it by this little oneline suggested by Ard: bic rd, sp, #(THREAD_SIZE - 1) & ~63 Where THREAD_SIZE is defined using THREAD_SIZE_ORDER. We have to also include since the THREAD_SIZE expands to use the _AC() macro. Cc: Ard Biesheuvel Cc: Florian Fainelli Suggested-by: Ard Biesheuvel Signed-off-by: Linus Walleij Signed-off-by: Russell King Signed-off-by: Sasha Levin --- arch/arm/mm/proc-macros.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S index f8bb65032b79..796e8f675a93 100644 --- a/arch/arm/mm/proc-macros.S +++ b/arch/arm/mm/proc-macros.S @@ -4,6 +4,7 @@ * VMA_VM_FLAGS * VM_EXEC */ +#include #include #include @@ -34,7 +35,7 @@ * act_mm - get current->active_mm */ .macro act_mm, rd - bic \rd, sp, #8128 + bic \rd, sp, #(THREAD_SIZE - 1) & ~63 bic \rd, \rd, #63 ldr \rd, [\rd, #TI_TASK] ldr \rd, [\rd, #TSK_ACTIVE_MM]