All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fat: Fix uninitialized field in nostale filehandles
@ 2024-02-05 12:26 Jan Kara
  2024-02-05 14:35 ` OGAWA Hirofumi
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kara @ 2024-02-05 12:26 UTC (permalink / raw)
  To: OGAWA Hirofumi
  Cc: linux-fsdevel, Amir Goldstein, Jan Kara, syzbot+3ce5dea5b1539ff36769

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.

Reported-by: syzbot+3ce5dea5b1539ff36769@syzkaller.appspotmail.com
Fixes: ea3983ace6b7 ("fat: restructure export_operations")
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/fat/nfs.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/fat/nfs.c b/fs/fat/nfs.c
index c52e63e10d35..509eea96a457 100644
--- a/fs/fat/nfs.c
+++ b/fs/fat/nfs.c
@@ -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;
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fat: Fix uninitialized field in nostale filehandles
  2024-02-05 12:26 [PATCH] fat: Fix uninitialized field in nostale filehandles Jan Kara
@ 2024-02-05 14:35 ` OGAWA Hirofumi
  0 siblings, 0 replies; 2+ messages in thread
From: OGAWA Hirofumi @ 2024-02-05 14:35 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Jan Kara, linux-fsdevel, Amir Goldstein, syzbot+3ce5dea5b1539ff36769

Jan Kara <jack@suse.cz> writes:

> 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.
>
> Reported-by: syzbot+3ce5dea5b1539ff36769@syzkaller.appspotmail.com
> Fixes: ea3983ace6b7 ("fat: restructure export_operations")
> Signed-off-by: Jan Kara <jack@suse.cz>

We can clean up more though, the fix itself looks good. Thanks.

Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

> ---
>  fs/fat/nfs.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/fs/fat/nfs.c b/fs/fat/nfs.c
> index c52e63e10d35..509eea96a457 100644
> --- a/fs/fat/nfs.c
> +++ b/fs/fat/nfs.c
> @@ -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;

-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-05 14:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-05 12:26 [PATCH] fat: Fix uninitialized field in nostale filehandles Jan Kara
2024-02-05 14:35 ` OGAWA Hirofumi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.