Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1952301ima; Thu, 25 Oct 2018 07:29:40 -0700 (PDT) X-Google-Smtp-Source: AJdET5d/XvEMxzbCQzyUw4D+t2ug2+ol0e1F1g65CZPJc793RLOgbdGcxbcjskrwsaJspEEDg4tL X-Received: by 2002:a63:8b4b:: with SMTP id j72mr1706898pge.126.1540477780507; Thu, 25 Oct 2018 07:29:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540477780; cv=none; d=google.com; s=arc-20160816; b=ivnQqT70CbsNpmOisrOxLw/G0Z4QbqjReX/V4OaU07Ab8L/AnHvOLlpku28UM//L6t WeKTMtb+xO0Fm4EOiBDl7ryVZaNDCb3CUAYwVEAdA3uBK2c5q2t5gbyyoi4NSzNz0kPz G8orpyuGSLne8Q0kxKHoI2cTVG0mFrebjeHhcSNe2gA+M8HAY5dkWRZgXsfaTYPB1uts zgRjFRkWZq9M/WM2bcGDrrrMpfFOCFnhHyW0xR4IzsSQhyNAl0lWVHJOzRbFdpZ0lLLk dzF31wC15OpayYw06kCPsIoF2EUnyc8Drg3c7YWZsdlHmBtzxDIIu9D1fMM4F7ODNEXs /FqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=x4WXG+KRFP0bJkfk6jFzlK/X+jnTpc9RdixAIE/lD4s=; b=s0vMYU5wx9XZyeP1GlsI7dazoXQH7UNX4r3hgbUauuw99e75pS1LnwNhj1VOn2jvYS Vyo8OWEUa8FcF4M54XCQZKeDu9ixYjFUNDoNxS094xr89R758F93aLBs442Djc/bRGRk GQF+Ski6jXfVHGsh9rRJRlLXyeFQzWjJXnSMTqdd/iHey85TevQ9BZ5ssxmx4XhotRpu +sYhQ+fbpM1lbse4Qy1oofAvhsGksL/1KBW8X+SnrDaWoAtXMENTpSKsrqn3uLcsWd2z Vnwod1p+7TKK8lpJ73VmThUZ8R8GGSL4CubYpX5mQOKx7pKKnhfk5LwX370dQJcCnyyN wNrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="XzeLz/hU"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1-v6si779863pld.334.2018.10.25.07.29.06; Thu, 25 Oct 2018 07:29:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="XzeLz/hU"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730594AbeJYWwb (ORCPT + 99 others); Thu, 25 Oct 2018 18:52:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:34566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729403AbeJYWwa (ORCPT ); Thu, 25 Oct 2018 18:52:30 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 507CE20873; Thu, 25 Oct 2018 14:19:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540477173; bh=o3RfPsHLywGEn+DFJooVUJqYBbyLN005zqhD++nQpSk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XzeLz/hUB3JcmZZWJo3HR+FIiUp2T7cprpIKDPcP8E5SeAohxFGxZ2hgBt5gZLiGK +N1mM6jFagxLevrKZK4CZgdvAwMbq5M1m731c+th8WUIlXE9GkCFhIrH/lEr2uZ0Yi UWwiLpJLJlafQEoK/HhgmOr0HPY2jrwEbYmwWFpU= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Trond Myklebust , Chuck Lever , Sasha Levin Subject: [PATCH AUTOSEL 3.18 25/98] NFSv4/v4.1: Verify the client owner id during trunking detection Date: Thu, 25 Oct 2018 10:17:40 -0400 Message-Id: <20181025141853.214051-25-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141853.214051-1-sashal@kernel.org> References: <20181025141853.214051-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit 55b9df93ddd684cbc4c2dee9b8a99f6e48348212 ] While we normally expect the NFSv4 client to always send the same client owner to all servers, there are a couple of situations where that is not the case: 1) In NFSv4.0, switching between use of '-omigration' and not will cause the kernel to switch between using the non-uniform and uniform client strings. 2) In NFSv4.1, or NFSv4.0 when using uniform client strings, if the uniquifier string is suddenly changed. This patch will catch those situations by checking the client owner id in the trunking detection code, and will do the right thing if it notices that the strings differ. Cc: Chuck Lever Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/nfs4client.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index d748d403bab1..a8a9be4c6cf4 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -456,6 +456,14 @@ static void nfs4_swap_callback_idents(struct nfs_client *keep, spin_unlock(&nn->nfs_client_lock); } +static bool nfs4_match_client_owner_id(const struct nfs_client *clp1, + const struct nfs_client *clp2) +{ + if (clp1->cl_owner_id == NULL || clp2->cl_owner_id == NULL) + return true; + return strcmp(clp1->cl_owner_id, clp2->cl_owner_id) == 0; +} + /** * nfs40_walk_client_list - Find server that recognizes a client ID * @@ -515,6 +523,9 @@ int nfs40_walk_client_list(struct nfs_client *new, if (pos->cl_clientid != new->cl_clientid) continue; + if (!nfs4_match_client_owner_id(pos, new)) + continue; + atomic_inc(&pos->cl_count); spin_unlock(&nn->nfs_client_lock); @@ -664,6 +675,13 @@ int nfs41_walk_client_list(struct nfs_client *new, if (!nfs4_check_clientid_trunking(pos, new)) continue; + /* Unlike NFSv4.0, we know that NFSv4.1 always uses the + * uniform string, however someone might switch the + * uniquifier string on us. + */ + if (!nfs4_match_client_owner_id(pos, new)) + continue; + atomic_inc(&pos->cl_count); *result = pos; status = 0; -- 2.17.1