From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com
Subject: fs/notify/fanotify/fanotify.c:101:13: warning: use of NULL where non-null expected [CWE-476]
Date: Sun, 5 Feb 2023 20:51:20 +0800 [thread overview]
Message-ID: <202302052014.DfDOVxgX-lkp@intel.com> (raw)
::::::
:::::: Manual check reason: "low confidence bisect report"
:::::: Manual check reason: "low confidence static check first_new_problem: fs/notify/fanotify/fanotify.c:101:13: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Vlastimil Babka <vbabka@suse.cz>
CC: Christoph Lameter <cl@linux-foundation.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 837c07cf68fec9cad455d5fc86aab5350cc06c53
commit: 2f7c1c1396b587e8cfe18a1f0d628cedaae56b6a mm, slub: don't create kmalloc-rcl caches with CONFIG_SLUB_TINY
date: 2 months ago
:::::: branch date: 10 hours ago
:::::: commit date: 2 months ago
config: arm-randconfig-c002-20230205 (https://download.01.org/0day-ci/archive/20230205/202302052014.DfDOVxgX-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
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
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2f7c1c1396b587e8cfe18a1f0d628cedaae56b6a
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 2f7c1c1396b587e8cfe18a1f0d628cedaae56b6a
# save the config file
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross ARCH=arm KBUILD_USERCFLAGS='-fanalyzer -Wno-error' olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross ARCH=arm KBUILD_USERCFLAGS='-fanalyzer -Wno-error'
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
gcc_analyzer warnings: (new ones prefixed by >>)
| | | (6) calling 'fanotify_should_merge' from 'fanotify_merge'
| | (5) ...to here
|
+--> 'fanotify_should_merge': events 7-20
|
| 136 | static bool fanotify_should_merge(struct fanotify_event *old,
| | ^~~~~~~~~~~~~~~~~~~~~
| | |
| | (7) entry to 'fanotify_should_merge'
|......
| 141 | if (old->hash != new->hash ||
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~
| | | |
| | | (10) following 'false' branch...
| | (8) following 'false' branch...
| 142 | old->type != new->type || old->pid != new->pid)
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | | | |
| | | | (11) ...to here
| | | (12) following 'false' branch...
| | (9) ...to here
|......
| 153 | if ((old->mask & FS_ISDIR) != (new->mask & FS_ISDIR))
| | ~~ ~
| | | |
| | | (14) following 'false' branch...
| | (13) ...to here
|......
| 160 | if ((old->mask & FAN_RENAME) != (new->mask & FAN_RENAME))
| | ~~ ~
| | | |
| | | (16) following 'false' branch...
| | (15) ...to here
|......
| 163 | switch (old->type) {
| | ~~~~~~
| | |
| | (17) ...to here
| | (18) following 'case 2:' branch...
| 164 | case FANOTIFY_EVENT_TYPE_PATH:
| | ~~~~
| | |
| | (19) ...to here
| 165 | return fanotify_path_equal(fanotify_event_path(old),
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (20) calling 'fanotify_event_path' from 'fanotify_should_merge'
| 166 | fanotify_event_path(new));
| | ~~~~~~~~~~~~~~~~~~~~~~~~~
|
+--> 'fanotify_event_path': events 21-24
|
|fs/notify/fanotify/fanotify.h:455:34:
| 455 | static inline const struct path *fanotify_event_path(struct fanotify_event *event)
| | ^~~~~~~~~~~~~~~~~~~
| | |
| | (21) entry to 'fanotify_event_path'
| 456 | {
| 457 | if (event->type == FANOTIFY_EVENT_TYPE_PATH)
| | ~
| | |
| | (22) following 'false' branch...
| 458 | return &FANOTIFY_PE(event)->path;
| 459 | else if (event->type == FANOTIFY_EVENT_TYPE_PATH_PERM)
| | ~~ ~
| | | |
| | | (24) following 'false' branch...
| | (23) ...to here
|
'fanotify_event_path': event 25
|
|cc1:
| (25): ...to here
|
<------+
|
'fanotify_should_merge': events 26-27
|
|fs/notify/fanotify/fanotify.c:165:24:
| 165 | return fanotify_path_equal(fanotify_event_path(old),
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (26) returning to 'fanotify_should_merge' from 'fanotify_event_path'
| | (27) calling 'fanotify_path_equal' from 'fanotify_should_merge'
| 166 | fanotify_event_path(new));
| | ~~~~~~~~~~~~~~~~~~~~~~~~~
|
+--> 'fanotify_path_equal': events 28-29
|
| 21 | static bool fanotify_path_equal(const struct path *p1, const struct path *p2)
| | ^~~~~~~~~~~~~~~~~~~
| | |
| | (28) entry to 'fanotify_path_equal'
| 22 | {
| 23 | return p1->mnt == p2->mnt && p1->dentry == p2->dentry;
| | ~~~~~~~
| | |
| | (29) dereference of NULL 'p2'
|
fs/notify/fanotify/fanotify.c: In function 'fanotify_info_equal':
>> fs/notify/fanotify/fanotify.c:101:13: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]
101 | memcmp(fanotify_info_name(info1), fanotify_info_name(info2),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102 | info1->name_len))
| ~~~~~~~~~~~~~~~~
'fanotify_merge': event 1
|
| 187 | static int fanotify_merge(struct fsnotify_group *group,
| | ^~~~~~~~~~~~~~
| | |
| | (1) entry to 'fanotify_merge'
|
'fanotify_merge': event 2
|
|include/linux/list.h:1029:57:
| 1029 | ____ptr ? hlist_entry(____ptr, type, member) : NULL; \
include/linux/list.h:1039:20: note: in expansion of macro 'hlist_entry_safe'
| 1039 | for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
| | ^~~~~~~~~~~~~~~~
fs/notify/fanotify/fanotify.c:206:9: note: in expansion of macro 'hlist_for_each_entry'
| 206 | hlist_for_each_entry(old, hlist, merge_list) {
| | ^~~~~~~~~~~~~~~~~~~~
|
'fanotify_merge': events 3-6
|
| 207 | if (++i > FANOTIFY_MAX_MERGE_EVENTS)
| | ^~ ~
| | | |
| | | (4) following 'false' branch (when 'i != 129')...
| | (3) ...to here
| 208 | break;
| 209 | if (fanotify_should_merge(old, new)) {
| | ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | | |
| | | (6) calling 'fanotify_should_merge' from 'fanotify_merge'
| | (5) ...to here
|
+--> 'fanotify_should_merge': events 7-20
|
| 136 | static bool fanotify_should_merge(struct fanotify_event *old,
| | ^~~~~~~~~~~~~~~~~~~~~
| | |
| | (7) entry to 'fanotify_should_merge'
|......
| 141 | if (old->hash != new->hash ||
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~
| | | |
| | | (10) following 'false' branch...
| | (8) following 'false' branch...
| 142 | old->type != new->type || old->pid != new->pid)
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | | | |
| | | | (11) ...to here
| | | (12) following 'false' branch...
| | (9) ...to here
|......
| 153 | if ((old->mask & FS_ISDIR) != (new->mask & FS_ISDIR))
| | ~~ ~
| | | |
| | | (14) following 'false' branch...
| | (13) ...to here
|......
| 160 | if ((old->mask & FAN_RENAME) != (new->mask & FAN_RENAME))
| | ~~ ~
| | | |
| | | (16) following 'false' branch...
| | (15) ...to here
|......
| 163 | switch (old->type) {
| | ~~~~~~
| | |
| | (17) ...to here
| | (18) following 'case 1:' branch...
|......
| 171 | return fanotify_name_event_equal(FANOTIFY_NE(old),
| | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | | |
| | | (20) calling 'fanotify_name_event_equal' from 'fanotify_should_merge'
| | (19) ...to here
| 172 | FANOTIFY_NE(new));
| | ~~~~~~~~~~~~~~~~~
|
+--> 'fanotify_name_event_equal': events 21-26
|
| 110 | static bool fanotify_name_event_equal(struct fanotify_name_event *fne1,
| | ^~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (21) entry to 'fanotify_name_event_equal'
|......
| 117 | if (!info1->dir_fh_totlen)
| | ~
| | |
| | (22) following 'false' branch...
|......
| 120 | if (!fanotify_fsid_equal(&fne1->fsid, &fne2->fsid))
| | ~~ ~
| | | |
| | | (24) following 'true' branch...
| | (23) ...to here
|......
| 123 | return fanotify_info_equal(info1, info2);
--
| | |
| | (42) ...to here
|
<------+
|
'fanotify_info_equal': events 43-48
|
| 95 | if (info1->file_fh_totlen &&
| | ~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (44) following 'true' branch...
| 96 | !fanotify_fh_equal(fanotify_info_file_fh(info1),
| | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (43) returning to 'fanotify_info_equal' from 'fanotify_fh_equal'
| 97 | fanotify_info_file_fh(info2)))
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|......
| 100 | if (info1->name_len &&
| | ~~ ~
| | | |
| | | (46) following 'true' branch...
| | (45) ...to here
| 101 | memcmp(fanotify_info_name(info1), fanotify_info_name(info2),
| | ~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (47) ...to here
| | (48) calling 'fanotify_info_name' from 'fanotify_info_equal'
|
+--> 'fanotify_info_name': events 49-50
|
|fs/notify/fanotify/fanotify.h:151:21:
| 151 | static inline char *fanotify_info_name(struct fanotify_info *info)
| | ^~~~~~~~~~~~~~~~~~
| | |
| | (49) entry to 'fanotify_info_name'
| 152 | {
| 153 | if (!info->name_len)
| | ~
| | |
| | (50) following 'true' branch...
|
'fanotify_info_name': event 51
|
|cc1:
| (51): ...to here
|
<------+
|
'fanotify_info_equal': events 52-53
|
|fs/notify/fanotify/fanotify.c:101:20:
| 101 | memcmp(fanotify_info_name(info1), fanotify_info_name(info2),
| | ^~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
| | | |
| | | (53) calling 'fanotify_info_name' from 'fanotify_info_equal'
| | (52) returning to 'fanotify_info_equal' from 'fanotify_info_name'
|
+--> 'fanotify_info_name': events 54-55
|
|fs/notify/fanotify/fanotify.h:151:21:
| 151 | static inline char *fanotify_info_name(struct fanotify_info *info)
| | ^~~~~~~~~~~~~~~~~~
| | |
| | (54) entry to 'fanotify_info_name'
| 152 | {
| 153 | if (!info->name_len)
| | ~
| | |
| | (55) following 'true' branch...
|
'fanotify_info_name': event 56
|
|cc1:
| (56): ...to here
|
<------+
|
'fanotify_info_equal': events 57-58
|
|fs/notify/fanotify/fanotify.c:101:47:
| 101 | memcmp(fanotify_info_name(info1), fanotify_info_name(info2),
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
| | | |
| | | (57) returning to 'fanotify_info_equal' from 'fanotify_info_name'
| | (58) argument 1 ('fanotify_info_name(info1)') NULL where non-null expected
| 102 | info1->name_len))
| | ~~~~~~~~~~~~~~~~
|
In file included from include/linux/bitmap.h:11,
from include/linux/cpumask.h:12,
from include/linux/smp.h:13,
from include/linux/lockdep.h:14,
from include/linux/rcupdate.h:29,
from include/linux/sysctl.h:26,
from include/linux/fanotify.h:5,
from fs/notify/fanotify/fanotify.c:2:
include/linux/string.h:156:12: note: argument 1 of 'memcmp' must be non-null
156 | extern int memcmp(const void *,const void *,__kernel_size_t);
| ^~~~~~
>> fs/notify/fanotify/fanotify.c:101:13: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument]
101 | memcmp(fanotify_info_name(info1), fanotify_info_name(info2),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102 | info1->name_len))
| ~~~~~~~~~~~~~~~~
'fanotify_merge': event 1
|
| 187 | static int fanotify_merge(struct fsnotify_group *group,
| | ^~~~~~~~~~~~~~
| | |
| | (1) entry to 'fanotify_merge'
|
'fanotify_merge': event 2
|
|include/linux/list.h:1029:57:
| 1029 | ____ptr ? hlist_entry(____ptr, type, member) : NULL; \
include/linux/list.h:1039:20: note: in expansion of macro 'hlist_entry_safe'
| 1039 | for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
| | ^~~~~~~~~~~~~~~~
fs/notify/fanotify/fanotify.c:206:9: note: in expansion of macro 'hlist_for_each_entry'
| 206 | hlist_for_each_entry(old, hlist, merge_list) {
| | ^~~~~~~~~~~~~~~~~~~~
|
'fanotify_merge': events 3-6
|
| 207 | if (++i > FANOTIFY_MAX_MERGE_EVENTS)
| | ^~ ~
| | | |
| | | (4) following 'false' branch (when 'i != 129')...
| | (3) ...to here
| 208 | break;
| 209 | if (fanotify_should_merge(old, new)) {
| | ~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | | |
| | | (6) calling 'fanotify_should_merge' from 'fanotify_merge'
| | (5) ...to here
|
+--> 'fanotify_should_merge': events 7-20
|
| 136 | static bool fanotify_should_merge(struct fanotify_event *old,
| | ^~~~~~~~~~~~~~~~~~~~~
| | |
| | (7) entry to 'fanotify_should_merge'
|......
| 141 | if (old->hash != new->hash ||
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~
| | | |
| | | (10) following 'false' branch...
| | (8) following 'false' branch...
| 142 | old->type != new->type || old->pid != new->pid)
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | | | |
| | | | (11) ...to here
| | | (12) following 'false' branch...
| | (9) ...to here
|......
| 153 | if ((old->mask & FS_ISDIR) != (new->mask & FS_ISDIR))
| | ~~ ~
| | | |
| | | (14) following 'false' branch...
| | (13) ...to here
|......
| 160 | if ((old->mask & FAN_RENAME) != (new->mask & FAN_RENAME))
| | ~~ ~
| | | |
| | | (16) following 'false' branch...
| | (15) ...to here
|......
| 163 | switch (old->type) {
| | ~~~~~~
| | |
| | (17) ...to here
| | (18) following 'case 1:' branch...
|......
| 171 | return fanotify_name_event_equal(FANOTIFY_NE(old),
| | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | | |
| | | (20) calling 'fanotify_name_event_equal' from 'fanotify_should_merge'
| | (19) ...to here
| 172 | FANOTIFY_NE(new));
| | ~~~~~~~~~~~~~~~~~
|
+--> 'fanotify_name_event_equal': events 21-26
|
| 110 | static bool fanotify_name_event_equal(struct fanotify_name_event *fne1,
| | ^~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (21) entry to 'fanotify_name_event_equal'
|......
| 117 | if (!info1->dir_fh_totlen)
| | ~
| | |
| | (22) following 'false' branch...
|......
| 120 | if (!fanotify_fsid_equal(&fne1->fsid, &fne2->fsid))
| | ~~ ~
| | | |
| | | (24) following 'true' branch...
| | (23) ...to here
|......
| 123 | return fanotify_info_equal(info1, info2);
vim +101 fs/notify/fanotify/fanotify.c
7088f35720a55b Jan Kara 2020-03-24 74
f454fa610a69b9 Amir Goldstein 2020-07-16 75 static bool fanotify_info_equal(struct fanotify_info *info1,
f454fa610a69b9 Amir Goldstein 2020-07-16 76 struct fanotify_info *info2)
f454fa610a69b9 Amir Goldstein 2020-07-16 77 {
f454fa610a69b9 Amir Goldstein 2020-07-16 78 if (info1->dir_fh_totlen != info2->dir_fh_totlen ||
3cf984e950c1c3 Amir Goldstein 2021-11-29 79 info1->dir2_fh_totlen != info2->dir2_fh_totlen ||
f454fa610a69b9 Amir Goldstein 2020-07-16 80 info1->file_fh_totlen != info2->file_fh_totlen ||
3cf984e950c1c3 Amir Goldstein 2021-11-29 81 info1->name_len != info2->name_len ||
3cf984e950c1c3 Amir Goldstein 2021-11-29 82 info1->name2_len != info2->name2_len)
f454fa610a69b9 Amir Goldstein 2020-07-16 83 return false;
f454fa610a69b9 Amir Goldstein 2020-07-16 84
f454fa610a69b9 Amir Goldstein 2020-07-16 85 if (info1->dir_fh_totlen &&
f454fa610a69b9 Amir Goldstein 2020-07-16 86 !fanotify_fh_equal(fanotify_info_dir_fh(info1),
f454fa610a69b9 Amir Goldstein 2020-07-16 87 fanotify_info_dir_fh(info2)))
f454fa610a69b9 Amir Goldstein 2020-07-16 88 return false;
f454fa610a69b9 Amir Goldstein 2020-07-16 89
3cf984e950c1c3 Amir Goldstein 2021-11-29 90 if (info1->dir2_fh_totlen &&
3cf984e950c1c3 Amir Goldstein 2021-11-29 91 !fanotify_fh_equal(fanotify_info_dir2_fh(info1),
3cf984e950c1c3 Amir Goldstein 2021-11-29 92 fanotify_info_dir2_fh(info2)))
3cf984e950c1c3 Amir Goldstein 2021-11-29 93 return false;
3cf984e950c1c3 Amir Goldstein 2021-11-29 94
f454fa610a69b9 Amir Goldstein 2020-07-16 95 if (info1->file_fh_totlen &&
f454fa610a69b9 Amir Goldstein 2020-07-16 96 !fanotify_fh_equal(fanotify_info_file_fh(info1),
f454fa610a69b9 Amir Goldstein 2020-07-16 97 fanotify_info_file_fh(info2)))
f454fa610a69b9 Amir Goldstein 2020-07-16 98 return false;
f454fa610a69b9 Amir Goldstein 2020-07-16 99
3cf984e950c1c3 Amir Goldstein 2021-11-29 100 if (info1->name_len &&
3cf984e950c1c3 Amir Goldstein 2021-11-29 @101 memcmp(fanotify_info_name(info1), fanotify_info_name(info2),
3cf984e950c1c3 Amir Goldstein 2021-11-29 102 info1->name_len))
3cf984e950c1c3 Amir Goldstein 2021-11-29 103 return false;
3cf984e950c1c3 Amir Goldstein 2021-11-29 104
3cf984e950c1c3 Amir Goldstein 2021-11-29 105 return !info1->name2_len ||
3cf984e950c1c3 Amir Goldstein 2021-11-29 106 !memcmp(fanotify_info_name2(info1), fanotify_info_name2(info2),
3cf984e950c1c3 Amir Goldstein 2021-11-29 107 info1->name2_len);
f454fa610a69b9 Amir Goldstein 2020-07-16 108 }
f454fa610a69b9 Amir Goldstein 2020-07-16 109
:::::: The code at line 101 was first introduced by commit
:::::: 3cf984e950c1c3f41d407ed31db33beb996be132 fanotify: support secondary dir fh and name in fanotify_info
:::::: TO: Amir Goldstein <amir73il@gmail.com>
:::::: CC: Jan Kara <jack@suse.cz>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
next reply other threads:[~2023-02-05 12:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-05 12:51 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-02-07 4:27 fs/notify/fanotify/fanotify.c:101:13: warning: use of NULL where non-null expected [CWE-476] kernel test robot
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=202302052014.DfDOVxgX-lkp@intel.com \
--to=lkp@intel.com \
--cc=oe-kbuild@lists.linux.dev \
/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.