Received: by 10.223.185.116 with SMTP id b49csp4374141wrg; Mon, 26 Feb 2018 16:46:57 -0800 (PST) X-Google-Smtp-Source: AH8x226oltQQLRbCQTdw1F8t9F52UJLMEaR5/UKfoV94HKwZEMKTckqJn7JbLII5G/CV/2Hm37By X-Received: by 10.99.95.15 with SMTP id t15mr9685698pgb.183.1519692417108; Mon, 26 Feb 2018 16:46:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519692417; cv=none; d=google.com; s=arc-20160816; b=E+HCpEXBRYKrPC5/3/e2Smdr5QpTULDdHFgXzLG9D35K4kDrucr90vEleHHe6mSRKW sfbMH9y8h+deTR8jiolsY7VZa9VPnS8KNbmAs/eG3NHHgoAV+lb0Ww7G2MBGAFJ1r7Qd Kt5+IIQuK7GTAF67CGjEEn55pFdVt8ts/pAWQGBczmOJKw2q7dmH2aDBkGa8NvK7mxMd lfkcxdPykNC3HzCeAr6x4OdZ2PzEIqNJSJsbx7ntcWL8ae+wZeQk3px6f+X2+nOzmYpC jyAc7RicRYU4GRe56va7QPImdUna5oRijcgjsFULZUd5kuIsEjk9myH1ZL7LSBY2aV/0 nfKQ== 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 :arc-authentication-results; bh=8fVpKOPQ6B5A9jPksktqid2q0geKpPASwzjnBu4Wk/0=; b=xTXK7/uNZ2HEe+fvuffdEVv9FZJ8UNDu/V33vmrrmNzG5WM9ghYAfvCHIxhLR3j16o Ew4u5x2jC5fxIYwsnbgWgIAzaBGm4icZ2ltL9Lk3LqbXH4tXlmcP1jUfx7SXPzWkDZt0 n65e/cgR0Tn9WsiAZwWO4zx1jhj7WUnl/aRHxLWnsEYSdELPEexsXNQvgVC1an8+qEnP sb9iXkhr1KywjkLaURK3pBj4IBt8fgU9E1/zsq7CZdnlz2+WbmYlxQg0nGsKxPA5Koau QpJOsvtJWZkaQljLI96z4wVTQy2glOy/KRg70o3wMGYng8ySmUnzEb25/eUhpkeh+iqf oyaw== 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 v189si6203757pgd.414.2018.02.26.16.46.42; Mon, 26 Feb 2018 16:46:57 -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 S1751908AbeB0Ao3 (ORCPT + 99 others); Mon, 26 Feb 2018 19:44:29 -0500 Received: from smtp-sh.infomaniak.ch ([128.65.195.4]:40121 "EHLO smtp-sh.infomaniak.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751487AbeB0Amt (ORCPT ); Mon, 26 Feb 2018 19:42:49 -0500 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 w1R0fZW7007756 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Feb 2018 01:41:35 +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 w1R0fY5R120109; Tue, 27 Feb 2018 01:41:34 +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?= , Alexei Starovoitov , Andy Lutomirski , Arnaldo Carvalho de Melo , Casey Schaufler , Daniel Borkmann , David Drysdale , "David S . Miller" , "Eric W . Biederman" , James Morris , Jann Horn , Jonathan Corbet , Michael Kerrisk , Kees Cook , Paul Moore , Sargun Dhillon , "Serge E . Hallyn" , Shuah Khan , Tejun Heo , Thomas Graf , Tycho Andersen , Will Drewry , kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-security-module@vger.kernel.org, netdev@vger.kernel.org, Alexander Viro , James Morris , John Johansen , Stephen Smalley , Tetsuo Handa , linux-fsdevel@vger.kernel.org Subject: [PATCH bpf-next v8 02/11] fs,security: Add a new file access type: MAY_CHROOT Date: Tue, 27 Feb 2018 01:41:12 +0100 Message-Id: <20180227004121.3633-3-mic@digikod.net> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180227004121.3633-1-mic@digikod.net> References: <20180227004121.3633-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 For compatibility reason, MAY_CHROOT is always set with MAY_CHDIR. However, this new flag enable to differentiate a chdir form a chroot. This is needed for the Landlock LSM to be able to evaluate a new root directory. Signed-off-by: Mickaël Salaün Cc: Alexander Viro Cc: Casey Schaufler Cc: James Morris Cc: John Johansen Cc: Kees Cook Cc: Paul Moore Cc: "Serge E. Hallyn" Cc: Stephen Smalley Cc: Tetsuo Handa Cc: linux-fsdevel@vger.kernel.org --- fs/open.c | 3 ++- include/linux/fs.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/open.c b/fs/open.c index 7ea118471dce..084d147c0e96 100644 --- a/fs/open.c +++ b/fs/open.c @@ -489,7 +489,8 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename) if (error) goto out; - error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR); + error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR | + MAY_CHROOT); if (error) goto dput_and_out; diff --git a/include/linux/fs.h b/include/linux/fs.h index 2a815560fda0..67c62374446c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -90,6 +90,7 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset, #define MAY_CHDIR 0x00000040 /* called from RCU mode, don't block */ #define MAY_NOT_BLOCK 0x00000080 +#define MAY_CHROOT 0x00000100 /* * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond -- 2.16.2