Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp10781373rwl; Mon, 2 Jan 2023 08:04:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXsNrMprcC/j93l6XM2ohWG4l3fpbejnWa9U6oj+JeuJG/DlN15GvoFbSq1zl7Pbtc4sAldp X-Received: by 2002:a05:6402:2899:b0:48b:c8de:9d20 with SMTP id eg25-20020a056402289900b0048bc8de9d20mr7189683edb.32.1672675483862; Mon, 02 Jan 2023 08:04:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672675483; cv=none; d=google.com; s=arc-20160816; b=fCqxvzgnRBpEeMRqDYF2pr8HRIVmsakik2u4BHWjSTFsaopppGb8pgF+K1KWvgHwwT F6/QVJY0QBgSrswVTSLb0l4VTimAdtoN0wuWwCP/4dSghcwzrrI7i/bl2JdgCI12/5Gd VgOtI+WEUKyxTTqeX4Fnry2GOEYOjYiYeuXpdSVNSUcTxCOBrDbYVPlzOP0XTeqTo1RP 6mll/EZNEbFHZZjJ3hrvKiJwNTUuk4E+jBFrT0DzXoDmbqfPXD4N6EJnDJ6XJdWONIJ9 3ebmLVSVMIUfc84NBSR6SGQn0WVdeuPB9PcFIYG8lFzpqvwF9VjIwPtjip2vAVDUgq+X 9dow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=DCHn4uPDMWjrDLEIfbxsv5BEQLkmP9jK6mAwHR4tfPY=; b=UOzpIMfBMcKK9LSvqoc0UDkUQS0cPfmI6NDnrDNr1oxXwLNVdTVl/fuDSVI5EB7mme kJCXZ+8TW72FNNwC7AQQ1ZylR2x7yl5n/kglKeLs8MZW9vcrULZui5V6W6OSKLs1SWwf 4RWQwYr0U8itP839mLvaSj7cOGQHxFzEoomj9v0O75njwKQlaTfCo8ppFufqTXcsN+7y 9gTiGOtaJSjV/n+FH7exVf2eubgwqVc9bly+VVGFt1wDh0iO+OW+ulOFI+pbFcPjibdL xJjuA3hqFKHD/9SkKPUilzsie9NpoZW0kY/v//09WDcsOPKC+BB8nTvDCj1hwpT7hXMS VDvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=r5UT4MIP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y6-20020a056402270600b0047035379d79si7833617edd.556.2023.01.02.08.04.28; Mon, 02 Jan 2023 08:04:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=r5UT4MIP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236240AbjABPNQ (ORCPT + 61 others); Mon, 2 Jan 2023 10:13:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236231AbjABPMt (ORCPT ); Mon, 2 Jan 2023 10:12:49 -0500 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87C338FE6; Mon, 2 Jan 2023 07:12:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1672672364; bh=NXjw6+rKKlfiUhcOC13HUdlVvOIiNsxG9TWj+5AVcIw=; h=From:To:Cc:Subject:Date:From; b=r5UT4MIPL/pFPmCMszOD5+rkZ6FAF+gPIqMWw+xNObFLDXaU5dEIECX4G5qNxSVou NRrFMJn9sf9dZRb4/DWw/tKk75H3GzNRczXAfQFZr1EWlVPXUKvXxjPqJB4BR4jgU5 1MfD5fEv8tS1THB/ulXN+i+K+t3qmETRwq7N5grONjL2C8qIsnOSxEr3NIm673R383 AOv1kKzusKsqYGOfLqwfMGm04BF4bQTWPPTy0VNkRuztC0WxSJH9eivZsCkPDeHAF9 fdyaKiYvdlV84k3Sziil0EEjY46KIxZQAaOwuoE4mRMwJdizSESccDpu9hSW9me0wT h0mN/nL29MJVg== Received: from localhost.localdomain (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4NlzrC6lcrzd3y; Mon, 2 Jan 2023 10:12:43 -0500 (EST) From: Mathieu Desnoyers To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , "Paul E . McKenney" , Boqun Feng , "H . Peter Anvin" , Paul Turner , linux-api@vger.kernel.org, Christian Brauner , Florian Weimer , David.Laight@ACULAB.COM, carlos@redhat.com, Peter Oskolkov , Alexander Mikhalitsyn , Chris Kennelly , Mathieu Desnoyers , kernel test robot , Borislav Petkov Subject: [RFC PATCH for tip] sched: Fix concurrency ID handling of usermodehelper kthreads Date: Mon, 2 Jan 2023 10:12:16 -0500 Message-Id: <20230102151216.328117-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RDNS_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sched_mm_cid_after_execve does not expect NULL t->mm, but it may happen if a usermodehelper kthread fails when attempting to execute a binary. sched_mm_cid_fork can be issued from a usermodehelper kthread, which has t->flags PF_KTHREAD set. Fixes: af7f588d8f73 ("sched: Introduce per-memory-map concurrency ID") Reported-by: kernel test robot Link: https://lore.kernel.org/oe-lkp/202212301353.5c959d72-yujie.liu@intel.com Reported-by: Borislav Petkov Signed-off-by: Mathieu Desnoyers --- kernel/sched/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 048ec2417990..f99ee69867e3 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -11343,8 +11343,8 @@ void sched_mm_cid_after_execve(struct task_struct *t) struct mm_struct *mm = t->mm; unsigned long flags; - WARN_ON_ONCE((t->flags & PF_KTHREAD) || !t->mm); - + if (!mm) + return; local_irq_save(flags); t->mm_cid = mm_cid_get(mm); t->mm_cid_active = 1; @@ -11354,7 +11354,7 @@ void sched_mm_cid_after_execve(struct task_struct *t) void sched_mm_cid_fork(struct task_struct *t) { - WARN_ON_ONCE((t->flags & PF_KTHREAD) || !t->mm || t->mm_cid != -1); + WARN_ON_ONCE(!t->mm || t->mm_cid != -1); t->mm_cid_active = 1; } #endif -- 2.25.1