[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220506233443.GA3336@bytedance>
Date: Fri, 6 May 2022 16:34:43 -0700
From: Peilin Ye <yepeilin.cs@...il.com>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <eric.dumazet@...il.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
David Ahern <dsahern@...nel.org>,
Jamal Hadi Salim <jhs@...atatu.com>,
Cong Wang <xiyou.wangcong@...il.com>,
Jiri Pirko <jiri@...nulli.us>,
Peilin Ye <peilin.ye@...edance.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Cong Wang <cong.wang@...edance.com>
Subject: Re: [PATCH RFC v1 net-next 1/4] net: Introduce Qdisc backpressure
infrastructure
Hi Stephen,
On Fri, May 06, 2022 at 01:31:11PM -0700, Stephen Hemminger wrote:
> On Fri, 6 May 2022 12:44:22 -0700, Peilin Ye <yepeilin.cs@...il.com> wrote:
> > +static inline void qdisc_backpressure_overlimit(struct Qdisc *sch, struct sk_buff *skb)
> > +{
> > + struct sock *sk = skb->sk;
> > +
> > + if (!sk || !sk_fullsock(sk))
> > + return;
> > +
> > + if (cmpxchg(&sk->sk_backpressure_status, SK_UNTHROTTLED, SK_OVERLIMIT) == SK_UNTHROTTLED) {
> > + sock_hold(sk);
> > + list_add_tail(&sk->sk_backpressure_node, &sch->backpressure_list);
> > + }
> > +}
>
> What if socket is closed? You are holding reference but application maybe gone.
Thanks for pointing this out! I just understood how sk_refcnt works
together with sk_wmem_alloc.
By the time we process this in-flight skb, sk_refcnt may have already
reached 0, which means sk_free() may have already decreased that "extra" 1
sk_wmem_alloc, so skb->destructor() may call __sk_free() while I "hold"
the sock here. Seems like a UAF.
> Or if output is stalled indefinitely?
It would be better to do a cleanup in sock destroying code, but I am
trying to avoid acquiring Qdisc root_lock there. I will try to come up
with a better solution.
Thanks,
Peilin Ye
Powered by blists - more mailing lists