From patchwork Thu Dec 15 19:37:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Mayhew X-Patchwork-Id: 9476819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3D7A460826 for ; Thu, 15 Dec 2016 19:44:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C77D287BB for ; Thu, 15 Dec 2016 19:44:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 219E22882C; Thu, 15 Dec 2016 19:44:20 +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=-6.9 required=2.0 tests=BAYES_00,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 BCA1B28816 for ; Thu, 15 Dec 2016 19:44:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754449AbcLOToL (ORCPT ); Thu, 15 Dec 2016 14:44:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44788 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754428AbcLOToK (ORCPT ); Thu, 15 Dec 2016 14:44:10 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 524CE64D97 for ; Thu, 15 Dec 2016 19:37:22 +0000 (UTC) Received: from tonberry.usersys.redhat.com (dhcp145-110.rdu.redhat.com [10.13.145.110]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBFJbMIF024683; Thu, 15 Dec 2016 14:37:22 -0500 Received: by tonberry.usersys.redhat.com (Postfix, from userid 1000) id D40591206D4; Thu, 15 Dec 2016 14:37:21 -0500 (EST) From: Scott Mayhew To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH] exportfs: fix path comparison in unexportfs_parsed() Date: Thu, 15 Dec 2016 14:37:21 -0500 Message-Id: <1481830641-15595-1-git-send-email-smayhew@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 15 Dec 2016 19:37:22 +0000 (UTC) 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 Passing a path like /export1 to unexportfs_parsed() matches not only /export1, but /export11, /export100, /export1forthemoney, etc. which can result in some nasty surprises when unexporting individual exports. Signed-off-by: Scott Mayhew --- utils/exportfs/exportfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c index b7a910e..a763272 100644 --- a/utils/exportfs/exportfs.c +++ b/utils/exportfs/exportfs.c @@ -345,6 +345,8 @@ unexportfs_parsed(char *hname, char *path, int verbose) nlen--; for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) { + if (strlen(exp->m_export.e_path) != nlen) + continue; if (path && strncmp(path, exp->m_export.e_path, nlen)) continue; if (htype != exp->m_client->m_type)