From: kbuild test robot <lkp@intel.com>
Cc: linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Alexei Starovoitov <ast@kernel.org>,
linux-mips@vger.kernel.org, David Howells <dhowells@redhat.com>,
linux-kselftest@vger.kernel.org, sparclinux@vger.kernel.org,
Jiri Olsa <jolsa@redhat.com>,
linux-arch@vger.kernel.org, linux-s390@vger.kernel.org,
Tycho Andersen <tycho@tycho.ws>, Aleksa Sarai <asarai@suse.de>,
Shuah Khan <shuah@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
Christian Brauner <christian@brauner.io>,
Eric Biederman <ebiederm@xmission.com>,
linux-xtensa@linux-xtensa.org, Kees Cook <keescook@chromium.org>,
Arnd Bergmann <arnd@arndb.de>, Jann Horn <jannh@google.com>,
Oleg Nesterov <oleg@redhat.com>, Aleksa Sarai <cyphar@cyphar.com>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH v13 7/9] open: openat2(2) syscall
Date: Tue, 01 Oct 2019 05:06:23 +0000 [thread overview]
Message-ID: <201910011326.iTYOtJYo%lkp@intel.com> (raw)
In-Reply-To: <20190930183316.10190-8-cyphar@cyphar.com>
Hi Aleksa,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[cannot apply to v5.4-rc1 next-20191001]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Aleksa-Sarai/namei-openat2-2-path-resolution-restrictions/20191001-025628
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-rc1-37-gd466a02-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
fs/open.c:757:13: sparse: sparse: restricted fmode_t degrades to integer
fs/open.c:983:18: sparse: sparse: restricted fmode_t degrades to integer
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: | fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: | fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: | fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
fs/open.c:1173:15: sparse: sparse: undefined identifier 'copy_struct_from_user'
vim +1011 fs/open.c
957
958 static inline int build_open_flags(const struct open_how *how,
959 struct open_flags *op)
960 {
961 int flags = how->flags;
962 int lookup_flags = 0;
963 int opath_mask = 0;
964 int acc_mode = ACC_MODE(flags);
965
966 /*
967 * Older syscalls still clear these bits before calling
968 * build_open_flags(), but openat2(2) checks all its arguments.
969 */
970 if (flags & ~VALID_OPEN_FLAGS)
971 return -EINVAL;
972 if (how->resolve & ~VALID_RESOLVE_FLAGS)
973 return -EINVAL;
974 if (!(how->flags & (O_PATH | O_CREAT | __O_TMPFILE)) && how->mode != 0)
975 return -EINVAL;
976
977 if (flags & (O_CREAT | __O_TMPFILE))
978 op->mode = (how->mode & S_IALLUGO) | S_IFREG;
979 else
980 op->mode = 0;
981
982 /* Must never be set by userspace */
> 983 flags &= ~FMODE_NONOTIFY & ~O_CLOEXEC;
984
985 /*
986 * O_SYNC is implemented as __O_SYNC|O_DSYNC. As many places only
987 * check for O_DSYNC if the need any syncing at all we enforce it's
988 * always set instead of having to deal with possibly weird behaviour
989 * for malicious applications setting only __O_SYNC.
990 */
991 if (flags & __O_SYNC)
992 flags |= O_DSYNC;
993
994 if (flags & __O_TMPFILE) {
995 if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
996 return -EINVAL;
997 if (!(acc_mode & MAY_WRITE))
998 return -EINVAL;
999 } else if (flags & O_PATH) {
1000 /*
1001 * If we have O_PATH in the open flag. Then we
1002 * cannot have anything other than the below set of flags
1003 */
1004 flags &= O_DIRECTORY | O_NOFOLLOW | O_PATH;
1005 acc_mode = 0;
1006
1007 /* Allow userspace to restrict the re-opening of O_PATH fds. */
1008 if (how->upgrade_mask & ~VALID_UPGRADE_FLAGS)
1009 return -EINVAL;
1010 if (!(how->upgrade_mask & UPGRADE_NOREAD))
> 1011 opath_mask |= FMODE_PATH_READ;
1012 if (!(how->upgrade_mask & UPGRADE_NOWRITE))
1013 opath_mask |= FMODE_PATH_WRITE;
1014 }
1015
1016 op->open_flag = flags;
1017
1018 /* O_TRUNC implies we need access checks for write permissions */
1019 if (flags & O_TRUNC)
1020 acc_mode |= MAY_WRITE;
1021
1022 /* Allow the LSM permission hook to distinguish append
1023 access from general write access. */
1024 if (flags & O_APPEND)
1025 acc_mode |= MAY_APPEND;
1026
1027 op->acc_mode = acc_mode;
1028 op->intent = flags & O_PATH ? 0 : LOOKUP_OPEN;
> 1029 op->opath_mask = opath_mask;
1030
1031 if (flags & O_CREAT) {
1032 op->intent |= LOOKUP_CREATE;
1033 if (flags & O_EXCL)
1034 op->intent |= LOOKUP_EXCL;
1035 }
1036
1037 if (flags & O_DIRECTORY)
1038 lookup_flags |= LOOKUP_DIRECTORY;
1039 if (!(flags & O_NOFOLLOW))
1040 lookup_flags |= LOOKUP_FOLLOW;
1041 if (flags & O_EMPTYPATH)
1042 lookup_flags |= LOOKUP_EMPTY;
1043
1044 if (how->resolve & RESOLVE_NO_XDEV)
1045 lookup_flags |= LOOKUP_NO_XDEV;
1046 if (how->resolve & RESOLVE_NO_MAGICLINKS)
1047 lookup_flags |= LOOKUP_NO_MAGICLINKS;
1048 if (how->resolve & RESOLVE_NO_SYMLINKS)
1049 lookup_flags |= LOOKUP_NO_SYMLINKS;
1050 if (how->resolve & RESOLVE_BENEATH)
1051 lookup_flags |= LOOKUP_BENEATH;
1052 if (how->resolve & RESOLVE_IN_ROOT)
1053 lookup_flags |= LOOKUP_IN_ROOT;
1054
1055 op->lookup_flags = lookup_flags;
1056 return 0;
1057 }
1058
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
WARNING: multiple messages have this Message-ID (diff)
From: kbuild test robot <lkp@intel.com>
To: Aleksa Sarai <cyphar@cyphar.com>
Cc: kbuild-all@01.org, Al Viro <viro@zeniv.linux.org.uk>,
Jeff Layton <jlayton@kernel.org>,
"J. Bruce Fields" <bfields@fieldses.org>,
Arnd Bergmann <arnd@arndb.de>,
David Howells <dhowells@redhat.com>,
Shuah Khan <shuah@kernel.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Alexei Starovoitov <ast@kernel.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
sparclinux@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>,
linux-arch@vger.kernel.org, linux-s390@vger.kernel.org,
Tycho Andersen <tycho@tycho.ws>, Aleksa Sarai <asarai@suse.de>,
linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
linux-xtensa@linux-xtensa.org, Kees Cook <keescook@chromium.org>,
Jann Horn <jannh@google.com>,
linuxppc-dev@lists.ozlabs.org, Aleksa Sarai <cyphar@cyphar.com>,
Andy Lutomirski <luto@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
David Drysdale <drysdale@google.com>,
Christian Brauner <christian@brauner.io>,
libc-alpha@sourceware.org, linux-parisc@vger.kernel.org,
linux-m68k@lists.linux-m68k.org, linux-api@vger.kernel.org,
Chanho Min <chanho.min@lge.com>, Oleg Nesterov <oleg@redhat.com>,
Eric Biederman <ebiederm@xmission.com>,
linux-alpha@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
containers@lists.linux-foundation.org
Subject: Re: [PATCH v13 7/9] open: openat2(2) syscall
Date: Tue, 1 Oct 2019 13:06:23 +0800 [thread overview]
Message-ID: <201910011326.iTYOtJYo%lkp@intel.com> (raw)
In-Reply-To: <20190930183316.10190-8-cyphar@cyphar.com>
Hi Aleksa,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[cannot apply to v5.4-rc1 next-20191001]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Aleksa-Sarai/namei-openat2-2-path-resolution-restrictions/20191001-025628
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-rc1-37-gd466a02-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
fs/open.c:757:13: sparse: sparse: restricted fmode_t degrades to integer
fs/open.c:983:18: sparse: sparse: restricted fmode_t degrades to integer
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
fs/open.c:1173:15: sparse: sparse: undefined identifier 'copy_struct_from_user'
vim +1011 fs/open.c
957
958 static inline int build_open_flags(const struct open_how *how,
959 struct open_flags *op)
960 {
961 int flags = how->flags;
962 int lookup_flags = 0;
963 int opath_mask = 0;
964 int acc_mode = ACC_MODE(flags);
965
966 /*
967 * Older syscalls still clear these bits before calling
968 * build_open_flags(), but openat2(2) checks all its arguments.
969 */
970 if (flags & ~VALID_OPEN_FLAGS)
971 return -EINVAL;
972 if (how->resolve & ~VALID_RESOLVE_FLAGS)
973 return -EINVAL;
974 if (!(how->flags & (O_PATH | O_CREAT | __O_TMPFILE)) && how->mode != 0)
975 return -EINVAL;
976
977 if (flags & (O_CREAT | __O_TMPFILE))
978 op->mode = (how->mode & S_IALLUGO) | S_IFREG;
979 else
980 op->mode = 0;
981
982 /* Must never be set by userspace */
> 983 flags &= ~FMODE_NONOTIFY & ~O_CLOEXEC;
984
985 /*
986 * O_SYNC is implemented as __O_SYNC|O_DSYNC. As many places only
987 * check for O_DSYNC if the need any syncing at all we enforce it's
988 * always set instead of having to deal with possibly weird behaviour
989 * for malicious applications setting only __O_SYNC.
990 */
991 if (flags & __O_SYNC)
992 flags |= O_DSYNC;
993
994 if (flags & __O_TMPFILE) {
995 if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
996 return -EINVAL;
997 if (!(acc_mode & MAY_WRITE))
998 return -EINVAL;
999 } else if (flags & O_PATH) {
1000 /*
1001 * If we have O_PATH in the open flag. Then we
1002 * cannot have anything other than the below set of flags
1003 */
1004 flags &= O_DIRECTORY | O_NOFOLLOW | O_PATH;
1005 acc_mode = 0;
1006
1007 /* Allow userspace to restrict the re-opening of O_PATH fds. */
1008 if (how->upgrade_mask & ~VALID_UPGRADE_FLAGS)
1009 return -EINVAL;
1010 if (!(how->upgrade_mask & UPGRADE_NOREAD))
> 1011 opath_mask |= FMODE_PATH_READ;
1012 if (!(how->upgrade_mask & UPGRADE_NOWRITE))
1013 opath_mask |= FMODE_PATH_WRITE;
1014 }
1015
1016 op->open_flag = flags;
1017
1018 /* O_TRUNC implies we need access checks for write permissions */
1019 if (flags & O_TRUNC)
1020 acc_mode |= MAY_WRITE;
1021
1022 /* Allow the LSM permission hook to distinguish append
1023 access from general write access. */
1024 if (flags & O_APPEND)
1025 acc_mode |= MAY_APPEND;
1026
1027 op->acc_mode = acc_mode;
1028 op->intent = flags & O_PATH ? 0 : LOOKUP_OPEN;
> 1029 op->opath_mask = opath_mask;
1030
1031 if (flags & O_CREAT) {
1032 op->intent |= LOOKUP_CREATE;
1033 if (flags & O_EXCL)
1034 op->intent |= LOOKUP_EXCL;
1035 }
1036
1037 if (flags & O_DIRECTORY)
1038 lookup_flags |= LOOKUP_DIRECTORY;
1039 if (!(flags & O_NOFOLLOW))
1040 lookup_flags |= LOOKUP_FOLLOW;
1041 if (flags & O_EMPTYPATH)
1042 lookup_flags |= LOOKUP_EMPTY;
1043
1044 if (how->resolve & RESOLVE_NO_XDEV)
1045 lookup_flags |= LOOKUP_NO_XDEV;
1046 if (how->resolve & RESOLVE_NO_MAGICLINKS)
1047 lookup_flags |= LOOKUP_NO_MAGICLINKS;
1048 if (how->resolve & RESOLVE_NO_SYMLINKS)
1049 lookup_flags |= LOOKUP_NO_SYMLINKS;
1050 if (how->resolve & RESOLVE_BENEATH)
1051 lookup_flags |= LOOKUP_BENEATH;
1052 if (how->resolve & RESOLVE_IN_ROOT)
1053 lookup_flags |= LOOKUP_IN_ROOT;
1054
1055 op->lookup_flags = lookup_flags;
1056 return 0;
1057 }
1058
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
WARNING: multiple messages have this Message-ID (diff)
From: kbuild test robot <lkp@intel.com>
To: Aleksa Sarai <cyphar@cyphar.com>
Cc: kbuild-all@01.org, Al Viro <viro@zeniv.linux.org.uk>,
Jeff Layton <jlayton@kernel.org>,
"J. Bruce Fields" <bfields@fieldses.org>,
Arnd Bergmann <arnd@arndb.de>,
David Howells <dhowells@redhat.com>,
Shuah Khan <shuah@kernel.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Alexei Starovoitov <ast@kernel.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
sparclinux@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>,
linux-arch@vger.kernel.org, linux-s390@vger.kernel.org,
Tycho Andersen <tycho@tycho.ws>, Aleksa Sarai <asarai@suse.de>,
linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
linux-xtensa@linux-xtensa.org, Kees Cook <keescook@chromium.org>,
Jann Horn <jannh@google.com>,
linuxppc-dev@lists.ozlabs.org, Andy Lutomirski <luto@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
David Drysdale <drysdale@google.com>,
Christian Brauner <christian@brauner.io>,
libc-alpha@sourceware.org, linux-parisc@vger.kernel.org,
linux-m68k@lists.linux-m68k.org, linux-api@vger.kernel.org,
Chanho Min <chanho.min@lge.com>, Oleg Nesterov <oleg@redhat.com>,
Eric Biederman <ebiederm@xmission.com>,
linux-alpha@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
containers@lists.linux-foundation.org
Subject: Re: [PATCH v13 7/9] open: openat2(2) syscall
Date: Tue, 1 Oct 2019 13:06:23 +0800 [thread overview]
Message-ID: <201910011326.iTYOtJYo%lkp@intel.com> (raw)
In-Reply-To: <20190930183316.10190-8-cyphar@cyphar.com>
Hi Aleksa,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[cannot apply to v5.4-rc1 next-20191001]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Aleksa-Sarai/namei-openat2-2-path-resolution-restrictions/20191001-025628
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-rc1-37-gd466a02-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
fs/open.c:757:13: sparse: sparse: restricted fmode_t degrades to integer
fs/open.c:983:18: sparse: sparse: restricted fmode_t degrades to integer
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
fs/open.c:1173:15: sparse: sparse: undefined identifier 'copy_struct_from_user'
vim +1011 fs/open.c
957
958 static inline int build_open_flags(const struct open_how *how,
959 struct open_flags *op)
960 {
961 int flags = how->flags;
962 int lookup_flags = 0;
963 int opath_mask = 0;
964 int acc_mode = ACC_MODE(flags);
965
966 /*
967 * Older syscalls still clear these bits before calling
968 * build_open_flags(), but openat2(2) checks all its arguments.
969 */
970 if (flags & ~VALID_OPEN_FLAGS)
971 return -EINVAL;
972 if (how->resolve & ~VALID_RESOLVE_FLAGS)
973 return -EINVAL;
974 if (!(how->flags & (O_PATH | O_CREAT | __O_TMPFILE)) && how->mode != 0)
975 return -EINVAL;
976
977 if (flags & (O_CREAT | __O_TMPFILE))
978 op->mode = (how->mode & S_IALLUGO) | S_IFREG;
979 else
980 op->mode = 0;
981
982 /* Must never be set by userspace */
> 983 flags &= ~FMODE_NONOTIFY & ~O_CLOEXEC;
984
985 /*
986 * O_SYNC is implemented as __O_SYNC|O_DSYNC. As many places only
987 * check for O_DSYNC if the need any syncing at all we enforce it's
988 * always set instead of having to deal with possibly weird behaviour
989 * for malicious applications setting only __O_SYNC.
990 */
991 if (flags & __O_SYNC)
992 flags |= O_DSYNC;
993
994 if (flags & __O_TMPFILE) {
995 if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
996 return -EINVAL;
997 if (!(acc_mode & MAY_WRITE))
998 return -EINVAL;
999 } else if (flags & O_PATH) {
1000 /*
1001 * If we have O_PATH in the open flag. Then we
1002 * cannot have anything other than the below set of flags
1003 */
1004 flags &= O_DIRECTORY | O_NOFOLLOW | O_PATH;
1005 acc_mode = 0;
1006
1007 /* Allow userspace to restrict the re-opening of O_PATH fds. */
1008 if (how->upgrade_mask & ~VALID_UPGRADE_FLAGS)
1009 return -EINVAL;
1010 if (!(how->upgrade_mask & UPGRADE_NOREAD))
> 1011 opath_mask |= FMODE_PATH_READ;
1012 if (!(how->upgrade_mask & UPGRADE_NOWRITE))
1013 opath_mask |= FMODE_PATH_WRITE;
1014 }
1015
1016 op->open_flag = flags;
1017
1018 /* O_TRUNC implies we need access checks for write permissions */
1019 if (flags & O_TRUNC)
1020 acc_mode |= MAY_WRITE;
1021
1022 /* Allow the LSM permission hook to distinguish append
1023 access from general write access. */
1024 if (flags & O_APPEND)
1025 acc_mode |= MAY_APPEND;
1026
1027 op->acc_mode = acc_mode;
1028 op->intent = flags & O_PATH ? 0 : LOOKUP_OPEN;
> 1029 op->opath_mask = opath_mask;
1030
1031 if (flags & O_CREAT) {
1032 op->intent |= LOOKUP_CREATE;
1033 if (flags & O_EXCL)
1034 op->intent |= LOOKUP_EXCL;
1035 }
1036
1037 if (flags & O_DIRECTORY)
1038 lookup_flags |= LOOKUP_DIRECTORY;
1039 if (!(flags & O_NOFOLLOW))
1040 lookup_flags |= LOOKUP_FOLLOW;
1041 if (flags & O_EMPTYPATH)
1042 lookup_flags |= LOOKUP_EMPTY;
1043
1044 if (how->resolve & RESOLVE_NO_XDEV)
1045 lookup_flags |= LOOKUP_NO_XDEV;
1046 if (how->resolve & RESOLVE_NO_MAGICLINKS)
1047 lookup_flags |= LOOKUP_NO_MAGICLINKS;
1048 if (how->resolve & RESOLVE_NO_SYMLINKS)
1049 lookup_flags |= LOOKUP_NO_SYMLINKS;
1050 if (how->resolve & RESOLVE_BENEATH)
1051 lookup_flags |= LOOKUP_BENEATH;
1052 if (how->resolve & RESOLVE_IN_ROOT)
1053 lookup_flags |= LOOKUP_IN_ROOT;
1054
1055 op->lookup_flags = lookup_flags;
1056 return 0;
1057 }
1058
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
WARNING: multiple messages have this Message-ID (diff)
From: kbuild test robot <lkp@intel.com>
Cc: linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Alexei Starovoitov <ast@kernel.org>,
linux-mips@vger.kernel.org, David Howells <dhowells@redhat.com>,
linux-kselftest@vger.kernel.org, sparclinux@vger.kernel.org,
Jiri Olsa <jolsa@redhat.com>,
linux-arch@vger.kernel.org, linux-s390@vger.kernel.org,
Tycho Andersen <tycho@tycho.ws>, Aleksa Sarai <asarai@suse.de>,
Shuah Khan <shuah@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
Christian Brauner <christian@brauner.io>,
Eric Biederman <ebiederm@xmission.com>,
linux-xtensa@linux-xtensa.org, Kees Cook <keescook@chromium.org>,
Arnd Bergmann <arnd@arndb.de>, Jann Horn <jannh@google.com>,
Oleg Nesterov <oleg@redhat.com>, Aleksa Sarai <cyphar@cyphar.com>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH v13 7/9] open: openat2(2) syscall
Date: Tue, 1 Oct 2019 13:06:23 +0800 [thread overview]
Message-ID: <201910011326.iTYOtJYo%lkp@intel.com> (raw)
In-Reply-To: <20190930183316.10190-8-cyphar@cyphar.com>
Hi Aleksa,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[cannot apply to v5.4-rc1 next-20191001]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Aleksa-Sarai/namei-openat2-2-path-resolution-restrictions/20191001-025628
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-rc1-37-gd466a02-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
fs/open.c:757:13: sparse: sparse: restricted fmode_t degrades to integer
fs/open.c:983:18: sparse: sparse: restricted fmode_t degrades to integer
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
fs/open.c:1173:15: sparse: sparse: undefined identifier 'copy_struct_from_user'
vim +1011 fs/open.c
957
958 static inline int build_open_flags(const struct open_how *how,
959 struct open_flags *op)
960 {
961 int flags = how->flags;
962 int lookup_flags = 0;
963 int opath_mask = 0;
964 int acc_mode = ACC_MODE(flags);
965
966 /*
967 * Older syscalls still clear these bits before calling
968 * build_open_flags(), but openat2(2) checks all its arguments.
969 */
970 if (flags & ~VALID_OPEN_FLAGS)
971 return -EINVAL;
972 if (how->resolve & ~VALID_RESOLVE_FLAGS)
973 return -EINVAL;
974 if (!(how->flags & (O_PATH | O_CREAT | __O_TMPFILE)) && how->mode != 0)
975 return -EINVAL;
976
977 if (flags & (O_CREAT | __O_TMPFILE))
978 op->mode = (how->mode & S_IALLUGO) | S_IFREG;
979 else
980 op->mode = 0;
981
982 /* Must never be set by userspace */
> 983 flags &= ~FMODE_NONOTIFY & ~O_CLOEXEC;
984
985 /*
986 * O_SYNC is implemented as __O_SYNC|O_DSYNC. As many places only
987 * check for O_DSYNC if the need any syncing at all we enforce it's
988 * always set instead of having to deal with possibly weird behaviour
989 * for malicious applications setting only __O_SYNC.
990 */
991 if (flags & __O_SYNC)
992 flags |= O_DSYNC;
993
994 if (flags & __O_TMPFILE) {
995 if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
996 return -EINVAL;
997 if (!(acc_mode & MAY_WRITE))
998 return -EINVAL;
999 } else if (flags & O_PATH) {
1000 /*
1001 * If we have O_PATH in the open flag. Then we
1002 * cannot have anything other than the below set of flags
1003 */
1004 flags &= O_DIRECTORY | O_NOFOLLOW | O_PATH;
1005 acc_mode = 0;
1006
1007 /* Allow userspace to restrict the re-opening of O_PATH fds. */
1008 if (how->upgrade_mask & ~VALID_UPGRADE_FLAGS)
1009 return -EINVAL;
1010 if (!(how->upgrade_mask & UPGRADE_NOREAD))
> 1011 opath_mask |= FMODE_PATH_READ;
1012 if (!(how->upgrade_mask & UPGRADE_NOWRITE))
1013 opath_mask |= FMODE_PATH_WRITE;
1014 }
1015
1016 op->open_flag = flags;
1017
1018 /* O_TRUNC implies we need access checks for write permissions */
1019 if (flags & O_TRUNC)
1020 acc_mode |= MAY_WRITE;
1021
1022 /* Allow the LSM permission hook to distinguish append
1023 access from general write access. */
1024 if (flags & O_APPEND)
1025 acc_mode |= MAY_APPEND;
1026
1027 op->acc_mode = acc_mode;
1028 op->intent = flags & O_PATH ? 0 : LOOKUP_OPEN;
> 1029 op->opath_mask = opath_mask;
1030
1031 if (flags & O_CREAT) {
1032 op->intent |= LOOKUP_CREATE;
1033 if (flags & O_EXCL)
1034 op->intent |= LOOKUP_EXCL;
1035 }
1036
1037 if (flags & O_DIRECTORY)
1038 lookup_flags |= LOOKUP_DIRECTORY;
1039 if (!(flags & O_NOFOLLOW))
1040 lookup_flags |= LOOKUP_FOLLOW;
1041 if (flags & O_EMPTYPATH)
1042 lookup_flags |= LOOKUP_EMPTY;
1043
1044 if (how->resolve & RESOLVE_NO_XDEV)
1045 lookup_flags |= LOOKUP_NO_XDEV;
1046 if (how->resolve & RESOLVE_NO_MAGICLINKS)
1047 lookup_flags |= LOOKUP_NO_MAGICLINKS;
1048 if (how->resolve & RESOLVE_NO_SYMLINKS)
1049 lookup_flags |= LOOKUP_NO_SYMLINKS;
1050 if (how->resolve & RESOLVE_BENEATH)
1051 lookup_flags |= LOOKUP_BENEATH;
1052 if (how->resolve & RESOLVE_IN_ROOT)
1053 lookup_flags |= LOOKUP_IN_ROOT;
1054
1055 op->lookup_flags = lookup_flags;
1056 return 0;
1057 }
1058
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
WARNING: multiple messages have this Message-ID (diff)
From: kbuild test robot <lkp@intel.com>
To: Aleksa Sarai <cyphar@cyphar.com>
Cc: linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Alexei Starovoitov <ast@kernel.org>,
linux-mips@vger.kernel.org, David Howells <dhowells@redhat.com>,
linux-kselftest@vger.kernel.org, sparclinux@vger.kernel.org,
Jiri Olsa <jolsa@redhat.com>,
linux-arch@vger.kernel.org, linux-s390@vger.kernel.org,
Tycho Andersen <tycho@tycho.ws>, Aleksa Sarai <asarai@suse.de>,
Shuah Khan <shuah@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
Christian Brauner <christian@brauner.io>,
Eric Biederman <ebiederm@xmission.com>,
linux-xtensa@linux-xtensa.org, Kees Cook <keescook@chromium.org>,
Arnd Bergmann <arnd@arndb.de>, Jann Horn <jannh@google.com>,
Oleg Nesterov <oleg@redhat.com>, Aleksa Sarai <cyphar@cyphar.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Andy Lutomirski <luto@kernel.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Namhyung Kim <namhyung@kernel.org>,
David Drysdale <drysdale@google.com>,
linux-arm-kernel@lists.infradead.org,
"J. Bruce Fields" <bfields@fieldses.org>,
libc-alpha@sourceware.org, linux-parisc@vger.kernel.org,
linux-m68k@lists.linux-m68k.org, linux-api@vger.kernel.org,
Chanho Min <chanho.min@lge.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Jeff Layton <jlayton@kernel.org>,
linux-kernel@vger.kernel.org, kbuild-all@01.org,
linux-alpha@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
linuxppc-dev@lists.ozlabs.org,
containers@lists.linux-foundation.org
Subject: Re: [PATCH v13 7/9] open: openat2(2) syscall
Date: Tue, 1 Oct 2019 13:06:23 +0800 [thread overview]
Message-ID: <201910011326.iTYOtJYo%lkp@intel.com> (raw)
In-Reply-To: <20190930183316.10190-8-cyphar@cyphar.com>
Hi Aleksa,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[cannot apply to v5.4-rc1 next-20191001]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Aleksa-Sarai/namei-openat2-2-path-resolution-restrictions/20191001-025628
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-rc1-37-gd466a02-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
fs/open.c:757:13: sparse: sparse: restricted fmode_t degrades to integer
fs/open.c:983:18: sparse: sparse: restricted fmode_t degrades to integer
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
fs/open.c:1173:15: sparse: sparse: undefined identifier 'copy_struct_from_user'
vim +1011 fs/open.c
957
958 static inline int build_open_flags(const struct open_how *how,
959 struct open_flags *op)
960 {
961 int flags = how->flags;
962 int lookup_flags = 0;
963 int opath_mask = 0;
964 int acc_mode = ACC_MODE(flags);
965
966 /*
967 * Older syscalls still clear these bits before calling
968 * build_open_flags(), but openat2(2) checks all its arguments.
969 */
970 if (flags & ~VALID_OPEN_FLAGS)
971 return -EINVAL;
972 if (how->resolve & ~VALID_RESOLVE_FLAGS)
973 return -EINVAL;
974 if (!(how->flags & (O_PATH | O_CREAT | __O_TMPFILE)) && how->mode != 0)
975 return -EINVAL;
976
977 if (flags & (O_CREAT | __O_TMPFILE))
978 op->mode = (how->mode & S_IALLUGO) | S_IFREG;
979 else
980 op->mode = 0;
981
982 /* Must never be set by userspace */
> 983 flags &= ~FMODE_NONOTIFY & ~O_CLOEXEC;
984
985 /*
986 * O_SYNC is implemented as __O_SYNC|O_DSYNC. As many places only
987 * check for O_DSYNC if the need any syncing at all we enforce it's
988 * always set instead of having to deal with possibly weird behaviour
989 * for malicious applications setting only __O_SYNC.
990 */
991 if (flags & __O_SYNC)
992 flags |= O_DSYNC;
993
994 if (flags & __O_TMPFILE) {
995 if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
996 return -EINVAL;
997 if (!(acc_mode & MAY_WRITE))
998 return -EINVAL;
999 } else if (flags & O_PATH) {
1000 /*
1001 * If we have O_PATH in the open flag. Then we
1002 * cannot have anything other than the below set of flags
1003 */
1004 flags &= O_DIRECTORY | O_NOFOLLOW | O_PATH;
1005 acc_mode = 0;
1006
1007 /* Allow userspace to restrict the re-opening of O_PATH fds. */
1008 if (how->upgrade_mask & ~VALID_UPGRADE_FLAGS)
1009 return -EINVAL;
1010 if (!(how->upgrade_mask & UPGRADE_NOREAD))
> 1011 opath_mask |= FMODE_PATH_READ;
1012 if (!(how->upgrade_mask & UPGRADE_NOWRITE))
1013 opath_mask |= FMODE_PATH_WRITE;
1014 }
1015
1016 op->open_flag = flags;
1017
1018 /* O_TRUNC implies we need access checks for write permissions */
1019 if (flags & O_TRUNC)
1020 acc_mode |= MAY_WRITE;
1021
1022 /* Allow the LSM permission hook to distinguish append
1023 access from general write access. */
1024 if (flags & O_APPEND)
1025 acc_mode |= MAY_APPEND;
1026
1027 op->acc_mode = acc_mode;
1028 op->intent = flags & O_PATH ? 0 : LOOKUP_OPEN;
> 1029 op->opath_mask = opath_mask;
1030
1031 if (flags & O_CREAT) {
1032 op->intent |= LOOKUP_CREATE;
1033 if (flags & O_EXCL)
1034 op->intent |= LOOKUP_EXCL;
1035 }
1036
1037 if (flags & O_DIRECTORY)
1038 lookup_flags |= LOOKUP_DIRECTORY;
1039 if (!(flags & O_NOFOLLOW))
1040 lookup_flags |= LOOKUP_FOLLOW;
1041 if (flags & O_EMPTYPATH)
1042 lookup_flags |= LOOKUP_EMPTY;
1043
1044 if (how->resolve & RESOLVE_NO_XDEV)
1045 lookup_flags |= LOOKUP_NO_XDEV;
1046 if (how->resolve & RESOLVE_NO_MAGICLINKS)
1047 lookup_flags |= LOOKUP_NO_MAGICLINKS;
1048 if (how->resolve & RESOLVE_NO_SYMLINKS)
1049 lookup_flags |= LOOKUP_NO_SYMLINKS;
1050 if (how->resolve & RESOLVE_BENEATH)
1051 lookup_flags |= LOOKUP_BENEATH;
1052 if (how->resolve & RESOLVE_IN_ROOT)
1053 lookup_flags |= LOOKUP_IN_ROOT;
1054
1055 op->lookup_flags = lookup_flags;
1056 return 0;
1057 }
1058
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
WARNING: multiple messages have this Message-ID (diff)
From: kbuild test robot <lkp@intel.com>
To: Aleksa Sarai <cyphar@cyphar.com>
Cc: linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Alexei Starovoitov <ast@kernel.org>,
linux-mips@vger.kernel.org, David Howells <dhowells@redhat.com>,
linux-kselftest@vger.kernel.org, sparclinux@vger.kernel.org,
Jiri Olsa <jolsa@redhat.com>,
linux-arch@vger.kernel.org, linux-s390@vger.kernel.org,
Tycho Andersen <tycho@tycho.ws>, Aleksa Sarai <asarai@suse.de>,
Shuah Khan <shuah@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
Christian Brauner <christian@brauner.io>,
Eric Biederman <ebiederm@xmission.com>,
linux-xtensa@linux-xtensa.org, Kees Cook <keescook@chromium.org>,
Arnd Bergmann <arnd@arndb.de>, Jann Horn <jannh@google.com>,
Oleg Nesterov <oleg@redhat.com>, Aleksa Sarai <cyphar@cyphar.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Andy Lutomirski <luto@kernel.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Namhyung Kim <namhyung@kernel.org>,
David Drysdale <drysdale@google.com>,
linux-arm-kernel@lists.infradead.org,
"J. Bruce Fields" <bfields@fieldses.org>,
libc-alpha@sourceware.org, linux-parisc@vger.kernel.org,
linux-m68k@lists.linux-m68k.org, linux-api@vger.kernel.org,
Chanho Min <chanho.min@lge.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Jeff Layton <jlayton@kernel.org>,
linux-kernel@vger.kernel.org, kbuild-all@01.org,
linux-alpha@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
linuxppc-dev@lists.ozlabs.org,
containers@lists.linux-foundation.org
Subject: Re: [PATCH v13 7/9] open: openat2(2) syscall
Date: Tue, 1 Oct 2019 13:06:23 +0800 [thread overview]
Message-ID: <201910011326.iTYOtJYo%lkp@intel.com> (raw)
In-Reply-To: <20190930183316.10190-8-cyphar@cyphar.com>
Hi Aleksa,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[cannot apply to v5.4-rc1 next-20191001]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Aleksa-Sarai/namei-openat2-2-path-resolution-restrictions/20191001-025628
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-rc1-37-gd466a02-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
fs/open.c:757:13: sparse: sparse: restricted fmode_t degrades to integer
fs/open.c:983:18: sparse: sparse: restricted fmode_t degrades to integer
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
fs/open.c:1173:15: sparse: sparse: undefined identifier 'copy_struct_from_user'
vim +1011 fs/open.c
957
958 static inline int build_open_flags(const struct open_how *how,
959 struct open_flags *op)
960 {
961 int flags = how->flags;
962 int lookup_flags = 0;
963 int opath_mask = 0;
964 int acc_mode = ACC_MODE(flags);
965
966 /*
967 * Older syscalls still clear these bits before calling
968 * build_open_flags(), but openat2(2) checks all its arguments.
969 */
970 if (flags & ~VALID_OPEN_FLAGS)
971 return -EINVAL;
972 if (how->resolve & ~VALID_RESOLVE_FLAGS)
973 return -EINVAL;
974 if (!(how->flags & (O_PATH | O_CREAT | __O_TMPFILE)) && how->mode != 0)
975 return -EINVAL;
976
977 if (flags & (O_CREAT | __O_TMPFILE))
978 op->mode = (how->mode & S_IALLUGO) | S_IFREG;
979 else
980 op->mode = 0;
981
982 /* Must never be set by userspace */
> 983 flags &= ~FMODE_NONOTIFY & ~O_CLOEXEC;
984
985 /*
986 * O_SYNC is implemented as __O_SYNC|O_DSYNC. As many places only
987 * check for O_DSYNC if the need any syncing at all we enforce it's
988 * always set instead of having to deal with possibly weird behaviour
989 * for malicious applications setting only __O_SYNC.
990 */
991 if (flags & __O_SYNC)
992 flags |= O_DSYNC;
993
994 if (flags & __O_TMPFILE) {
995 if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
996 return -EINVAL;
997 if (!(acc_mode & MAY_WRITE))
998 return -EINVAL;
999 } else if (flags & O_PATH) {
1000 /*
1001 * If we have O_PATH in the open flag. Then we
1002 * cannot have anything other than the below set of flags
1003 */
1004 flags &= O_DIRECTORY | O_NOFOLLOW | O_PATH;
1005 acc_mode = 0;
1006
1007 /* Allow userspace to restrict the re-opening of O_PATH fds. */
1008 if (how->upgrade_mask & ~VALID_UPGRADE_FLAGS)
1009 return -EINVAL;
1010 if (!(how->upgrade_mask & UPGRADE_NOREAD))
> 1011 opath_mask |= FMODE_PATH_READ;
1012 if (!(how->upgrade_mask & UPGRADE_NOWRITE))
1013 opath_mask |= FMODE_PATH_WRITE;
1014 }
1015
1016 op->open_flag = flags;
1017
1018 /* O_TRUNC implies we need access checks for write permissions */
1019 if (flags & O_TRUNC)
1020 acc_mode |= MAY_WRITE;
1021
1022 /* Allow the LSM permission hook to distinguish append
1023 access from general write access. */
1024 if (flags & O_APPEND)
1025 acc_mode |= MAY_APPEND;
1026
1027 op->acc_mode = acc_mode;
1028 op->intent = flags & O_PATH ? 0 : LOOKUP_OPEN;
> 1029 op->opath_mask = opath_mask;
1030
1031 if (flags & O_CREAT) {
1032 op->intent |= LOOKUP_CREATE;
1033 if (flags & O_EXCL)
1034 op->intent |= LOOKUP_EXCL;
1035 }
1036
1037 if (flags & O_DIRECTORY)
1038 lookup_flags |= LOOKUP_DIRECTORY;
1039 if (!(flags & O_NOFOLLOW))
1040 lookup_flags |= LOOKUP_FOLLOW;
1041 if (flags & O_EMPTYPATH)
1042 lookup_flags |= LOOKUP_EMPTY;
1043
1044 if (how->resolve & RESOLVE_NO_XDEV)
1045 lookup_flags |= LOOKUP_NO_XDEV;
1046 if (how->resolve & RESOLVE_NO_MAGICLINKS)
1047 lookup_flags |= LOOKUP_NO_MAGICLINKS;
1048 if (how->resolve & RESOLVE_NO_SYMLINKS)
1049 lookup_flags |= LOOKUP_NO_SYMLINKS;
1050 if (how->resolve & RESOLVE_BENEATH)
1051 lookup_flags |= LOOKUP_BENEATH;
1052 if (how->resolve & RESOLVE_IN_ROOT)
1053 lookup_flags |= LOOKUP_IN_ROOT;
1054
1055 op->lookup_flags = lookup_flags;
1056 return 0;
1057 }
1058
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: kbuild test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: Re: [PATCH v13 7/9] open: openat2(2) syscall
Date: Tue, 01 Oct 2019 13:06:23 +0800 [thread overview]
Message-ID: <201910011326.iTYOtJYo%lkp@intel.com> (raw)
In-Reply-To: <20190930183316.10190-8-cyphar@cyphar.com>
[-- Attachment #1: Type: text/plain, Size: 7001 bytes --]
Hi Aleksa,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[cannot apply to v5.4-rc1 next-20191001]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Aleksa-Sarai/namei-openat2-2-path-resolution-restrictions/20191001-025628
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-rc1-37-gd466a02-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
fs/open.c:757:13: sparse: sparse: restricted fmode_t degrades to integer
fs/open.c:983:18: sparse: sparse: restricted fmode_t degrades to integer
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
fs/open.c:1173:15: sparse: sparse: undefined identifier 'copy_struct_from_user'
vim +1011 fs/open.c
957
958 static inline int build_open_flags(const struct open_how *how,
959 struct open_flags *op)
960 {
961 int flags = how->flags;
962 int lookup_flags = 0;
963 int opath_mask = 0;
964 int acc_mode = ACC_MODE(flags);
965
966 /*
967 * Older syscalls still clear these bits before calling
968 * build_open_flags(), but openat2(2) checks all its arguments.
969 */
970 if (flags & ~VALID_OPEN_FLAGS)
971 return -EINVAL;
972 if (how->resolve & ~VALID_RESOLVE_FLAGS)
973 return -EINVAL;
974 if (!(how->flags & (O_PATH | O_CREAT | __O_TMPFILE)) && how->mode != 0)
975 return -EINVAL;
976
977 if (flags & (O_CREAT | __O_TMPFILE))
978 op->mode = (how->mode & S_IALLUGO) | S_IFREG;
979 else
980 op->mode = 0;
981
982 /* Must never be set by userspace */
> 983 flags &= ~FMODE_NONOTIFY & ~O_CLOEXEC;
984
985 /*
986 * O_SYNC is implemented as __O_SYNC|O_DSYNC. As many places only
987 * check for O_DSYNC if the need any syncing at all we enforce it's
988 * always set instead of having to deal with possibly weird behaviour
989 * for malicious applications setting only __O_SYNC.
990 */
991 if (flags & __O_SYNC)
992 flags |= O_DSYNC;
993
994 if (flags & __O_TMPFILE) {
995 if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
996 return -EINVAL;
997 if (!(acc_mode & MAY_WRITE))
998 return -EINVAL;
999 } else if (flags & O_PATH) {
1000 /*
1001 * If we have O_PATH in the open flag. Then we
1002 * cannot have anything other than the below set of flags
1003 */
1004 flags &= O_DIRECTORY | O_NOFOLLOW | O_PATH;
1005 acc_mode = 0;
1006
1007 /* Allow userspace to restrict the re-opening of O_PATH fds. */
1008 if (how->upgrade_mask & ~VALID_UPGRADE_FLAGS)
1009 return -EINVAL;
1010 if (!(how->upgrade_mask & UPGRADE_NOREAD))
> 1011 opath_mask |= FMODE_PATH_READ;
1012 if (!(how->upgrade_mask & UPGRADE_NOWRITE))
1013 opath_mask |= FMODE_PATH_WRITE;
1014 }
1015
1016 op->open_flag = flags;
1017
1018 /* O_TRUNC implies we need access checks for write permissions */
1019 if (flags & O_TRUNC)
1020 acc_mode |= MAY_WRITE;
1021
1022 /* Allow the LSM permission hook to distinguish append
1023 access from general write access. */
1024 if (flags & O_APPEND)
1025 acc_mode |= MAY_APPEND;
1026
1027 op->acc_mode = acc_mode;
1028 op->intent = flags & O_PATH ? 0 : LOOKUP_OPEN;
> 1029 op->opath_mask = opath_mask;
1030
1031 if (flags & O_CREAT) {
1032 op->intent |= LOOKUP_CREATE;
1033 if (flags & O_EXCL)
1034 op->intent |= LOOKUP_EXCL;
1035 }
1036
1037 if (flags & O_DIRECTORY)
1038 lookup_flags |= LOOKUP_DIRECTORY;
1039 if (!(flags & O_NOFOLLOW))
1040 lookup_flags |= LOOKUP_FOLLOW;
1041 if (flags & O_EMPTYPATH)
1042 lookup_flags |= LOOKUP_EMPTY;
1043
1044 if (how->resolve & RESOLVE_NO_XDEV)
1045 lookup_flags |= LOOKUP_NO_XDEV;
1046 if (how->resolve & RESOLVE_NO_MAGICLINKS)
1047 lookup_flags |= LOOKUP_NO_MAGICLINKS;
1048 if (how->resolve & RESOLVE_NO_SYMLINKS)
1049 lookup_flags |= LOOKUP_NO_SYMLINKS;
1050 if (how->resolve & RESOLVE_BENEATH)
1051 lookup_flags |= LOOKUP_BENEATH;
1052 if (how->resolve & RESOLVE_IN_ROOT)
1053 lookup_flags |= LOOKUP_IN_ROOT;
1054
1055 op->lookup_flags = lookup_flags;
1056 return 0;
1057 }
1058
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
WARNING: multiple messages have this Message-ID (diff)
From: kbuild test robot <lkp@intel.com>
To: Aleksa Sarai <cyphar@cyphar.com>
Cc: linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Alexei Starovoitov <ast@kernel.org>,
linux-mips@vger.kernel.org, David Howells <dhowells@redhat.com>,
linux-kselftest@vger.kernel.org, sparclinux@vger.kernel.org,
Jiri Olsa <jolsa@redhat.com>,
linux-arch@vger.kernel.org, linux-s390@vger.kernel.org,
Tycho Andersen <tycho@tycho.ws>, Aleksa Sarai <asarai@suse.de>,
Shuah Khan <shuah@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
Christian Brauner <christian@brauner.io>,
Eric Biederman <ebiederm@xmission.com>,
linux-xtensa@linux-xtensa.org, Kees Cook <keescook@chromium.org>,
Arnd Bergmann <arnd@arndb.de>, Jann Horn <jannh@google.com>,
Oleg Nesterov <oleg@redhat.com>, Aleksa Sarai <cyphar@cyphar.com>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH v13 7/9] open: openat2(2) syscall
Date: Tue, 1 Oct 2019 13:06:23 +0800 [thread overview]
Message-ID: <201910011326.iTYOtJYo%lkp@intel.com> (raw)
In-Reply-To: <20190930183316.10190-8-cyphar@cyphar.com>
Hi Aleksa,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[cannot apply to v5.4-rc1 next-20191001]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Aleksa-Sarai/namei-openat2-2-path-resolution-restrictions/20191001-025628
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-rc1-37-gd466a02-dirty
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
fs/open.c:757:13: sparse: sparse: restricted fmode_t degrades to integer
fs/open.c:983:18: sparse: sparse: restricted fmode_t degrades to integer
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
>> fs/open.c:1011:36: sparse: sparse: invalid assignment: |=
>> fs/open.c:1011:36: sparse: left side has type int
>> fs/open.c:1011:36: sparse: right side has type restricted fmode_t
fs/open.c:1013:36: sparse: sparse: invalid assignment: |=
fs/open.c:1013:36: sparse: left side has type int
fs/open.c:1013:36: sparse: right side has type restricted fmode_t
>> fs/open.c:1029:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted fmode_t [usertype] opath_mask @@ got pe] opath_mask @@
>> fs/open.c:1029:24: sparse: expected restricted fmode_t [usertype] opath_mask
>> fs/open.c:1029:24: sparse: got int opath_mask
fs/open.c:1173:15: sparse: sparse: undefined identifier 'copy_struct_from_user'
vim +1011 fs/open.c
957
958 static inline int build_open_flags(const struct open_how *how,
959 struct open_flags *op)
960 {
961 int flags = how->flags;
962 int lookup_flags = 0;
963 int opath_mask = 0;
964 int acc_mode = ACC_MODE(flags);
965
966 /*
967 * Older syscalls still clear these bits before calling
968 * build_open_flags(), but openat2(2) checks all its arguments.
969 */
970 if (flags & ~VALID_OPEN_FLAGS)
971 return -EINVAL;
972 if (how->resolve & ~VALID_RESOLVE_FLAGS)
973 return -EINVAL;
974 if (!(how->flags & (O_PATH | O_CREAT | __O_TMPFILE)) && how->mode != 0)
975 return -EINVAL;
976
977 if (flags & (O_CREAT | __O_TMPFILE))
978 op->mode = (how->mode & S_IALLUGO) | S_IFREG;
979 else
980 op->mode = 0;
981
982 /* Must never be set by userspace */
> 983 flags &= ~FMODE_NONOTIFY & ~O_CLOEXEC;
984
985 /*
986 * O_SYNC is implemented as __O_SYNC|O_DSYNC. As many places only
987 * check for O_DSYNC if the need any syncing at all we enforce it's
988 * always set instead of having to deal with possibly weird behaviour
989 * for malicious applications setting only __O_SYNC.
990 */
991 if (flags & __O_SYNC)
992 flags |= O_DSYNC;
993
994 if (flags & __O_TMPFILE) {
995 if ((flags & O_TMPFILE_MASK) != O_TMPFILE)
996 return -EINVAL;
997 if (!(acc_mode & MAY_WRITE))
998 return -EINVAL;
999 } else if (flags & O_PATH) {
1000 /*
1001 * If we have O_PATH in the open flag. Then we
1002 * cannot have anything other than the below set of flags
1003 */
1004 flags &= O_DIRECTORY | O_NOFOLLOW | O_PATH;
1005 acc_mode = 0;
1006
1007 /* Allow userspace to restrict the re-opening of O_PATH fds. */
1008 if (how->upgrade_mask & ~VALID_UPGRADE_FLAGS)
1009 return -EINVAL;
1010 if (!(how->upgrade_mask & UPGRADE_NOREAD))
> 1011 opath_mask |= FMODE_PATH_READ;
1012 if (!(how->upgrade_mask & UPGRADE_NOWRITE))
1013 opath_mask |= FMODE_PATH_WRITE;
1014 }
1015
1016 op->open_flag = flags;
1017
1018 /* O_TRUNC implies we need access checks for write permissions */
1019 if (flags & O_TRUNC)
1020 acc_mode |= MAY_WRITE;
1021
1022 /* Allow the LSM permission hook to distinguish append
1023 access from general write access. */
1024 if (flags & O_APPEND)
1025 acc_mode |= MAY_APPEND;
1026
1027 op->acc_mode = acc_mode;
1028 op->intent = flags & O_PATH ? 0 : LOOKUP_OPEN;
> 1029 op->opath_mask = opath_mask;
1030
1031 if (flags & O_CREAT) {
1032 op->intent |= LOOKUP_CREATE;
1033 if (flags & O_EXCL)
1034 op->intent |= LOOKUP_EXCL;
1035 }
1036
1037 if (flags & O_DIRECTORY)
1038 lookup_flags |= LOOKUP_DIRECTORY;
1039 if (!(flags & O_NOFOLLOW))
1040 lookup_flags |= LOOKUP_FOLLOW;
1041 if (flags & O_EMPTYPATH)
1042 lookup_flags |= LOOKUP_EMPTY;
1043
1044 if (how->resolve & RESOLVE_NO_XDEV)
1045 lookup_flags |= LOOKUP_NO_XDEV;
1046 if (how->resolve & RESOLVE_NO_MAGICLINKS)
1047 lookup_flags |= LOOKUP_NO_MAGICLINKS;
1048 if (how->resolve & RESOLVE_NO_SYMLINKS)
1049 lookup_flags |= LOOKUP_NO_SYMLINKS;
1050 if (how->resolve & RESOLVE_BENEATH)
1051 lookup_flags |= LOOKUP_BENEATH;
1052 if (how->resolve & RESOLVE_IN_ROOT)
1053 lookup_flags |= LOOKUP_IN_ROOT;
1054
1055 op->lookup_flags = lookup_flags;
1056 return 0;
1057 }
1058
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
next prev parent reply other threads:[~2019-10-01 5:06 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-30 18:33 [PATCH v13 0/9] namei: openat2(2) path resolution restrictions Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` [PATCH v13 1/9] namei: obey trailing magic-link DAC permissions Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` [PATCH v13 2/9] procfs: switch magic-link modes to be more sane Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` [PATCH v13 3/9] open: O_EMPTYPATH: procfs-less file descriptor re-opening Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 22:51 ` kbuild test robot
2019-09-30 22:51 ` kbuild test robot
2019-09-30 22:51 ` kbuild test robot
2019-09-30 22:51 ` kbuild test robot
2019-09-30 22:51 ` kbuild test robot
2019-09-30 22:51 ` kbuild test robot
2019-09-30 22:51 ` kbuild test robot
2019-09-30 23:09 ` Aleksa Sarai
2019-09-30 23:09 ` Aleksa Sarai
2019-09-30 23:09 ` Aleksa Sarai
2019-09-30 23:09 ` Aleksa Sarai
2019-09-30 23:09 ` Aleksa Sarai
2019-09-30 23:09 ` Aleksa Sarai
2019-09-30 18:33 ` [PATCH v13 4/9] namei: O_BENEATH-style path resolution flags Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` [PATCH v13 5/9] namei: LOOKUP_IN_ROOT: chroot-like path resolution Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` [PATCH v13 6/9] namei: permit ".." resolution with LOOKUP_{IN_ROOT,BENEATH} Aleksa Sarai
2019-09-30 18:33 ` [PATCH v13 6/9] namei: permit ".." resolution with LOOKUP_{IN_ROOT, BENEATH} Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` [PATCH v13 6/9] namei: permit ".." resolution with LOOKUP_{IN_ROOT,BENEATH} Aleksa Sarai
2019-09-30 18:33 ` [PATCH v13 7/9] open: openat2(2) syscall Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 20:58 ` kbuild test robot
2019-09-30 20:58 ` kbuild test robot
2019-09-30 20:58 ` kbuild test robot
2019-09-30 20:58 ` kbuild test robot
2019-09-30 20:58 ` kbuild test robot
2019-09-30 20:58 ` kbuild test robot
2019-09-30 20:58 ` kbuild test robot
2019-09-30 22:41 ` Aleksa Sarai
2019-09-30 22:41 ` Aleksa Sarai
2019-09-30 22:41 ` Aleksa Sarai
2019-09-30 22:41 ` Aleksa Sarai
2019-09-30 22:41 ` Aleksa Sarai
2019-09-30 22:41 ` Aleksa Sarai
2019-10-01 0:22 ` kbuild test robot
2019-10-01 0:22 ` kbuild test robot
2019-10-01 0:22 ` kbuild test robot
2019-10-01 0:22 ` kbuild test robot
2019-10-01 0:22 ` kbuild test robot
2019-10-01 0:22 ` kbuild test robot
2019-10-01 0:22 ` kbuild test robot
2019-10-01 5:06 ` kbuild test robot [this message]
2019-10-01 5:06 ` kbuild test robot
2019-10-01 5:06 ` kbuild test robot
2019-10-01 5:06 ` kbuild test robot
2019-10-01 5:06 ` kbuild test robot
2019-10-01 5:06 ` kbuild test robot
2019-10-01 5:06 ` kbuild test robot
2019-10-01 5:06 ` kbuild test robot
2019-09-30 18:33 ` [PATCH v13 8/9] selftests: add openat2(2) selftests Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` [PATCH v13 9/9] Documentation: update path-lookup to mention trailing magic-links Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
2019-09-30 18:33 ` Aleksa Sarai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201910011326.iTYOtJYo%lkp@intel.com \
--to=lkp@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=arnd@arndb.de \
--cc=asarai@suse.de \
--cc=ast@kernel.org \
--cc=christian@brauner.io \
--cc=cyphar@cyphar.com \
--cc=dhowells@redhat.com \
--cc=ebiederm@xmission.com \
--cc=jannh@google.com \
--cc=jolsa@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=linux-xtensa@linux-xtensa.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=shuah@kernel.org \
--cc=sparclinux@vger.kernel.org \
--cc=tycho@tycho.ws \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.