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: <CAL+tcoAmYayRmZ=GFpzwczudT4pTwRpH+AMv4TkwSP39q3snDQ@mail.gmail.com>
Date: Fri, 14 Feb 2025 07:42:34 +0800
From: Jason Xing <kerneljasonxing@...il.com>
To: Mina Almasry <almasrymina@...gle.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 Fri, Feb 14, 2025 at 4:14 AM Mina Almasry <almasrymina@...gle.com> wrote:
>
> 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.

Allow me to double-check what you meant here. Applying the above
patch, we do at least see the warning once in
page_pool_release_retry()->page_pool_release()->page_pool_inflight()->WARN()
before stopping the reschedule.

Do you expect to see another warning, namely, pr_warn() in
page_pool_release_retry()? If so, I assume you expect to only print
out the pool->user.id?

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

Based on the above analysis, can we adjust in this way:
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 1c6fec08bc43..e1831cc23d9c 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -625,8 +625,8 @@ s32 page_pool_inflight(const struct page_pool
*pool, bool strict)

        if (strict) {
                trace_page_pool_release(pool, inflight, hold_cnt, release_cnt);
-               WARN(inflight < 0, "Negative(%d) inflight packet-pages",
-                    inflight);
+               WARN(inflight < 0, "Pool id(%u): negative(%d) inflight
packet-pages",
+                    pool->user.id, inflight);
        } else {
                inflight = max(0, inflight);
        }
@@ -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;

Thanks,
Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ