Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6312260ybi; Sun, 21 Jul 2019 14:44:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLouS3IBukRmNy/OQC566DqvZG9hgm2wbau4STLMWrZsFtMOliQiW3TLbO+a+QyLfdix6t X-Received: by 2002:a63:460c:: with SMTP id t12mr67809924pga.69.1563745495157; Sun, 21 Jul 2019 14:44:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563745495; cv=none; d=google.com; s=arc-20160816; b=m/+yKM3QhdNGsQW26b8K+xpvWxL/cX7Xbwk4hW0sJAl9YPf7j8/f/IhgJd3QEaZfn3 tgOcINW+iaWztamUq9BiqA/3YpvW6OW+wmzoTiDlD400BH8rBz+7dYz6XEahqCCf1uTn weiZCxV6TWd2te3mCFiuYlv+YH8R34Nmyk5MivmIvHg+0CfueiAuHTkb+PDf+ItNqkXv fXHgi/er90Eu6ki+v8HzFcEWVZdMjUYGA3XSR0M2J37E/xewWtG+aI0xatUjJ2AJv80p brFdp1EJ423hlN+oVi7O9NQ9QooKGuENG0EhRXtHARD8RO94s85xotsI5XDB/4Juy418 TrSg== 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=47TnWQLVRy5f6OpujFMjZ+N7fBE6gZYqf2Zd7PCy4N4=; b=RuaPYopnqTmMkfnxRkW4LrHIBHhmmX0NGjoAwQ23pX5qe1I6XwM69LuzDzt/YDb0bl NmErfSBdojMvc/EcxleDS+mtDzyrC8UW4UnQ+cSWhksyVs+IMicCRwACE5Dx0g/J7wHQ ZWhq1wXzTuVKf9TnVnqjRzig6xUIRlX8r89BjM0xa086oWmkuW5hvsBedHdnchDnJwS8 ukdHW6M5yawEuJJLID4Q0Hn369LWFjkHfsS6NKMz/JQXYuHDfzuF7sR4HHWJjbfZmKcu KquapZ701fSaO+NgH2hVyI8gRY5UyrKyhTJ4RpEFN65snnjM5FA8whcJey8LDkkZVJxk YSEw== 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 z193si7437243pgd.235.2019.07.21.14.44.39; Sun, 21 Jul 2019 14:44:55 -0700 (PDT) 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 S1726402AbfGUVct (ORCPT + 99 others); Sun, 21 Jul 2019 17:32:49 -0400 Received: from smtp-sh2.infomaniak.ch ([128.65.195.6]:55905 "EHLO smtp-sh2.infomaniak.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726287AbfGUVct (ORCPT ); Sun, 21 Jul 2019 17:32:49 -0400 Received: from smtp7.infomaniak.ch (smtp7.infomaniak.ch [83.166.132.30]) by smtp-sh2.infomaniak.ch (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id x6LLVU5D253757 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Jul 2019 23:31:30 +0200 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 x6LLVRN8069488; Sun, 21 Jul 2019 23:31:28 +0200 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?= , Alexander Viro , Alexei Starovoitov , Andrew Morton , Andy Lutomirski , Arnaldo Carvalho de Melo , Casey Schaufler , Daniel Borkmann , David Drysdale , "David S . Miller" , "Eric W . Biederman" , James Morris , Jann Horn , John Johansen , Jonathan Corbet , Kees Cook , Michael Kerrisk , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Paul Moore , Sargun Dhillon , "Serge E . Hallyn" , Shuah Khan , Stephen Smalley , Tejun Heo , Tetsuo Handa , Thomas Graf , Tycho Andersen , Will Drewry , kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH bpf-next v10 01/10] fs,security: Add a new file access type: MAY_CHROOT Date: Sun, 21 Jul 2019 23:31:07 +0200 Message-Id: <20190721213116.23476-2-mic@digikod.net> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190721213116.23476-1-mic@digikod.net> References: <20190721213116.23476-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 b5b80469b93d..e8767318fd03 100644 --- a/fs/open.c +++ b/fs/open.c @@ -494,7 +494,8 @@ int ksys_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 75f2ed289a3f..7a0d92b1da85 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -99,6 +99,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.22.0