Skip to content

Commit ab62de2

Browse files
committed
Merge: EDAC/thunderx: Fix possible out-of-bounds string access
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/3834 JIRA: https://issues.redhat.com/browse/RHEL-26577 Tested: sanity CVE: CVE-2023-52464 commit 475c58e Author: Arnd Bergmann <arnd@arndb.de> Date: Wed Nov 22 23:19:53 2023 +0100 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. ] Fixes: 4100339 ("EDAC, thunderx: Add Cavium ThunderX EDAC driver") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Link: https://lore.kernel.org/r/20231122222007.3199885-1-arnd@kernel.org Signed-off-by: Aristeu Rozanski <arozansk@redhat.com> Approved-by: John B. Wyatt IV <jwyatt@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: David Arcari <darcari@redhat.com> Approved-by: Prarit Bhargava <prarit@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents 951be50 + 0549c6a commit ab62de2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/edac/thunderx_edac.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ static irqreturn_t thunderx_ocx_com_threaded_isr(int irq, void *irq_id)
11331133
decode_register(other, OCX_OTHER_SIZE,
11341134
ocx_com_errors, ctx->reg_com_int);
11351135

1136-
strncat(msg, other, OCX_MESSAGE_SIZE);
1136+
strlcat(msg, other, OCX_MESSAGE_SIZE);
11371137

11381138
for (lane = 0; lane < OCX_RX_LANES; lane++)
11391139
if (ctx->reg_com_int & BIT(lane)) {
@@ -1142,12 +1142,12 @@ static irqreturn_t thunderx_ocx_com_threaded_isr(int irq, void *irq_id)
11421142
lane, ctx->reg_lane_int[lane],
11431143
lane, ctx->reg_lane_stat11[lane]);
11441144

1145-
strncat(msg, other, OCX_MESSAGE_SIZE);
1145+
strlcat(msg, other, OCX_MESSAGE_SIZE);
11461146

11471147
decode_register(other, OCX_OTHER_SIZE,
11481148
ocx_lane_errors,
11491149
ctx->reg_lane_int[lane]);
1150-
strncat(msg, other, OCX_MESSAGE_SIZE);
1150+
strlcat(msg, other, OCX_MESSAGE_SIZE);
11511151
}
11521152

11531153
if (ctx->reg_com_int & OCX_COM_INT_CE)
@@ -1217,7 +1217,7 @@ static irqreturn_t thunderx_ocx_lnk_threaded_isr(int irq, void *irq_id)
12171217
decode_register(other, OCX_OTHER_SIZE,
12181218
ocx_com_link_errors, ctx->reg_com_link_int);
12191219

1220-
strncat(msg, other, OCX_MESSAGE_SIZE);
1220+
strlcat(msg, other, OCX_MESSAGE_SIZE);
12211221

12221222
if (ctx->reg_com_link_int & OCX_COM_LINK_INT_UE)
12231223
edac_device_handle_ue(ocx->edac_dev, 0, 0, msg);
@@ -1896,7 +1896,7 @@ static irqreturn_t thunderx_l2c_threaded_isr(int irq, void *irq_id)
18961896

18971897
decode_register(other, L2C_OTHER_SIZE, l2_errors, ctx->reg_int);
18981898

1899-
strncat(msg, other, L2C_MESSAGE_SIZE);
1899+
strlcat(msg, other, L2C_MESSAGE_SIZE);
19001900

19011901
if (ctx->reg_int & mask_ue)
19021902
edac_device_handle_ue(l2c->edac_dev, 0, 0, msg);

0 commit comments

Comments
 (0)