lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZoG6zreEtQhAUr_2@linux.ibm.com>
Date: Mon, 1 Jul 2024 01:36:38 +0530
From: Vishal Chourasia <vishalc@...ux.ibm.com>
To: Tejun Heo <tj@...nel.org>, David Vernet <void@...ifault.com>
Cc: linux-kernel@...r.kernel.org, Vishal Chourasia <vishalc@...ux.ibm.com>
Subject: sched_ext/for-6.11: Warning [-Wcalloc-transposed-args] during build

I encountered a warning while building the sched-ext for the for-6.11
branch. Below are the details:

# make -j40 -s vmlinux
In file included from ./include/linux/rhashtable-types.h:12,
                 from ./include/linux/sched/ext.h:15,
                 from ./include/linux/sched.h:83,
                 from ./include/linux/sched/signal.h:7,
                 from ./include/linux/sched/cputime.h:5,
                 from kernel/sched/build_policy.c:17:
kernel/sched/ext.c: In function ‘alloc_exit_info’:
kernel/sched/ext.c:3815:32: warning: ‘kmalloc_array_noprof’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
 3815 |         ei->bt = kcalloc(sizeof(ei->bt[0]), SCX_EXIT_BT_LEN, GFP_KERNEL);
      |                                ^
./include/linux/alloc_tag.h:206:16: note: in definition of macro ‘alloc_hooks_tag’
  206 |         typeof(_do_alloc) _res = _do_alloc;                             \
      |                ^~~~~~~~~
./include/linux/slab.h:701:49: note: in expansion of macro ‘alloc_hooks’
  701 | #define kmalloc_array(...)                      alloc_hooks(kmalloc_array_noprof(__VA_ARGS__))
      |                                                 ^~~~~~~~~~~
./include/linux/slab.h:730:41: note: in expansion of macro ‘kmalloc_array’
  730 | #define kcalloc(n, size, flags)         kmalloc_array(n, size, (flags) | __GFP_ZERO)
      |                                         ^~~~~~~~~~~~~
kernel/sched/ext.c:3815:18: note: in expansion of macro ‘kcalloc’
 3815 |         ei->bt = kcalloc(sizeof(ei->bt[0]), SCX_EXIT_BT_LEN, GFP_KERNEL);
      |                  ^~~~~~~
kernel/sched/ext.c:3815:32: note: earlier argument should specify number of elements, later size of each element
 3815 |         ei->bt = kcalloc(sizeof(ei->bt[0]), SCX_EXIT_BT_LEN, GFP_KERNEL);
      |                                ^
./include/linux/alloc_tag.h:206:16: note: in definition of macro ‘alloc_hooks_tag’
  206 |         typeof(_do_alloc) _res = _do_alloc;                             \
      |                ^~~~~~~~~
./include/linux/slab.h:701:49: note: in expansion of macro ‘alloc_hooks’
  701 | #define kmalloc_array(...)                      alloc_hooks(kmalloc_array_noprof(__VA_ARGS__))
      |                                                 ^~~~~~~~~~~
./include/linux/slab.h:730:41: note: in expansion of macro ‘kmalloc_array’
  730 | #define kcalloc(n, size, flags)         kmalloc_array(n, size, (flags) | __GFP_ZERO)
      |                                         ^~~~~~~~~~~~~
kernel/sched/ext.c:3815:18: note: in expansion of macro ‘kcalloc’
 3815 |         ei->bt = kcalloc(sizeof(ei->bt[0]), SCX_EXIT_BT_LEN, GFP_KERNEL);
      |                  ^~~~~~~

# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/ppc64le-redhat-linux/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: ppc64le-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release
--enable-targets=powerpcle-linux --disable-multilib --with-system-zlib
--enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --enable-libstdcxx-backtrace
--with-libstdcxx-zoneinfo=/usr/share/zoneinfo
--with-linker-hash-style=gnu --enable-plugin --enable-initfini-array
--without-isl --enable-offload-targets=nvptx-none
--enable-offload-defaulted --without-cuda-driver
--enable-gnu-indirect-function --enable-secureplt --with-long-double-128
--with-long-double-format=ieee --with-cpu-32=power9
--with-tune-32=power9 --with-cpu-64=power9 --with-tune-64=power9
--build=ppc64le-redhat-linux --with-build-config=bootstrap-lto
--enable-link-serialization=1 --enable-host-pie --enable-host-bind-now
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.1.1 20240507 (Red Hat 14.1.1-2) (GCC)


If this is intentional, (I am not sure why)

// consider changing to 

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index f6e25545bfc0..9050f8051918 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -3812,7 +3812,7 @@ static struct scx_exit_info *alloc_exit_info(size_t exit_dump_len)
        if (!ei)
                return NULL;

-       ei->bt = kcalloc(sizeof(ei->bt[0]), SCX_EXIT_BT_LEN, GFP_KERNEL);
+       ei->bt = kcalloc(sizeof(ei->bt[0]) * SCX_EXIT_BT_LEN, 1, GFP_KERNEL);
        ei->msg = kzalloc(SCX_EXIT_MSG_LEN, GFP_KERNEL);
        ei->dump = kzalloc(exit_dump_len, GFP_KERNEL);

else 

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index f6e25545bfc0..ae9ec8f542f2 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -3812,7 +3812,7 @@ static struct scx_exit_info *alloc_exit_info(size_t exit_dump_len)
        if (!ei)
                return NULL;

-       ei->bt = kcalloc(sizeof(ei->bt[0]), SCX_EXIT_BT_LEN, GFP_KERNEL);
+       ei->bt = kcalloc(SCX_EXIT_BT_LEN, sizeof(ei->bt[0]), GFP_KERNEL);
        ei->msg = kzalloc(SCX_EXIT_MSG_LEN, GFP_KERNEL);
        ei->dump = kzalloc(exit_dump_len, GFP_KERNEL);

https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wcalloc-transposed-args

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ