lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <70bd7480-508a-451d-bc0a-f78e652cf511@kadam.mountain> Date: Tue, 24 Oct 2023 08:35:33 +0300 From: Dan Carpenter <dan.carpenter@...aro.org> To: Christophe JAILLET <christophe.jaillet@...adoo.fr> Cc: keescook@...omium.org, Robert Richter <rric@...nel.org>, Borislav Petkov <bp@...en8.de>, Tony Luck <tony.luck@...el.com>, James Morse <james.morse@....com>, Mauro Carvalho Chehab <mchehab@...nel.org>, Sergey Temerkhanov <s.temerkhanov@...il.com>, linux-hardening@...r.kernel.org, linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org, Borislav Petkov <bp@...e.de>, linux-edac@...r.kernel.org Subject: Re: [PATCH v2] EDAC/thunderx: Fix some potential buffer overflow in thunderx_ocx_com_threaded_isr() On Sat, Oct 21, 2023 at 07:13:51PM +0200, Christophe JAILLET wrote: > @@ -1127,27 +1128,26 @@ static irqreturn_t thunderx_ocx_com_threaded_isr(int irq, void *irq_id) > ARRAY_SIZE(ocx->com_err_ctx)); > ctx = &ocx->com_err_ctx[tail]; > > - snprintf(msg, OCX_MESSAGE_SIZE, "%s: OCX_COM_INT: %016llx", > - ocx->edac_dev->ctl_name, ctx->reg_com_int); > - > decode_register(other, OCX_OTHER_SIZE, > ocx_com_errors, ctx->reg_com_int); > > - strncat(msg, other, OCX_MESSAGE_SIZE); > + remaining = OCX_MESSAGE_SIZE; > + remaining -= scnprintf(msg, remaining, "%s: OCX_COM_INT: %016llx%s", > + ocx->edac_dev->ctl_name, ctx->reg_com_int, > + other); > > for (lane = 0; lane < OCX_RX_LANES; lane++) > if (ctx->reg_com_int & BIT(lane)) { > - snprintf(other, OCX_OTHER_SIZE, > - "\n\tOCX_LNE_INT[%02d]: %016llx OCX_LNE_STAT11[%02d]: %016llx", > - lane, ctx->reg_lane_int[lane], > - lane, ctx->reg_lane_stat11[lane]); > - > - strncat(msg, other, OCX_MESSAGE_SIZE); > - > decode_register(other, OCX_OTHER_SIZE, > ocx_lane_errors, > ctx->reg_lane_int[lane]); > - strncat(msg, other, OCX_MESSAGE_SIZE); > + > + remaining -= scnprintf(msg + (OCX_MESSAGE_SIZE - remaining), > + remaining, Instead of doing "remaining -=" the canonincal way is "off +=". Then the snprintf() becomes: off += scnprintf(msg + off, OCX_MESSAGE_SIZE - off, ""\n\tOCX_... Your way works but it makes my head hurt. regards, dan carpenter
Powered by blists - more mailing lists