]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/2.6.27.36/net-ax25-fix-signed-comparison-in-the-sockopt-handler.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 2.6.27.36 / net-ax25-fix-signed-comparison-in-the-sockopt-handler.patch
CommitLineData
0294f785
GKH
1From arjan@infradead.org Thu Oct 1 11:19:55 2009
2From: Arjan van de Ven <arjan@infradead.org>
3Date: Wed, 30 Sep 2009 13:51:11 +0200
4Subject: net ax25: Fix signed comparison in the sockopt handler
5To: davem@davemloft.net
6Cc: jakub@redhat.com, security@kernel.org, torvalds@linux-foundation.org, mingo@elte.hu, stable@kernel.org
7Message-ID: <20090930135111.64240d86@infradead.org>
8
9
10From: Arjan van de Ven <arjan@linux.intel.com>
11
12fixed upstream in commit b7058842c940ad2c08dd829b21e5c92ebe3b8758 in a different way
13
14The ax25 code tried to use
15
16 if (optlen < sizeof(int))
17 return -EINVAL;
18
19as a security check against optlen being negative (or zero) in the
20set socket option.
21
22Unfortunately, "sizeof(int)" is an unsigned property, with the
23result that the whole comparison is done in unsigned, letting
24negative values slip through.
25
26This patch changes this to
27
28 if (optlen < (int)sizeof(int))
29 return -EINVAL;
30
31so that the comparison is done as signed, and negative values
32get properly caught.
33
34Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
35Cc: David S. Miller <davem@davemloft.net>
36Cc: Ingo Molnar <mingo@elte.hu>
37Cc: Linus Torvalds <torvalds@linux-foundation.org>
38Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
39
40---
41 net/ax25/af_ax25.c | 2 +-
42 1 file changed, 1 insertion(+), 1 deletion(-)
43
44--- a/net/ax25/af_ax25.c
45+++ b/net/ax25/af_ax25.c
46@@ -539,7 +539,7 @@ static int ax25_setsockopt(struct socket
47 if (level != SOL_AX25)
48 return -ENOPROTOOPT;
49
50- if (optlen < sizeof(int))
51+ if (optlen < (int)sizeof(int))
52 return -EINVAL;
53
54 if (get_user(opt, (int __user *)optval))