[lkml]   [2009]   [Oct]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[071/136] net ax25: Fix signed comparison in the sockopt handler

2.6.31-stable review patch. If anyone has any objections, please let us know.

From: Arjan van de Ven <>

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 <>
Cc: David S. Miller <>
Cc: Ingo Molnar <>
Cc: Linus Torvalds <>
Signed-off-by: Greg Kroah-Hartman <>

net/ax25/af_ax25.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -538,7 +538,7 @@ static int ax25_setsockopt(struct socket
if (level != SOL_AX25)

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

if (get_user(opt, (int __user *)optval))

 \ /
  Last update: 2009-10-02 03:53    [W:0.292 / U:3.644 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site