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]
Message-ID: <1447117918.17135.59.camel@edumazet-glaptop2.roam.corp.google.com>
Date:	Mon, 09 Nov 2015 17:11:58 -0800
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Hannes Frederic Sowa <hannes@...essinduktion.org>
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

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.

tcp_read_sock() :

                        used = recv_actor(desc, skb, offset, len);
                        if (used <= 0) {
                                if (!copied)
                                        copied = used;
                                break;
                        } else if (used <= len) {
                                seq += used;
                                copied += used;
                                offset += used;
                        }
                        /* If recv_actor drops the lock (e.g. TCP splice
                         * receive) the skb pointer might be invalid when
                         * getting here: tcp_collapse might have deleted it
                         * while aggregating skbs from the socket queue.
                         */
                        skb = tcp_recv_skb(sk, seq - 1, &offset);
                        if (!skb)
                                break;
                        /* TCP coalescing might have appended data to the skb.
                         * Try to splice more frags
                         */
                        if (offset + 1 != skb->len)
                                continue;


--
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