Hallo, On Tue, Nov 10, 2015, at 02:11, Eric Dumazet wrote: > On Thu, 2015-05-21 at 17:00 +0200, Hannes Frederic Sowa wrote: > > > + > > +static ssize_t skb_unix_socket_splice(struct sock *sk, > > + struct pipe_inode_info *pipe, > > + struct splice_pipe_desc *spd) > > +{ > > + int ret; > > + struct unix_sock *u = unix_sk(sk); > > + > > + mutex_unlock(&u->readlock); > > + ret = splice_to_pipe(pipe, spd); > > + mutex_lock(&u->readlock); > > + > > + return ret; > > +} > > + > > Hi Hannes > > Since we release u->readlock, what prevents another thread to read() the > same af_unix socket and consume the skb while we splice it ? > > TCP stack has special code to take care of this possibility.
Hm, I do see the problem, yes. I left a window open for races happening. Without having a closer look what spontaneously comes to my mind: increment skb->users before splice_to_pipe, re-peek the socket queue after the splice, recheck if we have the same skb pointer in the front, and then consume_skb the skb properly and indicating a short read. Let me try tomorrow if that works, but I fear we can read data multiple times with this fix, so I don't know if this is a proper fix. I have to check the TCP code closer. Thanks for the hint! Thanks for the report, Hannes -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html