Commit 3a3f61c
committed
exec: Make sure task->comm is always NUL-terminated
Using strscpy() meant that the final character in task->comm may be
non-NUL for a moment before the "string too long" truncation happens.
Instead of adding a new use of the ambiguous strncpy(), we'd want to
use memtostr_pad() which enforces being able to check at compile time
that sizes are sensible, but this requires being able to see string
buffer lengths. Instead of trying to inline __set_task_comm() (which
needs to call trace and perf functions), just open-code it. But to
make sure we're always safe, add compile-time checking like we already
do for get_task_comm().
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Suggested-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Kees Cook <kees@kernel.org>1 parent fa1bdca commit 3a3f61c
5 files changed
+14
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1200 | 1200 | | |
1201 | 1201 | | |
1202 | 1202 | | |
1203 | | - | |
1204 | | - | |
| 1203 | + | |
| 1204 | + | |
1205 | 1205 | | |
1206 | | - | |
1207 | 1206 | | |
1208 | 1207 | | |
1209 | | - | |
| 1208 | + | |
| 1209 | + | |
1210 | 1210 | | |
1211 | | - | |
1212 | | - | |
| 1211 | + | |
| 1212 | + | |
1213 | 1213 | | |
1214 | 1214 | | |
1215 | 1215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1932 | 1932 | | |
1933 | 1933 | | |
1934 | 1934 | | |
1935 | | - | |
1936 | | - | |
1937 | | - | |
1938 | | - | |
1939 | | - | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
1940 | 1939 | | |
1941 | 1940 | | |
1942 | 1941 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
634 | 634 | | |
635 | 635 | | |
636 | 636 | | |
637 | | - | |
| 637 | + | |
638 | 638 | | |
639 | 639 | | |
640 | 640 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
| 274 | + | |
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
736 | 736 | | |
737 | 737 | | |
738 | 738 | | |
| 739 | + | |
739 | 740 | | |
740 | 741 | | |
741 | 742 | | |
742 | | - | |
| 743 | + | |
743 | 744 | | |
744 | 745 | | |
745 | 746 | | |
| |||
0 commit comments