Skip to content

Commit

Permalink
Merge tag 'hardening-v6.1-rc4' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
torvalds committed Nov 4, 2022
2 parents 1caa2f1 + 6f7630b commit bd74502
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions include/linux/fortify-string.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,18 @@ __FORTIFY_INLINE bool fortify_memcpy_chk(__kernel_size_t size,

#define __fortify_memcpy_chk(p, q, size, p_size, q_size, \
p_size_field, q_size_field, op) ({ \
size_t __fortify_size = (size_t)(size); \
WARN_ONCE(fortify_memcpy_chk(__fortify_size, p_size, q_size, \
p_size_field, q_size_field, #op), \
const size_t __fortify_size = (size_t)(size); \
const size_t __p_size = (p_size); \
const size_t __q_size = (q_size); \
const size_t __p_size_field = (p_size_field); \
const size_t __q_size_field = (q_size_field); \
WARN_ONCE(fortify_memcpy_chk(__fortify_size, __p_size, \
__q_size, __p_size_field, \
__q_size_field, #op), \
#op ": detected field-spanning write (size %zu) of single %s (size %zu)\n", \
__fortify_size, \
"field \"" #p "\" at " __FILE__ ":" __stringify(__LINE__), \
p_size_field); \
__p_size_field); \
__underlying_##op(p, q, __fortify_size); \
})

Expand Down

0 comments on commit bd74502

Please sign in to comment.