]> git.baikalelectronics.ru Git - kernel.git/commit
string.h: add FORTIFY coverage for strscpy()
authorFrancis Laniel <laniel_francis@privacyrequired.com>
Wed, 16 Dec 2020 04:43:50 +0000 (20:43 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 16 Dec 2020 06:46:16 +0000 (22:46 -0800)
commitd53a91cd9b38de5f81dadb4969cc65dab1618933
tree7dad2afbc8c1984d3434b3bfb23f8c3cb5addc3f
parentb703ed7b0e05fc20acc3513bed5e3fa95f6874c2
string.h: add FORTIFY coverage for strscpy()

The fortified version of strscpy ensures the following before vanilla strscpy
is called:

1. There is no read overflow because we either size is smaller than
   src length or we shrink size to src length by calling fortified
   strnlen.

2. There is no write overflow because we either failed during
   compilation or at runtime by checking that size is smaller than dest
   size.

Link: https://lkml.kernel.org/r/20201122162451.27551-4-laniel_francis@privacyrequired.com
Signed-off-by: Francis Laniel <laniel_francis@privacyrequired.com>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Daniel Axtens <dja@axtens.net>
Cc: Daniel Micay <danielmicay@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/string.h