[RFC PATCH v2 1/1] string.h: Move fortified functions definitions in a dedicated header.

2021-01-11 Thread laniel_francis
From: Francis Laniel This patch adds fortify-string.h to contain fortified functions definitions. Thus, the code is more separated and compile time is slightly faster for people who do not set CONFIG_FORTIFY_SOURCE. Signed-off-by: Francis Laniel --- include/linux/fortify-string.h | 302 +++

[RFC PATCH v2 0/1] Create header for fortified string functions.

2021-01-11 Thread laniel_francis
From: Francis Laniel Hi. First, I hope your families, friends and yourself are fine. In a recent mail about the merge of a new fortified string function, Linus Torvalds suggested the creation of a dedicated header file for these functions: https://marc.info/?l=linux-mm-commits&m=16081036611124

[RFC PATCH 0/1] Create header for fortified string functions.

2021-01-07 Thread laniel_francis
From: Francis Laniel Hi. First, I do hope you are fine and the same for your relatives. In a recent mail about the merge of a new fortified string function, Linus Torvalds suggested the creation of a dedicated header file for these functions: https://marc.info/?l=linux-mm-commits&m=16081036611

[RFC PATCH 1/1] string.h: Create header for fortified string functions.

2021-01-07 Thread laniel_francis
From: Francis Laniel This patch adds fortify-string.h to contain fortified functions definitions. Thus, the code is more separated and compile time is slightly faster for people who do not set CONFIG_FORTIFY_SOURCE. Signed-off-by: Francis Laniel --- include/linux/fortify-string.h | 302 +++

[RFC PATCH v1 09/12] mips: Replace strstarts() by str_has_prefix().

2020-12-04 Thread laniel_francis
From: Francis Laniel The two functions indicates if a string begins with a given prefix. The only difference is that strstarts() returns a bool while str_has_prefix() returns the length of the prefix if the string begins with it or 0 otherwise. Signed-off-by: Francis Laniel --- arch/mips/bcm63

[RFC PATCH v1 07/12] efi: Replace strstarts() by str_has_prefix().

2020-12-04 Thread laniel_francis
From: Francis Laniel The two functions indicates if a string begins with a given prefix. The only difference is that strstarts() returns a bool while str_has_prefix() returns the length of the prefix if the string begins with it or 0 otherwise. Signed-off-by: Francis Laniel --- drivers/firmwar

[RFC PATCH v1 08/12] ide: Replace strstarts() by str_has_prefix().

2020-12-04 Thread laniel_francis
From: Francis Laniel The two functions indicates if a string begins with a given prefix. The only difference is that strstarts() returns a bool while str_has_prefix() returns the length of the prefix if the string begins with it or 0 otherwise. Signed-off-by: Francis Laniel --- drivers/ide/ide

[RFC PATCH v1 10/12] module: Replace strstarts() by str_has_prefix().

2020-12-04 Thread laniel_francis
From: Francis Laniel The two functions indicates if a string begins with a given prefix. The only difference is that strstarts() returns a bool while str_has_prefix() returns the length of the prefix if the string begins with it or 0 otherwise. Signed-off-by: Francis Laniel --- kernel/module.c

[RFC PATCH v1 11/12] musb: Replace strstarts() by str_has_prefix().

2020-12-04 Thread laniel_francis
From: Francis Laniel The two functions indicates if a string begins with a given prefix. The only difference is that strstarts() returns a bool while str_has_prefix() returns the length of the prefix if the string begins with it or 0 otherwise. Signed-off-by: Francis Laniel --- drivers/usb/mus

[RFC PATCH v1 04/12] device-mapper: Replace strstarts() by str_has_prefix().

2020-12-04 Thread laniel_francis
From: Francis Laniel The two functions indicates if a string begins with a given prefix. The only difference is that strstarts() returns a bool while str_has_prefix() returns the length of the prefix if the string begins with it or 0 otherwise. Signed-off-by: Francis Laniel --- drivers/md/dm-c

[RFC PATCH v1 12/12] string.h: Remove strstarts().

2020-12-04 Thread laniel_francis
From: Francis Laniel When str_has_prefix() was introduced in commit 495d714ad140 ("Merge tag 'trace-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace"), this commit stated that the new function should replace the existing one. Signed-off-by: Francis Laniel --- include

[RFC PATCH v1 03/12] crypto: Replace strstarts() by str_has_prefix().

2020-12-04 Thread laniel_francis
From: Francis Laniel The two functions indicates if a string begins with a given prefix. The only difference is that strstarts() returns a bool while str_has_prefix() returns the length of the prefix if the string begins with it or 0 otherwise. Signed-off-by: Francis Laniel --- crypto/essiv.c

[RFC PATCH v1 06/12] omap: Replace strstarts() by str_has_prefix().

2020-12-04 Thread laniel_francis
From: Francis Laniel The two functions indicates if a string begins with a given prefix. The only difference is that strstarts() returns a bool while str_has_prefix() returns the length of the prefix if the string begins with it or 0 otherwise. Signed-off-by: Francis Laniel --- drivers/gpu/drm

[RFC PATCH v1 05/12] renesas: Replace strstarts() by str_has_prefix().

2020-12-04 Thread laniel_francis
From: Francis Laniel The two functions indicates if a string begins with a given prefix. The only difference is that strstarts() returns a bool while str_has_prefix() returns the length of the prefix if the string begins with it or 0 otherwise. Signed-off-by: Francis Laniel --- drivers/gpu/drm

[RFC PATCH v1 02/12] mips: Replace strstarts() by str_has_prefix().

2020-12-04 Thread laniel_francis
From: Francis Laniel The two functions indicates if a string begins with a given prefix. The only difference is that strstarts() returns a bool while str_has_prefix() returns the length of the prefix if the string begins with it or 0 otherwise. Signed-off-by: Francis Laniel --- arch/mips/bcm47

[RFC PATCH v1 01/12] arm: Replace strstarts() by str_has_prefix().

2020-12-04 Thread laniel_francis
From: Francis Laniel The two functions indicates if a string begins with a given prefix. The only difference is that strstarts() returns a bool while str_has_prefix() returns the length of the prefix if the string begins with it or 0 otherwise. Signed-off-by: Francis Laniel --- arch/arm/kernel

[RFC PATCH v1 00/12] Replace strstarts() by str_has_prefix()

2020-12-04 Thread laniel_francis
From: Francis Laniel Hi. First, I hope you are fine and the same for your relatives. In this patch set, I replaced all calls to strstarts() by calls to str_has_prefix(). Indeed, the kernel has two functions to test if a string begins with an other: 1. strstarts() which returns a bool, so 1 if

[PATCH v7 1/5] string.h: detect intra-object overflow in fortified string functions

2020-11-22 Thread laniel_francis
From: Daniel Axtens When the fortify feature was first introduced in commit 6974f0c4555e ("include/linux/string.h: add the option of fortified string.h functions"), Daniel Micay observed: * It should be possible to optionally use __builtin_object_size(x, 1) for some functions (C strings) t

[PATCH v7 5/5] Correct wrong filenames in comment.

2020-11-22 Thread laniel_francis
From: Francis Laniel In lkdtm.h, files targeted in comments are named "lkdtm_file.c" while there are named "file.c" in directory. Acked-by: Kees Cook Signed-off-by: Francis Laniel --- drivers/misc/lkdtm/lkdtm.h | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a

[PATCH v7 4/5] Add new file in LKDTM to test fortified strscpy.

2020-11-22 Thread laniel_francis
From: Francis Laniel This new test ensures that fortified strscpy has the same behavior than vanilla strscpy (e.g. returning -E2BIG when src content is truncated). Finally, it generates a crash at runtime because there is a write overflow in destination string. Reviewed-by: Kees Cook Signed-off

[PATCH v7 3/5] string.h: Add FORTIFY coverage for strscpy()

2020-11-22 Thread laniel_francis
From: Francis Laniel 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 eithe

[PATCH v7 2/5] lkdtm: tests for FORTIFY_SOURCE

2020-11-22 Thread laniel_francis
From: Daniel Axtens Add code to test both: - runtime detection of the overrun of a structure. This covers the __builtin_object_size(x, 0) case. This test is called FORTIFY_OBJECT. - runtime detection of the overrun of a char array within a structure. This covers the __builtin_object_siz

[PATCH v7 0/5] Fortify strscpy()

2020-11-22 Thread laniel_francis
From: Francis Laniel Hi. I hope your families, friends and yourselves are fine. This patch implements a fortified version of strscpy() enabled by setting CONFIG_FORTIFY_SOURCE=y. The new version ensures the following before calling vanilla strscpy(): 1. There is no read overflow because either

[PATCH v6 3/5] string.h: Add FORTIFY coverage for strscpy()

2020-11-19 Thread laniel_francis
From: Francis Laniel 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 eithe

[PATCH v6 1/5] string.h: detect intra-object overflow in fortified string functions

2020-11-19 Thread laniel_francis
From: Daniel Axtens When the fortify feature was first introduced in commit 6974f0c4555e ("include/linux/string.h: add the option of fortified string.h functions"), Daniel Micay observed: * It should be possible to optionally use __builtin_object_size(x, 1) for some functions (C strings) t

[PATCH v6 2/5] lkdtm: tests for FORTIFY_SOURCE

2020-11-19 Thread laniel_francis
From: Daniel Axtens Add code to test both: - runtime detection of the overrun of a structure. This covers the __builtin_object_size(x, 0) case. This test is called FORTIFY_OBJECT. - runtime detection of the overrun of a char array within a structure. This covers the __builtin_object_siz

[PATCH v6 0/5] Fortify strscpy()

2020-11-19 Thread laniel_francis
From: Francis Laniel Hi. I hope your families, friends and yourselves are fine. This patch set answers to this issue: https://github.com/KSPP/linux/issues/46 I based my modifications on top of two patches from Daniel Axtens which modify calls to __builtin_object_size to ensure the true size o

[PATCH v6 4/5] Add new file in LKDTM to test fortified strscpy.

2020-11-19 Thread laniel_francis
From: Francis Laniel This new test ensures that fortified strscpy has the same behavior than vanilla strscpy (e.g. returning -E2BIG when src content is truncated). Finally, it generates a crash at runtime because there is a write overflow in destination string. Signed-off-by: Francis Laniel Rev

[PATCH v6 5/5] Correct wrong filenames in comment.

2020-11-19 Thread laniel_francis
From: Francis Laniel In lkdtm.h, files targeted in comments are named "lkdtm_file.c" while there are named "file.c" in directory. Signed-off-by: Francis Laniel Acked-by: Kees Cook --- drivers/misc/lkdtm/lkdtm.h | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a

[PATCH v5 5/5] Correct wrong filenames in comment.

2020-11-18 Thread laniel_francis
From: Francis Laniel In lkdtm.h, files targeted in comments are named "lkdtm_file.c" while there are named "file.c" in directory. Signed-off-by: Francis Laniel Acked-by: Kees Cook --- drivers/misc/lkdtm/lkdtm.h | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a

[PATCH v5 2/5] lkdtm: tests for FORTIFY_SOURCE

2020-11-18 Thread laniel_francis
From: Daniel Axtens Add code to test both: - runtime detection of the overrun of a structure. This covers the __builtin_object_size(x, 0) case. This test is called FORTIFY_OBJECT. - runtime detection of the overrun of a char array within a structure. This covers the __builtin_object_siz

[PATCH v5 1/5] string.h: detect intra-object overflow in fortified string functions

2020-11-18 Thread laniel_francis
From: Daniel Axtens When the fortify feature was first introduced in commit 6974f0c4555e ("include/linux/string.h: add the option of fortified string.h functions"), Daniel Micay observed: * It should be possible to optionally use __builtin_object_size(x, 1) for some functions (C strings) t

[PATCH v5 4/5] Add new file in LKDTM to test fortified strscpy.

2020-11-18 Thread laniel_francis
From: Francis Laniel This new test ensures that fortified strscpy has the same behavior than vanilla strscpy (e.g. returning -E2BIG when src content is truncated). Finally, it generates a crash at runtime because there is a write overflow in destination string. Signed-off-by: Francis Laniel Rev

[PATCH v5 3/5] string.h: Add FORTIFY coverage for strscpy()

2020-11-18 Thread laniel_francis
From: Francis Laniel 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 eithe

[PATCH v5 0/5] Fortify strscpy()

2020-11-18 Thread laniel_francis
From: Francis Laniel Hi. I hope your families, friends and yourselves are fine. This patch set answers to this issue: https://github.com/KSPP/linux/issues/46 I based my modifications on top of two patches from Daniel Axtens which modify calls to __builtin_object_size to ensure the true size o