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]
Date:   Sat, 30 Apr 2022 10:22:33 -0700
From:   Cong Wang <xiyou.wangcong@...il.com>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     Linux Kernel Network Developers <netdev@...r.kernel.org>,
        Cong Wang <cong.wang@...edance.com>,
        Eric Dumazet <edumazet@...gle.com>,
        John Fastabend <john.fastabend@...il.com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Jakub Sitnicki <jakub@...udflare.com>
Subject: Re: [Patch bpf-next v1 1/4] tcp: introduce tcp_read_skb()

On Mon, Apr 25, 2022 at 12:07 PM Jakub Kicinski <kuba@...nel.org> wrote:
>
> On Sun, 10 Apr 2022 09:10:39 -0700 Cong Wang wrote:
> > +int tcp_read_skb(struct sock *sk, read_descriptor_t *desc,
> > +              sk_read_actor_t recv_actor)
> > +{
> > +     struct sk_buff *skb;
> > +     struct tcp_sock *tp = tcp_sk(sk);
> > +     u32 seq = tp->copied_seq;
> > +     u32 offset;
> > +     int copied = 0;
> > +
> > +     if (sk->sk_state == TCP_LISTEN)
> > +             return -ENOTCONN;
> > +     while ((skb = tcp_recv_skb(sk, seq, &offset, true)) != NULL) {
> > +             if (offset < skb->len) {
> > +                     int used;
> > +                     size_t len;
> > +
> > +                     len = skb->len - offset;
> > +                     used = recv_actor(desc, skb, offset, len);
> > +                     if (used <= 0) {
> > +                             if (!copied)
> > +                                     copied = used;
> > +                             break;
> > +                     }
> > +                     if (WARN_ON_ONCE(used > len))
> > +                             used = len;
> > +                     seq += used;
> > +                     copied += used;
> > +                     offset += used;
> > +
> > +                     if (offset != skb->len)
> > +                             continue;
> > +             }
> > +             if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) {
> > +                     kfree_skb(skb);
> > +                     ++seq;
> > +                     break;
> > +             }
> > +             kfree_skb(skb);
> > +             if (!desc->count)
> > +                     break;
> > +             WRITE_ONCE(tp->copied_seq, seq);
> > +     }
> > +     WRITE_ONCE(tp->copied_seq, seq);
> > +
> > +     tcp_rcv_space_adjust(sk);
> > +
> > +     /* Clean up data we have read: This will do ACK frames. */
> > +     if (copied > 0)
> > +             tcp_cleanup_rbuf(sk, copied);
> > +
> > +     return copied;
> > +}
> > +EXPORT_SYMBOL(tcp_read_skb);
>
> I started prototyping a similar patch for TLS a while back but I have
> two functions - one to get the skb and another to consume it. I thought
> that's better for TLS, otherwise skbs stuck in the middle layer are not
> counted towards the rbuf. Any thoughts on structuring the API that way?
> I guess we can refactor that later, since TLS TCP-only we don't need
> proto_ops plumbing there.

Do you have a pointer to the source code? I am not sure how TLS uses
->read_sock() (or which interface is relevant).

>
> Overall 👍 for adding such API.

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ