All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/4] Landlock filesystem caching
@ 2021-06-30 22:48 Mickaël Salaün
  2021-06-30 22:48 ` [PATCH v1 1/4] fs,security: Add resolve_path_at() hook Mickaël Salaün
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Mickaël Salaün @ 2021-06-30 22:48 UTC (permalink / raw)
  To: Al Viro, James Morris, Serge Hallyn
  Cc: Mickaël Salaün, Andy Lutomirski, Jann Horn, Kees Cook,
	Shuah Khan, linux-fsdevel, linux-kernel, linux-kselftest,
	linux-security-module

Hi,

The goal of this patch series is to reduce the performance impact of
walking through a lot of files while being landlocked.  Indeed, because
of the unprivileged nature of Landlock, each file access implies to
check access granted to each directory of the path, which slows down
open time.

Currently, openat(2) calls spend more than 22% of their time in
hook_file_open().  The performance impact for a common worth case
scenario is significantly reduced thanks to this patch series,
theoretically going from O(n) with n as the depth of a path, to O(1)
(cf. benchmarks in the caching patch).

This series adds a new security hook (resolve_path_at) and uses it to
implement access caching in Landlock.  I'm planning to build on top of
that for other improvements (using task's working directory and task's
root directory) but that will require other hook changes.

This new hook is also a first step to be able to securely restrict file
descriptors used for path resolution (e.g. dirfd in openat2).

Caching may be difficult to get right especially for security checks.  I
extended the current tests and I'm still working on new ones.  If you
have test/attack scenarios, please share them.  I would really
appreciate constructive reviews for these critical changes.  This series
can be applied on top of v5.13 .

Regards,

Mickaël Salaün (4):
  fs,security: Add resolve_path_at() hook
  landlock: Add filesystem rule caching
  selftests/landlock: Work in a temporary directory
  selftests/landlock: Check all possible intermediate directories

 fs/namei.c                                 |   9 +
 include/linux/lsm_hook_defs.h              |   2 +
 include/linux/lsm_hooks.h                  |   8 +
 include/linux/security.h                   |   9 +
 security/landlock/cache.h                  |  77 +++++++
 security/landlock/cred.c                   |  15 +-
 security/landlock/cred.h                   |  20 +-
 security/landlock/fs.c                     | 224 +++++++++++++++++++--
 security/landlock/fs.h                     |  29 +++
 security/landlock/setup.c                  |   2 +
 security/security.c                        |   6 +
 tools/testing/selftests/landlock/fs_test.c | 205 ++++++++++++++-----
 12 files changed, 544 insertions(+), 62 deletions(-)
 create mode 100644 security/landlock/cache.h


base-commit: 62fb9874f5da54fdb243003b386128037319b219
-- 
2.32.0


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [PATCH v1 2/4] landlock: Add filesystem rule caching
@ 2021-07-09 15:03 kernel test robot
  0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-07-09 15:03 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 2890 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210630224856.1313928-3-mic@digikod.net>
References: <20210630224856.1313928-3-mic@digikod.net>
TO: "Mickaël Salaün" <mic@digikod.net>
TO: Al Viro <viro@zeniv.linux.org.uk>
TO: James Morris <jmorris@namei.org>
TO: Serge Hallyn <serge@hallyn.com>
CC: "Mickaël Salaün" <mic@digikod.net>
CC: Andy Lutomirski <luto@amacapital.net>
CC: Jann Horn <jannh@google.com>
CC: Kees Cook <keescook@chromium.org>
CC: Shuah Khan <skhan@linuxfoundation.org>
CC: linux-fsdevel(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org

Hi "Mickaël,

I love your patch! Perhaps something to improve:

[auto build test WARNING on 62fb9874f5da54fdb243003b386128037319b219]

url:    https://github.com/0day-ci/linux/commits/Micka-l-Sala-n/Landlock-filesystem-caching/20210701-065103
base:   62fb9874f5da54fdb243003b386128037319b219
:::::: branch date: 9 days ago
:::::: commit date: 9 days ago
config: x86_64-randconfig-b001-20210709 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 8d69635ed9ecf36fd0ca85906bfde17949671cbe)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # apt-get install iwyu # include-what-you-use
        # https://github.com/0day-ci/linux/commit/6dc651e6e3eef4c1dc62e6c51ca136a18b2ec94d
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Micka-l-Sala-n/Landlock-filesystem-caching/20210701-065103
        git checkout 6dc651e6e3eef4c1dc62e6c51ca136a18b2ec94d
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross C=1 CHECK=iwyu O=build_dir ARCH=x86_64 SHELL=/bin/bash security/landlock/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


iwyu warnings: (new ones prefixed by >>)
>> security/landlock/cred.c:12:1: iwyu: warning: superfluous #include <linux/sched.h>
   security/landlock/cred.c:18:1: iwyu: warning: superfluous #include "setup.h"
--
   security/landlock/fs.c:19:1: iwyu: warning: superfluous #include <linux/limits.h>
>> security/landlock/fs.c:24:1: iwyu: warning: superfluous #include <linux/overflow.h>
   security/landlock/fs.c:31:1: iwyu: warning: superfluous #include <linux/workqueue.h>

vim +12 security/landlock/cred.c

6dc651e6e3eef4 Mickaël Salaün 2021-07-01 @12  #include <linux/sched.h>
385975dca53eb4 Mickaël Salaün 2021-04-22  13  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 43082 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-09 15:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-30 22:48 [PATCH v1 0/4] Landlock filesystem caching Mickaël Salaün
2021-06-30 22:48 ` [PATCH v1 1/4] fs,security: Add resolve_path_at() hook Mickaël Salaün
2021-06-30 22:48 ` [PATCH v1 2/4] landlock: Add filesystem rule caching Mickaël Salaün
2021-06-30 22:48 ` [PATCH v1 3/4] selftests/landlock: Work in a temporary directory Mickaël Salaün
2021-06-30 22:48 ` [PATCH v1 4/4] selftests/landlock: Check all possible intermediate directories Mickaël Salaün
2021-07-09 15:03 [PATCH v1 2/4] landlock: Add filesystem rule caching kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.