Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1274224

Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/ Fixes:)

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Rainer Weikusat <rweikusat@mobileactivedefense.com>
Newsgroups linux.kernel
Subject Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/ Fixes:)
Date Fri, 20 Nov 2015 17:30:02 +0100
Message-ID <qwWJs-1a6-13@gated-at.bofh.it> (permalink)
References <qiJ9o-5w0-9@gated-at.bofh.it> <qiK5s-6T6-11@gated-at.bofh.it> <qiKf8-74w-9@gated-at.bofh.it> <qiKf8-74w-7@gated-at.bofh.it> <qrOWd-4V2-11@gated-at.bofh.it> <qrQEG-5PE-15@gated-at.bofh.it> <qrQY1-6bv-3@gated-at.bofh.it> <qsVVE-7IC-11@gated-at.bofh.it> <qtp7j-2b1-1@gated-at.bofh.it> <qurJM-1FS-9@gated-at.bofh.it> <qvAhX-4Jx-7@gated-at.bofh.it> <qvArE-4ME-13@gated-at.bofh.it> <qwHho-7Oe-13@gated-at.bofh.it> <qwWq6-11X-7@gated-at.bofh.it>
X-Original-To Jason Baron <jbaron@akamai.com>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Greylist Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (tiger.mobileactivedefense.com [217.174.251.109]); Fri, 20 Nov 2015 16:21:32 +0000 (GMT)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 42
Organization linux.* mail to news gateway
X-Original-Cc Rainer Weikusat <rweikusat@mobileactivedefense.com>, Dmitry Vyukov <dvyukov@google.com>, syzkaller <syzkaller@googlegroups.com>, Michal Kubecek <mkubecek@suse.cz>, Al Viro <viro@zeniv.linux.org.uk>, "linux-fsdevel\@vger.kernel.org" <linux-fsdevel@vger.kernel.org>, LKML <linux-kernel@vger.kernel.org>, David Miller <davem@davemloft.net>, Hannes Frederic Sowa <hannes@stressinduktion.org>, David Howells <dhowells@redhat.com>, Paul Moore <paul@paul-moore.com>, salyzyn@android.com, sds@tycho.nsa.gov, ying.xue@windriver.com, netdev <netdev@vger.kernel.org>, Kostya Serebryany <kcc@google.com>, Alexander Potapenko <glider@google.com>, Andrey Konovalov <andreyknvl@google.com>, Sasha Levin <sasha.levin@oracle.com>, Julien Tinnes <jln@google.com>, Kees Cook <keescook@google.com>, Mathias Krause <minipli@googlemail.com>
X-Original-Date Fri, 20 Nov 2015 16:21:24 +0000
X-Original-Message-ID <87lh9sfxq3.fsf@doppelsaurus.mobileactivedefense.com>
X-Original-References <CACT4Y+b3xsLsKVFCz2M7nqqfXnyuMHEVYtJS2wN4WHLWs9A5ng@mail.gmail.com> <20151012120249.GB16370@unicorn.suse.cz> <1444652071.27760.156.camel@edumazet-glaptop2.roam.corp.google.com> <CACT4Y+Z2H8xPg1Dq0Z=HC3WKm+Uw+ZjK6zOLvxhPwFd4D0CsZw@mail.gmail.com> <CACT4Y+Zu7J0n6dU1dSfiW3F9Q0Us3_DBVcD5Pi9NG9LER8MmRg@mail.gmail.com> <563CC002.5050307@akamai.com> <87ziyrcg67.fsf@doppelsaurus.mobileactivedefense.com> <87fv0fnslr.fsf_-_@doppelsaurus.mobileactivedefense.com> <877flp34fl.fsf@doppelsaurus.mobileactivedefense.com> <87a8qhspfm.fsf@doppelsaurus.mobileactivedefense.com> <876111wpza.fsf@doppelsaurus.mobileactivedefense.com> <87ziydvasn.fsf_-_@doppelsaurus.mobileactivedefense.com> <87d1v57dif.fsf@doppelsaurus.mobileactivedefense.com> <564F4458.8050309@akamai.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1274224

Show key headers only | View raw


Jason Baron <jbaron@akamai.com> writes:
> On 11/19/2015 06:52 PM, Rainer Weikusat wrote:
>
> [...]
>
>> @@ -1590,21 +1718,35 @@ restart:
>>  			goto out_unlock;
>>  	}
>>  
>> -	if (unix_peer(other) != sk && unix_recvq_full(other)) {
>> -		if (!timeo) {
>> +	if (unlikely(unix_peer(other) != sk && unix_recvq_full(other))) {
>> +		if (timeo) {
>> +			timeo = unix_wait_for_peer(other, timeo);
>> +
>> +			err = sock_intr_errno(timeo);
>> +			if (signal_pending(current))
>> +				goto out_free;
>> +
>> +			goto restart;
>> +		}
>> +
>> +		if (unix_peer(sk) != other ||
>> +		    unix_dgram_peer_wake_me(sk, other)) {
>>  			err = -EAGAIN;
>>  			goto out_unlock;
>>  		}
>
> Hi,
>
> So here we are calling unix_dgram_peer_wake_me() without the sk lock the first time
> through - right?

Yes. And this is obviously wrong. I spend most of the 'evening time'
(some people would call that 'night time') with testing this and didn't
get to read through it again yet. Thank you for pointing this out. I'll
send an updated patch shortly.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-11-16 23:20 +0100
  Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/ Fixes:) Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-11-16 23:30 +0100
    Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/  Fixes:) Jason Baron <jbaron@akamai.com> - 2015-11-17 17:20 +0100
    Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/  Fixes:) David Miller <davem@davemloft.net> - 2015-11-17 21:20 +0100
      Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/ Fixes:) Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-11-17 22:40 +0100
        Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/ Fixes:) Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-11-17 23:20 +0100
          Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/ Fixes:) Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-11-20 00:50 +0100
        Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/ Fixes:) Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-11-17 23:50 +0100
      Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/ Fixes:) Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-11-18 19:20 +0100
        more statistics (was: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/ Fixes:)) Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-11-19 00:50 +0100
    Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/ Fixes:) Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-11-20 01:00 +0100
      Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/  Fixes:) Jason Baron <jbaron@akamai.com> - 2015-11-20 17:10 +0100
        Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/ Fixes:) Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-11-20 17:30 +0100
      Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-11-20 23:10 +0100
        Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue Jason Baron <jbaron@akamai.com> - 2015-11-23 17:30 +0100
        Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue David Miller <davem@davemloft.net> - 2015-11-23 18:40 +0100
          Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-11-23 22:40 +0100
            Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2015-11-24 00:10 +0100

csiph-web