Linux NFS development
 help / color / mirror / Atom feed
From: Dominik Maier <dmnk@google.com>
To: Chuck Lever <cel@kernel.org>, Jeff Layton <jlayton@kernel.org>,
	 Christian Brauner <brauner@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Jan Kara <jack@suse.cz>, NeilBrown <neil@brown.name>,
	 Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	 linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	 dmnk+artist@google.com, Dominik Maier <dmnk@google.com>
Subject: [PATCH 1/2] fs: export may_linkat() for nfsd
Date: Thu, 19 Nov 2026 20:23:10 +0100	[thread overview]
Message-ID: <20261119192311.2684978-1-dmnk@google.com> (raw)

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


             reply	other threads:[~2026-11-19 19:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 19:23 Dominik Maier [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119192311.2684978-1-dmnk@google.com \
    --to=dmnk@google.com \
    --cc=Dai.Ngo@oracle.com \
    --cc=brauner@kernel.org \
    --cc=cel@kernel.org \
    --cc=dmnk+artist@google.com \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=tom@talpey.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox