From patchwork Thu Jun 27 21:32:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 11020729 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9AC6E13B4 for ; Thu, 27 Jun 2019 21:33:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 905992864E for ; Thu, 27 Jun 2019 21:33:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84388286AE; Thu, 27 Jun 2019 21:33:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3612D2864E for ; Thu, 27 Jun 2019 21:33:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=xOEpFzvWpNbZGqw23zv/E5L09fUTgflGR6VYOMkU2us=; b=Ke1 rkru42yvJ6/vO2mqpuwX3DD0KY0T5H5X9MKVcvHU3OLaKjbnciVV1ZxkgH6Pk9LPNq8Af2Dzs5GJk IyDqhxdJnJWzCfVX650K+OhQ7eS28cIx0j2NZ6ETKap/lF+8ci1e9LMM7YHa454/VUcs+RGSRc0IA IfJ3P0EgvsEGjpcqcOCdzE+uYvRvxOZsjIkWob15SIXtXTaZEW+hBdi1mJMzO6D68n2it48+IMWV7 bz1G1QlKuPhF7HWqEPgRj3RWYweLYeFsqZ2BcwLoP9KXF4IJA5Oj0SdUEq8I5RazpSrtldlwExsC6 sIixg97Wjj73oCIzK+Jqdyq1YRSyqnw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hgc1I-0005fp-LL; Thu, 27 Jun 2019 21:33:28 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hgc1E-0005eo-QH for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2019 21:33:26 +0000 Received: by mail-pg1-x543.google.com with SMTP id k13so1583774pgq.9 for ; Thu, 27 Jun 2019 14:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=PZGYipUyd0OlxHfS8UkofkYjMsM1+ZdDLnbfUznJ73w=; b=Eiq/zgNYvuYsTc+BJ/I589PAFh3f4hL6NiOSVV7grwZJde+ytgdcZiTW0oWETZLd0c z1PcdwG6kjRnYDdS+KZ6VCrPsag/QMseoN/R0VnAwUlUFpWcs9/kR/tDy/6I7U3a2g4H ki9zHH0wvDrf/VkRgAfOLiiz5Srl8uhUbpF42vU8gBbuPXEDwPHw6W5H+u2CYLmz9LTp IPGdhuUkeZZCQg1QSJDTpfb6ZILNraVHxGvFf1KYr7asBN9d6RqpYJ6E0CgmKYRa23wR PfHsEjo5h4M8ncI0HWqB81jd3PZ3DgseeNWy9lHHijRZvbQTBrEuriQa1wMVBhAPfMqQ 1REA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PZGYipUyd0OlxHfS8UkofkYjMsM1+ZdDLnbfUznJ73w=; b=KW/UgZhZRqsMChDkyMtzbzXx+GO2miIvK2RKuTzY/bm1y34WO5Fmdijw1mtft0dIxW mZ5tmUAFT3jElelaQIcfvYVdgNVZFJNP7tTFCc8/fr/Np+r21Nq0dQtlERfPJL6dSLD0 dgQR6IhsH8hl12aUkd8lJI30zFYuTUQt/Pf6bAngkbO1eZj/td5cywTlO6jaAvsG2S5z o4H5EJJzWtqdofP+23ufxgLIzGJRU5SJSmXRDNCpArFmX2yA3SNEp7605DBVF6aMx0ph /s4VZZZrvfn6mGpIMJhNVySBJxveG81xuJ7QclPzhOE0ui6gICoMqMjg3E8M2tZwaPy9 tPGQ== X-Gm-Message-State: APjAAAX4/ClVj35Kur13TwxS/JgHrKwNBIm4PQvEg7tzmn+j9bvFgm1F EUW809oTYr/JdFCO5P4hAUOYfKJF X-Google-Smtp-Source: APXvYqygAgpdlhMUf0iJGc41fnT4h96RI4dGVHLFQHhK06uF/Xp9dkOpgaUN+KTq57ZE5aV3XyAZ0g== X-Received: by 2002:a63:1645:: with SMTP id 5mr5722563pgw.175.1561671203119; Thu, 27 Jun 2019 14:33:23 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id k197sm96223pgc.22.2019.06.27.14.33.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Jun 2019 14:33:22 -0700 (PDT) From: Doug Berger To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: mm: only adjust sections of valid mm structures Date: Thu, 27 Jun 2019 14:32:48 -0700 Message-Id: <1561671168-29896-1-git-send-email-opendmb@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190627_143324_853616_50A26B52 X-CRM114-Status: GOOD ( 13.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Herring , Peng Fan , Florian Fainelli , linux-kernel@vger.kernel.org, Russell King , "Steven Rostedt \(VMware\)" , Mike Rapoport , Doug Berger , Geert Uytterhoeven , Andrew Morton , Laura Abbott MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 be0b42937888..bdc70dff477b 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -616,7 +616,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);