From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7005EC433DF for ; Mon, 8 Jun 2020 23:40:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E34F20760 for ; Mon, 8 Jun 2020 23:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591659620; bh=FdpUTESJ9f6tKR31I9XJPxlSZiptBJC8TU1UArWeeCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=PSgT51jSWHAIFO/gF8ciW6ODfBdVsY72pqsA3csz3JnZzFTuRXf6+SsE0w3xBzUOT YMROjO88qZB3WNLoQtpNdBuszsTrHF7q6UOue2P23aD82xbI45A+vCeAoaZ3jdPnkK yCQRqzSo2tKYTEV9bWwd/xANI/dQ4K/R29BrYJHk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387703AbgFHXkT (ORCPT ); Mon, 8 Jun 2020 19:40:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:56808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731881AbgFHX2D (ORCPT ); Mon, 8 Jun 2020 19:28:03 -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 E77BD20872; Mon, 8 Jun 2020 23:28:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591658882; bh=FdpUTESJ9f6tKR31I9XJPxlSZiptBJC8TU1UArWeeCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iAQyAxx9GP9vrFKPdTdBPHPEA78OMOm4sgiRl2LPdTdgCFIYWqJLr3kfjsxNj3MF5 JDUMrH8dnLaUxQVXm4y0KUOGGR3lXVJJOD6b9ZvcYHLd60UMwAraLBoq9DxhLxJGkV lJu7++ryr5T7VKaZPKuvS/BEp46VP/jxhKD1yuwE= 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 4.4 09/37] ARM: 8978/1: mm: make act_mm() respect THREAD_SIZE Date: Mon, 8 Jun 2020 19:27:21 -0400 Message-Id: <20200608232750.3370747-9-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608232750.3370747-1-sashal@kernel.org> References: <20200608232750.3370747-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 e6bfdcc381f8..1da55d34f4d6 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 @@ -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] ldr \rd, [\rd, #TSK_ACTIVE_MM] -- 2.25.1