From patchwork Fri Jun 19 14:31:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 191213 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp603309ilo; Fri, 19 Jun 2020 07:58:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4fs7lZZt7d93GvndO1zVbXJTmo2CH2XDgkKQBYvj0keEBvjm5hFZ4/XP4edp6UXMI1p/1 X-Received: by 2002:a05:6402:17af:: with SMTP id j15mr3620250edy.67.1592578681813; Fri, 19 Jun 2020 07:58:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592578681; cv=none; d=google.com; s=arc-20160816; b=XgD2Pf97KY53bBYo9HzrbxQ0cDdR1BO2DpT+Taq3pNYJt7FXF4GFCoaGyxa6L354w0 43D5zlDjHk6HG1uXwpNIdWjYSwWOhD8lcFt8EXRhZD5ygnxtDfJE/IVN0ZKQ7RxbowrU qNd6jYuXTZLrTGSXjQJvbqG09habCSN82xj3uFPPTM5wntRz4q5qCBaNFTcCMNdhiPmx zHOK7X5CIWh9HvyDPuXPAQK7WH02eduYsiXJFgar2SL6wXEYeRzY/LkG45vY9C4jcChV Ks8gJho+fzyt3PCEUQlcmCs5fp45Avno8n6L9CRngR1UXbOuaQdUJped94YDkQCIJJ/2 3Ljw== 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=xCAvDxfZKdINyAiAmNyMTJ6+mDM6W5hItcEehMLiz/5Pf/CbyHcA6gAR41OzQcjOiE CwcOAWXRmMTLQqFzRUXBAWssOfv3gnK5eYUx1N6J5eIaVhkE61nfwo7QP665n3z3jNYo vDyIdwzDzAo+IcGXjqciXdkpYndIXddp87PrnzBzl/EaSnti7Vfn3+5Hs6oWVm9VbSjx TjFxL7wP5JG14Xp9bMbhNi0U4N028nepqhVLdM++0T4LdOsdOb0RGZjPYqb8NQ6HYf/E EaIJxcWl1wMmu0ORnkLyP9arlj++Ws8aIu7KnurfUuov5PgFxJnBXZShus0XmeY0ui8s BQig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dKPzIRkA; 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 m19si5184729edb.335.2020.06.19.07.58.01; Fri, 19 Jun 2020 07:58:01 -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=dKPzIRkA; 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 S2390304AbgFSO57 (ORCPT + 15 others); Fri, 19 Jun 2020 10:57:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:53516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390324AbgFSO56 (ORCPT ); Fri, 19 Jun 2020 10:57:58 -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 3D62A217D8; Fri, 19 Jun 2020 14:57:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578678; bh=asa8ONHvLvSLrkUv5RGqx9vJCcv05F7tTMtmQgGoEZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dKPzIRkAcI4FOMEFYu9CVS/GEsHsMzNKeshnUQK/6VCB+N/fuYDsyBDtDufxRo5mp gKupyn5BjYtqz7YVg3ZOEoq3iYcFmk9eYpeAJ2sU3psehcXHsuKV7tIgFYP4nN9TUm JX28rO0dRZLSA2lYIWP2JBUftS5bQI43OuTfLKnQ= 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.19 114/267] ARM: 8978/1: mm: make act_mm() respect THREAD_SIZE Date: Fri, 19 Jun 2020 16:31:39 +0200 Message-Id: <20200619141654.313034096@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@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)