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
| ||
|
Date: Fri, 24 Sep 2010 03:48:12 +0200 From: Eric Dumazet <eric.dumazet@...il.com> To: Tom Herbert <therbert@...gle.com> Cc: netdev@...r.kernel.org, davem@...emloft.net, sridharr@...gle.com Subject: Re: [PATCH v3] xmit_compl_seq: information to reclaim vmsplice buffers Le jeudi 23 septembre 2010 à 14:35 -0700, Tom Herbert a écrit : > diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c > index 3e8a4db..3d8d33f 100644 > --- a/net/ipv4/tcp.c > +++ b/net/ipv4/tcp.c > @@ -1768,6 +1768,12 @@ skip_copy: > > TCP_CHECK_TIMER(sk); > release_sock(sk); > + > + /* Copy the first unacked seq into the receive msg control part. */ > + if (sock_flag(sk, SOCK_XMIT_COMPL_SEQ)) > + put_cmsg(msg, SOL_SOCKET, SCM_XMIT_COMPL_SEQ, > + sizeof(tp->snd_una), &tp->snd_una); > + > return copied; > > out: Tom, I took the time to suggest : copy tp->snd_una before release_sock(). Why do you try to avoid this copy and introduce a bug ? Hint : put_cmsg() (and copy_to_user()) makes no guarantee the copy is atomic. It can be implemented by a 4 bytes copy, faut during this copy or being interrupted, and application might get a garbled value, if tcp stack modifies tp->snd_una during the copy. If you want to optimize this (because release_sock() can process the socket backlog, and update snd_una), please use : /* Copy the first unacked seq into the receive msg control part. * As put_cmsg() might sleep, we must copy snd_una in a private var. * Integer reads are atomic on all arches, so this copy can be * performed while socket is unlocked. */ if (sock_flag(sk, SOCK_XMIT_COMPL_SEQ)) { u32 snd_una = tp->snd_una; put_cmsg(msg, SOL_SOCKET, SCM_XMIT_COMPL_SEQ, sizeof(snd_una), &snd_una); } Thanks ! -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists