mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yazen Ghannam <yazen.ghannam@amd.com>
To: Borislav Petkov <bp@alien8.de>
Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org,
	tony.luck@intel.com, x86@kernel.org
Subject: Re: [PATCH 1/3] x86/mce/amd: Fix bank lookup in amd_mce_usable_address()
Date: Sun, 4 Oct 2026 11:16:08 -0400	[thread overview]
Message-ID: <20261004151608.GB2673@yaz-khff2.amd.com> (raw)
In-Reply-To: <20261002051942.GIar8-7qT6l3mUhofX@fat_crate.local>

On Thu, Oct 01, 2026 at 10:19:42PM -0700, Borislav Petkov wrote:
> On Thu, Sep 03, 2026 at 09:20:47AM -0500, Yazen Ghannam wrote:
> > amd_mce_usable_address() reads the per-CPU smca_banks array at index
> > m->bank on the running CPU. The index is not checked, and the bank
> > belongs to m->extcpu, not to whichever CPU is decoding.
> > 
> > m->bank is unbounded here. apei_mce_report_mem_error() sets it to -1,
> > which is 255 in the u8 field, and apei_smca_report_x86_error() takes it
> > from a firmware BERT record. Both reach this function through the
> > decoder chain, which runs from a workqueue on any CPU. Bank counts
> > differ per CPU on SMCA systems. So the read can land past the end of
> > the array, or on a CPU where that bank means something else.
> > 
> > Use m->extcpu for both the bound and the lookup.
> >
> > Fixes: 821f5fe4dbcb ("x86/mce: Add support for physical address valid bit")
> > Cc: stable@vger.kernel.org
> > Assisted-by: Claude:claude-opus-5
> 
> ...: LLM
> 
> For all three pls.
> 

Yes, will do.

> > Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
> > ---
> >  arch/x86/kernel/cpu/mce/amd.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
> > index f916fb4c5d13..e6542e00dc5a 100644
> > --- a/arch/x86/kernel/cpu/mce/amd.c
> > +++ b/arch/x86/kernel/cpu/mce/amd.c
> > @@ -837,7 +837,8 @@ bool amd_mce_usable_address(struct mce *m)
> >  			return false;
> >  	}
> >  
> > -	if (this_cpu_ptr(smca_banks)[m->bank].paddrv)
> > +	if (m->bank < per_cpu(mce_num_banks, m->extcpu) &&
> > +	    per_cpu(smca_banks, m->extcpu)[m->bank].paddrv)
> 
> Except that this conditional turns into an unreadable mess now. IOW, split it:
> 
>         if (m->bank >= per_cpu(mce_num_banks, m->extcpu)) 
>                 return false;
> 
>         if (per_cpu(smca_banks, m->extcpu)[m->bank].paddrv)
>                 return m->status & MCI_STATUS_PADDRV;
> 

Okay.

Thanks,
Yazen

  reply	other threads:[~2026-10-04 15:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 14:20 [PATCH 0/3] Increase MCA bank count Yazen Ghannam
2026-09-03 14:20 ` [PATCH 1/3] x86/mce/amd: Fix bank lookup in amd_mce_usable_address() Yazen Ghannam
2026-10-02  5:19   ` Borislav Petkov
2026-10-04 15:16     ` Yazen Ghannam [this message]
2026-09-03 14:20 ` [PATCH 2/3] x86/mce/amd: Convert bank_map to a bitmap Yazen Ghannam
2026-09-03 14:20 ` [PATCH 3/3] x86/mce: Increase MAX_NR_BANKS to 255 Yazen Ghannam

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=20261004151608.GB2673@yaz-khff2.amd.com \
    --to=yazen.ghannam@amd.com \
    --cc=bp@alien8.de \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /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®