Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp114725ybg; Mon, 8 Jun 2020 18:01:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMqWfmzlu1l2PmSuHFflypR1U6rLd7F03bSo99pNUTkoA8502G+WEHOq12VEVBtw13V3xD X-Received: by 2002:a17:906:c828:: with SMTP id dd8mr24043549ejb.550.1591664497868; Mon, 08 Jun 2020 18:01:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664497; cv=none; d=google.com; s=arc-20160816; b=UFOUjRF5a+qvCe+hUFMiRaCifd8sE3q44HxPcsiUb6XZEjoi7AmzEEzvPIy6RTIaqp rVgwMOviigHCnGLI8/ZaY5pASMOnhkvVhyfFjmWYKnKpRfgjZuvNWUOwJkffhaFHKhY/ /QU/PRtXCLX/fSuEbSJhmXq0t7cQaDf5chmXr9CsDqa5pX3+MrT79Xv1hYpfvJPoZ3iM QfS6riBoDgzbkFRfBmfy782LsN4ih7M7vpIDu+kBDmFSxbMeO2mrP2FTBhsmYRCfF3N4 nQilxFvce0/m3B1u49HzvRj8JXKQFbr6l06VwudeAuNa94gBqNCQXhHGgkDHVeZAiY+w YZvw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JyQ3X2TiDe+fHFyBZX6VluAjQK6hIr5E1IdwkkGi8y4=; b=y24uC1UaunuXa0FJh5cPEH3AFjs/k2OkzMsycXbplPQ5CIbSgbRvvg9FHe7zPC49oW iWbAL1ndEMsblAcpgU6SSUvFAM+sq7yDb32E9Fv2Uu/qlDNKkXWMfheCdNwARqjQIknn WBWxFQ1TSd8ZWITvlAaOv/bZNN+8juEWxwa7yWXoHqoluwxi8o87mdwmnHhkcrluxlpH /H1afxoJsZJkPXTDwOfY+9uGEZ2OJBLv5F5JacFQakq0BlNAgnVsz3XXoGOJWiZ5OPBN axJXMt8kthHyp51hQjfmFA5BGHENBGl4WTk5IUwPzb2N1gX7KSE3PMfH4lP0dxMkYiJ8 fmZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xFuu7ttf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 94si9990077edm.445.2020.06.08.18.01.10; Mon, 08 Jun 2020 18:01:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=xFuu7ttf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728190AbgFHXIe (ORCPT + 99 others); Mon, 8 Jun 2020 19:08:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:52096 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727125AbgFHXHi (ORCPT ); Mon, 8 Jun 2020 19:07:38 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2652E2086A; Mon, 8 Jun 2020 23:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657658; bh=asa8ONHvLvSLrkUv5RGqx9vJCcv05F7tTMtmQgGoEZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xFuu7ttfb3sjtwrGPnq9s6o7cB5lVCU14IoUfuvMsTMN4Dwus1QZH0/+C3YOA2Sek Lp60ROA2KDpvLj9IUXkwboIquzTIko5c48PcGNXE7Q0PTuw4UTz4XIUGJpSHebWMPY XmaEc1H/OyNSCgH2whzQlc9/iIywc0K23mka7mr8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Linus Walleij , Ard Biesheuvel , Florian Fainelli , Russell King , Sasha Levin , linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.7 070/274] ARM: 8978/1: mm: make act_mm() respect THREAD_SIZE Date: Mon, 8 Jun 2020 19:02:43 -0400 Message-Id: <20200608230607.3361041-70-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S index 5461d589a1e2..60ac7c5999a9 100644 --- a/arch/arm/mm/proc-macros.S +++ b/arch/arm/mm/proc-macros.S @@ -5,6 +5,7 @@ * VMA_VM_FLAGS * VM_EXEC */ +#include #include #include @@ -30,7 +31,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] .if (TSK_ACTIVE_MM > IMM12_MASK) -- 2.25.1