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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 5B048C4CEC4 for ; Thu, 19 Sep 2019 22:08:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D70B21927 for ; Thu, 19 Sep 2019 22:08:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568930928; bh=ep+37ZmQaFe9khzB1Ublxq7aT04QtrRwFlS7AmDIN7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=SimvVztPy1k3hXZQAcXhci4z8e5e/9XGY+4pmoJsx0EdQB6nfh1znmj1mf91bTfzU 8zqUzplIQGmep6AImL2QtSvLfbIuzd9ZhxWhKmq0LmoC3gtdeBOWk3Vcm/zrV8gXrF y3nhPf3mFMZLA7Wa2/caHCqhwnigL4JgQVPHlBh4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393473AbfISWIm (ORCPT ); Thu, 19 Sep 2019 18:08:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:46578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393451AbfISWIh (ORCPT ); Thu, 19 Sep 2019 18:08:37 -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 23A1B21907; Thu, 19 Sep 2019 22:08:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568930916; bh=ep+37ZmQaFe9khzB1Ublxq7aT04QtrRwFlS7AmDIN7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f/kD/85Dj/Ulnvf9UKmKb+vXNlCuZPNSPtknzpklr+UHdoSveUWE2O/fdIeLGlXQL zW843VI5EU8MKMDrcGvgaNxrlLrFrhrIYgwkOFKDHXSbmtVyd5Vsf0nRVuyTSeNafN RIcwsOr9b7m6Apk9VileJF7rteE/sXBf/jtH+usQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Doug Berger , Laura Abbott , Mike Rapoport , Andrew Morton , Florian Fainelli , Rob Herring , "Steven Rostedt (VMware)" , Peng Fan , Geert Uytterhoeven , Russell King , Sasha Levin Subject: [PATCH 5.2 061/124] ARM: 8874/1: mm: only adjust sections of valid mm structures Date: Fri, 20 Sep 2019 00:02:29 +0200 Message-Id: <20190919214821.217421318@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919214819.198419517@linuxfoundation.org> References: <20190919214819.198419517@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Doug Berger [ Upstream commit c51bc12d06b3a5494fbfcbd788a8e307932a06e9 ] A timing hazard exists when an early fork/exec thread begins exiting and sets its mm pointer to NULL while a separate core tries to update the section information. This commit ensures that the mm pointer is not NULL before setting its section parameters. The arguments provided by commit 11ce4b33aedc ("ARM: 8672/1: mm: remove tasklist locking from update_sections_early()") are equally valid for not requiring grabbing the task_lock around this check. Fixes: 08925c2f124f ("ARM: 8464/1: Update all mm structures with section adjustments") Signed-off-by: Doug Berger Acked-by: Laura Abbott Cc: Mike Rapoport Cc: Andrew Morton Cc: Florian Fainelli Cc: Rob Herring Cc: "Steven Rostedt (VMware)" Cc: Peng Fan Cc: Geert Uytterhoeven Signed-off-by: Russell King Signed-off-by: Sasha Levin --- arch/arm/mm/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 749a5a6f61433..8e793cddac661 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -613,7 +613,8 @@ static void update_sections_early(struct section_perm perms[], int n) if (t->flags & PF_KTHREAD) continue; for_each_thread(t, s) - set_section_perms(perms, n, true, s->mm); + if (s->mm) + set_section_perms(perms, n, true, s->mm); } set_section_perms(perms, n, true, current->active_mm); set_section_perms(perms, n, true, &init_mm); -- 2.20.1