From: Solar Designer <solar@openwall.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: netdev@vger.kernel.org, David Miller <davem@davemloft.net>
Subject: Re: [RFC] apparently bogus logics in unix_find_other() since 2002
Date: Mon, 11 Feb 2019 12:21:31 +0100 [thread overview]
Message-ID: <20190211112131.GA31022@openwall.com> (raw)
In-Reply-To: <20190210042414.GH2217@ZenIV.linux.org.uk>
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
prev parent reply other threads:[~2019-02-11 11:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-10 4:24 [RFC] apparently bogus logics in unix_find_other() since 2002 Al Viro
2019-02-11 3:19 ` Al Viro
2019-02-11 11:21 ` Solar Designer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190211112131.GA31022@openwall.com \
--to=solar@openwall.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.