Skip to contentSkip to conversation

drivers/auxdisplay/panel.c:1454:2: error: call to __compiletime_assert_309 declared with 'error' attribute: BUILD_BUG_ON failed: !__builtin_constant_p(_dest_len) || _dest_len == (size_t)-1

DISCUSSION kernel test robot 3 participants 6 messages Jan 31, 2025 – Feb 1, 2025 Memory management

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b4b0881156fb8209bf5ef6cb63211bb0ad6e1a6b
commit: 07438779313caafe52ac1a1a6958d735a5938988 alloc_tag: avoid current->alloc_tag manipulations when profiling is disabled
date:   5 days ago
config: hexagon-randconfig-r133-20250131 (https://download.01.org/0day-ci/archive/20250131/[email protected]/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce: (https://download.01.org/0day-ci/archive/20250131/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/auxdisplay/panel.c:1454:2: error: call to __compiletime_assert_309 declared with 'error' attribute: BUILD_BUG_ON failed: !__builtin_constant_p(_dest_len) || _dest_len == (size_t)-1
           strtomem_pad(key->u.kbd.release_str, release, '\0');
           ^
   include/linux/string.h:417:2: note: expanded from macro 'strtomem_pad'
           BUILD_BUG_ON(!__builtin_constant_p(_dest_len) ||                \
           ^
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
           BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
           ^
   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)
                                       ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:530:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:523:4: note: expanded from macro '__compiletime_assert'
                           prefix ## suffix();                             \
                           ^

<scratch space>:127:1: note: expanded from here __compiletime_assert_309
^
1 error generated.

vim +/error +1454 drivers/auxdisplay/panel.c

7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1426  
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1427  /* tries to bind a key to the signal name <name>. The key will send the
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1428   * strings <press>, <repeat>, <release> for these respective events.
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1429   * Returns the pointer to the new key if ok, NULL if the key could not be bound.
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1430   */
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1431  static struct logical_input *panel_bind_key(const char *name, const char *press,
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1432  					    const char *repeat,
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1433  					    const char *release)
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1434  {
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1435  	struct logical_input *key;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1436  
fdf4a4948ca8a1 drivers/staging/panel/panel.c Dominique van den Broeck 2014-05-21  1437  	key = kzalloc(sizeof(*key), GFP_KERNEL);
eb073a9bf2b6ed drivers/staging/panel/panel.c Toshiaki Yamane          2012-07-12  1438  	if (!key)
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1439  		return NULL;
eb073a9bf2b6ed drivers/staging/panel/panel.c Toshiaki Yamane          2012-07-12  1440  
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1441  	if (!input_name2mask(name, &key->mask, &key->value, &scan_mask_i,
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1442  			     &scan_mask_o)) {
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1443  		kfree(key);
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1444  		return NULL;
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1445  	}
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1446  
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1447  	key->type = INPUT_TYPE_KBD;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1448  	key->state = INPUT_ST_LOW;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1449  	key->rise_time = 1;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1450  	key->fall_time = 1;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1451  
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11  1452  	strtomem_pad(key->u.kbd.press_str, press, '\0');
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11  1453  	strtomem_pad(key->u.kbd.repeat_str, repeat, '\0');
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11 @1454  	strtomem_pad(key->u.kbd.release_str, release, '\0');
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1455  	list_add(&key->list, &logical_inputs);
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1456  	return key;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1457  }
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1458  

:::::: The code at line 1454 was first introduced by commit
:::::: a952abcdaa22116d940ca9cb9253caad1622ae93 auxdisplay: panel: Replace deprecated strncpy() with strtomem_pad()

:::::: TO: Justin Stitt <[email protected]>
:::::: CC: Kees Cook <[email protected]>

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw
Quoted 8 lines · kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b4b0881156fb8209bf5ef6cb63211bb0ad6e1a6b
commit: 07438779313caafe52ac1a1a6958d735a5938988 alloc_tag: avoid current->alloc_tag manipulations when profiling is disabled
date:   5 days ago
config: hexagon-randconfig-r133-20250131 (https://download.01.org/0day-ci/archive/20250131/[email protected]/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce: (https://download.01.org/0day-ci/archive/20250131/[email protected]/reproduce)

Just saw this report (was on vacation). Will try to figure out what's going on.

Quoted 78 lines

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

drivers/auxdisplay/panel.c:1454:2: error: call to __compiletime_assert_309 declared with 'error' attribute: BUILD_BUG_ON failed: !__builtin_constant_p(_dest_len) || _dest_len == (size_t)-1

           strtomem_pad(key->u.kbd.release_str, release, '\0');
           ^
   include/linux/string.h:417:2: note: expanded from macro 'strtomem_pad'
           BUILD_BUG_ON(!__builtin_constant_p(_dest_len) ||                \
           ^
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
           BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
           ^
   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)
                                       ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:530:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:523:4: note: expanded from macro '__compiletime_assert'
                           prefix ## suffix();                             \
                           ^

<scratch space>:127:1: note: expanded from here __compiletime_assert_309
^
1 error generated.

vim +/error +1454 drivers/auxdisplay/panel.c

7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1426
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1427  /* tries to bind a key to the signal name <name>. The key will send the
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1428   * strings <press>, <repeat>, <release> for these respective events.
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1429   * Returns the pointer to the new key if ok, NULL if the key could not be bound.
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1430   */
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1431  static struct logical_input *panel_bind_key(const char *name, const char *press,
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1432                                              const char *repeat,
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1433                                              const char *release)
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1434  {
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1435          struct logical_input *key;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1436
fdf4a4948ca8a1 drivers/staging/panel/panel.c Dominique van den Broeck 2014-05-21  1437          key = kzalloc(sizeof(*key), GFP_KERNEL);
eb073a9bf2b6ed drivers/staging/panel/panel.c Toshiaki Yamane          2012-07-12  1438          if (!key)
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1439                  return NULL;
eb073a9bf2b6ed drivers/staging/panel/panel.c Toshiaki Yamane          2012-07-12  1440
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1441          if (!input_name2mask(name, &key->mask, &key->value, &scan_mask_i,
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1442                               &scan_mask_o)) {
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1443                  kfree(key);
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1444                  return NULL;
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1445          }
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1446
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1447          key->type = INPUT_TYPE_KBD;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1448          key->state = INPUT_ST_LOW;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1449          key->rise_time = 1;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1450          key->fall_time = 1;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1451
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11  1452          strtomem_pad(key->u.kbd.press_str, press, '\0');
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11  1453          strtomem_pad(key->u.kbd.repeat_str, repeat, '\0');
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11 @1454          strtomem_pad(key->u.kbd.release_str, release, '\0');
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1455          list_add(&key->list, &logical_inputs);
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1456          return key;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1457  }
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1458

:::::: The code at line 1454 was first introduced by commit
:::::: a952abcdaa22116d940ca9cb9253caad1622ae93 auxdisplay: panel: Replace deprecated strncpy() with strtomem_pad()

:::::: TO: Justin Stitt <[email protected]>
:::::: CC: Kees Cook <[email protected]>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

#2 lore raw
Quoted 11 lines · Suren Baghdasaryan
Quoted 8 lines · kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b4b0881156fb8209bf5ef6cb63211bb0ad6e1a6b
commit: 07438779313caafe52ac1a1a6958d735a5938988 alloc_tag: avoid current->alloc_tag manipulations when profiling is disabled
date:   5 days ago
config: hexagon-randconfig-r133-20250131 (https://download.01.org/0day-ci/archive/20250131/[email protected]/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce: (https://download.01.org/0day-ci/archive/20250131/[email protected]/reproduce)
Quoted 1 line

Just saw this report (was on vacation). Will try to figure out what's going on.

I confirmed that my change at
https://lore.kernel.org/all/[email protected]
indeed causes this.
Looks like due to the additional mem_alloc_profiling_enabled() check, the compiler considers allocation size as unknown at compile time (__builtin_object_size(obj) returns -1) even though both branches of that condition make the same exact allocation.
I tried changing it to:

#define alloc_hooks_tag(_tag, _do_alloc) \

({ \
        typeof(_do_alloc) _res; \
        struct alloc_tag * __maybe_unused _old; \
         if (mem_alloc_profiling_enabled()) \
                _old = alloc_tag_save(_tag); \
        _res = _do_alloc; \
         if (mem_alloc_profiling_enabled()) \
                 alloc_tag_restore(_tag, _old); \
        _res; \
})

and that fixes the problem, however this would require two static key checks... I wonder if there is a way to tell the compiler that both branches cause the same result. Let me dig around.

Quoted 79 lines
Quoted 79 lines

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

drivers/auxdisplay/panel.c:1454:2: error: call to __compiletime_assert_309 declared with 'error' attribute: BUILD_BUG_ON failed: !__builtin_constant_p(_dest_len) || _dest_len == (size_t)-1

           strtomem_pad(key->u.kbd.release_str, release, '\0');
           ^
   include/linux/string.h:417:2: note: expanded from macro 'strtomem_pad'
           BUILD_BUG_ON(!__builtin_constant_p(_dest_len) ||                \
           ^
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
           BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
           ^
   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)
                                       ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:530:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:523:4: note: expanded from macro '__compiletime_assert'
                           prefix ## suffix();                             \
                           ^

<scratch space>:127:1: note: expanded from here __compiletime_assert_309
^
1 error generated.

vim +/error +1454 drivers/auxdisplay/panel.c

7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1426
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1427  /* tries to bind a key to the signal name <name>. The key will send the
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1428   * strings <press>, <repeat>, <release> for these respective events.
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1429   * Returns the pointer to the new key if ok, NULL if the key could not be bound.
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1430   */
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1431  static struct logical_input *panel_bind_key(const char *name, const char *press,
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1432                                              const char *repeat,
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1433                                              const char *release)
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1434  {
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1435          struct logical_input *key;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1436
fdf4a4948ca8a1 drivers/staging/panel/panel.c Dominique van den Broeck 2014-05-21  1437          key = kzalloc(sizeof(*key), GFP_KERNEL);
eb073a9bf2b6ed drivers/staging/panel/panel.c Toshiaki Yamane          2012-07-12  1438          if (!key)
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1439                  return NULL;
eb073a9bf2b6ed drivers/staging/panel/panel.c Toshiaki Yamane          2012-07-12  1440
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1441          if (!input_name2mask(name, &key->mask, &key->value, &scan_mask_i,
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1442                               &scan_mask_o)) {
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1443                  kfree(key);
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1444                  return NULL;
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1445          }
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1446
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1447          key->type = INPUT_TYPE_KBD;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1448          key->state = INPUT_ST_LOW;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1449          key->rise_time = 1;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1450          key->fall_time = 1;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1451
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11  1452          strtomem_pad(key->u.kbd.press_str, press, '\0');
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11  1453          strtomem_pad(key->u.kbd.repeat_str, repeat, '\0');
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11 @1454          strtomem_pad(key->u.kbd.release_str, release, '\0');
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1455          list_add(&key->list, &logical_inputs);
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1456          return key;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1457  }
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1458

:::::: The code at line 1454 was first introduced by commit
:::::: a952abcdaa22116d940ca9cb9253caad1622ae93 auxdisplay: panel: Replace deprecated strncpy() with strtomem_pad()

:::::: TO: Justin Stitt <[email protected]>
:::::: CC: Kees Cook <[email protected]>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

#3 lore raw
Quoted 36 lines · Suren Baghdasaryan
Quoted 11 lines · Suren Baghdasaryan
Quoted 8 lines · kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b4b0881156fb8209bf5ef6cb63211bb0ad6e1a6b
commit: 07438779313caafe52ac1a1a6958d735a5938988 alloc_tag: avoid current->alloc_tag manipulations when profiling is disabled
date:   5 days ago
config: hexagon-randconfig-r133-20250131 (https://download.01.org/0day-ci/archive/20250131/[email protected]/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce: (https://download.01.org/0day-ci/archive/20250131/[email protected]/reproduce)
Quoted 1 line

Just saw this report (was on vacation). Will try to figure out what's going on.

I confirmed that my change at
https://lore.kernel.org/all/[email protected]
indeed causes this.
Looks like due to the additional mem_alloc_profiling_enabled() check, the compiler considers allocation size as unknown at compile time (__builtin_object_size(obj) returns -1) even though both branches of that condition make the same exact allocation.
I tried changing it to:

#define alloc_hooks_tag(_tag, _do_alloc) \

({ \
        typeof(_do_alloc) _res; \
        struct alloc_tag * __maybe_unused _old; \
         if (mem_alloc_profiling_enabled()) \
                _old = alloc_tag_save(_tag); \
        _res = _do_alloc; \
         if (mem_alloc_profiling_enabled()) \
                 alloc_tag_restore(_tag, _old); \
        _res; \
})
Quoted 3 lines

and that fixes the problem, however this would require two static key checks... I wonder if there is a way to tell the compiler that both branches cause the same result. Let me dig around.

CC'ing Nathan Chancellor, Nick Desaulniers and [email protected]

Looks like this error happens only with clang version 14 (more specifically CONFIG_CLANG_VERSION=140006). I tested with clang-13, clang-15 and clang-17 and all of them build this code fine. Same thing for other archs (clang-14 fails, others don't). I tried hexagon, x86 and arm64.

To fix the build I can add:

#if defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION >= 140000 && CONFIG_CLANG_VERSION < 150000
// do this the old way
#else
// do this the new way
#endif

but I'm not sure if that's the right fix.

Andrew, while compiler folks investigate this issue, I'll post the above fix in case we need to deal with this build error urgently. Thanks,
Suren.

Quoted 80 lines
Quoted 80 lines
Quoted 80 lines

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

drivers/auxdisplay/panel.c:1454:2: error: call to __compiletime_assert_309 declared with 'error' attribute: BUILD_BUG_ON failed: !__builtin_constant_p(_dest_len) || _dest_len == (size_t)-1

           strtomem_pad(key->u.kbd.release_str, release, '\0');
           ^
   include/linux/string.h:417:2: note: expanded from macro 'strtomem_pad'
           BUILD_BUG_ON(!__builtin_constant_p(_dest_len) ||                \
           ^
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
           BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
           ^
   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)
                                       ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:530:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:523:4: note: expanded from macro '__compiletime_assert'
                           prefix ## suffix();                             \
                           ^

<scratch space>:127:1: note: expanded from here __compiletime_assert_309
^
1 error generated.

vim +/error +1454 drivers/auxdisplay/panel.c

7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1426
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1427  /* tries to bind a key to the signal name <name>. The key will send the
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1428   * strings <press>, <repeat>, <release> for these respective events.
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1429   * Returns the pointer to the new key if ok, NULL if the key could not be bound.
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1430   */
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1431  static struct logical_input *panel_bind_key(const char *name, const char *press,
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1432                                              const char *repeat,
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1433                                              const char *release)
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1434  {
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1435          struct logical_input *key;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1436
fdf4a4948ca8a1 drivers/staging/panel/panel.c Dominique van den Broeck 2014-05-21  1437          key = kzalloc(sizeof(*key), GFP_KERNEL);
eb073a9bf2b6ed drivers/staging/panel/panel.c Toshiaki Yamane          2012-07-12  1438          if (!key)
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1439                  return NULL;
eb073a9bf2b6ed drivers/staging/panel/panel.c Toshiaki Yamane          2012-07-12  1440
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1441          if (!input_name2mask(name, &key->mask, &key->value, &scan_mask_i,
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1442                               &scan_mask_o)) {
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1443                  kfree(key);
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1444                  return NULL;
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1445          }
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1446
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1447          key->type = INPUT_TYPE_KBD;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1448          key->state = INPUT_ST_LOW;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1449          key->rise_time = 1;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1450          key->fall_time = 1;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1451
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11  1452          strtomem_pad(key->u.kbd.press_str, press, '\0');
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11  1453          strtomem_pad(key->u.kbd.repeat_str, repeat, '\0');
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11 @1454          strtomem_pad(key->u.kbd.release_str, release, '\0');
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1455          list_add(&key->list, &logical_inputs);
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1456          return key;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1457  }
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1458

:::::: The code at line 1454 was first introduced by commit
:::::: a952abcdaa22116d940ca9cb9253caad1622ae93 auxdisplay: panel: Replace deprecated strncpy() with strtomem_pad()

:::::: TO: Justin Stitt <[email protected]>
:::::: CC: Kees Cook <[email protected]>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

#4 lore raw
Quoted 59 lines · Suren Baghdasaryan
Quoted 36 lines · Suren Baghdasaryan
Quoted 11 lines · Suren Baghdasaryan
Quoted 8 lines · kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b4b0881156fb8209bf5ef6cb63211bb0ad6e1a6b
commit: 07438779313caafe52ac1a1a6958d735a5938988 alloc_tag: avoid current->alloc_tag manipulations when profiling is disabled
date:   5 days ago
config: hexagon-randconfig-r133-20250131 (https://download.01.org/0day-ci/archive/20250131/[email protected]/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce: (https://download.01.org/0day-ci/archive/20250131/[email protected]/reproduce)
Quoted 1 line

Just saw this report (was on vacation). Will try to figure out what's going on.

I confirmed that my change at
https://lore.kernel.org/all/[email protected]
indeed causes this.
Looks like due to the additional mem_alloc_profiling_enabled() check, the compiler considers allocation size as unknown at compile time (__builtin_object_size(obj) returns -1) even though both branches of that condition make the same exact allocation.
I tried changing it to:

#define alloc_hooks_tag(_tag, _do_alloc) \

({ \
        typeof(_do_alloc) _res; \
        struct alloc_tag * __maybe_unused _old; \
         if (mem_alloc_profiling_enabled()) \
                _old = alloc_tag_save(_tag); \
        _res = _do_alloc; \
         if (mem_alloc_profiling_enabled()) \
                 alloc_tag_restore(_tag, _old); \
        _res; \
})
Quoted 3 lines

and that fixes the problem, however this would require two static key checks... I wonder if there is a way to tell the compiler that both branches cause the same result. Let me dig around.

CC'ing Nathan Chancellor, Nick Desaulniers and [email protected]

Looks like this error happens only with clang version 14 (more specifically CONFIG_CLANG_VERSION=140006). I tested with clang-13, clang-15 and clang-17 and all of them build this code fine. Same thing for other archs (clang-14 fails, others don't). I tried hexagon, x86 and arm64.

To fix the build I can add:

#if defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION >= 140000 && CONFIG_CLANG_VERSION < 150000
// do this the old way
#else
// do this the new way
#endif

Quoted 4 lines

but I'm not sure if that's the right fix.

Andrew, while compiler folks investigate this issue, I'll post the above fix in case we need to deal with this build error urgently.

Workaround is posted at:
https://lore.kernel.org/all/[email protected]/

Quoted 83 lines

Thanks,
Suren.

Quoted 80 lines
Quoted 80 lines
Quoted 80 lines

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

drivers/auxdisplay/panel.c:1454:2: error: call to __compiletime_assert_309 declared with 'error' attribute: BUILD_BUG_ON failed: !__builtin_constant_p(_dest_len) || _dest_len == (size_t)-1

           strtomem_pad(key->u.kbd.release_str, release, '\0');
           ^
   include/linux/string.h:417:2: note: expanded from macro 'strtomem_pad'
           BUILD_BUG_ON(!__builtin_constant_p(_dest_len) ||                \
           ^
   include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON'
           BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
           ^
   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)
                                       ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:530:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:523:4: note: expanded from macro '__compiletime_assert'
                           prefix ## suffix();                             \
                           ^

<scratch space>:127:1: note: expanded from here __compiletime_assert_309
^
1 error generated.

vim +/error +1454 drivers/auxdisplay/panel.c

7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1426
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1427  /* tries to bind a key to the signal name <name>. The key will send the
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1428   * strings <press>, <repeat>, <release> for these respective events.
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1429   * Returns the pointer to the new key if ok, NULL if the key could not be bound.
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1430   */
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1431  static struct logical_input *panel_bind_key(const char *name, const char *press,
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1432                                              const char *repeat,
36d2041a3d57b9 drivers/staging/panel/panel.c Peter Huewe              2013-02-15  1433                                              const char *release)
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1434  {
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1435          struct logical_input *key;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1436
fdf4a4948ca8a1 drivers/staging/panel/panel.c Dominique van den Broeck 2014-05-21  1437          key = kzalloc(sizeof(*key), GFP_KERNEL);
eb073a9bf2b6ed drivers/staging/panel/panel.c Toshiaki Yamane          2012-07-12  1438          if (!key)
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1439                  return NULL;
eb073a9bf2b6ed drivers/staging/panel/panel.c Toshiaki Yamane          2012-07-12  1440
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1441          if (!input_name2mask(name, &key->mask, &key->value, &scan_mask_i,
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1442                               &scan_mask_o)) {
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1443                  kfree(key);
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1444                  return NULL;
cb46f472cbb08c drivers/staging/panel/panel.c Kulikov Vasiliy          2010-07-12  1445          }
698b1515f03914 drivers/staging/panel/panel.c Willy Tarreau            2008-11-22  1446
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1447          key->type = INPUT_TYPE_KBD;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1448          key->state = INPUT_ST_LOW;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1449          key->rise_time = 1;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1450          key->fall_time = 1;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1451
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11  1452          strtomem_pad(key->u.kbd.press_str, press, '\0');
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11  1453          strtomem_pad(key->u.kbd.repeat_str, repeat, '\0');
a952abcdaa2211 drivers/auxdisplay/panel.c    Justin Stitt             2023-09-11 @1454          strtomem_pad(key->u.kbd.release_str, release, '\0');
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1455          list_add(&key->list, &logical_inputs);
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1456          return key;
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1457  }
7005b58458e4be drivers/staging/panel/panel.c Willy Tarreau            2008-11-13  1458

:::::: The code at line 1454 was first introduced by commit
:::::: a952abcdaa22116d940ca9cb9253caad1622ae93 auxdisplay: panel: Replace deprecated strncpy() with strtomem_pad()

:::::: TO: Justin Stitt <[email protected]>
:::::: CC: Kees Cook <[email protected]>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

#5 lore raw
In reply to Suren Baghdasaryan
Quoted 35 lines · Suren Baghdasaryan
Quoted 11 lines · Suren Baghdasaryan
Quoted 8 lines · kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b4b0881156fb8209bf5ef6cb63211bb0ad6e1a6b
commit: 07438779313caafe52ac1a1a6958d735a5938988 alloc_tag: avoid current->alloc_tag manipulations when profiling is disabled
date:   5 days ago
config: hexagon-randconfig-r133-20250131 (https://download.01.org/0day-ci/archive/20250131/[email protected]/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce: (https://download.01.org/0day-ci/archive/20250131/[email protected]/reproduce)
Quoted 1 line

Just saw this report (was on vacation). Will try to figure out what's going on.

I confirmed that my change at
https://lore.kernel.org/all/[email protected]
indeed causes this.
Looks like due to the additional mem_alloc_profiling_enabled() check, the compiler considers allocation size as unknown at compile time (__builtin_object_size(obj) returns -1) even though both branches of that condition make the same exact allocation.
I tried changing it to:

#define alloc_hooks_tag(_tag, _do_alloc) \

({ \
        typeof(_do_alloc) _res; \
        struct alloc_tag * __maybe_unused _old; \
         if (mem_alloc_profiling_enabled()) \
                _old = alloc_tag_save(_tag); \
        _res = _do_alloc; \
         if (mem_alloc_profiling_enabled()) \
                 alloc_tag_restore(_tag, _old); \
        _res; \
})
Quoted 3 lines

and that fixes the problem, however this would require two static key checks... I wonder if there is a way to tell the compiler that both branches cause the same result. Let me dig around.

strtomem_pad() looks pretty suspect to me.

I'm not seeing any reason for it to be using __builtin_object_size(), (and __builtin_object_size() failing looks like perhaps a bizarre compiler bug?).

It looks to me like ARRAY_SIZE() would be better here, and also there really should be some actual typechecking on the source and dest arguments - like strcpy(), they should be char *.