diff options
| author | Mikulas Patocka <[email protected]> | 2022-04-19 13:56:23 +0000 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2022-04-20 18:38:49 +0000 |
| commit | a6823e4e360fe975bd3da4ab156df7c74c8b07f3 (patch) | |
| tree | 0fdd5dfb998a6ca316ba4bcb7d89e94044ce29be /tools/perf/util/c++/clang.cpp | |
| parent | vmalloc: replace VM_NO_HUGE_VMAP with VM_ALLOW_HUGE_VMAP (diff) | |
| download | kernel-a6823e4e360fe975bd3da4ab156df7c74c8b07f3.tar.gz kernel-a6823e4e360fe975bd3da4ab156df7c74c8b07f3.zip | |
x86: __memcpy_flushcache: fix wrong alignment if size > 2^32
The first "if" condition in __memcpy_flushcache is supposed to align the
"dest" variable to 8 bytes and copy data up to this alignment. However,
this condition may misbehave if "size" is greater than 4GiB.
The statement min_t(unsigned, size, ALIGN(dest, 8) - dest); casts both
arguments to unsigned int and selects the smaller one. However, the
cast truncates high bits in "size" and it results in misbehavior.
For example:
suppose that size == 0x100000001, dest == 0x200000002
min_t(unsigned, size, ALIGN(dest, 8) - dest) == min_t(0x1, 0xe) == 0x1;
...
dest += 0x1;
so we copy just one byte "and" dest remains unaligned.
This patch fixes the bug by replacing unsigned with size_t.
Signed-off-by: Mikulas Patocka <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'tools/perf/util/c++/clang.cpp')
0 files changed, 0 insertions, 0 deletions
