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
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHS8izO0CdzNti7L3ktg4ynkJSptO96VtrzvtUEkzUiR7h38dg@mail.gmail.com>
Date: Thu, 13 Feb 2025 12:14:04 -0800
From: Mina Almasry <almasrymina@...gle.com>
To: Jason Xing <kerneljasonxing@...il.com>
Cc: Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org, davem@...emloft.net, 
	ilias.apalodimas@...aro.org, edumazet@...gle.com, kuba@...nel.org, 
	horms@...nel.org, hawk@...nel.org
Subject: Re: [PATCH v2 net-next] page_pool: avoid infinite loop to schedule
 delayed worker

On Thu, Feb 13, 2025 at 2:49 AM Jason Xing <kerneljasonxing@...il.com> wrote:
>
> On Thu, Feb 13, 2025 at 4:32 PM Paolo Abeni <pabeni@...hat.com> wrote:
> >
> > On 2/13/25 6:21 AM, Jason Xing wrote:
> > > diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> > > index 1c6fec08bc43..e1f89a19a6b6 100644
> > > --- a/net/core/page_pool.c
> > > +++ b/net/core/page_pool.c
> > > @@ -1112,13 +1112,12 @@ static void page_pool_release_retry(struct work_struct *wq)
> > >       int inflight;
> > >
> > >       inflight = page_pool_release(pool);
> > > -     if (!inflight)
> > > -             return;
> > >
> > >       /* Periodic warning for page pools the user can't see */
> > >       netdev = READ_ONCE(pool->slow.netdev);
> >
> > This causes UaF, as catched by the CI:
> >
> > https://netdev-3.bots.linux.dev/vmksft-net-dbg/results/990441/34-udpgro-bench-sh/stderr
> >
> > at this point 'inflight' could be 0 and 'pool' already freed.
>
> Oh, right, thanks for catching that.
>
> I'm going to use the previous approach (one-liner with a few comments):
> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> index 1c6fec08bc43..209b5028abd7 100644
> --- a/net/core/page_pool.c
> +++ b/net/core/page_pool.c
> @@ -1112,7 +1112,13 @@ static void page_pool_release_retry(struct
> work_struct *wq)
>         int inflight;
>
>         inflight = page_pool_release(pool);
> -       if (!inflight)
> +       /* In rare cases, a driver bug may cause inflight to go negative.
> +        * Don't reschedule release if inflight is 0 or negative.
> +        * - If 0, the page_pool has been destroyed
> +        * - if negative, we will never recover
> +        *   in both cases no reschedule is necessary.
> +        */
> +       if (inflight <= 0)
>                 return;
>

I think it could still be good to have us warn once so that this bug
is not silent.

We can return early if page_pool_release(pool) == 0, and then only
schedule_delayed_work() after the warning if inflight is positive.

-- 
Thanks,
Mina

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ