KSPP / linux

Linux kernel source tree (Kernel Self Protection Project)
https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project
Other
83 stars 5 forks source link

"error: call to ‘__compiletime_assert_721’ declared with attribute error: BUILD_BUG_ON failed: __mlx5_st_sz_bits(modify_tis_in) % 32" in drivers/net/ethernet/mellanox/mlx5/core/transobj.c: In function ‘mlx5_core_modify_tis’ #66

Closed GustavoARSilva closed 4 years ago

GustavoARSilva commented 4 years ago

When replacing the one-element array prio[0x1] with a flexible-array member in struct mlx5_ifc_modify_tis_bitmask_bits:

diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index b7551149458a..3b6a1eeebcb6 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -6073,7 +6073,7 @@ struct mlx5_ifc_modify_tis_bitmask_bits {
        u8         reserved_at_20[0x1d];
        u8         lag_tx_port_affinity[0x1];
        u8         strict_lag_tx_port_affinity[0x1];
-       u8         prio[0x1];
+       u8         prio[];
 };

 struct mlx5_ifc_modify_tis_in_bits {

the following errors show up:

                 from drivers/net/ethernet/mellanox/mlx5/core/transobj.c:33:
drivers/net/ethernet/mellanox/mlx5/core/transobj.c: In function ‘mlx5_core_modify_tis’:
./include/linux/compiler.h:350:38: error: call to ‘__compiletime_assert_721’ declared with attribute error: BUILD_BUG_ON failed: __mlx5_st_sz_bits(modify_tis_in) % 32
  350 |  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
      |                                      ^
./include/linux/compiler.h:331:4: note: in definition of macro ‘__compiletime_assert’
  331 |    prefix ## suffix();    \
      |    ^~~~~~
./include/linux/compiler.h:350:2: note: in expansion of macro ‘_compiletime_assert’
  350 |  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
      |  ^~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
   39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
      |                                     ^~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
   50 |  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
      |  ^~~~~~~~~~~~~~~~
./include/linux/mlx5/device.h:75:2: note: in expansion of macro ‘BUILD_BUG_ON’
   75 |  BUILD_BUG_ON(__mlx5_st_sz_bits(typ) % 32);             \
      |  ^~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/transobj.c:251:2: note: in expansion of macro ‘MLX5_SET’
  251 |  MLX5_SET(modify_tis_in, in, tisn, tisn);
      |  ^~~~~~~~
./include/linux/compiler.h:350:38: error: call to ‘__compiletime_assert_722’ declared with attribute error: BUILD_BUG_ON failed: __mlx5_st_sz_bits(modify_tis_in) % 32
  350 |  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
      |                                      ^
./include/linux/compiler.h:331:4: note: in definition of macro ‘__compiletime_assert’
  331 |    prefix ## suffix();    \
      |    ^~~~~~
./include/linux/compiler.h:350:2: note: in expansion of macro ‘_compiletime_assert’
  350 |  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
      |  ^~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’
   39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
      |                                     ^~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
   50 |  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
      |  ^~~~~~~~~~~~~~~~
./include/linux/mlx5/device.h:75:2: note: in expansion of macro ‘BUILD_BUG_ON’
   75 |  BUILD_BUG_ON(__mlx5_st_sz_bits(typ) % 32);             \
      |  ^~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlx5/core/transobj.c:252:2: note: in expansion of macro ‘MLX5_SET’
  252 |  MLX5_SET(modify_tis_in, in, opcode, MLX5_CMD_OP_MODIFY_TIS);
      |  ^~~~~~~~
scripts/Makefile.build:266: recipe for target 'drivers/net/ethernet/mellanox/mlx5/core/transobj.o' failed

See flexible-array conversions issue.

GustavoARSilva commented 4 years ago

Duplicate of https://github.com/KSPP/linux/issues/65