title: EDAC/thunderx: Fix possible out-of-bounds string access
description: In the Linux kernel, the following vulnerability has been resolved:
EDAC/thunderx: Fix possible out-of-bounds string access
Enabling -Wstringop-overflow globally exposes a warning for a common bug
in the usage of strncat():
drivers/edac/thunderx_edac.c: In function 'thunderx_ocx_com_threaded_isr':
drivers/edac/thunderx_edac.c:1136:17: error: 'strncat' specified bound 1024 equals destination size [-Werror=stringop-overflow=]
1136 |                 strncat(msg, other, OCX_MESSAGE_SIZE);
|                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
1145 |                                 strncat(msg, other, OCX_MESSAGE_SIZE);
...
1150 |                                 strncat(msg, other, OCX_MESSAGE_SIZE);
...
Apparently the author of this driver expected strncat() to behave the
way that strlcat() does, which uses the size of the destination buffer
as its third argument rather than the length of the source buffer. The
result is that there is no check on the size of the allocated buffer.
Change it to strlcat().
[ bp: Trim compiler output, fixup commit message. ]
affected:
{
product: Linux
vendor: Linux
defaultStatus: unaffected
repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
versions:
version: 41003396f932, lessThan: 71c17ee02538, status: affected, versionType: git
version: 41003396f932, lessThan: 5da3b6e7196f, status: affected, versionType: git
version: 41003396f932, lessThan: 6aa7865ba7ff, status: affected, versionType: git
version: 41003396f932, lessThan: 700cf4bead80, status: affected, versionType: git
version: 41003396f932, lessThan: 9dbac9fdae6e, status: affected, versionType: git
version: 41003396f932, lessThan: e1c865112415, status: affected, versionType: git
version: 41003396f932, lessThan: 426fae93c01d, status: affected, versionType: git
version: 41003396f932, lessThan: 475c58e1a471, status: affected, versionType: git
}
{
product: Linux
vendor: Linux
defaultStatus: affected
repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
versions:
version: 4.12, status: affected
version: 0, lessThan: 4.12, status: unaffected, versionType: custom
version: 4.19.306, lessThanOrEqual: 4.19.*, status: unaffected, versionType: custom
version: 5.4.268, lessThanOrEqual: 5.4.*, status: unaffected, versionType: custom
version: 5.10.209, lessThanOrEqual: 5.10.*, status: unaffected, versionType: custom
version: 5.15.148, lessThanOrEqual: 5.15.*, status: unaffected, versionType: custom
version: 6.1.75, lessThanOrEqual: 6.1.*, status: unaffected, versionType: custom
version: 6.6.14, lessThanOrEqual: 6.6.*, status: unaffected, versionType: custom
version: 6.7.2, lessThanOrEqual: 6.7.*, status: unaffected, versionType: custom
version: 6.8, lessThanOrEqual: *, status: unaffected, versionType: original_commit_for_fix
}
