All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] fs: export may_linkat() for nfsd
@ 2026-11-19 19:23 Dominik Maier
  2026-11-19 19:23 ` [PATCH 2/2] nfsd: enforce cross-export and may_linkat() checks in nfsd_link() Dominik Maier
  2026-11-20 10:18 ` [PATCH 1/2] fs: export may_linkat() for nfsd Jan Kara
  0 siblings, 2 replies; 6+ messages in thread
From: Dominik Maier @ 2026-11-19 19:23 UTC (permalink / raw)
  To: Chuck Lever, Jeff Layton, Christian Brauner, Alexander Viro
  Cc: Jan Kara, NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	linux-nfs, linux-fsdevel, dmnk+artist, Dominik Maier

vfs_link() expects its callers to enforce protected hardlink policy via
may_linkat() prior to creating a hardlink. Move the declaration of
may_linkat() from fs/internal.h to include/linux/fs.h and export it with
EXPORT_SYMBOL_GPL() so modular in-kernel file servers such as NFSD can
invoke it before calling vfs_link().

This prepares for fixing missing hardlink restrictions in nfsd_link(),
which was discovered by an AI-assisted code review tool (ARTIST),
validated in QEMU without kernel modifications or error injection, and
verified with kernel builds and checkpatch.pl.

Fixes: 800179c9b8a1 ("fs: add link restrictions")
Cc: stable@vger.kernel.org
Signed-off-by: Dominik Maier <dmnk@google.com>
---
 fs/internal.h      | 1 -
 fs/namei.c         | 1 +
 include/linux/fs.h | 1 +
 3 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/internal.h b/fs/internal.h
index 3f2fbac..7c30669 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -54,7 +54,6 @@ extern int filename_lookup(int dfd, struct filename *name, unsigned flags,
 			   struct path *path, const struct path *root);
 int filename_rmdir(int dfd, struct filename *name);
 int filename_unlinkat(int dfd, struct filename *name);
-int may_linkat(const struct mnt_idmap *idmap, const struct path *link);
 int filename_renameat2(int olddfd, struct filename *oldname, int newdfd,
 		 struct filename *newname, unsigned int flags);
 int filename_mkdirat(int dfd, struct filename *name, umode_t mode);
diff --git a/fs/namei.c b/fs/namei.c
index 925aeb6..8f7c2dc 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1385,6 +1385,7 @@ int may_linkat(const struct mnt_idmap *idmap, const struct path *link)
 	audit_log_path_denied(AUDIT_ANOM_LINK, "linkat");
 	return -EPERM;
 }
+EXPORT_SYMBOL_GPL(may_linkat);
 
 /**
  * may_create_in_sticky - Check whether an O_CREAT open in a sticky directory
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5b3a100..c165f27 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2740,6 +2740,7 @@ int may_delete_dentry(const struct mnt_idmap *idmap, struct inode *dir,
 		      struct dentry *victim, bool isdir);
 int may_create_dentry(const struct mnt_idmap *idmap,
 		      struct inode *dir, struct dentry *child);
+int may_linkat(const struct mnt_idmap *idmap, const struct path *link);
 
 static inline bool execute_ok(struct inode *inode)
 {
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-24 18:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 19:23 [PATCH 1/2] fs: export may_linkat() for nfsd Dominik Maier
2026-11-19 19:23 ` [PATCH 2/2] nfsd: enforce cross-export and may_linkat() checks in nfsd_link() Dominik Maier
2026-11-19 21:33   ` Jeff Layton
2026-11-20  0:08   ` Chuck Lever
2026-11-24 18:11     ` Dominik Maier
2026-11-20 10:18 ` [PATCH 1/2] fs: export may_linkat() for nfsd Jan Kara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.