* [PATCH] scsi: qedf: Use designated initializer for struct qed_fcoe_cb_ops
@ 2025-05-02 22:41 Kees Cook
2025-05-06 2:18 ` Martin K. Petersen
2025-05-07 20:22 ` Nathan Chancellor
0 siblings, 2 replies; 3+ messages in thread
From: Kees Cook @ 2025-05-02 22:41 UTC (permalink / raw)
To: Saurav Kashyap
Cc: Kees Cook, Javed Hasan, GR-QLogic-Storage-Upstream,
James E.J. Bottomley, Martin K. Petersen, linux-scsi, WangYuli,
Mark Brown, Dr. David Alan Gilbert, linux-kernel, linux-hardening
Recent fixes to the randstruct GCC plugin allowed it to notice
that this structure is entirely function pointers and is therefore
subject to randomization, but doing so requires that it always use
designated initializers. Explicitly specify the "common" member as being
initialized. Silences:
drivers/scsi/qedf/qedf_main.c:702:9: error: positional initialization of field in 'struct' declared with 'designated_init' attribute [-Werror=designated-init]
702 | {
| ^
Fixes: c2ea09b193d2 ("randstruct: gcc-plugin: Remove bogus void member")
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Saurav Kashyap <skashyap@marvell.com>
Cc: Javed Hasan <jhasan@marvell.com>
Cc: <GR-QLogic-Storage-Upstream@marvell.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: <linux-scsi@vger.kernel.org>
---
drivers/scsi/qedf/qedf_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 436bd29d5eba..6b1ebab36fa3 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -699,7 +699,7 @@ static u32 qedf_get_login_failures(void *cookie)
}
static struct qed_fcoe_cb_ops qedf_cb_ops = {
- {
+ .common = {
.link_update = qedf_link_update,
.bw_update = qedf_bw_update,
.schedule_recovery_handler = qedf_schedule_recovery_handler,
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: qedf: Use designated initializer for struct qed_fcoe_cb_ops
2025-05-02 22:41 [PATCH] scsi: qedf: Use designated initializer for struct qed_fcoe_cb_ops Kees Cook
@ 2025-05-06 2:18 ` Martin K. Petersen
2025-05-07 20:22 ` Nathan Chancellor
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2025-05-06 2:18 UTC (permalink / raw)
To: Kees Cook
Cc: Saurav Kashyap, Javed Hasan, GR-QLogic-Storage-Upstream,
James E.J. Bottomley, Martin K. Petersen, linux-scsi, WangYuli,
Mark Brown, Dr. David Alan Gilbert, linux-kernel, linux-hardening
Kees,
> Recent fixes to the randstruct GCC plugin allowed it to notice that
> this structure is entirely function pointers and is therefore subject
> to randomization, but doing so requires that it always use designated
> initializers. Explicitly specify the "common" member as being
> initialized.
Applied to 6.16/scsi-staging, thanks!
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: qedf: Use designated initializer for struct qed_fcoe_cb_ops
2025-05-02 22:41 [PATCH] scsi: qedf: Use designated initializer for struct qed_fcoe_cb_ops Kees Cook
2025-05-06 2:18 ` Martin K. Petersen
@ 2025-05-07 20:22 ` Nathan Chancellor
1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2025-05-07 20:22 UTC (permalink / raw)
To: Kees Cook
Cc: Saurav Kashyap, Javed Hasan, GR-QLogic-Storage-Upstream,
James E.J. Bottomley, Martin K. Petersen, linux-scsi, WangYuli,
Mark Brown, Dr. David Alan Gilbert, linux-kernel, linux-hardening
On Fri, May 02, 2025 at 03:41:57PM -0700, Kees Cook wrote:
> Recent fixes to the randstruct GCC plugin allowed it to notice
> that this structure is entirely function pointers and is therefore
> subject to randomization, but doing so requires that it always use
> designated initializers. Explicitly specify the "common" member as being
> initialized. Silences:
>
> drivers/scsi/qedf/qedf_main.c:702:9: error: positional initialization of field in 'struct' declared with 'designated_init' attribute [-Werror=designated-init]
> 702 | {
> | ^
>
> Fixes: c2ea09b193d2 ("randstruct: gcc-plugin: Remove bogus void member")
For the record, this is also needed after your recent change to clang to
do the same thing as the plugin:
drivers/scsi/qedf/qedf_main.c:702:2: error: a randomized struct can only be initialized with a designated initializer
702 | {
| ^
so this should probably have
Cc: stable@vger.kernel.org
Fixes: 035f7f87b729 ("randstruct: Enable Clang support")
> Signed-off-by: Kees Cook <kees@kernel.org>
> ---
> Cc: Saurav Kashyap <skashyap@marvell.com>
> Cc: Javed Hasan <jhasan@marvell.com>
> Cc: <GR-QLogic-Storage-Upstream@marvell.com>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: <linux-scsi@vger.kernel.org>
> ---
> drivers/scsi/qedf/qedf_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
> index 436bd29d5eba..6b1ebab36fa3 100644
> --- a/drivers/scsi/qedf/qedf_main.c
> +++ b/drivers/scsi/qedf/qedf_main.c
> @@ -699,7 +699,7 @@ static u32 qedf_get_login_failures(void *cookie)
> }
>
> static struct qed_fcoe_cb_ops qedf_cb_ops = {
> - {
> + .common = {
> .link_update = qedf_link_update,
> .bw_update = qedf_bw_update,
> .schedule_recovery_handler = qedf_schedule_recovery_handler,
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-07 20:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-02 22:41 [PATCH] scsi: qedf: Use designated initializer for struct qed_fcoe_cb_ops Kees Cook
2025-05-06 2:18 ` Martin K. Petersen
2025-05-07 20:22 ` Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox