From patchwork Mon Jun 3 17:12:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10973565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8FA6E933 for ; Mon, 3 Jun 2019 17:16:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F091285D1 for ; Mon, 3 Jun 2019 17:16:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6347628662; Mon, 3 Jun 2019 17:16:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 191FD28618 for ; Mon, 3 Jun 2019 17:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726823AbfFCRQC (ORCPT ); Mon, 3 Jun 2019 13:16:02 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:35421 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728993AbfFCRP4 (ORCPT ); Mon, 3 Jun 2019 13:15:56 -0400 Received: by mail-it1-f195.google.com with SMTP id n189so9385524itd.0 for ; Mon, 03 Jun 2019 10:15:56 -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=GT8X+EsNYBb5UMZWBMZ2Z4O0Ne33KByhJ3ztwwgYRAs=; b=oXfU8Kd+U3YooLaIdo2/Uk53G9kxv6p6ODuXkBiZM8GzLU3MvCCrosJ2j4JL+MHojs /72WbxaLQlHQXcZrM9Y/BCT8+XU3tFJqi6sX3kW8qwrCEtf+dCGCoI+tAE+hJ3ZmanQq zishqNcmHAo93zyHAigQMrqhXRytR7ngC5JRV8KWSWzGLv2v6kYWQds3XKZ0nnrNdT4+ VColuGs3k5QIercFxjE97kcyOWqKlGcxdvlT0t/3zyNvblteJUefn++kb1DtYVd2gKxV dTOLJbr0HK1LVessxeYmZEWP4ml+qWQboqKQzfZeF/fXb9JasWX2VQfRaap3kgjxhIw+ BRcw== 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=GT8X+EsNYBb5UMZWBMZ2Z4O0Ne33KByhJ3ztwwgYRAs=; b=lwcJCDTZsyoVtjzWo6f5NRS+pESGMIIsPYylIl6sfoGZ9ZNeS2Xi66DEEcWEemntEQ ns35cyq1APkg7OTSWxpYXpHYKYkrOcE71sFRQ20YG+RVHaG2Zj3TldEXiyC4E8i5y7P3 fpRYku4FCO7hRGjJ5APgpWpPasiINy647U8cuzExQUxPnzoheDx/7lYV9jqBbJhWImgz 4sl4t0A1CUezDnZqazUr+L8Cqd3NlqSe5pwYlORC78tuSSL90p8REdjw7zBOgvvJ15WJ 5nVrSp/N8Sln1BXfto/U1oljF1yxJxyFLgUmF/3Rc53uunm4PVcaG6ijfTuoGi4bj1/O Rl9g== X-Gm-Message-State: APjAAAX5AbF4cygK1EKNAtFVXfCe3YgwV8CdQMy4q5b/oDKwhCY+1Tep TXv+21ZkdrD7KaYQ8l8eNL4HSEI= X-Google-Smtp-Source: APXvYqxnKPEb4K6rViVc8FY38myUuvCBqLU4L170ybmlL4AX+lnZZgDtxxwtUi91xiejLHorikLsRg== X-Received: by 2002:a02:c95a:: with SMTP id u26mr2423772jao.15.1559582155559; Mon, 03 Jun 2019 10:15:55 -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.54 (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 1/3] mountd: Fix up incorrect comparison in next_mnt() Date: Mon, 3 Jun 2019 13:12:25 -0400 Message-Id: <20190603171227.29148-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190603171227.29148-1-trond.myklebust@hammerspace.com> References: <20190603171227.29148-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We want to ensure that we compare the full name of the last component. Reported-by: "J. Bruce Fields" Signed-off-by: Trond Myklebust --- utils/mountd/cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c index d818c971bded..d616d526667e 100644 --- a/utils/mountd/cache.c +++ b/utils/mountd/cache.c @@ -400,7 +400,7 @@ static char *next_mnt(void **v, char *p) while ((me = getmntent(f)) != NULL && l > 1) { mnt_dir = nfsd_path_strip_root(me->mnt_dir); - if (strncmp(mnt_dir, p, l) == 0 && mnt_dir[l] != '/') + if (strncmp(mnt_dir, p, l) == 0 && mnt_dir[l] == '/') return mnt_dir; } endmntent(f); From patchwork Mon Jun 3 17:12:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10973561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16B0D933 for ; Mon, 3 Jun 2019 17:16:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECA78285D1 for ; Mon, 3 Jun 2019 17:15:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0A9F28662; Mon, 3 Jun 2019 17:15:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87CB3285D1 for ; Mon, 3 Jun 2019 17:15:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729078AbfFCRP6 (ORCPT ); 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-Google-Smtp-Source: APXvYqzy5m9NUcbwSEdQiZeUWdu8MlNmDsWkEcuBlyCir3gMP628fIJC56Mu7ucbBYfoof3AL+ZkQw== 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 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 * From patchwork Mon Jun 3 17:12:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10973563 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F1FF14E5 for ; Mon, 3 Jun 2019 17:16:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 017F3285D1 for ; Mon, 3 Jun 2019 17:16:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E846C28662; Mon, 3 Jun 2019 17:16:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95A4B285D1 for ; Mon, 3 Jun 2019 17:16:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729031AbfFCRP7 (ORCPT ); Mon, 3 Jun 2019 13:15:59 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:41254 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726823AbfFCRP6 (ORCPT ); Mon, 3 Jun 2019 13:15:58 -0400 Received: by mail-io1-f66.google.com with SMTP id w25so14926258ioc.8 for ; Mon, 03 Jun 2019 10:15:58 -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=j1UkUfTZsFI//kdDQAkgjA8sveaR01sXEVy3hYpGpgU=; b=O+PWbM4X5IO/s7or71I4Nisp4D6ldT9VlOAVIMGioG4xDqAmF7IXYEQ1d1E8u+aX7R CAHFlj8LZgomtIi0XTt4AVICdFclpp2hhEgwuPbtRDuYnK8W85xF0AMT306NxpZRUjji VAeon4QPwE5oIYKfyUgjTOs5ZkaGcK8f7RZYMxBxxTVcVoaLc44n21YGCH+IRDvTjB3B sh65XncYpp2CsqYyl/sprfCekuKM9rkDkKTycRv6OUrb20XpfzLs+ZBKWRARjF4ERD+j Av0bzhwxKDKWPGj6+66er6SPppIos+ANEp/FtHZ3g+jtzHVRTSvlfJnks2rFTWkHZYPD YIog== 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=j1UkUfTZsFI//kdDQAkgjA8sveaR01sXEVy3hYpGpgU=; b=gtH0tNT5V9CIInvpCn3IsiN0qjLt7f/ZTOfV6n8ow0Nahp3FyLUqU6DxZ/ISkh2Ml4 dHMTMSHP0H2Ph+BghZ7n4gGJUnuL+ZlypFj4A2iQctuN3oSAFKTughVXm1+HaY3ILZrS +3ZijloE8opX3WnETkV8rpZZADK44VbC9ZU4S4iEaMowJJTq0co9YL1v6lJ8jp/d2AXR YCayCVOMsaemtQJqTYIbj+c7/i80l1wIAt3MVBggonuUPA+U5rGrdIbW1IIyX2WnVqhm JnbT27bzCvA0leAYx0T0TbmOkGxfvzuUGFkWj8j8RxfqQSFc/yzS3j+w0nhso5+jeRa4 SJgg== X-Gm-Message-State: APjAAAWIt2epoX+j4CY0LSPLvQY1NJOYwj0WFsVq4xvg1gPAA5mMwuNW x+AgVuk9oPjeJhCUDgWeAQAbd9s= X-Google-Smtp-Source: APXvYqxVK8DlWi0F9zjydtMLkKHQYdYkxdVnueulwP3Xm2u4AvUnwiQEkxDuqN03lq0fCI8w8/8EqA== X-Received: by 2002:a6b:7d49:: with SMTP id d9mr11490728ioq.50.1559582157600; Mon, 03 Jun 2019 10:15:57 -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.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Jun 2019 10:15:56 -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 3/3] mountd: Canonicalise the rootdir in exportent_mkrealpath() Date: Mon, 3 Jun 2019 13:12:27 -0400 Message-Id: <20190603171227.29148-4-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190603171227.29148-3-trond.myklebust@hammerspace.com> References: <20190603171227.29148-1-trond.myklebust@hammerspace.com> <20190603171227.29148-2-trond.myklebust@hammerspace.com> <20190603171227.29148-3-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Ensure that we canonicalise the export path when generating the real path. Signed-off-by: Trond Myklebust --- support/export/export.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/support/export/export.c b/support/export/export.c index 82bbb54c5e9e..c753f68e4d63 100644 --- a/support/export/export.c +++ b/support/export/export.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +22,7 @@ #include "nfslib.h" #include "exportfs.h" #include "nfsd_path.h" +#include "xlog.h" exp_hash_table exportlist[MCL_MAXTYPES] = {{NULL, {{NULL,NULL}, }}, }; static int export_hash(char *); @@ -38,8 +40,14 @@ exportent_mkrealpath(struct exportent *eep) const char *chroot = nfsd_path_nfsd_rootdir(); char *ret = NULL; - if (chroot) - ret = nfsd_path_prepend_dir(chroot, eep->e_path); + if (chroot) { + char buffer[PATH_MAX]; + if (realpath(chroot, buffer)) + ret = nfsd_path_prepend_dir(buffer, eep->e_path); + else + xlog(D_GENERAL, "%s: failed to resolve path %s: %m", + __func__, chroot); + } if (!ret) ret = xstrdup(eep->e_path); eep->e_realpath = ret;