diff options
| author | Justin Stitt <[email protected]> | 2023-09-11 20:36:44 +0000 |
|---|---|---|
| committer | Rafael J. Wysocki <[email protected]> | 2023-09-21 18:55:43 +0000 |
| commit | f1fce1cf4509aa0676b363c203b9ab190c1fd8e8 (patch) | |
| tree | 7429e70128606f2d224c629536299a8451e23a26 /drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | |
| parent | Linux 6.6-rc2 (diff) | |
| download | kernel-f1fce1cf4509aa0676b363c203b9ab190c1fd8e8.tar.gz kernel-f1fce1cf4509aa0676b363c203b9ab190c1fd8e8.zip | |
ACPI: OSI: refactor deprecated strncpy()
`strncpy()` is deprecated for use on NUL-terminated destination strings [1].
We know `osi->string` is a NUL-terminated string due to its eventual use
in `acpi_install_interface()` and `acpi_remove_interface()` which expect
a `acpi_string` which has been specifically typedef'd as:
| typedef char *acpi_string; /* Null terminated ASCII string */
... and which also has other string functions used on it like `strlen`.
Furthermore, padding is not needed in this instance either.
Due to the reasoning above a suitable replacement is `strscpy` [2] since
it guarantees NUL-termination on the destination buffer and doesn't
unnecessarily NUL-pad.
While there is unlikely to be a buffer overread (or other related bug)
in this case, we should still favor a more robust and less ambiguous
interface.
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2]
Link: https://github.com/KSPP/linux/issues/90
Signed-off-by: Justin Stitt <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c')
0 files changed, 0 insertions, 0 deletions
