Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4440191ybi; Mon, 3 Jun 2019 10:53:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5l+obaXcKN96FFmtMA7n50AE0MQpdLU1jFv2zhG9FFmdW6ERph23O2ds6C42Rq3m5vVbH X-Received: by 2002:a17:90a:650c:: with SMTP id i12mr32220895pjj.44.1559584419095; Mon, 03 Jun 2019 10:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559584419; cv=none; d=google.com; s=arc-20160816; b=j6n66RKqQo14IAM9v3Ae5BdA5aD0bDuKnm3Q/e9x6L+IeecqHf0JGPH9UKNdjbjLQu nY3GY2P8gadwnbucasTckZXOlTiYdM8JRrJ14QX8SwOy18dg3KK808/2EXwKjPTOedVj WyAs0Gb2Jp9IEkWF3ZnJa4LYeSukdDLoFDAS7AFXLDrStsp3U4h8bLjr5sPMpFhwSFWY pn8UoIiiIvoL4DxWM/89ro0UUBZDW2VSD1Skho60MvIADK//kTRoXF5rQCVtIiuffS/a fhT28YmVQdnuswNc7kT6WYa8MSWNqKxf1e0GBPP+BhwOBxZmcccEg9JFcV969uk3zebv l6pg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=54eXN7xcmcx5yI3W1cCqULRllgy5g2GJtxxP9B6eUlU=; b=ug23UiNhNOMkC3lhqkjo1L4kt7VXza3vxpELa+BTYkzAXyZU7Va4cc+9oAXChSoMBY ivKAAyIowxlW58KrOSNuG8/nCIFhqPy+IB/C79cYcQY4rYU0vjVsijRZY8zI0sErqmc9 Wsh3ip061MQ9k/d52KFcaaVGzBUVgECixc1elKSjThcGA1wZLQFzSv7AuDJQCThnq/5P 9CJcLQ4aRjJzUiw8IQROYRWUFXARtJfUhZ6m5aigjca1y8Bj4ov/7cWJNqH2/yJxW6hW 4eXBo9tlBw91JkLFXQMpD6UlKJNWmY8Gjv1407GZ6jH/whEioq3noZ9mknaC6hG2sE1M DRqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Vue87Z9+; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x12si17257313pll.438.2019.06.03.10.53.25; Mon, 03 Jun 2019 10:53:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-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=@gmail.com header.s=20161025 header.b=Vue87Z9+; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729078AbfFCRP6 (ORCPT + 99 others); Mon, 3 Jun 2019 13:15:58 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:39751 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729031AbfFCRP5 (ORCPT ); Mon, 3 Jun 2019 13:15:57 -0400 Received: by mail-it1-f195.google.com with SMTP id j204so22482183ite.4 for ; Mon, 03 Jun 2019 10:15:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=54eXN7xcmcx5yI3W1cCqULRllgy5g2GJtxxP9B6eUlU=; b=Vue87Z9+wKhPUx22cv1MMj9KcgiBhGjP3NxmET8NwQtdydsbYU+C2Y7rg2jC5vsALW 0Ww7DpF6ta1Fw6bCzqOomhgMHlP0fvl8onn1Wb/JgDgweCckYshpY95jWfvRmzT0idB5 mAArlFEUoNMqGFL9BwLlNRCSs5JElYul56FWlbhfBsZ2r3QAf9Q/LC6zpIzD2mccgrk2 4fu2gyapaaOr7iiecrh+HiQtE8VIjR38UMxflo902lsBThXzk2PP6HzD4TtVxyHUj7A6 Vp6cFIiIgG/MXlnzg+MudLfiQqvolB5ighghNx7ojbl1ngemdUg8PnZp7YwHrgSEmiPj X0/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=54eXN7xcmcx5yI3W1cCqULRllgy5g2GJtxxP9B6eUlU=; b=CZGGyetdfYtKkiBrxsftCxbPF1nY9/3Ckumqd+lz8Pgw0UfKvuGXkEEuY7EElcCmyK HmKjLO/7pJH+BEKf/f6ZBBT2+6OggSciL1+EU1fARUrsaHtHIrbBQdBTmGbEpR9BrKVs nYtQI08ctQqZ0m3Limp6+Uf43g80mAGhTutv05yLbePXUUUWxd2xQAXMnIgFUCR4YjRc +67xdM2KoTT2vZMWmR8ArOhv0AVIlSt9EkQqTG/BYonfFhWGlBvmXYhshu7B1GbPx1rR ltwy1CmYnKJJgCga6a9oqZ2aI6Npniw9rhl3b9H2yiL+eTxFz5jPkpb2IUADHephOq+0 yi7A== X-Gm-Message-State: APjAAAWLyKMYBDWya2fhb2EM3B97OGa+SP4P31am3GER1O949V2x+oel bRBo+OQ6DWEBqw41FJ4GWlUhG/Q= X-Received: by 2002:a02:7715:: with SMTP id g21mr17853440jac.24.1559582156589; Mon, 03 Jun 2019 10:15:56 -0700 (PDT) Received: from localhost.localdomain (50-36-175-138.alma.mi.frontiernet.net. [50.36.175.138]) by smtp.gmail.com with ESMTPSA id b8sm1971375ioj.16.2019.06.03.10.15.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Jun 2019 10:15:55 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Steve Dickson Cc: "J. Bruce Fields" , linux-nfs@vger.kernel.org Subject: [PATCH 2/3] mountd: Ensure nfsd_path_strip_root() uses the canonicalised path Date: Mon, 3 Jun 2019 13:12:26 -0400 Message-Id: <20190603171227.29148-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190603171227.29148-2-trond.myklebust@hammerspace.com> References: <20190603171227.29148-1-trond.myklebust@hammerspace.com> <20190603171227.29148-2-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org When attempting to strip the root path, we should first canonicalise the root pathname. Signed-off-by: Trond Myklebust --- support/misc/nfsd_path.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/support/misc/nfsd_path.c b/support/misc/nfsd_path.c index 2f41a793c534..9b38dd96007f 100644 --- a/support/misc/nfsd_path.c +++ b/support/misc/nfsd_path.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -62,13 +63,21 @@ nfsd_path_nfsd_rootdir(void) char * nfsd_path_strip_root(char *pathname) { + char buffer[PATH_MAX]; const char *dir = nfsd_path_nfsd_rootdir(); char *ret; - ret = strstr(pathname, dir); - if (!ret || ret != pathname) - return pathname; - return pathname + strlen(dir); + if (!dir) + goto out; + if (realpath(dir, buffer)) { + ret = strstr(pathname, buffer); + if (ret == pathname) + return pathname + strlen(dir); + } else + xlog(D_GENERAL, "%s: failed to resolve path %s: %m", + __func__, dir); +out: + return pathname; } char * -- 2.21.0