[lucid,2/2] floppy: don't write kernel-only members to FDRAWCMD ioctl output
diff mbox

Message ID 1399403436-21214-3-git-send-email-apw@canonical.com
State New
Headers show

Commit Message

Andy Whitcroft May 6, 2014, 7:10 p.m. UTC
From: Matthew Daley <mattd@bugfuzz.com>

Do not leak kernel-only floppy_raw_cmd structure members to userspace.
This includes the linked-list pointer and the pointer to the allocated
DMA space.

Signed-off-by: Matthew Daley <mattd@bugfuzz.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(backported from commit 2145e15e0557a01b9195d1c7199a1b92cb9be81f upstream)
CVE-2014-1738
BugLink: http://bugs.launchpad.net/bugs/1316735
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 drivers/block/floppy.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Brad Figg June 16, 2014, 4:28 p.m. UTC | #1
On 05/06/2014 12:10 PM, Andy Whitcroft wrote:
> From: Matthew Daley <mattd@bugfuzz.com>
> 
> Do not leak kernel-only floppy_raw_cmd structure members to userspace.
> This includes the linked-list pointer and the pointer to the allocated
> DMA space.
> 
> Signed-off-by: Matthew Daley <mattd@bugfuzz.com>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> 
> (backported from commit 2145e15e0557a01b9195d1c7199a1b92cb9be81f upstream)
> CVE-2014-1738
> BugLink: http://bugs.launchpad.net/bugs/1316735
> Signed-off-by: Andy Whitcroft <apw@canonical.com>
> ---
>  drivers/block/floppy.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index e0022b1..ca539c6 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c
> @@ -3162,7 +3162,10 @@ static inline int raw_cmd_copyout(int cmd, char __user *param,
>  	int ret;
>  
>  	while (ptr) {
> -		COPYOUT(*ptr);
> +		struct floppy_raw_cmd cmd = *ptr;
> +		cmd.next = NULL;
> +		cmd.kernel_data = NULL;
> +		COPYOUT(cmd);
>  		param += sizeof(struct floppy_raw_cmd);
>  		if ((ptr->flags & FD_RAW_READ) && ptr->buffer_length) {
>  			if (ptr->length >= 0
>

Patch
diff mbox

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index e0022b1..ca539c6 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3162,7 +3162,10 @@  static inline int raw_cmd_copyout(int cmd, char __user *param,
 	int ret;
 
 	while (ptr) {
-		COPYOUT(*ptr);
+		struct floppy_raw_cmd cmd = *ptr;
+		cmd.next = NULL;
+		cmd.kernel_data = NULL;
+		COPYOUT(cmd);
 		param += sizeof(struct floppy_raw_cmd);
 		if ((ptr->flags & FD_RAW_READ) && ptr->buffer_length) {
 			if (ptr->length >= 0