From: Vlad Yasevich <vladislav.yasevich@hp.com>
To: Eugene Teo <eteo@redhat.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
linux-sctp@vger.kernel.org, security@kernel.org
Subject: Re: [PATCH] sctp: add verification checks to SCTP_AUTH_KEY option
Date: Tue, 26 Aug 2008 01:24:41 +0000 [thread overview]
Message-ID: <48B35B59.2020208@hp.com> (raw)
In-Reply-To: <48B35561.2010001@redhat.com>
Eugene Teo wrote:
> Vlad Yasevich wrote:
>> The structure used for SCTP_AUTH_KEY option contains a
>> length that needs to be verfied to prevent buffer overflow
>> conditions. Spoted by Eugene Teo <eteo@redhat.com>.
>>
>> Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
>> ---
>> net/sctp/auth.c | 4 ++++
>> net/sctp/socket.c | 5 +++++
>> 2 files changed, 9 insertions(+), 0 deletions(-)
>>
>> diff --git a/net/sctp/auth.c b/net/sctp/auth.c
>> index 675a5c3..1fcb4cf 100644
>> --- a/net/sctp/auth.c
>> +++ b/net/sctp/auth.c
>> @@ -80,6 +80,10 @@ static struct sctp_auth_bytes *sctp_auth_create_key(__u32 key_len, gfp_t gfp)
>
> This should be __u16 key_len.
>
>> {
>> struct sctp_auth_bytes *key;
>>
>> + /* Verify that we are not going to overflow INT_MAX */
>> + if ((INT_MAX - key_len) < sizeof(struct sctp_auth_bytes))
>> + return NULL;
>
> Shouldn't this be UINT_MAX? But then if you are going to change
> sctp_auth_create_key() to accept __u16 key_len, then it should be
> USHORT_MAX.
>
I'd rather keep it a u32 since this function is not only for userspace,
but for creating a generated key.
Yes, UINT_MAX makes more sense.
>> /* Allocate the shared key */
>> key = kmalloc(sizeof(struct sctp_auth_bytes) + key_len, gfp);
>> if (!key)
>> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
>> index bb5c9ef..afa952e 100644
>> --- a/net/sctp/socket.c
>> +++ b/net/sctp/socket.c
>> @@ -3144,6 +3144,11 @@ static int sctp_setsockopt_auth_key(struct sock *sk,
>> goto out;
>> }
>>
>> + if (authkey->sca_keylength > optlen) {
>> + ret = -EINVAL;
>> + goto out;
>
> Is there a better upper bound check?
Hm... optlen - sizeof(struct sctp_authkey) is more accurate.
There is really no other bound.
-vlad
>
>> asoc = sctp_id2assoc(sk, authkey->sca_assoc_id);
>> if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) {
>> ret = -EINVAL;
>
> Thanks,
> Eugene
>
WARNING: multiple messages have this Message-ID (diff)
From: Vlad Yasevich <vladislav.yasevich@hp.com>
To: Eugene Teo <eteo@redhat.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
linux-sctp@vger.kernel.org, security@kernel.org
Subject: Re: [PATCH] sctp: add verification checks to SCTP_AUTH_KEY option
Date: Mon, 25 Aug 2008 21:24:41 -0400 [thread overview]
Message-ID: <48B35B59.2020208@hp.com> (raw)
In-Reply-To: <48B35561.2010001@redhat.com>
Eugene Teo wrote:
> Vlad Yasevich wrote:
>> The structure used for SCTP_AUTH_KEY option contains a
>> length that needs to be verfied to prevent buffer overflow
>> conditions. Spoted by Eugene Teo <eteo@redhat.com>.
>>
>> Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
>> ---
>> net/sctp/auth.c | 4 ++++
>> net/sctp/socket.c | 5 +++++
>> 2 files changed, 9 insertions(+), 0 deletions(-)
>>
>> diff --git a/net/sctp/auth.c b/net/sctp/auth.c
>> index 675a5c3..1fcb4cf 100644
>> --- a/net/sctp/auth.c
>> +++ b/net/sctp/auth.c
>> @@ -80,6 +80,10 @@ static struct sctp_auth_bytes *sctp_auth_create_key(__u32 key_len, gfp_t gfp)
>
> This should be __u16 key_len.
>
>> {
>> struct sctp_auth_bytes *key;
>>
>> + /* Verify that we are not going to overflow INT_MAX */
>> + if ((INT_MAX - key_len) < sizeof(struct sctp_auth_bytes))
>> + return NULL;
>
> Shouldn't this be UINT_MAX? But then if you are going to change
> sctp_auth_create_key() to accept __u16 key_len, then it should be
> USHORT_MAX.
>
I'd rather keep it a u32 since this function is not only for userspace,
but for creating a generated key.
Yes, UINT_MAX makes more sense.
>> /* Allocate the shared key */
>> key = kmalloc(sizeof(struct sctp_auth_bytes) + key_len, gfp);
>> if (!key)
>> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
>> index bb5c9ef..afa952e 100644
>> --- a/net/sctp/socket.c
>> +++ b/net/sctp/socket.c
>> @@ -3144,6 +3144,11 @@ static int sctp_setsockopt_auth_key(struct sock *sk,
>> goto out;
>> }
>>
>> + if (authkey->sca_keylength > optlen) {
>> + ret = -EINVAL;
>> + goto out;
>
> Is there a better upper bound check?
Hm... optlen - sizeof(struct sctp_authkey) is more accurate.
There is really no other bound.
-vlad
>
>> asoc = sctp_id2assoc(sk, authkey->sca_assoc_id);
>> if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) {
>> ret = -EINVAL;
>
> Thanks,
> Eugene
>
next prev parent reply other threads:[~2008-08-26 1:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080825164440.GA504@kernel.sg>
2008-08-25 20:25 ` [PATCH] sctp: add verification checks to SCTP_AUTH_KEY option Vlad Yasevich
2008-08-25 20:25 ` Vlad Yasevich
2008-08-25 22:17 ` David Miller
2008-08-25 22:17 ` David Miller
2008-08-26 0:59 ` Eugene Teo
2008-08-26 0:59 ` Eugene Teo
2008-08-26 1:19 ` [Security] [PATCH] sctp: add verification checks to SCTP_AUTH_KEY Linus Torvalds
2008-08-26 1:19 ` [Security] [PATCH] sctp: add verification checks to SCTP_AUTH_KEY option Linus Torvalds
2008-08-26 1:28 ` [Security] [PATCH] sctp: add verification checks to SCTP_AUTH_KEY Linus Torvalds
2008-08-26 1:28 ` [Security] [PATCH] sctp: add verification checks to SCTP_AUTH_KEY option Linus Torvalds
2008-08-26 1:24 ` Vlad Yasevich [this message]
2008-08-26 1:24 ` Vlad Yasevich
2008-08-26 3:01 ` Eugene Teo
2008-08-26 3:01 ` Eugene Teo
2008-08-26 13:37 ` Vlad Yasevich
2008-08-26 13:37 ` Vlad Yasevich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48B35B59.2020208@hp.com \
--to=vladislav.yasevich@hp.com \
--cc=davem@davemloft.net \
--cc=eteo@redhat.com \
--cc=linux-sctp@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=security@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.