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=-7.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,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 D8408C169C4 for ; Mon, 11 Feb 2019 11:28:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF81521773 for ; Mon, 11 Feb 2019 11:28:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726212AbfBKL2k (ORCPT ); Mon, 11 Feb 2019 06:28:40 -0500 Received: from mother.openwall.net ([195.42.179.200]:37389 "HELO mother.openwall.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726045AbfBKL2k (ORCPT ); Mon, 11 Feb 2019 06:28:40 -0500 X-Greylist: delayed 400 seconds by postgrey-1.27 at vger.kernel.org; Mon, 11 Feb 2019 06:28:39 EST Received: (qmail 13440 invoked from network); 11 Feb 2019 11:21:58 -0000 Received: from localhost (HELO pvt.openwall.com) (127.0.0.1) by localhost with SMTP; 11 Feb 2019 11:21:58 -0000 Received: by pvt.openwall.com (Postfix, from userid 503) id F0396AA7D0; Mon, 11 Feb 2019 12:21:31 +0100 (CET) Date: Mon, 11 Feb 2019 12:21:31 +0100 From: Solar Designer To: Al Viro Cc: netdev@vger.kernel.org, David Miller Subject: Re: [RFC] apparently bogus logics in unix_find_other() since 2002 Message-ID: <20190211112131.GA31022@openwall.com> References: <20190210042414.GH2217@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190210042414.GH2217@ZenIV.linux.org.uk> User-Agent: Mutt/1.4.2.3i Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Sun, Feb 10, 2019 at 04:24:22AM +0000, Al Viro wrote: > In "net/unix/af_unix.c: Set ATIME on socket inode" (back in > 2002) we'd grown something rather odd in unix_find_other(). In the > original patch it was > u=unix_find_socket_byname(sunname, len, type, hash); > - if (!u) > + if (u) { > + struct dentry *dentry; > + dentry = u->protinfo.af_unix.dentry; > + if (dentry) > + UPDATE_ATIME(dentry->d_inode); > + } else > goto fail; It's this commit: https://github.com/dmgerman/linux-bitkeeper/commit/80cbc5b9c7393c4456236543ca1e639ea0841c19 There are two hunks in that patch: one after "if (sunname->sun_path[0])" and the other after "else". I just did some more digging and found the private discussion of the time, as well as a previous revision of the patch (against 2.2.21, whereas the committed one was against 2.4.x of the same era). Even the earliest revision I found already has both hunks. I couldn't find any discussion as to why the second hunk was possibly needed. It is quite possible that I had added it in error. The original problem this patch addressed was stmpclean deleting sockets that were still actively used - specifically, PostgreSQL's. I found that I also tested the patch on /dev/log and X11 sockets. However, I can't find any indication of me ever testing with the first hunk only, so it's quite possible I wrote both hunks at once and only tested both. > These days the code is > > u = unix_find_socket_byname(net, sunname, len, type, hash); > if (u) { > struct dentry *dentry; > dentry = unix_sk(u)->path.dentry; > if (dentry) > touch_atime(&unix_sk(u)->path); > } else > goto fail; > > but the logics is the same. It's the abstract address case - we have > '\0' in sunname->sun_path[0]. How in hell could that possibly have > non-NULL ->path.dentry and what would it be? This is probably in fact impossible. I think it'd make sense to drop this logic, reverting to: if (!u) goto fail; and then see if atime on an actively used socket in /tmp or on /dev/log keeps getting updated (due to the first hunk of the above commit). Alexander