Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp500787pxu; Thu, 3 Dec 2020 05:55:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEhG8ZgHaU9Ru8hQijsv0Qro90nMm1zZx4WfbKDipIHmNFFAloI34yCFrIcr4mR8a6qMy9 X-Received: by 2002:a17:907:6e6:: with SMTP id yh6mr2650638ejb.512.1607003739037; Thu, 03 Dec 2020 05:55:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607003739; cv=none; d=google.com; s=arc-20160816; b=FOWG8Et4s7nwD58vn5YFkeSkWTftiHTF9MYYjqsWKd1L8YhLHryh81HI4CRHvHTLW9 GqWwl7xejJ9Tyd80F6nXcVAFCPuB9XRGED4kcC9wRDruDvriYqbkN9dVGzUj+oSZHzeu oca9NxDXL/qCQf8T9oAgkp7JOWhMYvpiOfVfYA7rSEPZYHPqZmVndtqAASVRK/xPvRUn aYpVsXrgeTLrjd/Sa27U/JUBLJpiLYOBSnL3XjBBNCldDn1hNsAlv1j9HaXrMX41RdRf PlxntQ+JgJY009qf90AZmauCCnCQ5pMRDkhRuykhHQy8Zo6JdJki60ggTeKoO9Xcg810 ilYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=8W06ecDumYTvMB7ZEPeHsuqGpzgyFozIr/EU4/bs1b0=; b=vOpqrjVMhcWHDFiLKhmgS7AtYtv3Tz/Q5jhj78BLfA1ckLR3a9x6Rir2EP8WNkpvYP YUuLDHALSFXlmi6anVG5nBbji+RouvalBjo0Az3PJIorYfV956so8OZO3RvLiSpvRTsK GGLzu3l43nOHiAYmaF32A9gzONrkj+EElYmRcTAZJaYp0lhRsMSqtcRPpNiPzTN2soQ8 zpIj5vo2Bj+7Hla+4EMputlZr2+DI3+Ab9R+Tnwkv4bXhbgvl5pWhXD0ruWZ1COTC9p9 Opvzr1WRO6vAaI0h9HrKtvwLdzbWXLKJFU1nFthxU42BRY0ODKWHfEBCy5jltYoY5+nY 6DRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e16si1107166eja.462.2020.12.03.05.55.15; Thu, 03 Dec 2020 05:55:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388369AbgLCNxC (ORCPT + 99 others); Thu, 3 Dec 2020 08:53:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:59406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728830AbgLCNxB (ORCPT ); Thu, 3 Dec 2020 08:53:01 -0500 From: Jessica Yu Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org, systemd-devel@lists.freedesktop.org Cc: Nicolas Morey-Chaisemartin , Franck Bui , Jessica Yu Subject: [PATCH RFC 0/1] Delay module uevent until after initialization Date: Thu, 3 Dec 2020 14:51:23 +0100 Message-Id: <20201203135124.16695-1-jeyu@kernel.org> X-Mailer: git-send-email 2.16.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, This patch addresses a race condition between udev and the module loader that was recently described here: https://github.com/systemd/systemd/issues/17586 Currently, the module loader issues a KOBJ_ADD uevent before it calls a module's initialization function. Some mount units expect that the module has initialized already upon receiving the uevent. For instance, the configfs module creates the /sys/kernel/config mount point during its init function, but the module loader issues the uevent before the init function is called. If udev processes the uevent before the module loader calls the init function, then the mount unit will fail, since /sys/kernel/config will not exist yet. Nicolas Morey-Chaisemartin provided a simple test script to trigger the race condition: while true; do umount configfs rmmod configfs sleep 1 modprobe configfs ls -alFd /sys/kernel/config sleep 1 systemctl status sys-kernel-config.mount | tail -n 1 done When the mount fails due to the race condition, you would see a message like: systemd[1]: Condition check resulted in Kernel Configuration File System being skipped. I ran the script for about 30 minutes on my own machine and managed to trigger the failure condition 4 times. With the patch applied, I was not able to trigger the failed condition anymore after running the script for the same amount of time. Nicolas also reported similar test results after testing a kernel with the patch applied. This is sent first as an RFC to both LKML and systemd mailing lists since the uevent call has been like this in the module loader for more than a decade (since v2.6), I would be cautious as to not break anything that actually relies on the current behavior for whatever reason. More testing would be greatly appreciated. Thanks, Jessica Jessica Yu (1): module: delay kobject uevent until after module init call kernel/module.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)