From patchwork Fri Jun 19 14:29:43 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: 191237 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp654948ilo; Fri, 19 Jun 2020 08:59:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMvlUAdmn5bukxDQ4BcCnt9QYkCH0r0bsrbOeLPVBWoMY4Ydvi8M7+9FoaH5+e660Mg2nV X-Received: by 2002:aa7:d7ca:: with SMTP id e10mr4065755eds.45.1592582377354; Fri, 19 Jun 2020 08:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592582377; cv=none; d=google.com; s=arc-20160816; b=EMeIoZfkJnFoHvWTNyP7RdmPZ5kZ72DZpkduDaGg8KL6f9y7YA3qID9j3/ho/xtO2d vTHLdFTGS9AVcVqSufVWgTFD++Rby6El/KnIuLhDGFiOvNNT7Uru/mBsj2qKI9h56GOb T7nDg1LWv6GV9plDuB/b2fSUyiEgiSdneeq/OSHBekavMhInzljOGNxaVF4aFsqBupT8 VrAWLXtkVxf4c7iNlAuXBsM+O3y/KBAdrFFlUGH8vZIRLbzEfpgsDYg0W1uKeRSplvhA YiO0TM4FwEm3k3K2PFcyVVTm2TNht/LD5rvMnJ6WSzrDgVFFjpFVr3jkSzfv0/cya9tP tPhg== 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=JyQ3X2TiDe+fHFyBZX6VluAjQK6hIr5E1IdwkkGi8y4=; b=nOm0PsAe9m1zbngLdSX8dYib0hq5IRNNR7/CBz1TLLs37XXg1dmYkCCr3N7ey1viJi 25BD/T2NMrDrc7uJSPC3LzAYZ4m+ZiC1rzha9nwIVqj4X3pz8AUAyWSCpBHb73Zqd9NA HUsRQlGdRDsJGMPEDm8nGN/R5BlNYDisBGYOlSX0ZIrJr9KlekQwODgqUI2QPZuOnAhT QXwveZg9AtkTM9waYiB9Li2UIwidiCDPV7LJUJcK04SWZglNxbBj/5CPDeMiQMEPT18B CejQFIkd/YY8o4W/sdlKTQb7qCrNgTyvEQh4Al5oM2tq3pa6SBYYvmhe8j90qZqO24gr INGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=td7Jr9+s; 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 no7si3745943ejb.145.2020.06.19.08.59.37; Fri, 19 Jun 2020 08:59:37 -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=td7Jr9+s; 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 S2392762AbgFSP7f (ORCPT + 15 others); Fri, 19 Jun 2020 11:59:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:49774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390420AbgFSPTJ (ORCPT ); Fri, 19 Jun 2020 11:19:09 -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 F2A0A2184D; Fri, 19 Jun 2020 15:19:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592579947; bh=asa8ONHvLvSLrkUv5RGqx9vJCcv05F7tTMtmQgGoEZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=td7Jr9+sxMVEAx+qz7lHYq+bde7pTrGeYQy9XWisn/at3cta0Ekb96CarJZw+uAw+ P0DSPAjXuHOEbC9mxsXhoISLJnK6GTkofib1KVdm+LSRA1VF6oPeaUb5O4qTidxi3U /c5XVvTcmLFazgkUpXidpbLvYNz9ol+gmihRPWV4= 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 5.7 065/376] ARM: 8978/1: mm: make act_mm() respect THREAD_SIZE Date: Fri, 19 Jun 2020 16:29:43 +0200 Message-Id: <20200619141713.430930456@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141710.350494719@linuxfoundation.org> References: <20200619141710.350494719@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 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)