Skip to content

Commit

Permalink
fat: fix uninitialized field in nostale filehandles
Browse files Browse the repository at this point in the history
[ Upstream commit fde2497 ]

When fat_encode_fh_nostale() encodes file handle without a parent it
stores only first 10 bytes of the file handle. However the length of the
file handle must be a multiple of 4 so the file handle is actually 12
bytes long and the last two bytes remain uninitialized. This is not
great at we potentially leak uninitialized information with the handle
to userspace. Properly initialize the full handle length.

Link: https://lkml.kernel.org/r/[email protected]
Reported-by: [email protected]
Fixes: ea3983a ("fat: restructure export_operations")
Signed-off-by: Jan Kara <[email protected]>
Acked-by: OGAWA Hirofumi <[email protected]>
Cc: Amir Goldstein <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
jankara authored and gregkh committed Apr 10, 2024
1 parent d2a7a81 commit b7fb63e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/fat/nfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ fat_encode_fh_nostale(struct inode *inode, __u32 *fh, int *lenp,
fid->parent_i_gen = parent->i_generation;
type = FILEID_FAT_WITH_PARENT;
*lenp = FAT_FID_SIZE_WITH_PARENT;
} else {
/*
* We need to initialize this field because the fh is actually
* 12 bytes long
*/
fid->parent_i_pos_hi = 0;
}

return type;
Expand Down

0 comments on commit b7fb63e

Please sign in to comment.