Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1705126
| From | Chandan Rajendra <chandan@linux.vnet.ibm.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/2] ext4: fix warning about stack corruption |
| Date | 2017-08-07 08:50 +0200 |
| Message-ID | <ubK1s-4ID-3@gated-at.bofh.it> (permalink) |
| References | <u7zHk-3ZT-15@gated-at.bofh.it> <u9E9S-3Rb-37@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Tuesday, August 1, 2017 5:34:03 PM IST Arnd Bergmann wrote:
> After commit 62d1034f53e3 ("fortify: use WARN instead of BUG for now"),
> we get a warning about possible stack overflow from a memcpy that
> was not strictly bounded to the size of the local variable:
>
> inlined from 'ext4_mb_seq_groups_show' at fs/ext4/mballoc.c:2322:2:
> include/linux/string.h:309:9: error: '__builtin_memcpy': writing between 161 and 1116 bytes into a region of size 160 overflows the destination [-Werror=stringop-overflow=]
>
> We actually had a bug here that would have been found by the warning,
> but it was already fixed last year in commit 30a9d7afe70e ("ext4: fix
> stack memory corruption with 64k block size").
>
> This replaces the fixed-length structure on the stack with a variable-length
> structure, using the correct upper bound that tells the compiler that
> everything is really fine here. I also change the loop count to check
> for the same upper bound for consistency, but the existing code is
> already correct here.
>
> Note that while clang won't allow certain kinds of variable-length arrays
> in structures, this particular instance is fine, as the array is at the
> end of the structure, and the size is strictly bounded.
>
> There is one remaining issue with the function that I'm not addressing
> here: With s_blocksize_bits==16, we don't actually print the last two
> members of the array, as we loop though just the first 14 members.
> This could be easily addressed by adding two extra columns in the output,
> but that could in theory break parsers in user space, and should be
> a separate patch if we decide to modify it.
>
I executed xfstests on a ppc64 machine with both 4k and 64k block size
combination.
Tested-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
--
chandan
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH 1/2] ext4: fix warning about stack corruption Arnd Bergmann <arnd@arndb.de> - 2017-08-01 14:10 +0200
[PATCH 2/2] adfs: use 'unsigned' types for memcpy length Arnd Bergmann <arnd@arndb.de> - 2017-08-01 14:10 +0200
Re: [PATCH 2/2] adfs: use 'unsigned' types for memcpy length Kees Cook <keescook@chromium.org> - 2017-08-01 20:30 +0200
Re: [PATCH 2/2] adfs: use 'unsigned' types for memcpy length Stephen Rothwell <sfr@canb.auug.org.au> - 2017-08-01 23:50 +0200
Re: [PATCH 1/2] ext4: fix warning about stack corruption Kees Cook <keescook@chromium.org> - 2017-08-01 20:30 +0200
Re: [PATCH 1/2] ext4: fix warning about stack corruption Theodore Ts'o <tytso@mit.edu> - 2017-08-06 04:00 +0200
Re: [PATCH 1/2] ext4: fix warning about stack corruption Arnd Bergmann <arnd@arndb.de> - 2017-08-06 22:40 +0200
Re: [PATCH 1/2] ext4: fix warning about stack corruption Chandan Rajendra <chandan@linux.vnet.ibm.com> - 2017-08-07 08:50 +0200
csiph-web