]> git.proxmox.com Git - mirror_ubuntu-hirsute-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)
commit33e56a59e64dfb68778e5da0be13f0c47dc5d445
tree7dad2afbc8c1984d3434b3bfb23f8c3cb5addc3f
parentd96938daae2a2ae20e5d3d38ddb85d8afdaee628
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