]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
sctp: correct bounds check in sctp_setsockopt_auth_key
authorVlad Yasevich <vladislav.yasevich@hp.com>
Wed, 3 Sep 2008 08:02:19 +0000 (01:02 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 8 Sep 2008 10:20:21 +0000 (03:20 -0700)
[ Upstream commit 328fc47ea0bcc27d9afa69c3ad6e52431cadd76c ]

The bonds check to prevent buffer overlflow was not exactly
right.  It still allowed overflow of up to 8 bytes which is
sizeof(struct sctp_authkey).

Since optlen is already checked against the size of that struct,
we are guaranteed not to cause interger overflow either.

Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/sctp/socket.c

index d9373c358ab2d8844b490f890c7a85eab9f0e500..05185c772d25d86c219689c9bc05086e04261be8 100644 (file)
@@ -3072,7 +3072,7 @@ static int sctp_setsockopt_auth_key(struct sock *sk,
                goto out;
        }
 
-       if (authkey->sca_keylength > optlen) {
+       if (authkey->sca_keylength > optlen - sizeof(struct sctp_authkey)) {
                ret = -EINVAL;
                goto out;
        }