Skip to content

Commit bd74502

Browse files
committed
Merge tag 'hardening-v6.1-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull hardening fix from Kees Cook: - Correctly report struct member size on memcpy overflow (Kees Cook) * tag 'hardening-v6.1-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: fortify: Capture __bos() results in const temp vars
2 parents 1caa2f1 + 6f7630b commit bd74502

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

include/linux/fortify-string.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,18 @@ __FORTIFY_INLINE bool fortify_memcpy_chk(__kernel_size_t size,
454454

455455
#define __fortify_memcpy_chk(p, q, size, p_size, q_size, \
456456
p_size_field, q_size_field, op) ({ \
457-
size_t __fortify_size = (size_t)(size); \
458-
WARN_ONCE(fortify_memcpy_chk(__fortify_size, p_size, q_size, \
459-
p_size_field, q_size_field, #op), \
457+
const size_t __fortify_size = (size_t)(size); \
458+
const size_t __p_size = (p_size); \
459+
const size_t __q_size = (q_size); \
460+
const size_t __p_size_field = (p_size_field); \
461+
const size_t __q_size_field = (q_size_field); \
462+
WARN_ONCE(fortify_memcpy_chk(__fortify_size, __p_size, \
463+
__q_size, __p_size_field, \
464+
__q_size_field, #op), \
460465
#op ": detected field-spanning write (size %zu) of single %s (size %zu)\n", \
461466
__fortify_size, \
462467
"field \"" #p "\" at " __FILE__ ":" __stringify(__LINE__), \
463-
p_size_field); \
468+
__p_size_field); \
464469
__underlying_##op(p, q, __fortify_size); \
465470
})
466471

0 commit comments

Comments
 (0)