* [PATCH] NFS: abort nfs_atomic_open_v23 if name is too long.
@ 2024-05-28 23:11 NeilBrown
2024-05-29 6:25 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: NeilBrown @ 2024-05-28 23:11 UTC (permalink / raw)
To: Trond Myklebust, Anna Schumaker
Cc: james.clark, ltp, broonie, Aishwarya.TCV, linux-nfs
An attempt to open a file with a name longer than NFS3_MAXNAMLEN will
trigger a WARN_ON_ONCE in encode_filename3() because
nfs_atomic_open_v23() doesn't have the test on ->d_name.len that
nfs_atomic_open() has.
So add that test.
Reported-by: James Clark <james.clark@arm.com>
Closes: https://lore.kernel.org/all/20240528105249.69200-1-james.clark@arm.com/
Fixes: 7c6c5249f061 ("NFS: add atomic_open for NFSv3 to handle O_TRUNC correctly.")
Signed-off-by: NeilBrown <neilb@suse.de>
---
fs/nfs/dir.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 342930996226..2b09b5416ef1 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2255,6 +2255,9 @@ int nfs_atomic_open_v23(struct inode *dir, struct dentry *dentry,
*/
int error = 0;
+ if (dentry->d_name.len > NFS_SERVER(dir)->namelen)
+ return -ENAMETOOLONG;
+
if (open_flags & O_CREAT) {
file->f_mode |= FMODE_CREATED;
error = nfs_do_create(dir, dentry, mode, open_flags);
--
2.44.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] NFS: abort nfs_atomic_open_v23 if name is too long.
2024-05-28 23:11 [PATCH] NFS: abort nfs_atomic_open_v23 if name is too long NeilBrown
@ 2024-05-29 6:25 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2024-05-29 6:25 UTC (permalink / raw)
To: NeilBrown
Cc: Trond Myklebust, Anna Schumaker, james.clark, ltp, broonie,
Aishwarya.TCV, linux-nfs
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-29 6:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-28 23:11 [PATCH] NFS: abort nfs_atomic_open_v23 if name is too long NeilBrown
2024-05-29 6:25 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox