mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* include/linux/compiler_types.h:631:45: error: call to '__compiletime_assert_433' declared with attribute error: BUILD_BUG_ON failed: offsetof(struct qla_tgt_sess_op, atio) + sizeof(u->atio) != sizeof(*u)
@ 2026-11-21  2:49 kernel test robot
  2026-11-21  4:10 ` Finn Thain
  0 siblings, 1 reply; 6+ messages in thread
From: kernel test robot @ 2026-11-21  2:49 UTC (permalink / raw)
  To: Finn Thain
  Cc: oe-kbuild-all, linux-kernel, Andrew Morton,
	Linux Memory Management List, Arnd Bergmann

Hi Finn,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   5f22fb20497f4983094131f00a734362300d22d2
commit: e428b013d9dff30f7a65509e33047ba975cce8ba atomic: specify alignment for atomic_t and atomic64_t
date:   10 months ago
config: m68k-randconfig-2000-20261121 (https://download.01.org/0day-ci/archive/20261121/20261121034304.2dPxVKzk-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261121/20261121034304.2dPxVKzk-lkp@intel.com/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
| Fixes: e428b013d9df ("atomic: specify alignment for atomic_t and atomic64_t")
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261121034304.2dPxVKzk-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from <command-line>:
   In function 'qlt_queue_unknown_atio',
       inlined from 'qlt_24xx_atio_pkt_all_vps.isra' at drivers/scsi/qla2xxx/qla_target.c:331:4:
>> include/linux/compiler_types.h:631:45: error: call to '__compiletime_assert_433' declared with attribute error: BUILD_BUG_ON failed: offsetof(struct qla_tgt_sess_op, atio) + sizeof(u->atio) != sizeof(*u)
     631 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |                                             ^
   include/linux/compiler_types.h:612:25: note: in definition of macro '__compiletime_assert'
     612 |                         prefix ## suffix();                             \
         |                         ^~~~~~
   include/linux/compiler_types.h:631:9: note: in expansion of macro '_compiletime_assert'
     631 |         _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:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^~~~~~~~~~~~~~~~
   drivers/scsi/qla2xxx/qla_target.c:216:9: note: in expansion of macro 'BUILD_BUG_ON'
     216 |         BUILD_BUG_ON(offsetof(struct qla_tgt_sess_op, atio) + sizeof(u->atio) != sizeof(*u));
         |         ^~~~~~~~~~~~


vim +/__compiletime_assert_433 +631 include/linux/compiler_types.h

eb5c2d4b45e3d2 Will Deacon 2020-07-21  617  
eb5c2d4b45e3d2 Will Deacon 2020-07-21  618  #define _compiletime_assert(condition, msg, prefix, suffix) \
eb5c2d4b45e3d2 Will Deacon 2020-07-21  619  	__compiletime_assert(condition, msg, prefix, suffix)
eb5c2d4b45e3d2 Will Deacon 2020-07-21  620  
eb5c2d4b45e3d2 Will Deacon 2020-07-21  621  /**
eb5c2d4b45e3d2 Will Deacon 2020-07-21  622   * compiletime_assert - break build and emit msg if condition is false
eb5c2d4b45e3d2 Will Deacon 2020-07-21  623   * @condition: a compile-time constant condition to check
eb5c2d4b45e3d2 Will Deacon 2020-07-21  624   * @msg:       a message to emit if condition is false
eb5c2d4b45e3d2 Will Deacon 2020-07-21  625   *
eb5c2d4b45e3d2 Will Deacon 2020-07-21  626   * In tradition of POSIX assert, this macro will break the build if the
eb5c2d4b45e3d2 Will Deacon 2020-07-21  627   * supplied condition is *false*, emitting the supplied error message if the
eb5c2d4b45e3d2 Will Deacon 2020-07-21  628   * compiler has support to do so.
eb5c2d4b45e3d2 Will Deacon 2020-07-21  629   */
eb5c2d4b45e3d2 Will Deacon 2020-07-21  630  #define compiletime_assert(condition, msg) \
eb5c2d4b45e3d2 Will Deacon 2020-07-21 @631  	_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
eb5c2d4b45e3d2 Will Deacon 2020-07-21  632  

:::::: The code at line 631 was first introduced by commit
:::::: eb5c2d4b45e3d2d5d052ea6b8f1463976b1020d5 compiler.h: Move compiletime_assert() macros into compiler_types.h

:::::: TO: Will Deacon <will@kernel.org>
:::::: CC: Will Deacon <will@kernel.org>

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: include/linux/compiler_types.h:631:45: error: call to '__compiletime_assert_433' declared with attribute error: BUILD_BUG_ON failed: offsetof(struct qla_tgt_sess_op, atio) + sizeof(u->atio) != sizeof(*u)
  2026-11-21  2:49 include/linux/compiler_types.h:631:45: error: call to '__compiletime_assert_433' declared with attribute error: BUILD_BUG_ON failed: offsetof(struct qla_tgt_sess_op, atio) + sizeof(u->atio) != sizeof(*u) kernel test robot
@ 2026-11-21  4:10 ` Finn Thain
  2026-11-23  9:48   ` Geert Uytterhoeven
  0 siblings, 1 reply; 6+ messages in thread
From: Finn Thain @ 2026-11-21  4:10 UTC (permalink / raw)
  To: kernel test robot
  Cc: oe-kbuild-all, linux-kernel, Andrew Morton,
	Linux Memory Management List, Arnd Bergmann


On Sat, 21 Nov 2026, kernel test robot wrote:

> FYI, the error/warning still remains.
> 

That's because the qla2xxx maintainers at Marvell did not respond to any 
of the three fixes I sent. I'm not a paying customer so all bets are off.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: include/linux/compiler_types.h:631:45: error: call to '__compiletime_assert_433' declared with attribute error: BUILD_BUG_ON failed: offsetof(struct qla_tgt_sess_op, atio) + sizeof(u->atio) != sizeof(*u)
  2026-11-21  4:10 ` Finn Thain
@ 2026-11-23  9:48   ` Geert Uytterhoeven
  2026-11-23 23:05     ` Finn Thain
  0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2026-11-23  9:48 UTC (permalink / raw)
  To: Finn Thain
  Cc: kernel test robot, oe-kbuild-all, linux-kernel, Andrew Morton,
	Linux Memory Management List, Arnd Bergmann, James Bottomley,
	Martin K. Petersen, scsi

Hi Finn,

CC scsi

On Sat, 21 Nov 2026 at 05:10, Finn Thain <fthain@linux-m68k.org> wrote:
> On Sat, 21 Nov 2026, kernel test robot wrote:
> > FYI, the error/warning still remains.
>
> That's because the qla2xxx maintainers at Marvell did not respond to any
> of the three fixes I sent. I'm not a paying customer so all bets are off.

That's "[PATCH] scsi: qla2xxx: Rework BUILD_BUG_ON() assertion",
first submittted in March, right?
https://lore.kernel.org/all/4808a5dc1a71528ffa3360868561009744277450.1791502886.git.fthain@linux-m68k.org

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: include/linux/compiler_types.h:631:45: error: call to '__compiletime_assert_433' declared with attribute error: BUILD_BUG_ON failed: offsetof(struct qla_tgt_sess_op, atio) + sizeof(u->atio) != sizeof(*u)
  2026-11-23  9:48   ` Geert Uytterhoeven
@ 2026-11-23 23:05     ` Finn Thain
  2026-11-23 23:37       ` Bart Van Assche
  0 siblings, 1 reply; 6+ messages in thread
From: Finn Thain @ 2026-11-23 23:05 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: kernel test robot, oe-kbuild-all, linux-kernel, Andrew Morton,
	Linux Memory Management List, Arnd Bergmann, James Bottomley,
	Martin K. Petersen, scsi


On Mon, 23 Nov 2026, Geert Uytterhoeven wrote:

> Hi Finn,
> 
> CC scsi
> 
> On Sat, 21 Nov 2026 at 05:10, Finn Thain <fthain@linux-m68k.org> wrote:
> > On Sat, 21 Nov 2026, kernel test robot wrote:
> > > FYI, the error/warning still remains.
> >
> > That's because the qla2xxx maintainers at Marvell did not respond to any
> > of the three fixes I sent. I'm not a paying customer so all bets are off.
> 
> That's "[PATCH] scsi: qla2xxx: Rework BUILD_BUG_ON() assertion",
> first submittted in March, right?
> https://lore.kernel.org/all/4808a5dc1a71528ffa3360868561009744277450.1791502886.git.fthain@linux-m68k.org
> 

Yes, two alternative solutions were submitted in March (either remove the 
assertion or rework it). The build bot reported the problem again in 
September so I resubmitted the "rework" alternative. Sashiko-bot didn't 
have much praise for that*, so now I'm leaning towards the "remove" 
alternative. I have been advised to keep re-submitting, and I will do so 
after a suitable back-off in retry rate i.e. 2027 or 2028.

*
https://lore.kernel.org/r/93e35f60-e465-7f76-0043-f997fe2ec8c7@linux-m68k.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: include/linux/compiler_types.h:631:45: error: call to '__compiletime_assert_433' declared with attribute error: BUILD_BUG_ON failed: offsetof(struct qla_tgt_sess_op, atio) + sizeof(u->atio) != sizeof(*u)
  2026-11-23 23:05     ` Finn Thain
@ 2026-11-23 23:37       ` Bart Van Assche
  2026-11-24  3:31         ` Finn Thain
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2026-11-23 23:37 UTC (permalink / raw)
  To: Finn Thain, Geert Uytterhoeven
  Cc: kernel test robot, oe-kbuild-all, linux-kernel, Andrew Morton,
	Linux Memory Management List, Arnd Bergmann, James Bottomley,
	Martin K. Petersen, scsi

On 11/23/26 3:05 PM, Finn Thain wrote:
> Yes, two alternative solutions were submitted in March (either remove the
> assertion or rework it). The build bot reported the problem again in
> September so I resubmitted the "rework" alternative. Sashiko-bot didn't
> have much praise for that*, so now I'm leaning towards the "remove"
> alternative. I have been advised to keep re-submitting, and I will do so
> after a suitable back-off in retry rate i.e. 2027 or 2028.
> 
> *
> https://lore.kernel.org/r/93e35f60-e465-7f76-0043-f997fe2ec8c7@linux-m68k.org

What an LLM came up with after I asked it to fix
https://lore.kernel.org/lkml/202603030747.VX0v4otS-lkp@intel.com/ can be
found below. One of the comments of the LLM is "This is essentially Finn
Thain's "Rework BUILD_BUG_ON() assertion" patch with your two review 
comments from this morning applied". Sashiko reports "No issues found"
for the patch below. No Signed-off-by from me because I think Finn
should be credited for his work instead of I.

Bart.

     scsi: qla2xxx: Fix the qla_tgt_sess_op layout assertion

     qlt_queue_unknown_atio() allocates a struct qla_tgt_sess_op followed by
     add_cdb_len bytes and copies an ATIO plus its additional CDB bytes into
     the 'atio' member. Hence no other member may follow 'atio'. The
     BUILD_BUG_ON() that is supposed to verify this compares the end of
     'atio' with sizeof(struct qla_tgt_sess_op). That is wrong because it
     also triggers if the compiler adds tail padding. This is what 
happens on
     m68k since atomic_t is aligned on a four byte boundary: 'atio' ends at
     offset 102 and the structure size is 104 bytes. This breaks the build
     for CONFIG_COLDFIRE=y and CONFIG_SCSI_QLA_FC=y:

       error: call to '__compiletime_assert_431' declared with attribute
       error: BUILD_BUG_ON failed: offsetof(struct qla_tgt_sess_op, atio) +
       sizeof(u->atio) != sizeof(*u)

     Additionally, the BUILD_BUG_ON() does not detect all members that could
     be added after 'atio', e.g. a zero-length array.

     Fix this by adding a flexible array member after 'atio' that represents
     the additional CDB bytes. The compiler rejects any member that is added
     after a flexible array member. Assert that the flexible array member
     follows 'atio' immediately instead of making assumptions about the
     structure size. Use kzalloc_flex() to allocate the structure. This does
     not change the allocation size.

     This patch is based on a patch from Finn Thain and on a suggestion from
     Tony Battersby.

     Do not modify the memcpy() call in qlt_queue_unknown_atio(), which
     still writes past the end of the 'atio' member.

     Compile-tested only, for m68k (Coldfire) and x86_64.

     Reported-by: kernel test robot <lkp@intel.com>
     Closes: 
https://lore.kernel.org/oe-kbuild-all/202603030747.VX0v4otS-lkp@intel.com/
     Closes: 
https://lore.kernel.org/oe-kbuild-all/202609301230.CauIUXCF-lkp@intel.com/
     Link: 
https://lore.kernel.org/all/4808a5dc1a71528ffa3360868561009744277450.1791502886.git.fthain@linux-m68k.org/
     Fixes: 091719c21d5a ("scsi: qla2xxx: target: Fix invalid memory 
access with big CDBs")
     Fixes: e428b013d9df ("atomic: specify alignment for atomic_t and 
atomic64_t")

diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 5a7caff61b16..afa96551c13c 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -212,9 +212,6 @@ static void qlt_queue_unknown_atio(scsi_qla_host_t *vha,
  	unsigned long flags;
  	unsigned int add_cdb_len = 0;

-	/* atio must be the last member of qla_tgt_sess_op for add_cdb_len */
-	BUILD_BUG_ON(offsetof(struct qla_tgt_sess_op, atio) + sizeof(u->atio) 
!= sizeof(*u));
-
  	if (tgt->tgt_stop) {
  		ql_dbg(ql_dbg_async, vha, 0x502c,
  		    "qla_target(%d): dropping unknown ATIO_TYPE7, because tgt is 
being stopped",
@@ -227,7 +224,7 @@ static void qlt_queue_unknown_atio(scsi_qla_host_t *vha,
  		add_cdb_len =
  			((unsigned int) atio->u.isp24.fcp_cmnd.add_cdb_len) * 4;

-	u = kzalloc(sizeof(*u) + add_cdb_len, GFP_ATOMIC);
+	u = kzalloc_flex(*u, extra_cdb, add_cdb_len, GFP_ATOMIC);
  	if (u == NULL)
  		goto out_term;

diff --git a/drivers/scsi/qla2xxx/qla_target.h 
b/drivers/scsi/qla2xxx/qla_target.h
index 71bc1affb1bc..c1559f034f85 100644
--- a/drivers/scsi/qla2xxx/qla_target.h
+++ b/drivers/scsi/qla2xxx/qla_target.h
@@ -845,9 +845,16 @@ struct qla_tgt_sess_op {
  	struct rsp_que *rsp;

  	struct atio_from_isp atio;
-	/* DO NOT ADD ANYTHING ELSE HERE - atio must be last member */
+	/*
+	 * The part of atio.u.isp24.fcp_cmnd.add_cdb[] that extends past the
+	 * end of atio. Must follow atio immediately.
+	 */
+	uint8_t extra_cdb[];
  };

+static_assert(offsetofend(struct qla_tgt_sess_op, atio) ==
+	      offsetof(struct qla_tgt_sess_op, extra_cdb));
+
  enum trace_flags {
  	TRC_NEW_CMD = BIT_0,
  	TRC_DO_WORK = BIT_1,


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: include/linux/compiler_types.h:631:45: error: call to '__compiletime_assert_433' declared with attribute error: BUILD_BUG_ON failed: offsetof(struct qla_tgt_sess_op, atio) + sizeof(u->atio) != sizeof(*u)
  2026-11-23 23:37       ` Bart Van Assche
@ 2026-11-24  3:31         ` Finn Thain
  0 siblings, 0 replies; 6+ messages in thread
From: Finn Thain @ 2026-11-24  3:31 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Geert Uytterhoeven, kernel test robot, oe-kbuild-all,
	linux-kernel, Andrew Morton, Linux Memory Management List,
	Arnd Bergmann, James Bottomley, Martin K. Petersen, scsi


On Mon, 23 Nov 2026, Bart Van Assche wrote:

> On 11/23/26 3:05 PM, Finn Thain wrote:
> > Yes, two alternative solutions were submitted in March (either remove the
> > assertion or rework it). The build bot reported the problem again in
> > September so I resubmitted the "rework" alternative. Sashiko-bot didn't
> > have much praise for that*, so now I'm leaning towards the "remove"
> > alternative. I have been advised to keep re-submitting, and I will do so
> > after a suitable back-off in retry rate i.e. 2027 or 2028.
> > 
> > *
> > https://lore.kernel.org/r/93e35f60-e465-7f76-0043-f997fe2ec8c7@linux-m68k.org
> 
> What an LLM came up with after I asked it to fix 
> https://lore.kernel.org/lkml/202603030747.VX0v4otS-lkp@intel.com/ can be 
> found below. One of the comments of the LLM is "This is essentially Finn 
> Thain's "Rework BUILD_BUG_ON() assertion" patch with your two review 
> comments from this morning applied". Sashiko reports "No issues found" 
> for the patch below. No Signed-off-by from me because I think Finn 
> should be credited for his work instead of I.
> 

Thanks, Bart. I'll take that as a vote for "rework". There is an 
associated risk though: I can't test the patch as I don't have access to 
suitable hardware. (Perhaps someone with such access will volunteer.) 

Whereas, the "remove" alternative doesn't require testing as it doesn't 
risk a regression.

I have a question for your LLM. Sashiko-bot said, in response to my patch:

    Similarly, get_datalen_for_atio() accesses the array out-of-bounds 
    when len > 0:

    drivers/scsi/qla2xxx/qla_target.h:get_datalen_for_atio() {
    ...
        return get_unaligned_be32(&atio->u.isp24.fcp_cmnd.add_cdb[len * 4]);
    ...
    }

I don't understand why the patch from your LLM did not raise the same OOB 
access concerns.

Adding a flex array to struct qla_tgt_sess_op can prevent new struct 
members being added in the wrong spot in that struct but can't prevent new 
struct members being added to struct atio7_fcp_cmnd. Neither does the 
assertion. So the "remove" alternative doesn't have all the disadvantages 
that you might expect.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-24  3:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-21  2:49 include/linux/compiler_types.h:631:45: error: call to '__compiletime_assert_433' declared with attribute error: BUILD_BUG_ON failed: offsetof(struct qla_tgt_sess_op, atio) + sizeof(u->atio) != sizeof(*u) kernel test robot
2026-11-21  4:10 ` Finn Thain
2026-11-23  9:48   ` Geert Uytterhoeven
2026-11-23 23:05     ` Finn Thain
2026-11-23 23:37       ` Bart Van Assche
2026-11-24  3:31         ` Finn Thain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®