From patchwork Wed May 10 04:18:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 9719219 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 4CD28601E7 for ; Wed, 10 May 2017 04:19:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DB2D28552 for ; Wed, 10 May 2017 04:19:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30F4A28558; Wed, 10 May 2017 04:19:19 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable 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 B77E828552 for ; Wed, 10 May 2017 04:19:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751822AbdEJESv (ORCPT ); Wed, 10 May 2017 00:18:51 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:33233 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751737AbdEJESr (ORCPT ); Wed, 10 May 2017 00:18:47 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 2EBFB20BAB; Wed, 10 May 2017 00:18:46 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 10 May 2017 00:18:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=7/62A3y/4yxanZZpNw fJunfGoJObkMbekvifbrXVkyU=; b=A1G40w+G8fHEF1m9OUidj8WIs5bBoojgU1 h/qJdS4dsPc70X2G3TNzXC9hIrYzzripnvPtjYnvIcwDYdkqk2VpSvD/gj3wUD3S VF4SXaeW795fzTtHTe3AVXPSNulIc/CkbeAHh2XplrT9CSPlveM2VPZtJoP+PEB5 7DfF3stpDuHi1eOiFkCU/iS0h+Mcib25GB8E5y2MSGC7sX1XUV/RUbK38F++TX62 1X1QwOylQ18f8a8vZ3uvaeIURmDSpvkpvvFOb8t8zymhYKFoEOvEbMO11rqkgGMr ZL8r2ybku8Kd5vGarv196rIYpYR4SPPW8PjBxd04MI3LOfm4OMhA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=7/62A3y/4yxanZZpNwfJunfGoJObkMbekvifbrXVkyU=; b=NolMLiCw U3kvsDDPV4hFo7rm+ayh1SXpvV2jduOVKWGbK2Y5ojix/BGim6DWP8CutgKljnda knrWPQD5ui+zT12KK+3bVbx+GJBCDiswvnsTWB5BD5rAD+Lck6nTVQLkHwhtGgRZ CgTy7K81h5mKvADn6Bf6r0/o6d/Bn/Fgupya8/eSj01q2H8MhAPfFRGeKnHzovDt xvnFp7rqeicB5esqWBN2EainV/DbwpOMo3A7QASq/SKe7dd2EDZv4b07fUGR8UNW 6yqkTGm0Z9egjLwtsqGQjXysKvAUlv69+LMDfT8pcHlv94PSSwijrawh/ntyave1 K4l3vPAQNhomOQ== X-ME-Sender: X-Sasl-enc: Vh6qsr4ziLSCVKRVPuYQPLy/NbuU44MHfgEY4MWg/m4C 1494389925 Received: from pluto.themaw.net (220-253-147-189.dyn.iinet.net.au [220.253.147.189]) by mail.messagingengine.com (Postfix) with ESMTPA id 997657E876; Wed, 10 May 2017 00:18:45 -0400 (EDT) Received: from pluto.themaw.net (localhost [127.0.0.1]) by pluto.themaw.net (Postfix) with ESMTP id 671B1A00C2; Wed, 10 May 2017 12:18:43 +0800 (AWST) Subject: [PATCH 2/3] autofs - make dev ioctl version and ismountpoint user accessible From: Ian Kent To: Al Viro Cc: Colin Walters , Ondrej Holy , autofs mailing list , Kernel Mailing List , David Howells , linux-fsdevel Date: Wed, 10 May 2017 12:18:43 +0800 Message-ID: <149438992338.26550.10884570110596019368.stgit@pluto.themaw.net> In-Reply-To: <149438991819.26550.11290804420751932707.stgit@pluto.themaw.net> References: <149438991819.26550.11290804420751932707.stgit@pluto.themaw.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some of the autofs miscellaneous device ioctls need to be accessable to user space applications without CAP_SYS_ADMIN to get information about autofs mounts. Start by making the autofs miscellaneous device ioctl header available and allow applications to use version and ismountpoint ioctls. Signed-off-by: Ian Kent Cc: Colin Walters Cc: Ondrej Holy Cc: stable@vger.kernel.org --- fs/autofs4/dev-ioctl.c | 12 ++++++++---- include/uapi/linux/Kbuild | 1 + include/uapi/linux/auto_dev-ioctl.h | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c index 9b58d6e..f8cb3f6 100644 --- a/fs/autofs4/dev-ioctl.c +++ b/fs/autofs4/dev-ioctl.c @@ -628,10 +628,6 @@ static int _autofs_dev_ioctl(unsigned int command, ioctl_fn fn = NULL; int err = 0; - /* only root can play with this */ - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - cmd_first = _IOC_NR(AUTOFS_DEV_IOCTL_IOC_FIRST); cmd = _IOC_NR(command); @@ -640,6 +636,14 @@ static int _autofs_dev_ioctl(unsigned int command, return -ENOTTY; } + /* Only root can use ioctls other than AUTOFS_DEV_IOCTL_VERSION_CMD + * and AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD + */ + if (cmd != AUTOFS_DEV_IOCTL_VERSION_CMD && + cmd != AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD && + !capable(CAP_SYS_ADMIN)) + return -EPERM; + /* Copy the parameters into kernel space. */ param = copy_dev_ioctl(user); if (IS_ERR(param)) diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild index 662c592..1f22bbb 100644 --- a/include/uapi/linux/Kbuild +++ b/include/uapi/linux/Kbuild @@ -61,6 +61,7 @@ header-y += atm_zatm.h header-y += audit.h header-y += auto_fs4.h header-y += auto_fs.h +header-y += auto_dev-ioctl.h header-y += auxvec.h header-y += ax25.h header-y += b1lli.h diff --git a/include/uapi/linux/auto_dev-ioctl.h b/include/uapi/linux/auto_dev-ioctl.h index 744b3d0..5558db8 100644 --- a/include/uapi/linux/auto_dev-ioctl.h +++ b/include/uapi/linux/auto_dev-ioctl.h @@ -16,7 +16,7 @@ #define AUTOFS_DEVICE_NAME "autofs" #define AUTOFS_DEV_IOCTL_VERSION_MAJOR 1 -#define AUTOFS_DEV_IOCTL_VERSION_MINOR 0 +#define AUTOFS_DEV_IOCTL_VERSION_MINOR 1 #define AUTOFS_DEV_IOCTL_SIZE sizeof(struct autofs_dev_ioctl)