From: "Luck, Tony" <tony.luck@intel.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>,
LKML <linux-kernel@vger.kernel.org>,
linux-edac@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 1/2] ras: fix an off-by-one error in __find_elem()
Date: Tue, 16 Apr 2019 16:28:33 -0700 [thread overview]
Message-ID: <20190416232833.GA17372@agluck-desk> (raw)
In-Reply-To: <CAM_iQpWit6gHTEFPB5cN3XuHQjeR4mBSb03wRc1F44WEQfNH_w@mail.gmail.com>
On Tue, Apr 16, 2019 at 04:18:57PM -0700, Cong Wang wrote:
> > The problem case occurs when we've seen enough distinct
> > errors that we have filled every entry, then we try to
> > look up a pfn that is larger that any seen before.
> >
> > The loop:
> >
> > while (min < max) {
> > ...
> > }
> >
> > will terminate with "min" set to MAX_ELEMS. Then we
> > execute:
> >
> > this_pfn = PFN(ca->array[min]);
> >
> > which references beyond the end of the space allocated
> > for ca->array.
>
> Exactly.
Hmmm. But can we ever really have this happen? The call
sequence to get here looks like:
mutex_lock(&ce_mutex);
if (ca->n == MAX_ELEMS)
WARN_ON(!del_lru_elem_unlocked(ca));
ret = find_elem(ca, pfn, &to);
I.e. if the array was all the way full, we delete one element
before calling find_elem(). So when we get here:
static int __find_elem(struct ce_array *ca, u64 pfn, unsigned int *to)
{
u64 this_pfn;
int min = 0, max = ca->n;
The biggest value "max" can have is MAX_ELEMS-1
-Tony
next prev parent reply other threads:[~2019-04-16 23:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-16 1:20 [PATCH 1/2] ras: fix an off-by-one error in __find_elem() Cong Wang
2019-04-16 1:20 ` [PATCH 2/2] ras: close the race condition with timer Cong Wang
2019-04-16 9:58 ` Borislav Petkov
2019-04-16 17:09 ` Cong Wang
2019-04-16 17:42 ` Borislav Petkov
2019-04-16 18:00 ` Cong Wang
2019-04-16 18:06 ` Cong Wang
2019-04-16 9:07 ` [PATCH 1/2] ras: fix an off-by-one error in __find_elem() Borislav Petkov
2019-04-16 17:01 ` Cong Wang
2019-04-16 22:18 ` Luck, Tony
2019-04-16 23:18 ` Cong Wang
2019-04-16 23:28 ` Luck, Tony [this message]
2019-04-16 23:47 ` Cong Wang
2019-04-17 1:53 ` Luck, Tony
2019-04-17 2:31 ` Cong Wang
2019-04-17 2:37 ` Cong Wang
2019-04-17 21:15 ` Luck, Tony
2019-04-18 22:54 ` Cong Wang
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=20190416232833.GA17372@agluck-desk \
--to=tony.luck@intel.com \
--cc=bp@alien8.de \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=xiyou.wangcong@gmail.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