]> 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)
commit89888c0da7d456a9fc712022764973a4e9ca08a7
tree7dad2afbc8c1984d3434b3bfb23f8c3cb5addc3f
parent2b82b828a18a885dbb0035a19bbf4a125a6810e3
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