From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4BDEC43381 for ; Tue, 26 Feb 2019 19:03:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BA47B21852 for ; Tue, 26 Feb 2019 19:03:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728658AbfBZTDT (ORCPT ); Tue, 26 Feb 2019 14:03:19 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:37830 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727108AbfBZTDT (ORCPT ); Tue, 26 Feb 2019 14:03:19 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1gyi0a-0000DF-A1; Tue, 26 Feb 2019 19:03:16 +0000 Date: Tue, 26 Feb 2019 19:03:16 +0000 From: Al Viro To: Rainer Weikusat Cc: Jason Baron , netdev@vger.kernel.org Subject: Re: [RFC] nasty corner case in unix_dgram_sendmsg() Message-ID: <20190226190316.GJ2217@ZenIV.linux.org.uk> References: <20190225035121.GH2217@ZenIV.linux.org.uk> <20190226062817.GA17962@ZenIV.linux.org.uk> <20190226063804.GI2217@ZenIV.linux.org.uk> <878sy2k1m3.fsf@doppelsaurus.mobileactivedefense.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878sy2k1m3.fsf@doppelsaurus.mobileactivedefense.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, Feb 26, 2019 at 03:31:32PM +0000, Rainer Weikusat wrote: > Al Viro writes: > > On Tue, Feb 26, 2019 at 06:28:17AM +0000, Al Viro wrote: > > [...] > > > >> * if after relocking we see that unix_peer(sk) now > >> is equal to other, we arrange for wakeup forwarding from other's > >> peer_wait *and* if that has (likely) succeeded we fail with -EAGAIN. > >> Huh? > > This returns 1 if sending isn't possible at the moment, ie, if the > process which tries to send has to wait. Except that in _this_ case we won't be waiting at all - we'll just return -EAGAIN (as one could expect, what with no timeout given/left). So what's the point of forwarding wakeups? IOW, what is it that we expect to be waiting on sk_sleep(sk)? Note that it won't be this call of sendmsg(2) (it'll bugger off without any further waiting). It won't be subsequent calls of sendmsg(2) either - they either sleep on skb allocation (which has nothing to do with destination) _or_ they sleep directly on other->peer_wait. And poll(), while it will be sleeping on sk_sleep(sk), will make sure to set the forwarding up. I understand what the unix_dgram_peer_wake_me() is doing; I understand what unix_dgram_poll() is using it for. What I do not understand is what's the point of doing that in unix_dgram_sendmsg()...