From: Robert Richter <rric@kernel.org>
To: Borislav Petkov <bp@alien8.de>
Cc: Toshi Kani <toshi.kani@hpe.com>,
mchehab@kernel.org, elliott@hpe.com, linux-edac@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] EDAC/ghes: Fix buffer overflow in ghes_edac_register()
Date: Mon, 25 Jul 2022 12:45:18 +0200 [thread overview]
Message-ID: <Yt50Pp3kQRCtSqw6@rric.localdomain> (raw)
In-Reply-To: <Yt5s/f/jyRcFY1Md@zn.tnic>
On 25.07.22 12:14:21, Borislav Petkov wrote:
> On Mon, Jul 25, 2022 at 11:53:06AM +0200, Robert Richter wrote:
> > The dimm->label buffer must be pre-initialized zero. This broke with:
> >
> > b9cae27728d1 EDAC/ghes: Scan the system once on driver init
> >
> > since krealloc/krealloc_array() does not zero out the new allocated
> > buffer for struct dimm_info in enumerate_dimms(). This uninitialized
> > broken struct is then copied in ghes_edac_register() to the final
> > dimm_info destination. Originally, before b9cae27728d1, the struct was
> > zero initialized with kzalloc'ed by edac_mc_alloc() and directly used.
> > Now, that a copy is created first, this copy must be also zero
> > initialized.
> >
> > IMO this is the proper fix:
>
> Maybe, but this needs fixing too:
>
> /* both strings must be non-zero */
> if (bank && *bank && device && *device)
>
> Obviously one of those strings are zero coming from that BIOS...
But the label is pre-initialized in edac_mc_alloc_dimms():
p = dimm->label;
n = snprintf(p, len, "mc#%u", mci->mc_idx);
You check if the label is emtpy when copying it in
ghes_edac_register():
if (strlen(src->label))
memcpy(dst->label, src->label, sizeof(src->label));
So if there is nothing that comes from the bios, this default label
string from edac_mc_alloc_dimms() will be used.
If you write "N/A" to the label instead, the sysfs dimm_label values
wont be unique any longer between dimms, which might break existing
applications.
-Robert
>
> --
> Regards/Gruss,
> Boris.
>
> https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2022-07-25 10:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-21 18:05 Toshi Kani
2022-07-22 13:20 ` Borislav Petkov
2022-07-22 15:24 ` Kani, Toshi
2022-07-25 9:53 ` Robert Richter
2022-07-25 10:14 ` Borislav Petkov
2022-07-25 10:45 ` Robert Richter [this message]
2022-07-25 11:09 ` Robert Richter
2022-07-25 11:23 ` Borislav Petkov
2022-07-25 11:30 ` Robert Richter
2022-07-25 12:54 ` Borislav Petkov
2022-07-25 16:41 ` Kani, Toshi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yt50Pp3kQRCtSqw6@rric.localdomain \
--to=rric@kernel.org \
--cc=bp@alien8.de \
--cc=elliott@hpe.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=toshi.kani@hpe.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®