diff options
author | pengfuyuan <pengfuyuan@kylinos.cn> | 2023-05-23 15:09:55 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2023-05-26 23:24:55 +0200 |
commit | 5ad9b4719fc9bc4715c7e19875a962095b0577e7 (patch) | |
tree | d0d655df3368d055aa64505f7defeed9784db98a /crypto/curve25519-generic.c | |
parent | 8fd9f4232d8152c650fd15127f533a0f6d0a4b2b (diff) | |
download | linux-stable-5ad9b4719fc9bc4715c7e19875a962095b0577e7.tar.gz linux-stable-5ad9b4719fc9bc4715c7e19875a962095b0577e7.tar.bz2 linux-stable-5ad9b4719fc9bc4715c7e19875a962095b0577e7.zip |
btrfs: fix csum_tree_block page iteration to avoid tripping on -Werror=array-bounds
When compiling on a MIPS 64-bit machine we get these warnings:
In file included from ./arch/mips/include/asm/cacheflush.h:13,
from ./include/linux/cacheflush.h:5,
from ./include/linux/highmem.h:8,
from ./include/linux/bvec.h:10,
from ./include/linux/blk_types.h:10,
from ./include/linux/blkdev.h:9,
from fs/btrfs/disk-io.c:7:
fs/btrfs/disk-io.c: In function ‘csum_tree_block’:
fs/btrfs/disk-io.c:100:34: error: array subscript 1 is above array bounds of ‘struct page *[1]’ [-Werror=array-bounds]
100 | kaddr = page_address(buf->pages[i]);
| ~~~~~~~~~~^~~
./include/linux/mm.h:2135:48: note: in definition of macro ‘page_address’
2135 | #define page_address(page) lowmem_page_address(page)
| ^~~~
cc1: all warnings being treated as errors
We can check if i overflows to solve the problem. However, this doesn't make
much sense, since i == 1 and num_pages == 1 doesn't execute the body of the loop.
In addition, i < num_pages can also ensure that buf->pages[i] will not cross
the boundary. Unfortunately, this doesn't help with the problem observed here:
gcc still complains.
To fix this add a compile-time condition for the extent buffer page
array size limit, which would eventually lead to eliminating the whole
for loop.
CC: stable@vger.kernel.org # 5.10+
Signed-off-by: pengfuyuan <pengfuyuan@kylinos.cn>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'crypto/curve25519-generic.c')
0 files changed, 0 insertions, 0 deletions