[PATCH 1/4] Add path resolution flag LOOKUP_NEVER_FOLLOW

2019-02-12 Thread demiobenour
From: "Demi M. Obenour" This adds the flag LOOKUP_NEVER_FOLLOW to path resolution, which tells the code in fs/namei.c to never follow symlinks. This flag overrides LOOKUP_FOLLOW, since this makes internal APIs simpler: code can set the flag without needing to also clear LOOKUP_FOLLOW, which is o

[PATCH 4/4] Return -EINVAL if userspace passes bogus flags to open()

2019-02-12 Thread demiobenour
From: "Demi M. Obenour" While testing the O_PATHSTATIC patch, I discovered that Linux does not return any error if an invalid flag is passed to open(2). This prevents adding new flags without a (minor) risk of breaking userspace. Therefore, add a check for invalid flags, and return -EINVAL if an

[PATCH 3/4] Add AT_PATHSTATIC to linkat()

2019-02-12 Thread demiobenour
From: "Demi M. Obenour" This has the same meaning as O_PATHSTATIC does in openat(), and has the same uses. --- fs/namei.c | 8 +++- include/uapi/linux/fcntl.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/namei.c b/fs/namei.c index 4c90f265c103..b47f

[PATCH 2/4] Expose O_PATHSTATIC to userspace

2019-02-12 Thread demiobenour
From: "Demi M. Obenour" This adds the file open flag O_PATHSTATIC, which ensures that symbolic links are *never* followed, even in path components other than the last. This is distinct from O_NOFOLLOW, which only prevents symlinks in the *last* component from being followed. This is useful for a