Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1600018imu; Wed, 12 Dec 2018 00:35:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/U5abeWJ6kGgMI9U4RIztwOxZL1/GpZgeiXp3QWQwRy0vIRiZ6KcwWpOZ6unhGuGQRE5mNH X-Received: by 2002:a62:1e45:: with SMTP id e66mr19209645pfe.152.1544603718557; Wed, 12 Dec 2018 00:35:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544603718; cv=none; d=google.com; s=arc-20160816; b=GrbE3gMQ8lFRhAQJ6KSouP2z1z+IVANUER/vEpbGd9Y92/a0wO3vVdd6/wnLCGd+pb bMTeaUhKd+utojrurexCnP/Xcgct+u0unkcwumtvMeol4t5jQ56sn5DT5w2v1+eadq5E IG3mT6qHGyLnvUvmBLiN4qvZCidkOyRsp8V5/RmKdccenSYGv4ZbqW6XF3N38qD2Dza6 nCtGJdJBQP36yASnenN26TJQzpxF1c+J08gFJHozTKJekDnHK660M+/h1w2J+sFMSa8Z 9r2VnPAEIWTHf5TLWc0EVMpDQh1umMYhFRWJCkGvSeEGUNVOZuW+FdxcVgR0rYwH5rX9 TJnw== 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; bh=f5GOAP+0OGQg97EUsN1hnQXWVz2ntZQM47gMYKOleHM=; b=LQeQCoyB7Wuh91kfUlTYBzx53byLwrj97qrC3hfzQxeZfvPWX6VaenER4yRQZqwZE8 aJzn8UC7JPVthKBjzNQtpoLJK9fU9g1CRb+6Hzx+T0bbgpegjBTR0PgFqHlguQGeRSrR epewbhP3bgYiZHZSItw0l/n7LhhUfJQMnRfGD8ufQX++pOESPCGy8olU9CRyTVWt4ZUl SgGxoTYqjFzLXtT4Rnd+RruZRfD5OAyftNUMymFvotMh1rSq8hwMBs21eT1q3j3hHTe3 2mSecq3GEEb3KkjtSdB9HJ1EkWRCmTp02LJtk+R0NTqzwhzUw8pVE3q55zzFZ99oeiQt hxSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e22si13524617pge.479.2018.12.12.00.35.03; Wed, 12 Dec 2018 00:35:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726818AbeLLIdr (ORCPT + 99 others); Wed, 12 Dec 2018 03:33:47 -0500 Received: from smtp-sh2.infomaniak.ch ([128.65.195.6]:55862 "EHLO smtp-sh2.infomaniak.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726242AbeLLIdq (ORCPT ); Wed, 12 Dec 2018 03:33:46 -0500 X-Greylist: delayed 942 seconds by postgrey-1.27 at vger.kernel.org; Wed, 12 Dec 2018 03:33:45 EST Received: from smtp7.infomaniak.ch (smtp7.infomaniak.ch [83.166.132.30]) by smtp-sh.infomaniak.ch (8.14.5/8.14.5) with ESMTP id wBC8Hjjk022496 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Dec 2018 09:17:45 +0100 Received: from localhost (ns3096276.ip-94-23-54.eu [94.23.54.103]) (authenticated bits=0) by smtp7.infomaniak.ch (8.14.5/8.14.5) with ESMTP id wBC8HgY8061207; Wed, 12 Dec 2018 09:17:43 +0100 From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Al Viro , James Morris , Jonathan Corbet , Kees Cook , Matthew Garrett , Michael Kerrisk , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Mimi Zohar , =?UTF-8?q?Philippe=20Tr=C3=A9buchet?= , Shuah Khan , Thibaut Sautereau , Vincent Strubel , Yves-Alexis Perez , kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC PATCH v1 2/5] fs: Add a MAY_EXECMOUNT flag to infer the noexec mount propertie Date: Wed, 12 Dec 2018 09:17:09 +0100 Message-Id: <20181212081712.32347-3-mic@digikod.net> X-Mailer: git-send-email 2.20.0.rc2 In-Reply-To: <20181212081712.32347-1-mic@digikod.net> References: <20181212081712.32347-1-mic@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Antivirus: Dr.Web (R) for Unix mail servers drweb plugin ver.6.0.2.8 X-Antivirus-Code: 0x100000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org An LSM doesn't get path information related to an access request to open an inode. This new (internal) MAY_EXECMOUNT flag enables an LSM to check if the underlying mount point of an inode is marked as executable. This is useful to implement a security policy taking advantage of the noexec mount option. This flag is set according to path_noexec(), which checks if a mount point is mounted with MNT_NOEXEC or if the underlying superblock is SB_I_NOEXEC. Signed-off-by: Mickaël Salaün Reviewed-by: Philippe Trébuchet Reviewed-by: Thibaut Sautereau Cc: Al Viro Cc: Kees Cook Cc: Mickaël Salaün --- fs/namei.c | 2 ++ include/linux/fs.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/namei.c b/fs/namei.c index 0cab6494978c..de4f33b3f464 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2970,6 +2970,8 @@ static int may_open(const struct path *path, int acc_mode, int flag) break; } + /* Pass the mount point executability. */ + acc_mode |= path_noexec(path) ? 0 : MAY_EXECMOUNT; error = inode_permission(inode, MAY_OPEN | acc_mode); if (error) return error; diff --git a/include/linux/fs.h b/include/linux/fs.h index 584c9329ad78..083a31b8068e 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -96,6 +96,8 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset, #define MAY_NOT_BLOCK 0x00000080 /* the inode is opened with O_MAYEXEC */ #define MAY_OPENEXEC 0x00000100 +/* the mount point is marked as executable */ +#define MAY_EXECMOUNT 0x00000200 /* * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond -- 2.20.0.rc2