Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp58915imu; Thu, 8 Nov 2018 14:46:24 -0800 (PST) X-Google-Smtp-Source: AJdET5ePJPa5bAITKYNnhVS6PTvWWcebZAw3mdMdL8j+oMS6oUV1FN/+l0tytpfuGMZNnoSlzaXQ X-Received: by 2002:aa7:818a:: with SMTP id g10-v6mr6389083pfi.153.1541717184858; Thu, 08 Nov 2018 14:46:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541717184; cv=none; d=google.com; s=arc-20160816; b=FcJBcYxlHlBEOyPiLuDqc38GNpA4VdXfIAZJUHs6lzLIAIGvJEfA2Yz3n1Ny2CWsz4 AYOHJlkyT52mNkJM5wi9iu0yN6R2l8fu/YuYeFVWbsC3d0ru2powkFvLJHkpSpVWrx8d faeuo+KJHimPx1B/Qu7YmMUVgnOCVD4RLr4RQ6F0dmE+Nk68sxP37sop093RcYTbHhW3 pfHj0M+qnNsb5z84VwprEbcXLtCa1JVofh5ui7c9IC8mS/LAiBymppkuxf1ZWwji1itV KcSmkvqu3KIQWFbjqEp5bPco2F0cbGBPNO3NcJKJDsoUteef7/bKnEGMIiqV76pSDHQ3 uWIA== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=mL0xWF+XycQvnpyiy0CjAEwtp02Zxonrpac/NusTW/o=; b=KRtviSPUcIfC2sSQG69yGA8dWkmqyQw7UxyvD2+gMgcQAKxObeHkgAPFDRzq/pkG4M gXuDFxZAlbbCKYxgtIRxBgBSuu24UzwsXQBWwz3YDmUUQP9aMR+nmHoiD5N/WIYxX+bH L++t2K8QVYxBBDUxAhIkRvRrve6wWCzDuJCIOIvaHZBC1aqhaoTCx6tPwUvrYWKOOCMf ZVeq18I48JPTm6z09YoqXk8tlVAmBgkpb/Yw9Niz/Cnb/5U8O9AILewn54IcxmnxUp2N UxeWrbd5U2OTj/l5tlC5fVLIJlIF6cVTt5i4ZFmucB07hcBkOd8/TBynDawax/cN4lmy iz7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aCZg19uZ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si4307424pgb.105.2018.11.08.14.46.09; Thu, 08 Nov 2018 14:46:24 -0800 (PST) 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=aCZg19uZ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728556AbeKIHck (ORCPT + 99 others); Fri, 9 Nov 2018 02:32:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:47976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727055AbeKIHck (ORCPT ); Fri, 9 Nov 2018 02:32:40 -0500 Received: from localhost (unknown [208.72.13.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DBF5D2086C; Thu, 8 Nov 2018 21:55:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714113; bh=6CqUx3LUdLBqCz8zfw01CqvQkJXu6nZa3fgYW/BMau0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aCZg19uZYUcteVLDZS8tw0O0AOhIzYoNATdnEFFwNzJMgwM0ltVOA2EcWPiHM5HaY TpqO7qXhZ9YlSlBTd2aqLYWEtgmfVopvaO2+NXSA+c+6K+oaQ8Wxy88cC+npXOUDOr TmxU+r2KEMz63YoqQW5RB0nazRogiZIIBJw1Td5M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuck Lever , Trond Myklebust , Sasha Levin Subject: [PATCH 3.18 055/144] NFSv4/v4.1: Verify the client owner id during trunking detection Date: Thu, 8 Nov 2018 13:50:26 -0800 Message-Id: <20181108215058.824631804@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215054.826084593@linuxfoundation.org> References: <20181108215054.826084593@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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