Summary: | nfs: page fault during nfsrpc_readdir | ||||||
---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | Alan Somers <asomers> | ||||
Component: | kern | Assignee: | Rick Macklem <rmacklem> | ||||
Status: | Closed FIXED | ||||||
Severity: | Affects Only Me | CC: | emaste, rmacklem | ||||
Priority: | --- | Flags: | rmacklem:
mfc-stable14+
rmacklem: mfc-stable13+ |
||||
Version: | 15.0-CURRENT | ||||||
Hardware: | Any | ||||||
OS: | Any | ||||||
Attachments: |
|
Description
Alan Somers
2025-01-09 20:15:09 UTC
I've determined that the cause of the failure in nfscl_invalidfname is because my test fuse file system includes the NUL character in its readdir entries. That is, it replies something like this: ents[0].d_namlen = 3; ents[0].d_name = ".."; ents[1].d_namlen = 2; ents[1].d_name = "."; I can and will fix that in the tests. But I can't guarantee that other fuse file systems won't do the same. Even if I have fusefs sanitize these strings in-kernel, other file systems might do the same. For example, I see that ext2 trusts the on-disk data, and copies it into a dirent without sanitizing it. So NFS must be able to handle that. Created attachment 256592 [details]
Fix handling of a nul in a file name received from an NFS server
I think this patch should fix the crash.
Hopefully Alan can test it?
(In reply to Rick Macklem from comment #2) The patch works for me! A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=f9f0a1d61c7b97c705246c747baec385e0592966 commit f9f0a1d61c7b97c705246c747baec385e0592966 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2025-01-10 03:54:41 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2025-01-10 03:54:41 +0000 nfscl: Fix a crash when a readdir entry has nul in it Commit 026cdaa3b3a9 added a check for a nul or "/" in a file name in a readdir reply. Unfortunately, the minimal testing done on it did not detect a bug that can cause the client to crash. This patch fixes the code so that it does not crash. Note that a NFS server will not normally return a file name in a readdir reply that has a nul or "/" in it, so the crash is unlikely. PR: 283965 Reported by: asomers Tested by: asomers MFC after: 2 weeks sys/fs/nfsclient/nfs_clrpcops.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) The patch has been committed and will be MFC'd. A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d7b69bb536f7dd4857f1aec86536737a2e94c68a commit d7b69bb536f7dd4857f1aec86536737a2e94c68a Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2025-01-10 03:54:41 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2025-01-24 02:25:10 +0000 nfscl: Fix a crash when a readdir entry has nul in it Commit 026cdaa3b3a9 added a check for a nul or "/" in a file name in a readdir reply. Unfortunately, the minimal testing done on it did not detect a bug that can cause the client to crash. This patch fixes the code so that it does not crash. Note that a NFS server will not normally return a file name in a readdir reply that has a nul or "/" in it, so the crash is unlikely. PR: 283965 (cherry picked from commit f9f0a1d61c7b97c705246c747baec385e0592966) sys/fs/nfsclient/nfs_clrpcops.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=968abc191ea145040f4c2105755d11b63ecb2427 commit 968abc191ea145040f4c2105755d11b63ecb2427 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2025-01-10 03:54:41 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2025-01-24 02:30:22 +0000 nfscl: Fix a crash when a readdir entry has nul in it Commit 026cdaa3b3a9 added a check for a nul or "/" in a file name in a readdir reply. Unfortunately, the minimal testing done on it did not detect a bug that can cause the client to crash. This patch fixes the code so that it does not crash. Note that a NFS server will not normally return a file name in a readdir reply that has a nul or "/" in it, so the crash is unlikely. PR: 283965 (cherry picked from commit f9f0a1d61c7b97c705246c747baec385e0592966) sys/fs/nfsclient/nfs_clrpcops.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) Patch has been committed and MFC'd. |