Backport patch to ensure NUL-terminated task->comm buffer - #168
Conversation
bcressey
left a comment
There was a problem hiding this comment.
This should be submitted upstream, let's figure out how to do that.
| # Drop AL revert of upstream patch to minimize delta. The necessary dependency | ||
| # options for nvidia are instead included through DRM_SIMPLE | ||
| Patch1005: 1005-Revert-Revert-drm-fb_helper-improve-CONFIG_FB-depend.patch | ||
| # Prevent copying possible non-terminated strings |
There was a problem hiding this comment.
While the patch has wider ramifications because of the many uses of strscpy, the specific motivation is to ensure NUL-termination for task->comm:
| # Prevent copying possible non-terminated strings | |
| # Backport patch to ensure NUL-terminated task->comm buffer |
Backport patch to prevent copying non-terminated strings through strscpy Signed-off-by: Arnaldo Garcia Rincon <agarrcia@amazon.com>
8fc5415 to
7dbde8c
Compare
|
Forced push includes:
|
|
|
||
| Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> |
There was a problem hiding this comment.
The convention for this kind of backport appears to be:
commit <xyz> upstream.
<original commit message>
<original sign-off chain>
<your sign-off>
See this commit for an example.
So the patch would look like:
commit 9022ed0e7e65734d83a0648648589b9fbea8e8c9 upstream.
The point behind strscpy() was to once and for all avoid all the
problems with 'strncpy()' and later broken "fixed" versions like
strlcpy() that just made things worse.
...
So avoid any "copy possibly non-terminated string, and terminate later"
behavior, and write the destination buffer only once.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Arnaldo Garcia Rincon <agarrcia@amazon.com>
For the 6.1 patch, you could do the same thing but also add Shikha's sign-off.
This commit gives an example of how a [ note describing backport changes.] can be formatted. If present (as it would be for the 6.1 patch) it should come before the new sign-offs.
| @@ -0,0 +1,119 @@ | |||
| From b7d33b4621b8e722f69df30443421712c706bf6c Mon Sep 17 00:00:00 2001 | |||
There was a problem hiding this comment.
| From b7d33b4621b8e722f69df30443421712c706bf6c Mon Sep 17 00:00:00 2001 | |
| From 9022ed0e7e65734d83a0648648589b9fbea8e8c9 Mon Sep 17 00:00:00 2001 |
7dbde8c to
471c66e
Compare
|
Forced push addresses:
|
Backport patch to prevent copying non-terminated strings through strscpy Signed-off-by: Arnaldo Garcia Rincon <agarrcia@amazon.com>
471c66e to
6bfc47a
Compare
|
(Forced push fixes the patch format for the 6.1 kernel per suggestions) |
| [vyaghras: | ||
| - backport to 6.1 | ||
| - apply changes in original patch to strscpy, since sized_strscpy | ||
| doesn't exist in 6.1] |
There was a problem hiding this comment.
Per the example commit I linked to, and my earlier offline suggestion, it might be more conventional to write this note like this:
[vyaghras: adjust context since e6584c3964f2f ("string: Allow 2-argument
strscpy()") is not present]
Issue number:
Fixes #167
Description of changes:
Even though the kernel enforces NUL terminated strings, it seems like sometimes they do appear in the kernel causing it to panic. This has been observed upstream, particularly when reading the
commproperty of a task. There is a patch upstream that addresses this problem, but it doesn't apply cleanly, so back port the parts that are of interest to thestrscpyfunction.Testing done:
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.