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, 15 May 2021 13:14:37 +0900
From:   Kuniyuki Iwashima <kuniyu@...zon.co.jp>
To:     <kafai@...com>
CC:     <andrii@...nel.org>, <ast@...nel.org>, <benh@...zon.com>,
        <bpf@...r.kernel.org>, <daniel@...earbox.net>,
        <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
        <kuni1840@...il.com>, <kuniyu@...zon.co.jp>,
        <linux-kernel@...r.kernel.org>, <netdev@...r.kernel.org>
Subject: Re: [PATCH v5 bpf-next 05/11] tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.

From:   Martin KaFai Lau <kafai@...com>
Date:   Fri, 14 May 2021 18:06:16 -0700
> On Mon, May 10, 2021 at 12:44:27PM +0900, Kuniyuki Iwashima wrote:
> > diff --git a/net/core/request_sock.c b/net/core/request_sock.c
> > index f35c2e998406..7879a3660c52 100644
> > --- a/net/core/request_sock.c
> > +++ b/net/core/request_sock.c
> > @@ -130,3 +130,42 @@ void reqsk_fastopen_remove(struct sock *sk, struct request_sock *req,
> >  out:
> >  	spin_unlock_bh(&fastopenq->lock);
> >  }
> > +
> > +struct request_sock *reqsk_clone(struct request_sock *req, struct sock *sk)
> > +{
> > +	struct sock *req_sk, *nreq_sk;
> > +	struct request_sock *nreq;
> > +
> > +	nreq = kmem_cache_alloc(req->rsk_ops->slab, GFP_ATOMIC | __GFP_NOWARN);
> > +	if (!nreq) {
> > +		/* paired with refcount_inc_not_zero() in reuseport_migrate_sock() */
> > +		sock_put(sk);
> > +		return NULL;
> > +	}
> > +
> > +	req_sk = req_to_sk(req);
> > +	nreq_sk = req_to_sk(nreq);
> > +
> > +	memcpy(nreq_sk, req_sk,
> > +	       offsetof(struct sock, sk_dontcopy_begin));
> > +	memcpy(&nreq_sk->sk_dontcopy_end, &req_sk->sk_dontcopy_end,
> > +	       req->rsk_ops->obj_size - offsetof(struct sock, sk_dontcopy_end));
> > +
> > +	sk_node_init(&nreq_sk->sk_node);
> > +	nreq_sk->sk_tx_queue_mapping = req_sk->sk_tx_queue_mapping;
> > +#ifdef CONFIG_XPS
> > +	nreq_sk->sk_rx_queue_mapping = req_sk->sk_rx_queue_mapping;
> > +#endif
> > +	nreq_sk->sk_incoming_cpu = req_sk->sk_incoming_cpu;
> > +	refcount_set(&nreq_sk->sk_refcnt, 0);
> > +
> > +	nreq->rsk_listener = sk;
> > +
> > +	/* We need not acquire fastopenq->lock
> > +	 * because the child socket is locked in inet_csk_listen_stop().
> > +	 */
> > +	if (tcp_rsk(nreq)->tfo_listener)
> Should IPPROTO_TCP be tested first like other similar situations
> in inet_connection_sock.c?

I've written this way because migration happens only in TCP for now, but I
agree that test of IPPROTO_TCP makes less error-prone in the future. So,
I'll test it first in the next spin.

Thank you!


> 
> Also, reqsk_clone() is only used in inet_connection_sock.c.
> Can it be moved to inet_connection_sock.c instead and renamed to
> inet_reqsk_clone()?

I'll do that.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ