linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] scsi/bfa: use designated initializers
@ 2017-04-20 22:00 Kees Cook
  2017-04-21  5:34 ` Christoph Hellwig
  2017-04-21 14:13 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Kees Cook @ 2017-04-20 22:00 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Anil Gurumurthy, Sudarsana Kalluru, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, linux-kernel

Prepare to mark sensitive kernel structures for randomization by making
sure they're using designated initializers. This also initializes the
array members using the enum used to look up __port_action entries.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
v3:
- drop bfa_module_s changes, since that has been removed entirely; hch.
- init array with enum literals; hch.
---
 drivers/scsi/bfa/bfa_fcs_lport.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
index 4ddda72f60e6..638c0a2857f7 100644
--- a/drivers/scsi/bfa/bfa_fcs_lport.c
+++ b/drivers/scsi/bfa/bfa_fcs_lport.c
@@ -89,16 +89,27 @@ static struct {
 	void		(*online) (struct bfa_fcs_lport_s *port);
 	void		(*offline) (struct bfa_fcs_lport_s *port);
 } __port_action[] = {
-	{
-	bfa_fcs_lport_unknown_init, bfa_fcs_lport_unknown_online,
-			bfa_fcs_lport_unknown_offline}, {
-	bfa_fcs_lport_fab_init, bfa_fcs_lport_fab_online,
-			bfa_fcs_lport_fab_offline}, {
-	bfa_fcs_lport_n2n_init, bfa_fcs_lport_n2n_online,
-			bfa_fcs_lport_n2n_offline}, {
-	bfa_fcs_lport_loop_init, bfa_fcs_lport_loop_online,
-			bfa_fcs_lport_loop_offline},
-	};
+	[BFA_FCS_FABRIC_UNKNOWN] = {
+		.init = bfa_fcs_lport_unknown_init,
+		.online = bfa_fcs_lport_unknown_online,
+		.offline = bfa_fcs_lport_unknown_offline
+	},
+	[BFA_FCS_FABRIC_SWITCHED] = {
+		.init = bfa_fcs_lport_fab_init,
+		.online = bfa_fcs_lport_fab_online,
+		.offline = bfa_fcs_lport_fab_offline
+	},
+	[BFA_FCS_FABRIC_N2N] = {
+		.init = bfa_fcs_lport_n2n_init,
+		.online = bfa_fcs_lport_n2n_online,
+		.offline = bfa_fcs_lport_n2n_offline
+	},
+	[BFA_FCS_FABRIC_LOOP] = {
+		.init = bfa_fcs_lport_loop_init,
+		.online = bfa_fcs_lport_loop_online,
+		.offline = bfa_fcs_lport_loop_offline
+	},
+};
 
 /*
  *  fcs_port_sm FCS logical port state machine
-- 
2.7.4


-- 
Kees Cook
Pixel Security

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

* Re: [PATCH v3] scsi/bfa: use designated initializers
  2017-04-20 22:00 [PATCH v3] scsi/bfa: use designated initializers Kees Cook
@ 2017-04-21  5:34 ` Christoph Hellwig
  2017-04-21 14:13 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2017-04-21  5:34 UTC (permalink / raw)
  To: Kees Cook
  Cc: Christoph Hellwig, Anil Gurumurthy, Sudarsana Kalluru,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	linux-kernel

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3] scsi/bfa: use designated initializers
  2017-04-20 22:00 [PATCH v3] scsi/bfa: use designated initializers Kees Cook
  2017-04-21  5:34 ` Christoph Hellwig
@ 2017-04-21 14:13 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2017-04-21 14:13 UTC (permalink / raw)
  To: Kees Cook
  Cc: Christoph Hellwig, Anil Gurumurthy, Sudarsana Kalluru,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	linux-kernel

Kees Cook <keescook@chromium.org> writes:

Kees,

> Prepare to mark sensitive kernel structures for randomization by
> making sure they're using designated initializers. This also
> initializes the array members using the enum used to look up
> __port_action entries.

Applied to 4.12/scsi-queue.

Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2017-04-21 14:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-20 22:00 [PATCH v3] scsi/bfa: use designated initializers Kees Cook
2017-04-21  5:34 ` Christoph Hellwig
2017-04-21 14:13 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).