Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760560AbbKTQV5 (ORCPT ); Fri, 20 Nov 2015 11:21:57 -0500 Received: from tiger.mobileactivedefense.com ([217.174.251.109]:46832 "EHLO tiger.mobileactivedefense.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752011AbbKTQVz (ORCPT ); Fri, 20 Nov 2015 11:21:55 -0500 From: Rainer Weikusat To: Jason Baron Cc: Rainer Weikusat , Dmitry Vyukov , syzkaller , Michal Kubecek , Al Viro , "linux-fsdevel\@vger.kernel.org" , LKML , David Miller , Hannes Frederic Sowa , David Howells , Paul Moore , salyzyn@android.com, sds@tycho.nsa.gov, ying.xue@windriver.com, netdev , Kostya Serebryany , Alexander Potapenko , Andrey Konovalov , Sasha Levin , Julien Tinnes , Kees Cook , Mathias Krause Subject: Re: [PATCH] unix: avoid use-after-free in ep_remove_wait_queue (w/ Fixes:) In-Reply-To: <564F4458.8050309@akamai.com> (Jason Baron's message of "Fri, 20 Nov 2015 11:03:36 -0500") References: <20151012120249.GB16370@unicorn.suse.cz> <1444652071.27760.156.camel@edumazet-glaptop2.roam.corp.google.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> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Date: Fri, 20 Nov 2015 16:21:24 +0000 Message-ID: <87lh9sfxq3.fsf@doppelsaurus.mobileactivedefense.com> 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: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1276 Lines: 42 Jason Baron 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/