[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <56BDA3A8.6070807@pmhahn.de>
Date: Fri, 12 Feb 2016 10:19:36 +0100
From: Philipp Hahn <pmhahn@...ahn.de>
To: Rainer Weikusat <rweikusat@...ileactivedefense.com>,
Ben Hutchings <ben@...adent.org.uk>
Cc: Hannes Frederic Sowa <hannes@...essinduktion.org>,
Sasha Levin <sasha.levin@...cle.com>,
"David S. Miller" <davem@...emloft.net>,
linux-kernel@...r.kernel.org, Karolin Seeger <kseeger@...ba.org>,
Jason Baron <jbaron@...mai.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Arvid Requate <requate@...vention.de>,
Stefan Gohmann <gohmann@...vention.de>, netdev@...r.kernel.org
Subject: Re: [PATCH net] af_unix: Guard against other == sk in
unix_dgram_sendmsg
Hello Rainer,
Am 11.02.2016 um 20:37 schrieb Rainer Weikusat:
> The unix_dgram_sendmsg routine use the following test
>
> if (unlikely(unix_peer(other) != sk && unix_recvq_full(other))) {
>
> to determine if sk and other are in an n:1 association (either
> established via connect or by using sendto to send messages to an
> unrelated socket identified by address). This isn't correct as the
> specified address could have been bound to the sending socket itself or
> because this socket could have been connected to itself by the time of
> the unix_peer_get but disconnected before the unix_state_lock(other). In
> both cases, the if-block would be entered despite other == sk which
> might either block the sender unintentionally or lead to trying to unlock
> the same spin lock twice for a non-blocking send. Add a other != sk
> check to guard against this.
>
> Fixes: 7d267278a9ec ("unix: avoid use-after-free in ep_remove_wait_queue")
> Reported-By: Philipp Hahn <pmhahn@...ahn.de>
> Signed-off-by: Rainer Weikusat <rweikusat@...ileactivedefense.com>
> ---
> diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> index 29be035..f1ca279 100644
> --- a/net/unix/af_unix.c
> +++ b/net/unix/af_unix.c
> @@ -1781,7 +1781,12 @@ restart_locked:
> goto out_unlock;
> }
>
> - if (unlikely(unix_peer(other) != sk && unix_recvq_full(other))) {
> + /* other == sk && unix_peer(other) != sk if
> + * - unix_peer(sk) == NULL, destination address bound to sk
> + * - unix_peer(sk) == sk by time of get but disconnected before lock
> + */
> + if (other != sk &&
> + unlikely(unix_peer(other) != sk && unix_recvq_full(other))) {
> if (timeo) {
> timeo = unix_wait_for_peer(other, timeo);
>
>
After applying that patch at least my machine running the samba test no
longer crashes. So you might add
Tested-by: Philipp Hahn <pmhahn@...ahn.de>
Thanks for looking it that issues.
Philipp
Powered by blists - more mailing lists