nsfs: fix u32-vs-bytes unit mismatch in nsfs_fh_to_dentry() - #2644
Closed
vfsci-bot[bot] wants to merge 2 commits into
Closed
vfsci-bot[bot] wants to merge 2 commits into
vfsci-bot[bot] wants to merge 2 commits into
Conversation
In nsfs_fh_to_dentry(), both fh_len and NSFS_FID_SIZE_U32_LATEST (4) are expressed in units of 4-byte u32 words rather than bytes, whereas pointer arithmetic on (void *)fid and the byte count passed to memchr_inv() are in bytes (NSFS_FILE_HANDLE_SIZE_LATEST = 16). Passing (void *)fid + NSFS_FID_SIZE_U32_LATEST and fh_len - NSFS_FID_SIZE_U32_LATEST to memchr_inv() inspects bytes [4 .. fh_len) inside struct nsfs_file_handle (fid->ns_id and fid->ns_type) instead of the trailing bytes [16 .. fh_len * 4) after struct nsfs_file_handle. Consequently: 1. Valid zero-padded handles with handle_bytes >= 36 (fh_len >= 9) where fid->ns_type != 0 (at byte offset 8) are falsely rejected with -ESTALE. 2. Non-zero trailing garbage in bytes [16 .. fh_len * 4) is ignored when the upper 32 bits of fid->ns_id (bytes [4..7]) are zero. Fix this by offsetting (void *)fid by NSFS_FILE_HANDLE_SIZE_LATEST (16) and multiplying (fh_len - NSFS_FID_SIZE_U32_LATEST) by sizeof(u32). Fixes: 5222470 ("nsfs: support file handles") Assisted-by: LLM Signed-off-by: Hui Peng <benquike@gmail.com>
…to_dentry() In nsfs_fh_to_dentry(), ns_get_unless_inactive(ns) acquires an active reference to ns before switching on ns->ns_type. Unlike the CLONE_NEWPID error path and the owning_ns permission error path, the default: branch returns ERR_PTR(-EOPNOTSUPP) without calling ns->ops->put(ns), leaking the namespace reference. Call ns->ops->put(ns) before returning ERR_PTR(-EOPNOTSUPP) in the default: branch. Fixes: 5222470 ("nsfs: support file handles") Assisted-by: LLM Signed-off-by: Hui Peng <benquike@gmail.com>
Author
|
Superseded by series 1169168 (v1). Closing automatically. Automated by ml2pr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Series: https://patchwork.kernel.org/project/linux-fsdevel/list/?series=1169233
Submitter: Hui Peng
Version: 2
Patches: 2/2
Message-ID:
<20260919112519.3872163-1-benquike@gmail.com>Base: vfs.base.ci
Lore: https://lore.kernel.org/linux-fsdevel/20260919112519.3872163-1-benquike@gmail.com
Automated by ml2pr