lkml.org 
[lkml]   [2022]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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@gmail.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


\
 
 \ /
  Last update: 2022-05-07 01:35    [W:0.092 / U:1.572 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site