From: "Demi M. Obenour" <demiobenour@xxxxxxxxx> 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 any are found. --- fs/open.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/open.c b/fs/open.c index 717afa8179c0..eeaa2eeb342a 100644 --- a/fs/open.c +++ b/fs/open.c @@ -1074,6 +1074,13 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode) if (fd) return fd; + /* + * Enforce that open flags are valid, to ensure that new flags can be + * added later. + */ + if (unlikely(flags & ~VALID_OPEN_FLAGS)) + return -EINVAL; + tmp = getname(filename); if (IS_ERR(tmp)) return PTR_ERR(tmp); -- 2.20.1