Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4087720ybz; Mon, 20 Apr 2020 15:31:22 -0700 (PDT) X-Google-Smtp-Source: APiQypJLI8e8ta11nKEMW0h5D7JrAdysDzRq59eT8eJaMMtoHCp3r2gQyWpiAU2IZYHDPUDItMEq X-Received: by 2002:a50:e68e:: with SMTP id z14mr16779162edm.307.1587421882502; Mon, 20 Apr 2020 15:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587421882; cv=none; d=google.com; s=arc-20160816; b=slXQ0lQ2CGtAqwHVRfFH8B1GbUgca7UePTrUg2EQFAcEQV78bq4fkVdCaT9ZD+n620 luKQIva92BIm33Rbe9sqV4R7WXtfxelt1YB7M2v2xMa/+HCw5pN2lQEdzgFAfgkfLsQ9 PrOHzy+8w+DgWAnQREjKH8uYTuEoxx+l4w8p839jSuHa5GoGxkmLfIimiJK/dhWfAcXz E56X0T/0V548NFQmBi6iEsRHTwAdekSYJ0kJAVq7hD+4N0pWymLwxhxT086mD4jSi0/W P0A/76g1rHJ1HWbYhg+4YS9sOo6AgHiVkVvma9hqVxKdX9j3bT/Jtwm/KKcC+RFCzLSV +SVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=9q6YhDfeioGYYNbOwoNDtbd8XWXwGnM98df6kx4/308=; b=cZ7aYqPGgsrQ4sM6FzwklE5q1Z3JPWeBFvWBBYlWh5qpz24Gt7NeIsPXz94tFmvfIc MdqpQ7mTPsd+CSPMHq+FXrH/Utbx+jF+oeG9uU+c9HSc7HxpNEB3Itn8kQw5gbEGYHQU 2Z5qtc+g6erjSbfwX+0r7Zdsc3tdIViB5Vg+yit8hXZTqmLbhv2OZL3WYHbRGoNgHEkB uZJvIHSeOC7CC6lqRHvACLuXwBL+rQUTOBAjg7f1rIV0Mm0uq1noH9Z4MrxBNmc2U6hG NEcw41RuG6RBQ9+z4E6aenoeseiuMObYvkh5uPyGjrrWWik+NPYx3fVzCA2IJGqny97J jiTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M9K+Ce0p; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w16si448759edr.110.2020.04.20.15.30.52; Mon, 20 Apr 2020 15:31:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M9K+Ce0p; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726362AbgDTWao (ORCPT + 99 others); Mon, 20 Apr 2020 18:30:44 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:29712 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726201AbgDTWan (ORCPT ); Mon, 20 Apr 2020 18:30:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587421841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9q6YhDfeioGYYNbOwoNDtbd8XWXwGnM98df6kx4/308=; b=M9K+Ce0pFPTIUPMmsJa/84tA2++gzQV2giT50alI0titPuGjK4zvuhG12ohwkZ4D2mbODb 55NO65uVc3NxVaZQm75EdMdhocDXmJ+EKK+wUH90MO81UGXpoZQwwSSqTb0kVcD5WT5Tyn j0xhA7UqH0DNtzVKeLQHnsocxS1JvdU= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-337-Y77NcqemPEeIMZSN37AtQw-1; Mon, 20 Apr 2020 18:30:40 -0400 X-MC-Unique: Y77NcqemPEeIMZSN37AtQw-1 Received: by mail-qv1-f72.google.com with SMTP id m20so11880932qvy.13 for ; Mon, 20 Apr 2020 15:30:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=9q6YhDfeioGYYNbOwoNDtbd8XWXwGnM98df6kx4/308=; b=bBH84IulWVXGU2ZobiajySG7qUSuAgkoM1CxrJWimwHtjq9dw4688gMyc8pXnXd9Dq WprQobIIOLO0v/pBHmQJZ5/p2NIuEkVED+n9pKq5YHxZO9aAiTuFUXwI1S9/yd0y6LrB KmpXKm76OsRvdXhVJ6T5UIr9cyAEmhBh+WaBoqU0EobEfzNpKmXdNV55aQaeTqp1FBAR a39JvP1OOhaJ0t2vaP4KJuJpF6O9HvrIZaycepYy6J3aQDdOWL2fO+PykwHvSH7B260j ZtC2OSUX4P43OgyMTwtH22b1AcPQPIn/bkY/BXgqVEFitTGEjkNTbIPVCtJNOQlDkCn9 WxwA== X-Gm-Message-State: AGi0Puan62GhtZnAhN59itq57CvbQVxmzz4L57D99aIn6JyZPkDadv1G gRsijPc4wlXJtHmmhCH+4AFddp8G/ujRLtZm5AwLNj6ZLKgUsbFU3CMpZ1bECNbunhPVUpfx/aR TOafsRfZQ+wrgO4OozuDb X-Received: by 2002:ac8:1a8a:: with SMTP id x10mr18266936qtj.154.1587421839478; Mon, 20 Apr 2020 15:30:39 -0700 (PDT) X-Received: by 2002:ac8:1a8a:: with SMTP id x10mr18266910qtj.154.1587421839193; Mon, 20 Apr 2020 15:30:39 -0700 (PDT) Received: from tleilax.poochiereds.net (68-20-15-154.lightspeed.rlghnc.sbcglobal.net. [68.20.15.154]) by smtp.gmail.com with ESMTPSA id m40sm545368qtc.33.2020.04.20.15.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2020 15:30:38 -0700 (PDT) Message-ID: <93e1141d15e44a7490d756b0a00060660306fadc.camel@redhat.com> Subject: Re: cifs - Race between IP address change and sget()? From: Jeff Layton To: David Howells , Paulo Alcantara Cc: viro@zeniv.linux.org.uk, Steve French , linux-nfs , CIFS , linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, keyrings@vger.kernel.org, Network Development , LKML , fweimer@redhat.com Date: Mon, 20 Apr 2020 18:30:37 -0400 In-Reply-To: <1986040.1587420879@warthog.procyon.org.uk> References: <878siq587w.fsf@cjr.nz> <87imhvj7m6.fsf@cjr.nz> <3865908.1586874010@warthog.procyon.org.uk> <927453.1587285472@warthog.procyon.org.uk> <1136024.1587388420@warthog.procyon.org.uk> <1986040.1587420879@warthog.procyon.org.uk> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Mon, 2020-04-20 at 23:14 +0100, David Howells wrote: > Paulo Alcantara 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). > 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. -- Jeff Layton