From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A4A13EFD24 for ; Wed, 12 Aug 2026 21:44:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786571085; cv=none; b=rx7IgxBL00KYMF6lS2DIo7lK+RqEIxwn5Hhw2LtlPQKHeG+q9woJx9vU9tj93DSKv9QfW2+N5fHOnvkKUIoXFNVQKEdXvZ1skaxpaXR/Vj5YFCAG/ziLqgliDa/aK0GKw2JYwWnLikP51mIOWP4L72rqnIJ3F/1dD9JnYOpC17U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786571085; c=relaxed/simple; bh=89EwqujkVX8CqILmqZsH+8E2Zfqbt1N8OrlIniE5+R8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=uaE+Y5JeWAkD7uolt29ohmrwSJWBBW7piMfshi0kccJJxknymxznONuuur/tY2FGxj4bac2ab7KWaXnOznW3QTAX4kdgZmZ0k+6KR1raNWH8iOsiTv2O0WOdJsy+Yl3VvYRa97+tT/RWArH2aXDqwSqsC5JuuVHlc2fwAq2Hhd0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=iU2ZH82c; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=b5XvULwJ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iU2ZH82c"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="b5XvULwJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1786571083; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EpdR7lRgwsOXaHnV+8khs91uYzIEWMJ6GYggqjAM8+M=; b=iU2ZH82cAMOYoVF29oMqYn7Wn09tFvlzQxfS2yD4IuFETz0BO24m3mdqBF76N6TY0zzqty URnPEFK/FP10CPwX44zmuyzC/HWWF/lK5cFuijN1CllDDIlF+QOU9Aw1Ccgjy6BrHK01GX kqs7cCPLxTFQuoHjA630BBr+wCRicXg= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-529-NWHJBKLfMz6F2FZmB85Wjw-1; Wed, 12 Aug 2026 17:44:41 -0400 X-MC-Unique: NWHJBKLfMz6F2FZmB85Wjw-1 X-Mimecast-MFC-AGG-ID: NWHJBKLfMz6F2FZmB85Wjw_1786571081 Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-7ee1e335245so102326a34.1 for ; Wed, 12 Aug 2026 14:44:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1786571081; x=1787175881; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=EpdR7lRgwsOXaHnV+8khs91uYzIEWMJ6GYggqjAM8+M=; b=b5XvULwJLCbl1BwTTFuzYv3m7WPfR6Sem6f4cpy3vL4T1tp/PPt8ngpSzjjoXjkHAb /vOUDhiqrZ3o20QCT+QUduqXUOfzqcdbCmwxPdg+n/wKlHDWJOqaSre9px95lthSc3Ua WIOdLLNuTd3PpATloKh+C4XWSN1y3s0SRU59YqzqLQte1k1VtSGyGl4dJ6zjJve7sj1Y p/tAH8BNNGrylyHBKWFSlKSIl13kJwwbPUGDOyxcVgu9lxr+8g/mS0Q5jWtePeKM6kfJ aC3ZBUZpRidOOPsJP6U5bjYy9TORUkYdM2YQJfiAlz7KmAApMdk27P7IL0tVWCh55U6I 6VYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786571081; x=1787175881; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=EpdR7lRgwsOXaHnV+8khs91uYzIEWMJ6GYggqjAM8+M=; b=CEZAy1A3PhCyCNQzBPmUYlDfH73LBpwB58JheHwBDn7d68ckhxCII3R+rRdXidmJpn +x9Xaxcub04YjbJt9Tv9Fypof6pGVWuivFs08T58uP4U2Q+N7qe6n8o4p6AYwChC3PiD d0zDswijbWhhfTgYSkCm7e49ServF9tFdpd3jmKSJuDfuup4iyr8kldzkT+JuzLRmxK0 n/gz6QJ54A1lcKAYZ9dOj02OP/XB0bcPMdWU2WPoFE2Xunwf/EiDp2EuESPtEE41yh4c YYfqhKt4Vdfzm8907UKqs4kab7/c7d1yUcxRy5lgpTA6OFmw5u7/mE0Y4h+m1Q5crZls jgaw== X-Forwarded-Encrypted: i=1; AHgh+RqXxID6am4XXENOYe81PdNKJF5ndtu0VzAXyl5e7+38e4FId9e5cr6SwjcjZAjhpRQ/3II8xj4U+QEuZm8=@vger.kernel.org X-Gm-Message-State: AOJu0YyNVSUcRnLwbOanfaBN5tHAEDEwUrIdb4bxi+5+S1tUmgzSpKmZ fu5CFPhSIowOR95mySRfIBldJh2fe5t6aS5pF3pSxxym5PFg207EQOUh5aTFP8HP2/slU3R1x9M au1QfsTFrVTm6HskaA4AX0R9bxu3tYYPleCLojxJdwf/xXgr1GC0uhR3Sa1zp/e3CQA== X-Gm-Gg: AR+sD10/JzAJJc45A13CQPoayegTKzu2B8TkMcWsRq2XtndqCtxO9wTuOZKBH/k69wa eDYjBIGdb2/Dyip1u0LyNs5bGkJIEqfh1rceqcJr699sTAsYKKBxv/g27Iy95EH0rRZc4159qZH JQ7y98T3xMCtXWl5/3dFuVaFDRbce7erqrqj3RFfxmnhU9I0gXyoIYceyknHqAjbrrX/gCmZBgj DNBT045LTRW261yx8JmMWmwg3/zgw/lsNX5q0cjDXROZg9W1uFXyQxz6E8JrixewVqM8wdXaSjV XihNTYgLpK2hnP4O0ChZw5YI6ahMWzZnSTDIlJe+LPvPFRifoJ10VlnYKcSW86CFhnrl8IE3jWl 3JDfPhiReQXqesAdMq7kWLyPSsSlKUT9cgoPRwhjS X-Received: by 2002:a05:6820:4cc7:b0:6b0:40d9:8ac6 with SMTP id 006d021491bc7-6b0c41ff715mr1536509eaf.9.1786571080829; Wed, 12 Aug 2026 14:44:40 -0700 (PDT) X-Received: by 2002:a05:6820:4cc7:b0:6b0:40d9:8ac6 with SMTP id 006d021491bc7-6b0c41ff715mr1536452eaf.9.1786571080219; Wed, 12 Aug 2026 14:44:40 -0700 (PDT) Received: from [10.0.0.119] (97-127-68-83.mpls.qwest.net. [97.127.68.83]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7f3c9a172cesm438933a34.12.2026.08.12.14.44.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Aug 2026 14:44:39 -0700 (PDT) Message-ID: Date: Wed, 12 Aug 2026 16:44:38 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH V2] devtmpfs: restore mount option reconfiguration on get_tree To: Simon Liebold , Greg Kroah-Hartman , "Rafael J . Wysocki" , Danilo Krummrich , Christian Brauner , driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, Alexander Viro Cc: stable@vger.kernel.org References: <20260810083438.764684-1-simonlie@amazon.de> Content-Language: en-US From: Eric Sandeen In-Reply-To: <20260810083438.764684-1-simonlie@amazon.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit commit cb0e0a8bf4e1 ("devtmpfs: replace ->mount with ->get_tree in public instance") converted the public devtmpfs instance to the new mount API but broke the ability to reconfigure the shared superblock options via subsequent mount() calls, as had been fixed once in a6097180d884 ("devtmpfs regression fix: reconfigure on each mount") This makes boot-time defaults permanent. Fix this using an approach suggested by Al Viro: at init_fs_context time, create a reconfigure-mode context via fs_context_for_reconfigure() and save it in fc->fs_private. The devtmpfs parse ops can then use this context to parse options appropriately for the underlying filesystem. This also removes the devtmpfs_configure_context() one-time ops-copying approach and the global mutable ops table it required. Fixes: cb0e0a8bf4e1 ("devtmpfs: replace ->mount with ->get_tree in public instance") Reported-by: Simon Liebold Cc: stable@vger.kernel.org Suggested-by: Al Viro Signed-off-by: Eric Sandeen --- I think this might be a better approach; more involved, but it uses the right type of context for reconfigure and avoids the nasty ops copying I wrote the first time. :( First, sorry for breaking this. Second, Al please yell if I have mis-attributed or mis-implemented your suggestion from months back. Third, I have done only light testing on this but it seems ok, built and booted with CONFIG_TMPFS=y and confirmed that a fresh "mount" with new options takes hold, and confirmed it builds without CONFIG_TMPFS configured though I don't have a system that wants to boot that config. Thoughts? drivers/base/devtmpfs.c | 108 ++++++++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 44 deletions(-) diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index b1c4ceb65026..c32d3b963f2e 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c @@ -72,39 +72,90 @@ static struct file_system_type internal_fs_type = { .kill_sb = kill_anon_super, }; -/* Simply take a ref on the existing mount */ +struct devtmpfs_context { + struct fs_context *fc; +}; + +static void devtmpfs_free(struct fs_context *fc) +{ + struct devtmpfs_context *ctx = fc->fs_private; + + if (ctx) { + put_fs_context(ctx->fc); + kfree(ctx); + } +} + +static int devtmpfs_parse_param(struct fs_context *fc, struct fs_parameter *param) +{ + struct devtmpfs_context *ctx = fc->fs_private; + + return ctx->fc->ops->parse_param(ctx->fc, param); +} + +static int devtmpfs_parse_monolithic(struct fs_context *fc, void *data) +{ + struct devtmpfs_context *ctx = fc->fs_private; + + if (ctx->fc->ops->parse_monolithic) + return ctx->fc->ops->parse_monolithic(ctx->fc, data); + return generic_parse_monolithic(ctx->fc, data); +} + static int devtmpfs_get_tree(struct fs_context *fc) { + struct devtmpfs_context *ctx = fc->fs_private; struct super_block *sb = mnt->mnt_sb; + int err; atomic_inc(&sb->s_active); down_write(&sb->s_umount); + + if (ctx->fc->ops->reconfigure) { + err = ctx->fc->ops->reconfigure(ctx->fc); + if (err) { + deactivate_locked_super(sb); + return err; + } + } + fc->root = dget(sb->s_root); return 0; } -/* Ops are filled in during init depending on underlying shmem or ramfs type */ -static struct fs_context_operations devtmpfs_context_ops = {}; +static const struct fs_context_operations devtmpfs_context_ops = { + .free = devtmpfs_free, + .parse_param = devtmpfs_parse_param, + .parse_monolithic = devtmpfs_parse_monolithic, + .get_tree = devtmpfs_get_tree, +}; -/* Call the underlying initialization and set to our ops */ static int devtmpfs_init_fs_context(struct fs_context *fc) { - int ret; -#ifdef CONFIG_TMPFS - ret = shmem_init_fs_context(fc); -#else - ret = ramfs_init_fs_context(fc); -#endif - if (ret < 0) - return ret; + struct devtmpfs_context *ctx; + int err; + + ctx = kzalloc_obj(struct devtmpfs_context); + if (!ctx) + return -ENOMEM; + + /* Each mount will reconfigure the shared superblock w/ new options */ + ctx->fc = fs_context_for_reconfigure(mnt->mnt_root, + mnt->mnt_sb->s_flags, MS_RMT_MASK); + if (IS_ERR(ctx->fc)) { + err = PTR_ERR(ctx->fc); + kfree(ctx); + return err; + } + fc->fs_private = ctx; fc->ops = &devtmpfs_context_ops; return 0; } static struct file_system_type dev_fs_type = { - .name = "devtmpfs", + .name = "devtmpfs", .init_fs_context = devtmpfs_init_fs_context, }; @@ -442,31 +493,6 @@ static int __ref devtmpfsd(void *p) return 0; } -/* - * Get the underlying (shmem/ramfs) context ops to build ours - */ -static int devtmpfs_configure_context(void) -{ - struct fs_context *fc; - - fc = fs_context_for_reconfigure(mnt->mnt_root, mnt->mnt_sb->s_flags, - MS_RMT_MASK); - if (IS_ERR(fc)) - return PTR_ERR(fc); - - /* Set up devtmpfs_context_ops based on underlying type */ - devtmpfs_context_ops.free = fc->ops->free; - devtmpfs_context_ops.dup = fc->ops->dup; - devtmpfs_context_ops.parse_param = fc->ops->parse_param; - devtmpfs_context_ops.parse_monolithic = fc->ops->parse_monolithic; - devtmpfs_context_ops.get_tree = &devtmpfs_get_tree; - devtmpfs_context_ops.reconfigure = fc->ops->reconfigure; - - put_fs_context(fc); - - return 0; -} - /* * Create devtmpfs instance, driver-core devices will add their device * nodes here. @@ -482,12 +508,6 @@ int __init devtmpfs_init(void) return PTR_ERR(mnt); } - err = devtmpfs_configure_context(); - if (err) { - pr_err("unable to configure devtmpfs type %d\n", err); - return err; - } - err = register_filesystem(&dev_fs_type); if (err) { pr_err("unable to register devtmpfs type %d\n", err); -- 2.55.0