diff mbox

[Trusty,SRU] ipc: fix compat msgrcv with negative msgtyp

Message ID 1416514953-11465-1-git-send-email-tim.gardner@canonical.com
State New
Headers show

Commit Message

Tim Gardner Nov. 20, 2014, 8:22 p.m. UTC
From: Mateusz Guzik <mguzik@redhat.com>

BugLink: http://bugs.launchpad.net/bugs/1393355

Compat function takes msgtyp argument as u32 and passes it down to
do_msgrcv which results in casting to long, thus the sign is lost and we
get a big positive number instead.

Cast the argument to signed type before passing it down.

Signed-off-by: Mateusz Guzik <mguzik@redhat.com>
Reported-by: Gabriellla Schmidt <gsc@bruker.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Davidlohr Bueso <davidlohr@hp.com>
Cc: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit e7ca2552369c1dfe0216c626baf82c3d83ec36bb)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 ipc/compat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Seth Forshee Nov. 20, 2014, 8:36 p.m. UTC | #1

Chris J Arges Nov. 20, 2014, 9 p.m. UTC | #2
On 11/20/2014 02:22 PM, tim.gardner@canonical.com wrote:
> From: Mateusz Guzik <mguzik@redhat.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1393355
> 
> Compat function takes msgtyp argument as u32 and passes it down to
> do_msgrcv which results in casting to long, thus the sign is lost and we
> get a big positive number instead.
> 
> Cast the argument to signed type before passing it down.
> 
> Signed-off-by: Mateusz Guzik <mguzik@redhat.com>
> Reported-by: Gabriellla Schmidt <gsc@bruker.de>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Davidlohr Bueso <davidlohr@hp.com>
> Cc: Manfred Spraul <manfred@colorfullife.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> (cherry picked from commit e7ca2552369c1dfe0216c626baf82c3d83ec36bb)
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
>  ipc/compat.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ipc/compat.c b/ipc/compat.c
> index 892f658..d3b3760 100644
> --- a/ipc/compat.c
> +++ b/ipc/compat.c
> @@ -381,7 +381,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,
>  			uptr = compat_ptr(ipck.msgp);
>  			fifth = ipck.msgtyp;
>  		}
> -		return do_msgrcv(first, uptr, second, fifth, third,
> +		return do_msgrcv(first, uptr, second, (s32)fifth, third,
>  				 compat_do_msg_fill);
>  	}
>  	case MSGGET:
>
Tim Gardner Nov. 20, 2014, 9:03 p.m. UTC | #3

diff mbox

Patch

diff --git a/ipc/compat.c b/ipc/compat.c
index 892f658..d3b3760 100644
--- a/ipc/compat.c
+++ b/ipc/compat.c
@@ -381,7 +381,7 @@  COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,
 			uptr = compat_ptr(ipck.msgp);
 			fifth = ipck.msgtyp;
 		}
-		return do_msgrcv(first, uptr, second, fifth, third,
+		return do_msgrcv(first, uptr, second, (s32)fifth, third,
 				 compat_do_msg_fill);
 	}
 	case MSGGET: