Skip to contentSkip to conversation

x86/floppy: use designated initializers

PATCH In review Kees Cook 3 participants 4 messages Dec 17, 2016 – Dec 20, 2016 x86

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH v2 1/1 x86/floppy: use designated initializers

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.

---
v2:
- aligned rhs of initializer, ingo

---
 arch/x86/include/asm/floppy.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
arch/x86/include/asm/floppy.h +10 -10
index 1c7eefe32502..202fe3e1fae8 100644
@@ -229,18 +229,18 @@ static struct fd_routine_l {
 	int (*_dma_setup)(char *addr, unsigned long size, int mode, int io);
 } fd_routine[] = {
 	{
-		request_dma,
-		free_dma,
-		get_dma_residue,
-		dma_mem_alloc,
-		hard_dma_setup
+		._request_dma =		request_dma,
+		._free_dma =		free_dma,
+		._get_dma_residue =	get_dma_residue,
+		._dma_mem_alloc =	dma_mem_alloc,
+		._dma_setup =		hard_dma_setup
 	},
 	{
-		vdma_request_dma,
-		vdma_nop,
-		vdma_get_dma_residue,
-		vdma_mem_alloc,
-		vdma_dma_setup
+		._request_dma =		vdma_request_dma,
+		._free_dma =		vdma_nop,
+		._get_dma_residue =	vdma_get_dma_residue,
+		._dma_mem_alloc =	vdma_mem_alloc,
+		._dma_setup =		vdma_dma_setup
 	}
 };
 
Signature · 6 lines
2.7.4


-- 
Kees Cook
Nexus Security
#1 lore raw
Quoted 33 lines · Kees Cook

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.

---
v2:
- aligned rhs of initializer, ingo

---
 arch/x86/include/asm/floppy.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
arch/x86/include/asm/floppy.h +5 -5
index 1c7eefe32502..202fe3e1fae8 100644
@@ -229,18 +229,18 @@ static struct fd_routine_l {
 	int (*_dma_setup)(char *addr, unsigned long size, int mode, int io);
 } fd_routine[] = {
 	{
-		request_dma,
-		free_dma,
-		get_dma_residue,
-		dma_mem_alloc,
-		hard_dma_setup
+		._request_dma =		request_dma,
+		._free_dma =		free_dma,
+		._get_dma_residue =	get_dma_residue,
+		._dma_mem_alloc =	dma_mem_alloc,
+		._dma_setup =		hard_dma_setup
 	},
 	{

arch/x86/include/asm/floppy.h static struct fd_routine_l { · line 243

Quoted 10 lines
arch/x86/include/asm/floppy.h +5 -5
-		vdma_request_dma,
-		vdma_nop,
-		vdma_get_dma_residue,
-		vdma_mem_alloc,
-		vdma_dma_setup
+		._request_dma =		vdma_request_dma,
+		._free_dma =		vdma_nop,
+		._get_dma_residue =	vdma_get_dma_residue,
+		._dma_mem_alloc =	vdma_mem_alloc,
+		._dma_setup =		vdma_dma_setup

That's not how we organize named initializers, we do:

		._request_dma		= vdma_request_dma,
		._free_dma		= vdma_nop,
		._get_dma_residue	= vdma_get_dma_residue,
		._dma_mem_alloc		= vdma_mem_alloc,
		._dma_setup		= vdma_dma_setup

I have fixed up the patch.

Thanks,

Ingo

author
#2 lore raw
Quoted 49 lines · Ingo Molnar
Quoted 33 lines · Kees Cook

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.

---
v2:
- aligned rhs of initializer, ingo

---
 arch/x86/include/asm/floppy.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
arch/x86/include/asm/floppy.h +5 -5
index 1c7eefe32502..202fe3e1fae8 100644
@@ -229,18 +229,18 @@ static struct fd_routine_l {
      int (*_dma_setup)(char *addr, unsigned long size, int mode, int io);
 } fd_routine[] = {
      {
-             request_dma,
-             free_dma,
-             get_dma_residue,
-             dma_mem_alloc,
-             hard_dma_setup
+             ._request_dma =         request_dma,
+             ._free_dma =            free_dma,
+             ._get_dma_residue =     get_dma_residue,
+             ._dma_mem_alloc =       dma_mem_alloc,
+             ._dma_setup =           hard_dma_setup
      },
      {

arch/x86/include/asm/floppy.h static struct fd_routine_l { · line 243

Quoted 10 lines
arch/x86/include/asm/floppy.h +5 -5
-             vdma_request_dma,
-             vdma_nop,
-             vdma_get_dma_residue,
-             vdma_mem_alloc,
-             vdma_dma_setup
+             ._request_dma =         vdma_request_dma,
+             ._free_dma =            vdma_nop,
+             ._get_dma_residue =     vdma_get_dma_residue,
+             ._dma_mem_alloc =       vdma_mem_alloc,
+             ._dma_setup =           vdma_dma_setup

That's not how we organize named initializers, we do:

Quoted 7 lines
                ._request_dma           = vdma_request_dma,
                ._free_dma              = vdma_nop,
                ._get_dma_residue       = vdma_get_dma_residue,
                ._dma_mem_alloc         = vdma_mem_alloc,
                ._dma_setup             = vdma_dma_setup

I have fixed up the patch.

Ah-ha, thanks! When I did this patch, I first went looking through the source but there didn't seem to be a consensus on where to put the "=". :P Thanks for fixing it up!

-Kees

Signature · 2 lines
Kees Cook
Nexus Security
#3 lore raw

[tip:x86/urgent] x86/floppy: Use designated initializers

In reply to Kees Cook
x86/floppy: Use designated initializers
Commit-ID:  ffc7dc8d838c6403a550021e4f28a737334d80a7
Gitweb:     http://git.kernel.org/tip/ffc7dc8d838c6403a550021e4f28a737334d80a7
Author:     Kees Cook <[email protected]>
AuthorDate: Sat, 17 Dec 2016 13:37:05 -0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sun, 18 Dec 2016 09:25:38 +0100

x86/floppy: Use designated initializers

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.

---
 arch/x86/include/asm/floppy.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
arch/x86/include/asm/floppy.h +10 -10
index 1c7eefe..7ec59ed 100644
@@ -229,18 +229,18 @@ static struct fd_routine_l {
 	int (*_dma_setup)(char *addr, unsigned long size, int mode, int io);
 } fd_routine[] = {
 	{
-		request_dma,
-		free_dma,
-		get_dma_residue,
-		dma_mem_alloc,
-		hard_dma_setup
+		._request_dma		= request_dma,
+		._free_dma		= free_dma,
+		._get_dma_residue	= get_dma_residue,
+		._dma_mem_alloc		= dma_mem_alloc,
+		._dma_setup		= hard_dma_setup
 	},
 	{
-		vdma_request_dma,
-		vdma_nop,
-		vdma_get_dma_residue,
-		vdma_mem_alloc,
-		vdma_dma_setup
+		._request_dma		= vdma_request_dma,
+		._free_dma		= vdma_nop,
+		._get_dma_residue	= vdma_get_dma_residue,
+		._dma_mem_alloc		= vdma_mem_alloc,
+		._dma_setup		= vdma_dma_setup
 	}
 };