linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Suren Baghdasaryan <surenb@google.com>
To: kernel test robot <lkp@intel.com>,
	Nathan Chancellor <nathan@kernel.org>,
	 Nick Desaulniers <ndesaulniers@google.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org,
	 Linux Memory Management List <linux-mm@kvack.org>,
	Kent Overstreet <kent.overstreet@linux.dev>,
	 Kees Cook <keescook@chromium.org>,
	llvm@lists.linux.dev
Subject: Re: 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
Date: Sat, 1 Feb 2025 12:06:53 -0800	[thread overview]
Message-ID: <CAJuCfpECssDC2VZuNkeqEbb68MuAvoWeSt-zsV6mqouMzEeE4Q@mail.gmail.com> (raw)
In-Reply-To: <CAJuCfpExBhWxWdj3G-uQXA8HA-+ES6y=sz2H4eeze4xw4snYZg@mail.gmail.com>

On Sat, Feb 1, 2025 at 11:21 AM Suren Baghdasaryan <surenb@google.com> wrote:
>
> On Fri, Jan 31, 2025 at 2:51 PM Suren Baghdasaryan <surenb@google.com> wrote:
> >
> > On Fri, Jan 31, 2025 at 8:55 AM Suren Baghdasaryan <surenb@google.com> wrote:
> > >
> > > On Thu, Jan 30, 2025 at 4:06 PM kernel test robot <lkp@intel.com> wrote:
> > > >
> > > > 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/202501310832.kiAeOt2z-lkp@intel.com/config)
> > > > compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
> > > > reproduce: (https://download.01.org/0day-ci/archive/20250131/202501310832.kiAeOt2z-lkp@intel.com/reproduce)
> > >
> > > 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/20241226211639.1357704-1-surenb@google.com
> > 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.
>
> CC'ing Nathan Chancellor, Nick Desaulniers and llvm@lists.linux.dev
>
> 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.

Workaround is posted at:
https://lore.kernel.org/all/20250201200503.2532357-1-surenb@google.com/

> Thanks,
> Suren.
>
> >
> > >
> > > >
> > > > 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 <lkp@intel.com>
> > > > | Closes: https://lore.kernel.org/oe-kbuild-all/202501310832.kiAeOt2z-lkp@intel.com/
> > > >
> > > > 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 <justinstitt@google.com>
> > > > :::::: CC: Kees Cook <keescook@chromium.org>
> > > >
> > > > --
> > > > 0-DAY CI Kernel Test Service
> > > > https://github.com/intel/lkp-tests/wiki


  reply	other threads:[~2025-02-01 20:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-31  0:05 kernel test robot
2025-01-31 16:55 ` Suren Baghdasaryan
2025-01-31 22:51   ` Suren Baghdasaryan
2025-02-01 19:21     ` Suren Baghdasaryan
2025-02-01 20:06       ` Suren Baghdasaryan [this message]
2025-02-01 19:27     ` Kent Overstreet

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=CAJuCfpECssDC2VZuNkeqEbb68MuAvoWeSt-zsV6mqouMzEeE4Q@mail.gmail.com \
    --to=surenb@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=keescook@chromium.org \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=oe-kbuild-all@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox