[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ea7ff4e8-c21c-4847-8fcd-7a038782872c@kadam.mountain>
Date: Tue, 24 Oct 2023 08:40:09 +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 Tue, Oct 24, 2023 at 08:35:33AM +0300, Dan Carpenter wrote:
> 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.
Sorry, I shouldn't have sent this email. You're allowed to write it
however you want if you're fixing the bug.
regards,
dan carpenter
Powered by blists - more mailing lists