* 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; 10+ 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] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ 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 2026-11-24 10:18 ` Arnd Bergmann 0 siblings, 1 reply; 10+ 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] 10+ 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-24 3:31 ` Finn Thain @ 2026-11-24 10:18 ` Arnd Bergmann 2026-11-25 0:18 ` Finn Thain 0 siblings, 1 reply; 10+ messages in thread From: Arnd Bergmann @ 2026-11-24 10:18 UTC (permalink / raw) To: Finn Thain, Bart Van Assche Cc: Geert Uytterhoeven, kernel test robot, oe-kbuild-all, linux-kernel, Andrew Morton, Linux Memory Management List, James E . J . Bottomley, Martin K. Petersen, scsi On Tue, Nov 24, 2026, at 04:31, Finn Thain wrote: > 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. I suspect that is just from Bart specifically calling it out in the changelog already as a known limitation "Do not modify the memcpy() call in qlt_queue_unknown_atio(), which still writes past the end of the 'atio' member.". > 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. This is probably just a difference in perception: atio_from_isp and everything inside is clearly marked as a hardware structure that is meant to align exactly to the 64 byte cacheline, so it would not make any sense to change its layout and add more members here. qla_tgt_sess_op on the other hand is clearly not a hardware structure but an in-kernel one, so it is quite unexpected that one of its members extends past the end, especially when the other three instances of atio_from_isp in data structures don't seem to do that. >> @@ -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; While this does make the current implementation more correct by having the correct length, I'm worried that it just ends up establishing the complexity more in the sense that extra_cdb extends both into the padding and beyond qla_tgt_sess_op. If the driver is still actively maintained, it would be nice to reduce the complexity instead, in one of two ways: a) make atio_from_isp naturally aligned by dropping the bogus __packed attribute, so it is actually at the end of qla_tgt_sess_op as the driver was written to expect. Note that having the outer structure as __packed but the union and the inner structs as aligned is itself problematic and can lead to undefined behavior, if some code ever takes a pointer to one of the inner aggregates and expects it to be aligned. The only effect that I see from the __packed annotation is that it forces expensive byte access on dma-coherent memory despite it being fully aligned. b) rework the driver more broadly to never actually do any accesses beyond a struct boundary and make it work with sanitizers enabled. One way to do this would be to have a separate isp24 atio structure that is not in the union but that encloses the actual maximum length. Not sure how this would actually be done, but it appears that the current design keeps causing problems, see e.g. 091719c21d5a ("scsi: qla2xxx: target: Fix invalid memory access with big CDBs") which adds more complexity around keeping an extra copy for it. Arnd ^ permalink raw reply [flat|nested] 10+ 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-24 10:18 ` Arnd Bergmann @ 2026-11-25 0:18 ` Finn Thain 2026-11-25 7:25 ` Arnd Bergmann 0 siblings, 1 reply; 10+ messages in thread From: Finn Thain @ 2026-11-25 0:18 UTC (permalink / raw) To: Arnd Bergmann Cc: Andrew Morton, Bart Van Assche, Geert Uytterhoeven, kernel test robot, oe-kbuild-all, linux-kernel, Linux Memory Management List, James E.J. Bottomley, Martin K. Petersen, scsi, Nilesh Javali, GR-QLogic-Storage-Upstream [Cc qla2xxx maintainers] On Tue, 24 Nov 2026, Arnd Bergmann wrote: > On Tue, Nov 24, 2026, at 04:31, Finn Thain wrote: > > On Mon, 23 Nov 2026, Bart Van Assche wrote: > > > > 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. > > I suspect that is just from Bart specifically calling it out in the > changelog already as a known limitation "Do not modify the memcpy() call > in qlt_queue_unknown_atio(), which still writes past the end of the > 'atio' member.". > OK, so Bart's LLM has made a suggestion that doesn't improve upon my patch except for contributing some modernization i.e. the preferred flex array style. I'm not sure that's appropriate for a bug fix that is to be backported. > > 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. > > This is probably just a difference in perception: atio_from_isp and > everything inside is clearly marked as a hardware structure that is > meant to align exactly to the 64 byte cacheline, so it would not make > any sense to change its layout and add more members here. If this driver is for x86_64 only, as you seem to be implying, then the right fix for this build failure would seem to be Kconfig: --- a/drivers/scsi/qla2xxx/Kconfig +++ b/drivers/scsi/qla2xxx/Kconfig @@ -29,6 +29,7 @@ config SCSI_QLA_FC config TCM_QLA2XXX tristate "TCM_QLA2XXX fabric module for QLogic 24xx+ series target mode HBAs" + depends on X86_64 depends on SCSI_QLA_FC && TARGET_CORE depends on LIBFC select BTREE I wonder whether the driver maintainers would like to comment on this possibility. > qla_tgt_sess_op on the other hand is clearly not a hardware structure > but an in-kernel one so it is quite unexpected that one of its members > extends past the end, especially when the other three instances of > atio_from_isp in data structures don't seem to do that. > > >> @@ -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; > > While this does make the current implementation more correct by having > the correct length, I'm worried that it just ends up establishing > the complexity more in the sense that extra_cdb extends both into > the padding and beyond qla_tgt_sess_op. > > If the driver is still actively maintained, it would be nice to > reduce the complexity instead, in one of two ways: > > a) make atio_from_isp naturally aligned by dropping the bogus > __packed attribute, I don't think I follow. "Natural" alignment would be at integer multiples of the struct size, right? Moreover, the correct alignment for a hardware struct is a question for the hardware vendor, isn't it? > so it is actually at the end of qla_tgt_sess_op > as the driver was written to expect. FWIW, I think __packed on a hardware struct is at least as desirable as portable drivers are. If the host ABI places padding after the hardware struct, that's a non-issue -- unless, of course, there is a bogus BUILD_BUG_ON that trips over the padding, which is exactly the bogosity causing the issue. > Note that having the > outer structure as __packed but the union and the inner > structs as aligned is itself problematic and can lead to > undefined behavior, if some code ever takes a pointer to > one of the inner aggregates and expects it to be aligned. > The only effect that I see from the __packed annotation is > that it forces expensive byte access on dma-coherent memory > despite it being fully aligned. > > b) rework the driver more broadly to never actually do any > accesses beyond a struct boundary and make it work with > sanitizers enabled. One way to do this would be to > have a separate isp24 atio structure that is not in the > union but that encloses the actual maximum length. > Not sure how this would actually be done, but it appears > that the current design keeps causing problems, see e.g. > 091719c21d5a ("scsi: qla2xxx: target: Fix invalid memory > access with big CDBs") which adds more complexity around > keeping an extra copy for it. > It's not clear to me that UBSAN and FORTIFY can actually do what this static_assert() does. Maybe that's another "difference in perception". I agree that sanitizers are worthwhile but I fear that this horse has already bolted. Surely worth considering for new code though. ^ permalink raw reply [flat|nested] 10+ 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-25 0:18 ` Finn Thain @ 2026-11-25 7:25 ` Arnd Bergmann 2026-11-25 8:53 ` Finn Thain 0 siblings, 1 reply; 10+ messages in thread From: Arnd Bergmann @ 2026-11-25 7:25 UTC (permalink / raw) To: Finn Thain Cc: Andrew Morton, Bart Van Assche, Geert Uytterhoeven, kernel test robot, oe-kbuild-all, linux-kernel, Linux Memory Management List, James E . J . Bottomley, Martin K. Petersen, scsi, Nilesh Javali, GR-QLogic-Storage-Upstream On Wed, Nov 25, 2026, at 01:18, Finn Thain wrote: > [Cc qla2xxx maintainers] > On Tue, 24 Nov 2026, Arnd Bergmann wrote: >> On Tue, Nov 24, 2026, at 04:31, Finn Thain wrote: >> > On Mon, 23 Nov 2026, Bart Van Assche wrote: >> > 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. >> >> This is probably just a difference in perception: atio_from_isp and >> everything inside is clearly marked as a hardware structure that is >> meant to align exactly to the 64 byte cacheline, so it would not make >> any sense to change its layout and add more members here. > > If this driver is for x86_64 only, as you seem to be implying, then the > right fix for this build failure would seem to be Kconfig: > I did not say or imply that. >> qla_tgt_sess_op on the other hand is clearly not a hardware structure >> but an in-kernel one so it is quite unexpected that one of its members >> extends past the end, especially when the other three instances of >> atio_from_isp in data structures don't seem to do that. >> >> >> @@ -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; >> >> While this does make the current implementation more correct by having >> the correct length, I'm worried that it just ends up establishing >> the complexity more in the sense that extra_cdb extends both into >> the padding and beyond qla_tgt_sess_op. >> >> If the driver is still actively maintained, it would be nice to >> reduce the complexity instead, in one of two ways: >> >> a) make atio_from_isp naturally aligned by dropping the bogus >> __packed attribute, > > I don't think I follow. "Natural" alignment would be at integer multiples > of the struct size, right? Moreover, the correct alignment for a hardware > struct is a question for the hardware vendor, isn't it? I should have been clearer here, I meant having it aligned to the highest alignment of any of its members, in this case alignof(u64), which would avoid both the warning and the slow byte-at-a-time access. >> so it is actually at the end of qla_tgt_sess_op >> as the driver was written to expect. > > FWIW, I think __packed on a hardware struct is at least as desirable as > portable drivers are. I can certainly see an argument for marking the inner structures "__packed __aligned(8)" or similar, to ensure that the members are tightly packed but can still be accessed worth multi-byte load/store instructures. The way the __packed it written on the outer struct, it only causes problems but does not actually enforce packing of the inner struct. Arnd ^ permalink raw reply [flat|nested] 10+ 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-25 7:25 ` Arnd Bergmann @ 2026-11-25 8:53 ` Finn Thain 0 siblings, 0 replies; 10+ messages in thread From: Finn Thain @ 2026-11-25 8:53 UTC (permalink / raw) To: Arnd Bergmann Cc: Andrew Morton, Bart Van Assche, Geert Uytterhoeven, kernel test robot, oe-kbuild-all, linux-kernel, Linux Memory Management List, James E . J . Bottomley, Martin K. Petersen, scsi, Nilesh Javali, GR-QLogic-Storage-Upstream On Wed, 25 Nov 2026, Arnd Bergmann wrote: > >> >> @@ -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; > >> > >> While this does make the current implementation more correct by having > >> the correct length, I'm worried that it just ends up establishing > >> the complexity more in the sense that extra_cdb extends both into > >> the padding and beyond qla_tgt_sess_op. > >> > >> If the driver is still actively maintained, it would be nice to > >> reduce the complexity instead, in one of two ways: > >> > >> a) make atio_from_isp naturally aligned by dropping the bogus > >> __packed attribute, > > > > I don't think I follow. "Natural" alignment would be at integer multiples > > of the struct size, right? Moreover, the correct alignment for a hardware > > struct is a question for the hardware vendor, isn't it? > > I should have been clearer here, I meant having it aligned to the > highest alignment of any of its members, in this case alignof(u64), > which would avoid both the warning and the slow byte-at-a-time access. > > >> so it is actually at the end of qla_tgt_sess_op > >> as the driver was written to expect. > > > > FWIW, I think __packed on a hardware struct is at least as desirable as > > portable drivers are. > > I can certainly see an argument for marking the inner structures > "__packed __aligned(8)" or similar, to ensure that the members are > tightly packed but can still be accessed worth multi-byte load/store > instructures. > > The way the __packed it written on the outer struct, it only causes > problems but does not actually enforce packing of the inner struct. > Perhaps there is a way to alter the struct layouts in a portable way (so as to avoid the build failure) but it's simply not worth it. There is no actual bug here, that affects actual users, to justify the churn, or the complexity, or the regression testing effort, or the fruitless discussion to-date. If there was a maintainer who cared about this issue, perhaps that would put a different light on it. Maybe. As I pointed out in March, there is already a comment in the driver to make the bogus BUILD_BUG_ON() effectively redundant. So, at some point in the future, when I can get interested again, I will re-send the same untested yet risk-free patch that I sent back in March, to remove it. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-11-25 8:53 UTC | newest] Thread overview: 10+ 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 2026-11-24 10:18 ` Arnd Bergmann 2026-11-25 0:18 ` Finn Thain 2026-11-25 7:25 ` Arnd Bergmann 2026-11-25 8:53 ` 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®