Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fat: fix uninitialized field in nostale filehandles

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/20240205122626.13701-1-jack@suse.cz
Reported-by: syzbot+3ce5dea5b1539ff36769@syzkaller.appspotmail.com
Fixes: ea3983ace6b7 ("fat: restructure export_operations")
Signed-off-by: Jan Kara <jack@suse.cz>
Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Jan Kara and committed by
Andrew Morton
fde2497d a1fb1c77

+6
+6
fs/fat/nfs.c
··· 130 130 fid->parent_i_gen = parent->i_generation; 131 131 type = FILEID_FAT_WITH_PARENT; 132 132 *lenp = FAT_FID_SIZE_WITH_PARENT; 133 + } else { 134 + /* 135 + * We need to initialize this field because the fh is actually 136 + * 12 bytes long 137 + */ 138 + fid->parent_i_pos_hi = 0; 133 139 } 134 140 135 141 return type;