Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp748963pxf; Thu, 25 Mar 2021 13:11:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1Rikw7nK6h1A5SRTFMAb13NqhbiaYZPciqVLbhUDHWwTQ+jTbn+5zbs/jqgrvszSU8awY X-Received: by 2002:a17:906:3882:: with SMTP id q2mr11384147ejd.540.1616703075665; Thu, 25 Mar 2021 13:11:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616703075; cv=none; d=google.com; s=arc-20160816; b=wEncvIMo3mao1wLV2oWkhpDTVf+7JitmfBB0ZYWOZSMXpaH1qLqQiHx4xcAjOQpKVZ jeB8YJ7mGOkJ5bautpUPTCPDUIvKfjzyde9EvSkcDTYvSBZCgS2LUIWYoA4u6ImWNC8h C7BdM0Mp13lqpLQdJLVJG7kblpvYQnoafOiNMmgrTovRfU5zDLFY1lCjEPJFR6tzD5K/ M0oES9+R8FWZhYQRT3omvcCidYtXxgLwn17pKGsUPAx0V1Ll5K4Hz5Z5udDwoSbRnBdS N3cJFwcZCNaCN6jb1BVi/nE3AKx3E1/lktL/EUIbrLJjeKirXoWv/U95WL2HvTShJ+Xa 6QjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=+zf/AwflHb+wUTy9m4OXGAJWxxRZvXgH601Os6n4K/U=; b=kiXzvvXuw+UFpXDEILJ4lG/Esa3+W64rLHNvt31WwO+folUqjW4tBhv+M2YQnsvsB3 exXlQ+qOlfiZbBtiJyGsx9DoJC0ExFK7zv3hHDZI661HXsT51XWY2q9yre2URHS/4ucG f5HVI5CTVLJURi/l7+lJGuSoVShkldgh2jkhHg3mn/DpLnCD/v9aKkJSlT3bnCNFEI+m kR/NogAlURyI/oeYpbTjL1TodTzB0MTujL3Zum7QGwFDpdcOB7mtqhjdw6AHPppEUMVu qESN7jzMBY6Xaypm7zfu0CB/nnc9H5pwhwjfVNPC5w9Ix94ZVg0sdnt+0tWEWk2MxELb uxAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=rqiSQ91h; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s7si5113391edx.268.2021.03.25.13.10.42; Thu, 25 Mar 2021 13:11:15 -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=@fieldses.org header.s=default header.b=rqiSQ91h; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230009AbhCYUJf (ORCPT + 99 others); Thu, 25 Mar 2021 16:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbhCYUJ1 (ORCPT ); Thu, 25 Mar 2021 16:09:27 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8268AC06174A for ; Thu, 25 Mar 2021 13:09:27 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id 680FE6D18; Thu, 25 Mar 2021 16:09:26 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 680FE6D18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1616702966; bh=+zf/AwflHb+wUTy9m4OXGAJWxxRZvXgH601Os6n4K/U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rqiSQ91hhCFDzJ+imD9FFmC7i8Rv0udO+zDy/ppbGs8Sn3TxYdd0PJC/ecbUqGO9I MSOZECXaZilne0jWfy/SboTCPE4rtzBX+ospUdnnX6hur4S0P4fSWk9ebnL6qTqkNP CSo9sj5EFIv/TnylTjvJjloP+g7+kbW7uNvolBks= Date: Thu, 25 Mar 2021 16:09:26 -0400 From: "J. Bruce Fields" To: Ondrej Mosnacek Cc: Steve Dickson , linux-nfs Subject: Re: [PATCH] exportfs: fix unexporting of '/' Message-ID: <20210325200926.GB18351@fieldses.org> References: <20210322210238.96915-1-omosnace@redhat.com> <20210325191903.GA18351@fieldses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Thu, Mar 25, 2021 at 08:48:57PM +0100, Ondrej Mosnacek wrote: > On Thu, Mar 25, 2021 at 8:27 PM J. Bruce Fields wrote: > > On Mon, Mar 22, 2021 at 10:02:38PM +0100, Ondrej Mosnacek wrote: > > > The code that has been added to strip trailing slashes from path in > > > unexportfs_parsed() forgot to account for the case of the root > > > directory, which is simply '/'. In that case it accesses path[-1] and > > > reduces the path to an empty string, which then fails to match any > > > export. > > > > > > Fix it by stopping the stripping when the path is just a single > > > character - it doesn't matter if it's a '/' or not, we want to keep it > > > either way in that case. > > > > Makes sense to me. > > > > (Note nfs-exporting / is often a bad idea. I assume you had some good > > reason in this case.) > > I hit it in a test, so if the only issue is that it exposes more than > necessary, then I guess it's fine in this case :) Yes, in a lot of typical setups, exporting "/" would expose files to the network that you don't really want to. But, anyway, it should work. Looks like a good fix. --b. > > > > > --b. > > > > > > > > Reproducer: > > > > > > exportfs localhost:/ > > > exportfs -u localhost:/ > > > > > > Without this patch, the unexport step fails with "exportfs: Could not > > > find 'localhost:/' to unexport." > > > > > > Fixes: a9a7728d8743 ("exportfs: Deal with path's trailing "/" in unexportfs_parsed()") > > > Link: https://bugzilla.redhat.com/show_bug.cgi?id=1941171 > > > Signed-off-by: Ondrej Mosnacek > > > --- > > > utils/exportfs/exportfs.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c > > > index 262dd19a..1aedd3d6 100644 > > > --- a/utils/exportfs/exportfs.c > > > +++ b/utils/exportfs/exportfs.c > > > @@ -383,7 +383,7 @@ unexportfs_parsed(char *hname, char *path, int verbose) > > > * so need to deal with it. > > > */ > > > size_t nlen = strlen(path); > > > - while (path[nlen - 1] == '/') > > > + while (nlen > 1 && path[nlen - 1] == '/') > > > nlen--; > > > > > > for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) { > > > -- > > > 2.30.2 > > > > > -- > Ondrej Mosnacek > Software Engineer, Linux Security - SELinux kernel > Red Hat, Inc.