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] [day] [month] [year] [list]
Date:	Tue, 10 Nov 2015 03:34:30 +0100
From:	Hannes Frederic Sowa <hannes@...essinduktion.org>
To:	Eric Dumazet <eric.dumazet@...il.com>
Cc:	netdev@...r.kernel.org, edumazet@...gle.com, cwang@...pensource.com
Subject: Re: [PATCH v3 net-next 4/4] net: af_unix: implement splice for stream
 af_unix sockets

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 majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ