linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] scsi/bfa: use designated initializers
@ 2017-03-29 20:55 Kees Cook
  2017-03-30  8:18 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2017-03-29 20:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Christoph Hellwig, Anil Gurumurthy, Sudarsana Kalluru,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi

Prepare to mark sensitive kernel structures for randomization by making
sure they're using designated initializers. These were identified during
allyesconfig builds of x86, arm, and arm64, with most initializer fixes
extracted from grsecurity.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
This has been updated now that struct bfa_fcs_mod_s was dropped.
---
 drivers/scsi/bfa/bfa_fcs_lport.c | 29 ++++++++++++++++++++---------
 drivers/scsi/bfa/bfa_modules.h   | 12 ++++++------
 2 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
index 4ddda72f60e6..64860c730ec9 100644
--- a/drivers/scsi/bfa/bfa_fcs_lport.c
+++ b/drivers/scsi/bfa/bfa_fcs_lport.c
@@ -90,15 +90,26 @@ static struct {
 	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},
-	};
+		.init = bfa_fcs_lport_unknown_init,
+		.online = bfa_fcs_lport_unknown_online,
+		.offline = bfa_fcs_lport_unknown_offline
+	},
+	{
+		.init = bfa_fcs_lport_fab_init,
+		.online = bfa_fcs_lport_fab_online,
+		.offline = bfa_fcs_lport_fab_offline
+	},
+	{
+		.init = bfa_fcs_lport_n2n_init,
+		.online = bfa_fcs_lport_n2n_online,
+		.offline = bfa_fcs_lport_n2n_offline
+	},
+	{
+		.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
diff --git a/drivers/scsi/bfa/bfa_modules.h b/drivers/scsi/bfa/bfa_modules.h
index 53135f21fa0e..640621b4c3da 100644
--- a/drivers/scsi/bfa/bfa_modules.h
+++ b/drivers/scsi/bfa/bfa_modules.h
@@ -79,12 +79,12 @@ enum {
 									\
 	extern struct bfa_module_s hal_mod_ ## __mod;			\
 	struct bfa_module_s hal_mod_ ## __mod = {			\
-		bfa_ ## __mod ## _meminfo,				\
-		bfa_ ## __mod ## _attach,				\
-		bfa_ ## __mod ## _detach,				\
-		bfa_ ## __mod ## _start,				\
-		bfa_ ## __mod ## _stop,					\
-		bfa_ ## __mod ## _iocdisable,				\
+		.meminfo = bfa_ ## __mod ## _meminfo,			\
+		.attach = bfa_ ## __mod ## _attach,			\
+		.detach = bfa_ ## __mod ## _detach,			\
+		.start = bfa_ ## __mod ## _start,			\
+		.stop = bfa_ ## __mod ## _stop,				\
+		.iocdisable = bfa_ ## __mod ## _iocdisable,		\
 	}
 
 #define BFA_CACHELINE_SZ	(256)
-- 
2.7.4


-- 
Kees Cook
Pixel Security

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

* Re: [PATCH v2] scsi/bfa: use designated initializers
  2017-03-29 20:55 [PATCH v2] scsi/bfa: use designated initializers Kees Cook
@ 2017-03-30  8:18 ` Christoph Hellwig
  2017-04-13  0:21   ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2017-03-30  8:18 UTC (permalink / raw)
  To: Kees Cook
  Cc: linux-kernel, Christoph Hellwig, Anil Gurumurthy,
	Sudarsana Kalluru, James E.J. Bottomley, Martin K. Petersen,
	linux-scsi

On Wed, Mar 29, 2017 at 01:55:09PM -0700, Kees Cook wrote:
> Prepare to mark sensitive kernel structures for randomization by making
> sure they're using designated initializers. These were identified during
> allyesconfig builds of x86, arm, and arm64, with most initializer fixes
> extracted from grsecurity.
> 
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
> This has been updated now that struct bfa_fcs_mod_s was dropped.

Can you also add designated array initializers for __port_action while
you're at it?

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

* Re: [PATCH v2] scsi/bfa: use designated initializers
  2017-03-30  8:18 ` Christoph Hellwig
@ 2017-04-13  0:21   ` Kees Cook
  2017-04-13  7:08     ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2017-04-13  0:21 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: LKML, Anil Gurumurthy, Sudarsana Kalluru, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi

On Thu, Mar 30, 2017 at 1:18 AM, Christoph Hellwig <hch@lst.de> wrote:
> On Wed, Mar 29, 2017 at 01:55:09PM -0700, Kees Cook wrote:
>> Prepare to mark sensitive kernel structures for randomization by making
>> sure they're using designated initializers. These were identified during
>> allyesconfig builds of x86, arm, and arm64, with most initializer fixes
>> extracted from grsecurity.
>>
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> ---
>> This has been updated now that struct bfa_fcs_mod_s was dropped.
>
> Can you also add designated array initializers for __port_action while
> you're at it?

Hrm? This is what the patch already does. It adds them for both
__port_action and struct bfa_module_s.

-Kees

-- 
Kees Cook
Pixel Security

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

* Re: [PATCH v2] scsi/bfa: use designated initializers
  2017-04-13  0:21   ` Kees Cook
@ 2017-04-13  7:08     ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2017-04-13  7:08 UTC (permalink / raw)
  To: Kees Cook
  Cc: Christoph Hellwig, LKML, Anil Gurumurthy, Sudarsana Kalluru,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi

On Wed, Apr 12, 2017 at 05:21:20PM -0700, Kees Cook wrote:
> Hrm? This is what the patch already does. It adds them for both
> __port_action and struct bfa_module_s.

For __port_action it only uses designated initializers for the
structures in the array, not the array itself.

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

end of thread, other threads:[~2017-04-13  7:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-29 20:55 [PATCH v2] scsi/bfa: use designated initializers Kees Cook
2017-03-30  8:18 ` Christoph Hellwig
2017-04-13  0:21   ` Kees Cook
2017-04-13  7:08     ` Christoph Hellwig

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).