From: Ronnie Sahlberg <lsahlber@redhat.com>
To: Jeff Layton <jlayton@redhat.com>
Cc: David Howells <dhowells@redhat.com>, Paulo Alcantara <pc@cjr.nz>,
viro@zeniv.linux.org.uk, Steve French <smfrench@gmail.com>,
linux-nfs <linux-nfs@vger.kernel.org>,
CIFS <linux-cifs@vger.kernel.org>,
linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org,
keyrings@vger.kernel.org,
Network Development <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
fweimer@redhat.com
Subject: Re: cifs - Race between IP address change and sget()?
Date: Mon, 20 Apr 2020 21:29:59 -0400 (EDT) [thread overview]
Message-ID: <194431215.23515823.1587432599559.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <93e1141d15e44a7490d756b0a00060660306fadc.camel@redhat.com>
----- Original Message -----
> From: "Jeff Layton" <jlayton@redhat.com>
> To: "David Howells" <dhowells@redhat.com>, "Paulo Alcantara" <pc@cjr.nz>
> Cc: viro@zeniv.linux.org.uk, "Steve French" <smfrench@gmail.com>, "linux-nfs" <linux-nfs@vger.kernel.org>, "CIFS"
> <linux-cifs@vger.kernel.org>, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, keyrings@vger.kernel.org,
> "Network Development" <netdev@vger.kernel.org>, "LKML" <linux-kernel@vger.kernel.org>, fweimer@redhat.com
> Sent: Tuesday, 21 April, 2020 8:30:37 AM
> Subject: Re: cifs - Race between IP address change and sget()?
>
> On Mon, 2020-04-20 at 23:14 +0100, David Howells wrote:
> > Paulo Alcantara <pc@cjr.nz> wrote:
> >
> > > > > > What happens if the IP address the superblock is going to changes,
> > > > > > then
> > > > > > another mount is made back to the original IP address? Does the
> > > > > > second
> > > > > > mount just pick the original superblock?
> > > > >
> > > > > It is going to transparently reconnect to the new ip address, SMB
> > > > > share,
> > > > > and cifs superblock is kept unchanged. We, however, update internal
> > > > > TCP_Server_Info structure to reflect new destination ip address.
> > > > >
> > > > > For the second mount, since the hostname (extracted out of the UNC
> > > > > path
> > > > > at mount time) resolves to a new ip address and that address was
> > > > > saved
> > > > > earlier in TCP_Server_Info structure during reconnect, we will end up
> > > > > reusing same cifs superblock as per
> > > > > fs/cifs/connect.c:cifs_match_super().
> > > >
> > > > Would that be a bug?
> > >
> > > Probably.
> > >
> > > I'm not sure how that code is supposed to work, TBH.
> >
> > Hmmm... I think there may be a race here then - but I'm not sure it can be
> > avoided or if it matters.
> >
> > Since the address is part of the primary key to sget() for cifs, changing
> > the
> > IP address will change the primary key. Jeff tells me that this is
> > governed
> > by a spinlock taken by cifs_match_super(). However, sget() may be busy
> > attaching a new mount to the old superblock under the sb_lock core vfs
> > lock,
> > having already found a match.
> >
>
> Not exactly. Both places that match TCP_Server_Info objects by address
> hold the cifs_tcp_ses_lock. The address looks like it gets changed in
> reconn_set_ipaddr, and the lock is not currently taken there, AFAICT. I
> think it probably should be (at least around the cifs_convert_address
> call).
I think you are right. We need the spinlock around this call too.
I will send a patch to the list to add this.
>
> > Should the change of parameters made by cifs be effected with sb_lock held
> > to
> > try and avoid ending up using the wrong superblock?
> >
> > However, because the TCP_Server_Info is apparently updated, it looks like
> > my
> > original concern is not actually a problem (the idea that if a mounted
> > server
> > changes its IP address and then a new server comes online at the old IP
> > address, it might end up sharing superblocks because the IP address is part
> > of
> > the key).
> >
>
> I'm not sure we should concern ourselves with much more than just not
> allowing addresses to change while matching/searching. If you're
> standing up new servers at old addresses while you still have clients
> are migrating, then you are probably Doing it Wrong.
Agree. That is a migration process issue and not something we can/should
try to address in cifs.ko.
>
> --
> Jeff Layton <jlayton@redhat.com>
>
>
next prev parent reply other threads:[~2020-04-21 1:30 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-14 14:20 What's a good default TTL for DNS keys in the kernel David Howells
2020-04-14 20:16 ` Jeff Layton
2020-04-15 17:07 ` Steve French
2020-04-16 10:15 ` David Howells
2020-04-15 9:44 ` Florian Weimer
2020-04-16 10:27 ` David Howells
2020-04-16 10:33 ` Florian Weimer
2020-04-16 13:01 ` David Howells
2020-04-16 13:40 ` Chuck Lever
2020-04-17 11:31 ` Aurélien Aptel
2020-04-17 23:23 ` Steve French
2020-04-18 18:10 ` Florian Weimer
2020-04-19 4:53 ` Steve French
2020-04-19 8:37 ` David Howells
2020-04-20 0:58 ` Paulo Alcantara
2020-04-20 13:13 ` David Howells
2020-04-20 18:21 ` Paulo Alcantara
2020-04-20 22:14 ` cifs - Race between IP address change and sget()? David Howells
2020-04-20 22:30 ` Jeff Layton
2020-04-21 1:29 ` Ronnie Sahlberg [this message]
2020-04-21 2:26 ` Steve French
2020-04-21 2:29 ` Steve French
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=194431215.23515823.1587432599559.JavaMail.zimbra@redhat.com \
--to=lsahlber@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=dhowells@redhat.com \
--cc=fweimer@redhat.com \
--cc=jlayton@redhat.com \
--cc=keyrings@vger.kernel.org \
--cc=linux-afs@lists.infradead.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pc@cjr.nz \
--cc=smfrench@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).