From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE286156236 for ; Sat, 29 Nov 2025 15:55:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764431709; cv=none; b=BJJK4MBdxZ/Wib9Kmh2m4BYprplJjK4IXeXeAMCDniphuAxU2bO4ysBsw4+17suF12rTtLXrbvzJJeufz2wUmI3eLDbOQvnPsCxYbvCi2LxnCVdl9Gefl3vGXo+ApDbSAB0IHwA2YoGlUYjm0XZw55ElzdRwObpMXChomnYPvic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764431709; c=relaxed/simple; bh=HvAxUzJkGXn2qFdccmTMQrW6uWMggHj8e1fpYhNC0RY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RwIyBDWd6h9ijpBp4p9mwpvNm+nzL9lhRvTLyPMM7AhXWt7biR8pzyVmonbvYdVm6K6pfHbB36veGerGGz7AlE+l9ZABQQNma/RjlFKvkF9bqJrSia8GA/ZY3p/QhA4pdbUkL43NRDh7T9IhdQCnEKDcNruElNTY6fgQQjuL2o8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RFvYxQiR; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RFvYxQiR" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-b736d883ac4so293105766b.2 for ; Sat, 29 Nov 2025 07:55:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764431706; x=1765036506; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=X1eC10We295VV65umPfobtygoRy82cfYMzrL4jRtdf4=; b=RFvYxQiRxplSMSCCHCGcOoussVeuf2fSIZMnDBiGUi3sm8fGCvbXJuD9DoJ0xDJB95 aVmq4lNj5vK88M9ADeBiUWxfmdoNaT3CQcHvc2qm+3UyRF5T4XC2pc6pXSnQtHXGzOTa rGMROAZwwXt/Gk260QC1rXxU+ENMGZPP8vmt83XGkWvXMrDHoHHBadTE5hXz0aHq0AaI KY15GKNOeSTB2dS6j8ytGrf/muBlDAAAEXGbpdg6Yqdl+OU5uLgyfCiinsPzXCPmgbB2 lMAMk88OZXgv02mB8ccFYSw29/i8kYuXqvfpQApqUgJbA6P6XjP+SpLJFA9303Ux3KKZ x7MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764431706; x=1765036506; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=X1eC10We295VV65umPfobtygoRy82cfYMzrL4jRtdf4=; b=O/KZj+9Swjb/UYVCrBD7cuG9M1KVHS7PPHxX6c7qGvdxSLMfY5fn4VoVQy1DZDPgk9 SJnKJSw9API36CEiFzHt39Ll6+Do+Uj0QsR4iRGYuIZZgRT8nKWd8wx+fa5KBp8dgyfy j7snHQ0C/CqU1UEMlVZ+jk0VsGKkKz6oz01PAmarJsYpp/6mmEfbCuUQXk/BJAxJIOhO G9y57rNW3awoChFESziDZhoTxZLeXvpSQo0kxoQWNZrwMGgyJVCxW76kMmP3rpCQ95s8 kXCGjnFsObXUl8JolkTGCSwyUJhtX7vY9j9dTy1c7SbQAlEECK1qtmEtH7JGDEyBvtA5 eT2g== X-Forwarded-Encrypted: i=1; AJvYcCVEp9Cc+NI2nbSgBW/9wtcco/5wVS97sLfFWJkX5FDu6uD80FPucDeMGMGiRPwNtJLNduwRCAwoWGJYyOI=@vger.kernel.org X-Gm-Message-State: AOJu0YzkOqEK9m08kcQ3sdvY3a3HqaHvJyy84avmX7bKonVqaWO/z94G /QbQ1R3ECRDYrRy8e6hiFIo19GyPYoeezBQNZDtul2+LL+fjW4I512mP X-Gm-Gg: ASbGncvXwLEOXAgB42nHxPVZZP0DVCxoFeQ49Jh0i0PooQrFA4YWsASJGCeF7udeUsu IF1bOgp525M3dlri0VPjfsaZAXNdJylbQDb0urEXdaqSKAxrPKu1Nv4jfM39JX+fKPhV4c5gDbO oospGNabdFh8VsNQFSr83gQUmOj0AYKLNWp9HnBdthwAJxU31q8jQJX+tD1yg4allX6vS/IFPGq HqBmqZn3/LDUR+60OIbiDR2CFeW8Nlm+UcgxoLHTEos22sLV3cHYThYPMnP1wkNWj3i6JOk2vS4 z2pvyz1+tGDO5+pEW7KOzPUKHHvUO9SMmpnPZ3Sykmiq4aOy7lVlizSRpMnyCmVvc57AFRjviSP Fxnu48iFnUTbmN9avKGebLtL5XFOYmu9n/+xl3V4Os+bt0TwDVjIpOiGfn7e/Ne6BXA4AxTu6Yv uv9gGd9sjaCrwnR4WQ04/jhTteIzufWaROc1RPXQIkGkjgODwD4Lhm1dcfW7g= X-Google-Smtp-Source: AGHT+IElEh/cpVKjqvOyJ1pXnUpKsUtxPJQlyIWsiDMugYc0pMhFt+kg3jl0s1rlfy+4HeSOU2sZzA== X-Received: by 2002:a17:907:8e95:b0:b73:5958:7e6c with SMTP id a640c23a62f3a-b767153ee44mr3577062966b.3.1764431705861; Sat, 29 Nov 2025 07:55:05 -0800 (PST) Received: from f.. (cst-prg-14-82.cust.vodafone.cz. [46.135.14.82]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b76f5162c5csm746364766b.6.2025.11.29.07.55.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Nov 2025 07:55:05 -0800 (PST) From: Mateusz Guzik To: brauner@kernel.org Cc: viro@zeniv.linux.org.uk, jack@suse.cz, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Mateusz Guzik Subject: [PATCH 1/2] fs: move getname and putname handlers into namei.h Date: Sat, 29 Nov 2025 16:54:59 +0100 Message-ID: <20251129155500.43116-1-mjguzik@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This will enable use of runtime const machinery for namei_cachep. Existing header spaghetti makes it impossible to use while in fs.h Signed-off-by: Mateusz Guzik --- This may end up creating merge conflicts against the work which messed with audit and atomic refcounts on struct filename, but they should be trivially resolvable. Things just got moved fs.h -> namei.h tested with allmodconfig drivers/base/firmware_loader/main.c | 1 + fs/ceph/mds_client.h | 1 + fs/d_path.c | 1 + fs/exfat/dir.c | 1 + fs/f2fs/f2fs.h | 1 + fs/fat/dir.c | 1 + fs/filesystems.c | 1 + fs/ntfs3/dir.c | 1 + fs/ntfs3/fsntfs.c | 1 + fs/ntfs3/namei.c | 1 + fs/ntfs3/xattr.c | 1 + fs/smb/client/cifsproto.h | 1 + fs/vboxsf/file.c | 1 + include/linux/fs.h | 42 +---------------------------- include/linux/namei.h | 41 ++++++++++++++++++++++++++++ io_uring/statx.c | 1 + mm/huge_memory.c | 1 + security/integrity/ima/ima_api.c | 1 + security/integrity/ima/ima_main.c | 1 + 19 files changed, 59 insertions(+), 41 deletions(-) diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c index 4ebdca9e4da4..ac5a86d7692f 100644 --- a/drivers/base/firmware_loader/main.c +++ b/drivers/base/firmware_loader/main.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index 0428a5eaf28c..bc0b8da9fca2 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/fs/d_path.c b/fs/d_path.c index bb365511066b..19cde8b57771 100644 --- a/fs/d_path.c +++ b/fs/d_path.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include "mount.h" diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 3045a58e124a..9d588a64e5dd 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "exfat_raw.h" #include "exfat_fs.h" diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 5f104518c414..78d97ccb646e 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 92b091783966..6dd7d0f6043f 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "fat.h" /* diff --git a/fs/filesystems.c b/fs/filesystems.c index 95e5256821a5..fb0dac8aa916 100644 --- a/fs/filesystems.c +++ b/fs/filesystems.c @@ -17,6 +17,7 @@ #include #include #include +#include /* * Handling of filesystem drivers list. diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index b98e95d6b4d9..5e778cac4197 100644 --- a/fs/ntfs3/dir.c +++ b/fs/ntfs3/dir.c @@ -8,6 +8,7 @@ */ #include +#include #include #include "debug.h" diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index 5f138f715835..5099c8fbe6b2 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c index 3b24ca02de61..1251dae282bb 100644 --- a/fs/ntfs3/namei.c +++ b/fs/ntfs3/namei.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index c93df55e98d0..1211a0859000 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h index 3528c365a452..6438a2dc77c3 100644 --- a/fs/smb/client/cifsproto.h +++ b/fs/smb/client/cifsproto.h @@ -9,6 +9,7 @@ #define _CIFSPROTO_H #include #include +#include #include "cifsglob.h" #include "trace.h" #ifdef CONFIG_CIFS_DFS_UPCALL diff --git a/fs/vboxsf/file.c b/fs/vboxsf/file.c index 4bebd947314a..bb05e99c1d24 100644 --- a/fs/vboxsf/file.c +++ b/fs/vboxsf/file.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "vfsmod.h" struct vboxsf_handle { diff --git a/include/linux/fs.h b/include/linux/fs.h index 04ceeca12a0d..8b6f8e373ac7 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -55,6 +55,7 @@ struct bdi_writeback; struct bio; struct io_comp_batch; struct fiemap_extent_info; +struct filename; struct hd_geometry; struct iovec; struct kiocb; @@ -2408,16 +2409,6 @@ extern struct kobject *fs_kobj; #define MAX_RW_COUNT (INT_MAX & PAGE_MASK) /* fs/open.c */ -struct audit_names; -struct filename { - const char *name; /* pointer to actual string */ - const __user char *uptr; /* original userland pointer */ - atomic_t refcnt; - struct audit_names *aname; - const char iname[]; -}; -static_assert(offsetof(struct filename, iname) % sizeof(long) == 0); - static inline struct mnt_idmap *file_mnt_idmap(const struct file *file) { return mnt_idmap(file->f_path.mnt); @@ -2491,32 +2482,6 @@ static inline struct file *file_clone_open(struct file *file) } extern int filp_close(struct file *, fl_owner_t id); -extern struct filename *getname_flags(const char __user *, int); -extern struct filename *getname_uflags(const char __user *, int); -static inline struct filename *getname(const char __user *name) -{ - return getname_flags(name, 0); -} -extern struct filename *getname_kernel(const char *); -extern struct filename *__getname_maybe_null(const char __user *); -static inline struct filename *getname_maybe_null(const char __user *name, int flags) -{ - if (!(flags & AT_EMPTY_PATH)) - return getname(name); - - if (!name) - return NULL; - return __getname_maybe_null(name); -} -extern void putname(struct filename *name); -DEFINE_FREE(putname, struct filename *, if (!IS_ERR_OR_NULL(_T)) putname(_T)) - -static inline struct filename *refname(struct filename *name) -{ - atomic_inc(&name->refcnt); - return name; -} - extern int finish_open(struct file *file, struct dentry *dentry, int (*open)(struct inode *, struct file *)); extern int finish_no_open(struct file *file, struct dentry *dentry); @@ -2534,11 +2499,6 @@ static inline int finish_open_simple(struct file *file, int error) extern void __init vfs_caches_init_early(void); extern void __init vfs_caches_init(void); -extern struct kmem_cache *names_cachep; - -#define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL) -#define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) - void emergency_thaw_all(void); extern int sync_filesystem(struct super_block *); extern const struct file_operations def_blk_fops; diff --git a/include/linux/namei.h b/include/linux/namei.h index 58600cf234bc..bd4a7b058f97 100644 --- a/include/linux/namei.h +++ b/include/linux/namei.h @@ -52,6 +52,47 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT}; extern int path_pts(struct path *path); +struct audit_names; +struct filename { + const char *name; /* pointer to actual string */ + const __user char *uptr; /* original userland pointer */ + atomic_t refcnt; + struct audit_names *aname; + const char iname[]; +}; +static_assert(offsetof(struct filename, iname) % sizeof(long) == 0); + +struct filename *getname_flags(const char __user *, int); +struct filename *getname_uflags(const char __user *, int); +static inline struct filename *getname(const char __user *name) +{ + return getname_flags(name, 0); +} +struct filename *getname_kernel(const char *); +struct filename *__getname_maybe_null(const char __user *); +static inline struct filename *getname_maybe_null(const char __user *name, int flags) +{ + if (!(flags & AT_EMPTY_PATH)) + return getname(name); + + if (!name) + return NULL; + return __getname_maybe_null(name); +} +void putname(struct filename *name); +DEFINE_FREE(putname, struct filename *, if (!IS_ERR_OR_NULL(_T)) putname(_T)) + +static inline struct filename *refname(struct filename *name) +{ + atomic_inc(&name->refcnt); + return name; +} + +extern struct kmem_cache *names_cachep; + +#define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL) +#define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) + extern int user_path_at(int, const char __user *, unsigned, struct path *); struct dentry *lookup_one_qstr_excl(const struct qstr *name, diff --git a/io_uring/statx.c b/io_uring/statx.c index 5111e9befbfe..ba6442633214 100644 --- a/io_uring/statx.c +++ b/io_uring/statx.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include diff --git a/mm/huge_memory.c b/mm/huge_memory.c index f7c565f11a98..69c1eee121a4 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include "internal.h" diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c index c35ea613c9f8..7b1d73a7e7e3 100644 --- a/security/integrity/ima/ima_api.c +++ b/security/integrity/ima/ima_api.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index 5770cf691912..5fd40401d89f 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include -- 2.48.1