All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf v2 0/2] Fix bpf_probe_read_user_str() overcopying
@ 2020-11-05  2:25 Daniel Xu
  2020-11-05  2:25 ` [PATCH bpf v2 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator Daniel Xu
  2020-11-05  2:25 ` [PATCH bpf v2 2/2] selftest/bpf: Test bpf_probe_read_user_str() strips trailing bytes after NUL Daniel Xu
  0 siblings, 2 replies; 14+ messages in thread
From: Daniel Xu @ 2020-11-05  2:25 UTC (permalink / raw)
  To: bpf, linux-kernel, ast, daniel; +Cc: Daniel Xu, kernel-team

6ae08ae3dea2 ("bpf: Add probe_read_{user, kernel} and probe_read_{user,
kernel}_str helpers") introduced a subtle bug where
bpf_probe_read_user_str() would potentially copy a few extra bytes after
the NUL terminator.

This issue is particularly nefarious when strings are used as map keys,
as seemingly identical strings can occupy multiple entries in a map.

This patchset fixes the issue and introduces a selftest to prevent
future regressions.

Daniel Xu (2):
  lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator
  selftest/bpf: Test bpf_probe_read_user_str() strips trailing bytes
    after NUL

 lib/strncpy_from_user.c                       |  9 ++-
 .../bpf/prog_tests/probe_read_user_str.c      | 60 +++++++++++++++++++
 .../bpf/progs/test_probe_read_user_str.c      | 34 +++++++++++
 3 files changed, 101 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/probe_read_user_str.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_probe_read_user_str.c

-- 
2.28.0


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

end of thread, other threads:[~2020-11-15 10:27 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05  2:25 [PATCH bpf v2 0/2] Fix bpf_probe_read_user_str() overcopying Daniel Xu
2020-11-05  2:25 ` [PATCH bpf v2 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator Daniel Xu
2020-11-05  9:00   ` David Laight
2020-11-05 18:16   ` Song Liu
2020-11-05 18:18     ` Song Liu
2020-11-05 19:28     ` Daniel Xu
2020-11-15 10:41   ` [lib/strncpy_from_user.c] 2903f3d558: Kernel_panic-not_syncing:Attempted_to_kill_init!exitcode= kernel test robot
2020-11-05  2:25 ` [PATCH bpf v2 2/2] selftest/bpf: Test bpf_probe_read_user_str() strips trailing bytes after NUL Daniel Xu
2020-11-05 18:30   ` Song Liu
2020-11-05 19:27     ` Daniel Xu
2020-11-05 21:32   ` Andrii Nakryiko
2020-11-05 23:22     ` Daniel Xu
2020-11-05 23:31       ` Song Liu
2020-11-05 23:55         ` Daniel Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.