CC: [email protected]
CC: [email protected]
CC: [email protected]
TO: "Steven Rostedt (VMware)" <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git 
ftrace/core
head:   c8d01c02b46e599b057d7d24d1342ae9fcf828c2
commit: c8d01c02b46e599b057d7d24d1342ae9fcf828c2 [2/2] tracing: Create a sparse 
bitmask for pid filtering
:::::: branch date: 5 days ago
:::::: commit date: 5 days ago
config: riscv-randconfig-c006-20210927 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 
dc6e8dfdfe7efecfda318d43a06fae18b40eb498)
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 riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git/commit/?id=c8d01c02b46e599b057d7d24d1342ae9fcf828c2
        git remote add rostedt-trace 
https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
        git fetch --no-tags rostedt-trace ftrace/core
        git checkout c8d01c02b46e599b057d7d24d1342ae9fcf828c2
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 
clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


clang-analyzer warnings: (new ones prefixed by >>)
               ^~~~~~~~~~~~~~~~~
   drivers/clk/clk-fractional-divider.c:140:2: note: Taking false branch
           if (fd->approximation)
           ^
   drivers/clk/clk-fractional-divider.c:143:3: note: Calling 
'clk_fractional_divider_general_approximation'
                   clk_fractional_divider_general_approximation(hw, rate, 
parent_rate, &m, &n);
                   
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/clk/clk-fractional-divider.c:109:38: note: Left side of '&&' is false
           struct clk_fractional_divider *fd = to_clk_fd(hw);
                                               ^
   include/linux/clk-provider.h:1027:24: note: expanded from macro 'to_clk_fd'
   #define to_clk_fd(_hw) container_of(_hw, struct clk_fractional_divider, hw)
                          ^
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   drivers/clk/clk-fractional-divider.c:109:38: note: Taking false branch
           struct clk_fractional_divider *fd = to_clk_fd(hw);
                                               ^
   include/linux/clk-provider.h:1027:24: note: expanded from macro 'to_clk_fd'
   #define to_clk_fd(_hw) container_of(_hw, struct clk_fractional_divider, hw)
                          ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:322:2: note: expanded from macro 
'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
           ^
   include/linux/compiler_types.h:310:2: note: expanded from macro 
'_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:302:3: note: expanded from macro 
'__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   drivers/clk/clk-fractional-divider.c:109:38: note: Loop condition is false.  
Exiting loop
           struct clk_fractional_divider *fd = to_clk_fd(hw);
                                               ^
   include/linux/clk-provider.h:1027:24: note: expanded from macro 'to_clk_fd'
   #define to_clk_fd(_hw) container_of(_hw, struct clk_fractional_divider, hw)
                          ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:322:2: note: expanded from macro 
'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
           ^
   include/linux/compiler_types.h:310:2: note: expanded from macro 
'_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:300:2: note: expanded from macro 
'__compiletime_assert'
           do {                                                            \
           ^
   drivers/clk/clk-fractional-divider.c:118:6: note: Assuming the condition is 
true
           if (fd->flags & CLK_FRAC_DIVIDER_POWER_OF_TWO_PS) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/clk/clk-fractional-divider.c:118:2: note: Taking true branch
           if (fd->flags & CLK_FRAC_DIVIDER_POWER_OF_TWO_PS) {
           ^
   drivers/clk/clk-fractional-divider.c:121:7: note: Assuming 'scale' is > 
field 'nwidth'
                   if (scale > fd->nwidth)
                       ^~~~~~~~~~~~~~~~~~
   drivers/clk/clk-fractional-divider.c:121:3: note: Taking true branch
                   if (scale > fd->nwidth)
                   ^
   drivers/clk/clk-fractional-divider.c:126:32: note: The result of the right 
shift is undefined due to shifting by '32', which is greater or equal to the 
width of type 'unsigned long'
                           GENMASK(fd->mwidth - 1, 0), GENMASK(fd->nwidth - 1, 
0),
                                                       ^
   include/linux/bits.h:38:31: note: expanded from macro 'GENMASK'
           (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
                                        ^~~~~~~~~~~~~~~
   include/linux/bits.h:36:11: note: expanded from macro '__GENMASK'
            (~UL(0) >> (BITS_PER_LONG - 1 - (h))))
                    ^  ~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   8 warnings generated.
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   8 warnings generated.
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   9 warnings generated.
   kernel/trace/trace_printk.c:77:5: warning: Call to function 'strcpy' is 
insecure as it does not provide bounding of the memory buffer. Replace 
unbounded copy functions with analogous functions that support length arguments 
such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
                                   strcpy(fmt, *iter);
                                   ^~~~~~
   kernel/trace/trace_printk.c:77:5: note: Call to function 'strcpy' is 
insecure as it does not provide bounding of the memory buffer. Replace 
unbounded copy functions with analogous functions that support length arguments 
such as 'strlcpy'. CWE-119
                                   strcpy(fmt, *iter);
                                   ^~~~~~
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   10 warnings generated.
>> kernel/trace/pid_list.c:439:6: warning: Branch condition evaluates to a 
>> garbage value [clang-analyzer-core.uninitialized.Branch]
           if (upper) {
               ^~~~~
   kernel/trace/pid_list.c:396:36: note: Left side of '&&' is false
           struct trace_pid_list *pid_list = container_of(iwork, struct 
trace_pid_list,
                                             ^
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   kernel/trace/pid_list.c:396:36: note: Taking false branch
           struct trace_pid_list *pid_list = container_of(iwork, struct 
trace_pid_list,
                                             ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:322:2: note: expanded from macro 
'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
           ^
   include/linux/compiler_types.h:310:2: note: expanded from macro 
'_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:302:3: note: expanded from macro 
'__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   kernel/trace/pid_list.c:396:36: note: Loop condition is false.  Exiting loop
           struct trace_pid_list *pid_list = container_of(iwork, struct 
trace_pid_list,
                                             ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:322:2: note: expanded from macro 
'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
           ^
   include/linux/compiler_types.h:310:2: note: expanded from macro 
'_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:300:2: note: expanded from macro 
'__compiletime_assert'
           do {                                                            \
           ^
   kernel/trace/pid_list.c:398:2: note: 'upper' declared without an initial 
value
           union upper_chunk *upper;
           ^~~~~~~~~~~~~~~~~~~~~~~~
   kernel/trace/pid_list.c:413:6: note: Assuming 'upper_count' is > 0
           if (upper_count <= 0 && lower_count <= 0)
               ^~~~~~~~~~~~~~~~
   kernel/trace/pid_list.c:413:23: note: Left side of '&&' is false
           if (upper_count <= 0 && lower_count <= 0)
                                ^
   kernel/trace/pid_list.c:416:2: note: Loop condition is true.  Entering loop 
body
           while (upper_count-- > 0) {
           ^
   kernel/trace/pid_list.c:420:7: note: Assuming 'chunk' is null
                   if (!chunk)
                       ^~~~~~
   kernel/trace/pid_list.c:420:3: note: Taking true branch
                   if (!chunk)
                   ^
   kernel/trace/pid_list.c:421:4: note:  Execution continues on line 427
                           break;
                           ^
   kernel/trace/pid_list.c:427:9: note: Assuming the condition is false
           while (lower_count-- > 0) {
                  ^~~~~~~~~~~~~~~~~
   kernel/trace/pid_list.c:427:2: note: Loop condition is false. Execution 
continues on line 438
           while (lower_count-- > 0) {
           ^
   kernel/trace/pid_list.c:439:6: note: Branch condition evaluates to a garbage 
value
           if (upper) {
               ^~~~~
   kernel/trace/pid_list.c:444:6: warning: Branch condition evaluates to a 
garbage value [clang-analyzer-core.uninitialized.Branch]
           if (lower) {
               ^~~~~
   kernel/trace/pid_list.c:396:36: note: Left side of '&&' is false
           struct trace_pid_list *pid_list = container_of(iwork, struct 
trace_pid_list,
                                             ^
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   kernel/trace/pid_list.c:396:36: note: Taking false branch
           struct trace_pid_list *pid_list = container_of(iwork, struct 
trace_pid_list,
                                             ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:322:2: note: expanded from macro 
'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
           ^
   include/linux/compiler_types.h:310:2: note: expanded from macro 
'_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:302:3: note: expanded from macro 
'__compiletime_assert'
                   if (!(condition))                                       \

vim +439 kernel/trace/pid_list.c

c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  393) 
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  394) static void 
pid_list_refill_irq(struct irq_work *iwork)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  395) {
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  396)        struct 
trace_pid_list *pid_list = container_of(iwork, struct trace_pid_list,
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  397)                        
                               refill_irqwork);
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  398)        union 
upper_chunk *upper;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  399)        union 
lower_chunk *lower;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  400)        union 
upper_chunk **upper_next = &upper;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  401)        union 
lower_chunk **lower_next = &lower;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  402)        int upper_count;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  403)        int lower_count;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  404)        int ucnt = 0;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  405)        int lcnt = 0;
eff05923d317af7 Steven Rostedt (VMware  2021-09-23  406) 
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  407)  again:
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  408)        
raw_spin_lock(&pid_list->lock);
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  409)        upper_count = 
CHUNK_ALLOC - pid_list->free_upper_chunks;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  410)        lower_count = 
CHUNK_ALLOC - pid_list->free_lower_chunks;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  411)        
raw_spin_unlock(&pid_list->lock);
eff05923d317af7 Steven Rostedt (VMware  2021-09-23  412) 
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  413)        if (upper_count 
<= 0 && lower_count <= 0)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  414)                return;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  415) 
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  416)        while 
(upper_count-- > 0) {
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  417)                union 
upper_chunk *chunk;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  418) 
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  419)                chunk = 
kzalloc(sizeof(*chunk), GFP_KERNEL);
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  420)                if 
(!chunk)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  421)                        
break;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  422)                
*upper_next = chunk;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  423)                
upper_next = &chunk->next;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  424)                ucnt++;
eff05923d317af7 Steven Rostedt (VMware  2021-09-23  425)        }
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  426) 
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  427)        while 
(lower_count-- > 0) {
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  428)                union 
lower_chunk *chunk;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  429) 
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  430)                chunk = 
kzalloc(sizeof(*chunk), GFP_KERNEL);
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  431)                if 
(!chunk)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  432)                        
break;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  433)                
*lower_next = chunk;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  434)                
lower_next = &chunk->next;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  435)                lcnt++;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  436)        }
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  437) 
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  438)        
raw_spin_lock(&pid_list->lock);
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23 @439)        if (upper) {
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  440)                
*upper_next = pid_list->upper_list;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  441)                
pid_list->upper_list = upper;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  442)                
pid_list->free_upper_chunks += ucnt;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  443)        }
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  444)        if (lower) {
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  445)                
*lower_next = pid_list->lower_list;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  446)                
pid_list->lower_list = lower;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  447)                
pid_list->free_lower_chunks += lcnt;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  448)        }
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  449)        
raw_spin_unlock(&pid_list->lock);
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  450) 
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  451)        /*
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  452)         * On success 
of allocating all the chunks, both counters
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  453)         * will be less 
than zero. If they are not, then an allocation
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  454)         * failed, and 
we should not try again.
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  455)         */
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  456)        if (upper_count 
>= 0 || lower_count >= 0)
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  457)                return;
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  458)        /*
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  459)         * When the 
locks were released, free chunks could have
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  460)         * been used 
and allocation needs to be done again. Might as
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  461)         * well 
allocate it now.
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  462)         */
c8d01c02b46e599 Steven Rostedt (VMware  2021-09-23  463)        goto again;
eff05923d317af7 Steven Rostedt (VMware  2021-09-23  464) }
eff05923d317af7 Steven Rostedt (VMware  2021-09-23  465) 

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to