[f2fs-dev] [PATCH] mkfs.f2fs: Fix out-of-bounds read in f2fs_prepare_super_block
The path field in c.devices[i] is a pointer and is normally filled in using strdup. This makes it invalid to copy MAX_PATH_LEN bytes from it because the string may be shorter than that. Therefore, fix the code to use strncpy to copy the string instead. Signed-off-by: Peter Collingbourne --- mkfs/f2fs_format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index c9d335a..b053685 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -316,7 +316,7 @@ static int f2fs_prepare_super_block(void) c.blks_per_seg - 1; } if (c.ndevs > 1) { - memcpy(sb->devs[i].path, c.devices[i].path, MAX_PATH_LEN); + strncpy((char *)sb->devs[i].path, c.devices[i].path, MAX_PATH_LEN); sb->devs[i].total_segments = cpu_to_le32(c.devices[i].total_segments); } -- 2.46.0.rc1.232.g9752f9e123-goog ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 10/31] Verify structure sizes at compile time
Hi Bart, On Thu, Apr 21, 2022 at 03:18:15PM -0700, Bart Van Assche wrote: > +static_assert(sizeof(struct f2fs_dentry_block) == 4096, ""); I noticed that this static_assert fails when PAGE_SIZE is defined to a value other than 4096. I have to admit to being unfamiliar with f2fs. Is this an on-disk data structure? If so, does it mean that non-4K page size kernels are unable to mount f2fs file systems if the f2fs-tools were not built with a matching PAGE_SIZE define? In any event, maybe s/4096/PAGE_SIZE/g above is the correct fix for now? Peter ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH v2 1/5] Fix the struct f2fs_dentry_block definition
On Thu, Jun 23, 2022 at 11:12 AM Bart Van Assche wrote: > > Fix the struct f2fs_dentry_block definition on systems for which > PAGE_SIZE != 4096. This patch does not change the struct f2fs_dentry_block > definition if PAGE_SIZE == 4096. > > Cc: Peter Collingbourne > Reported-by: Peter Collingbourne > Signed-off-by: Bart Van Assche Thanks, this is what I had in mind and it fixes the build on my target with PAGE_SIZE != 4096. I also verified that a filesystem created on the PAGE_SIZE != 4096 target can be mounted on a machine with PAGE_SIZE == 4096. Reviewed-by: Peter Collingbourne Tested-by: Peter Collingbourne Peter ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel