kernel-hardening.lists.openwall.com archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] lib: Add safe string funtions
@ 2019-02-18 23:23 Tobin C. Harding
  2019-02-18 23:23 ` [PATCH 1/6] lib/string: Enable string selftesting Tobin C. Harding
                   ` (6 more replies)
  0 siblings, 7 replies; 41+ messages in thread
From: Tobin C. Harding @ 2019-02-18 23:23 UTC (permalink / raw)
  To: Kees Cook
  Cc: Tobin C. Harding, Shuah Khan, Alexander Shishkin,
	Greg Kroah-Hartman, Andy Shevchenko, kernel-hardening,
	linux-kernel

No file maintainer, CC'ing all those who touched this file :) And
Shua for kselftest stuff.


Hi Kess,

During your talk at LCA you mentioned that we could do with a couple
more safe string functions.  One to zero the tail of the destination
buffer after call to strscpy() and also the self explanatory
strscpy_from_user().

Here is a patch set with my attempts to implement these two functions.

While doing this I noticed that we have a test module for lib/string.c
(lib/test_string.c) that is not tied into kselftest.  So I enable this
first up in patch 1.

Patch 2 and 3 are function docstring cleanups.

Patch 4 adds the copy and zero function, naming it strscpy_zeroed().
I'd love some help naming this better.  Patch also adds test code.

Patch 5 fixes function docstring to correctly document the behavior of
strncpy_from_user().

Patch 6 adds strscpy_from_user().  Does not include test code.

I had to do a bit of learning for getting the tests hooked into
kselftest, I think its all correct.  Module is built correctly when the
config option is present and the tests run both via

	make -C tools/testing/selftests TARGETS=lib run_tests

and via loading the module manually.  As a side note, this series leaves
tools/testing/selftests/lib with 4 shell scripts that are identical
except the test name.  We could probably do with refactoring them into a
single script.

Patchset introduces a checkpatch warning

	WARNING:CONFIG_DESCRIPTION: please write a paragraph that describes the config symbol fully

I couldn't work out if this is a false positive or not?  Does the new
config option CONFIG_TEST_STRING need more documentation?  I don't see
where extra docs should be added and it seems self explanatory as is.


thanks,
Tobin.

Tobin C. Harding (6):
  lib/string: Enable string selftesting
  lib/string: Fix erroneous 'overflow' documentation
  lib/string: Use correct docstring format
  lib/string: Add string copy/zero function
  lib: Fix function documentation for strncpy_from_user
  lib: Add function strscpy_from_user()

 include/linux/string.h                |  4 ++
 lib/Kconfig.debug                     | 14 +++++++
 lib/Makefile                          |  2 +-
 lib/string.c                          | 41 ++++++++++++++----
 lib/strncpy_from_user.c               | 60 ++++++++++++++++++++++-----
 lib/test_string.c                     | 35 +++++++++++++++-
 tools/testing/selftests/lib/Makefile  |  2 +-
 tools/testing/selftests/lib/config    |  1 +
 tools/testing/selftests/lib/string.sh | 19 +++++++++
 9 files changed, 157 insertions(+), 21 deletions(-)
 create mode 100755 tools/testing/selftests/lib/string.sh

-- 
2.20.1

^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2019-02-25 20:09 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-18 23:23 [PATCH 0/6] lib: Add safe string funtions Tobin C. Harding
2019-02-18 23:23 ` [PATCH 1/6] lib/string: Enable string selftesting Tobin C. Harding
2019-02-19 10:55   ` Andy Shevchenko
2019-02-19 21:55     ` Tobin C. Harding
2019-02-20 10:49       ` Andy Shevchenko
2019-02-20 23:58       ` Kees Cook
2019-02-20 23:57   ` Kees Cook
2019-02-21  5:16     ` Tobin C. Harding
2019-02-18 23:23 ` [PATCH 2/6] lib/string: Fix erroneous 'overflow' documentation Tobin C. Harding
2019-02-21  0:02   ` Kees Cook
2019-02-21  5:17     ` Tobin C. Harding
2019-02-18 23:23 ` [PATCH 3/6] lib/string: Use correct docstring format Tobin C. Harding
2019-02-21  0:07   ` Kees Cook
2019-02-21  4:14     ` Randy Dunlap
2019-02-21  5:27       ` Kees Cook
2019-02-18 23:23 ` [PATCH 4/6] lib/string: Add string copy/zero function Tobin C. Harding
2019-02-21  0:48   ` Kees Cook
2019-02-21  5:20     ` Tobin C. Harding
2019-02-21 12:02     ` Andy Shevchenko
2019-02-25 20:09     ` Tobin C. Harding
2019-02-18 23:23 ` [PATCH 5/6] lib: Fix function documentation for strncpy_from_user Tobin C. Harding
2019-02-19  0:51   ` Jann Horn
2019-02-19 21:52     ` Tobin C. Harding
2019-02-21  1:05     ` Kees Cook
2019-02-21  5:24       ` Tobin C. Harding
2019-02-21  6:02         ` Kees Cook
2019-02-21 14:58           ` Rasmus Villemoes
2019-02-21 23:03             ` Kees Cook
2019-02-25 15:41               ` Rasmus Villemoes
2019-02-21 16:06           ` Jann Horn
2019-02-21 23:14             ` Kees Cook
2019-02-21 20:26           ` Stephen Rothwell
2019-02-21 23:16             ` Kees Cook
2019-02-21 14:28       ` Jann Horn
2019-02-21 22:52         ` Kees Cook
2019-02-18 23:23 ` [PATCH 6/6] lib: Add function strscpy_from_user() Tobin C. Harding
2019-02-19  2:09   ` Jann Horn
2019-02-19  2:12   ` Jann Horn
2019-02-19 21:53     ` Tobin C. Harding
2019-02-20 23:31 ` [PATCH 0/6] lib: Add safe string funtions Kees Cook
2019-02-21  5:15   ` Tobin C. Harding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).