Skip to content

Commit 296f4ce

Browse files
neilbrownTrond Myklebust
authored andcommitted
NFS: abort nfs_atomic_open_v23 if name is too long.
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 <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Fixes: 7c6c524 ("NFS: add atomic_open for NFSv3 to handle O_TRUNC correctly.") Signed-off-by: NeilBrown <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent 0c8c7c5 commit 296f4ce

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/nfs/dir.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,6 +2254,9 @@ int nfs_atomic_open_v23(struct inode *dir, struct dentry *dentry,
22542254
*/
22552255
int error = 0;
22562256

2257+
if (dentry->d_name.len > NFS_SERVER(dir)->namelen)
2258+
return -ENAMETOOLONG;
2259+
22572260
if (open_flags & O_CREAT) {
22582261
file->f_mode |= FMODE_CREATED;
22592262
error = nfs_do_create(dir, dentry, mode, open_flags);

0 commit comments

Comments
 (0)