All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, shankarapailoor@gmail.com,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	Lorenzo Colitti <lorenzo@google.com>
Subject: Re: [Patch net] socket: close race condition between sock_close() and sockfs_setattr()
Date: Thu, 7 Jun 2018 22:26:31 +0100	[thread overview]
Message-ID: <20180607212631.GW30522@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20180607203949.16945-1-xiyou.wangcong@gmail.com>

On Thu, Jun 07, 2018 at 01:39:49PM -0700, Cong Wang wrote:
> fchownat() doesn't even hold refcnt of fd until it figures out
> fd is really needed (otherwise is ignored) and releases it after
> it resolves the path. This means sock_close() could race with
> sockfs_setattr(), which leads to a NULL pointer dereference
> since typically we set sock->sk to NULL in ->release().
> 
> As pointed out by Al, this is unique to sockfs. So we can fix this
> in socket layer by acquiring inode_lock in sock_close() and
> checking against NULL in sockfs_setattr().

That looks like a massive overkill - it's way heavier than it should be.
And it's very likely to trigger shitloads of deadlock warnings, some
possibly even true.

  reply	other threads:[~2018-06-07 21:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07 20:39 [Patch net] socket: close race condition between sock_close() and sockfs_setattr() Cong Wang
2018-06-07 21:26 ` Al Viro [this message]
2018-06-07 21:45   ` Cong Wang
2018-06-07 22:04     ` Al Viro
2018-06-07 22:15       ` Cong Wang
2018-06-07 22:32         ` Al Viro
2018-06-10 19:27 ` David Miller
2018-06-10 19:43   ` Cong Wang

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=20180607212631.GW30522@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=lorenzo@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=shankarapailoor@gmail.com \
    --cc=xiyou.wangcong@gmail.com \
    /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.