]> git.hungrycats.org Git - linux/commitdiff
net ax25: Fix signed comparison in the sockopt handler
authorArjan van de Ven <arjan@linux.intel.com>
Wed, 30 Sep 2009 11:51:11 +0000 (13:51 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 5 Oct 2009 15:27:59 +0000 (08:27 -0700)
fixed upstream in commit b7058842c940ad2c08dd829b21e5c92ebe3b8758 in a different way

The ax25 code tried to use

        if (optlen < sizeof(int))
                return -EINVAL;

as a security check against optlen being negative (or zero) in the
set socket option.

Unfortunately, "sizeof(int)" is an unsigned property, with the
result that the whole comparison is done in unsigned, letting
negative values slip through.

This patch changes this to

        if (optlen < (int)sizeof(int))
                return -EINVAL;

so that the comparison is done as signed, and negative values
get properly caught.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/ax25/af_ax25.c

index fd9d06f291dc31f4bb0d108f85d3eff51ead0e3f..e7af49de4c8840b743208a10ff04e0e83ad6ed8a 100644 (file)
@@ -539,7 +539,7 @@ static int ax25_setsockopt(struct socket *sock, int level, int optname,
        if (level != SOL_AX25)
                return -ENOPROTOOPT;
 
-       if (optlen < sizeof(int))
+       if (optlen < (int)sizeof(int))
                return -EINVAL;
 
        if (get_user(opt, (int __user *)optval))