* [PATCH] scpt: Allow struct sctp_event_subscribe to grow without breaking binaries
@ 2012-04-04 8:17 Thomas Graf
2012-04-04 13:52 ` Vladislav Yasevich
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Graf @ 2012-04-04 8:17 UTC (permalink / raw)
To: davem; +Cc: vladislav.yasevich, linux-sctp, netdev
getsockopt(..., SCTP_EVENTS, ...) performs a length check and returns
an error if the user provides less bytes than the size of struct
sctp_event_subscribe.
Struct sctp_event_subscribe needs to be extended by an u8 for every
new event or notification type that is added.
This obviously makes getsockopt fail for binaries that are compiled
against an older versions of <net/sctp/user.h> which do not contain
all event types.
This patch changes getsockopt behaviour to no longer return an error
if not enough bytes are being provided by the user. Instead, it
returns as much of sctp_event_subscribe as fits into the provided buffer.
This leads to the new behavior that users see what they have been aware
of at compile time.
The setsockopt(..., SCTP_EVENTS, ...) API is already behaving like this.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
---
net/sctp/socket.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 06b42b7..92ba71d 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4133,9 +4133,10 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
int __user *optlen)
{
- if (len < sizeof(struct sctp_event_subscribe))
+ if (len <= 0)
return -EINVAL;
- len = sizeof(struct sctp_event_subscribe);
+ if (len > sizeof(struct sctp_event_subscribe))
+ len = sizeof(struct sctp_event_subscribe);
if (put_user(len, optlen))
return -EFAULT;
if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] scpt: Allow struct sctp_event_subscribe to grow without breaking binaries
2012-04-04 8:17 [PATCH] scpt: Allow struct sctp_event_subscribe to grow without breaking binaries Thomas Graf
@ 2012-04-04 13:52 ` Vladislav Yasevich
2012-04-04 22:05 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Vladislav Yasevich @ 2012-04-04 13:52 UTC (permalink / raw)
To: davem, linux-sctp, netdev
On 04/04/2012 04:17 AM, Thomas Graf wrote:
> getsockopt(..., SCTP_EVENTS, ...) performs a length check and returns
> an error if the user provides less bytes than the size of struct
> sctp_event_subscribe.
>
> Struct sctp_event_subscribe needs to be extended by an u8 for every
> new event or notification type that is added.
>
> This obviously makes getsockopt fail for binaries that are compiled
> against an older versions of <net/sctp/user.h> which do not contain
> all event types.
>
> This patch changes getsockopt behaviour to no longer return an error
> if not enough bytes are being provided by the user. Instead, it
> returns as much of sctp_event_subscribe as fits into the provided buffer.
>
> This leads to the new behavior that users see what they have been aware
> of at compile time.
>
> The setsockopt(..., SCTP_EVENTS, ...) API is already behaving like this.
>
> Signed-off-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Vlad Yasevich <vladislav.yasevich@hp.com>
-vlad
> ---
> net/sctp/socket.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 06b42b7..92ba71d 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -4133,9 +4133,10 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
> static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
> int __user *optlen)
> {
> - if (len < sizeof(struct sctp_event_subscribe))
> + if (len <= 0)
> return -EINVAL;
> - len = sizeof(struct sctp_event_subscribe);
> + if (len > sizeof(struct sctp_event_subscribe))
> + len = sizeof(struct sctp_event_subscribe);
> if (put_user(len, optlen))
> return -EFAULT;
> if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scpt: Allow struct sctp_event_subscribe to grow without breaking binaries
2012-04-04 13:52 ` Vladislav Yasevich
@ 2012-04-04 22:05 ` David Miller
2012-04-04 22:13 ` Thomas Graf
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2012-04-04 22:05 UTC (permalink / raw)
To: vladislav.yasevich; +Cc: linux-sctp, netdev
From: Vladislav Yasevich <vladislav.yasevich@hp.com>
Date: Wed, 04 Apr 2012 09:52:04 -0400
> On 04/04/2012 04:17 AM, Thomas Graf wrote:
>> getsockopt(..., SCTP_EVENTS, ...) performs a length check and returns
>> an error if the user provides less bytes than the size of struct
>> sctp_event_subscribe.
>>
>> Struct sctp_event_subscribe needs to be extended by an u8 for every
>> new event or notification type that is added.
>>
>> This obviously makes getsockopt fail for binaries that are compiled
>> against an older versions of <net/sctp/user.h> which do not contain
>> all event types.
>>
>> This patch changes getsockopt behaviour to no longer return an error
>> if not enough bytes are being provided by the user. Instead, it
>> returns as much of sctp_event_subscribe as fits into the provided buffer.
>>
>> This leads to the new behavior that users see what they have been aware
>> of at compile time.
>>
>> The setsockopt(..., SCTP_EVENTS, ...) API is already behaving like this.
>>
>> Signed-off-by: Thomas Graf <tgraf@suug.ch>
>
> Acked-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Applied, but I had to fix the Subject to read "sctp: " not "scpt: " :-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scpt: Allow struct sctp_event_subscribe to grow without breaking binaries
2012-04-04 22:05 ` David Miller
@ 2012-04-04 22:13 ` Thomas Graf
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Graf @ 2012-04-04 22:13 UTC (permalink / raw)
To: David Miller; +Cc: vladislav.yasevich, linux-sctp, netdev
On Wed, Apr 04, 2012 at 06:05:52PM -0400, David Miller wrote:
> From: Vladislav Yasevich <vladislav.yasevich@hp.com>
> Date: Wed, 04 Apr 2012 09:52:04 -0400
> >
> > Acked-by: Vlad Yasevich <vladislav.yasevich@hp.com>
>
> Applied, but I had to fix the Subject to read "sctp: " not "scpt: " :-)
Thanks much Dave :)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-04-04 22:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-04 8:17 [PATCH] scpt: Allow struct sctp_event_subscribe to grow without breaking binaries Thomas Graf
2012-04-04 13:52 ` Vladislav Yasevich
2012-04-04 22:05 ` David Miller
2012-04-04 22:13 ` Thomas Graf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).