aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp
diff options
context:
space:
mode:
authorThomas Graf <tgraf@infradead.org>2012-04-03 18:17:53 -0400
committerLuis Henriques <luis.henriques@canonical.com>2012-05-01 06:00:20 -0400
commit6a3d063452ad569178bc7ba914d373e0233ea412 (patch)
treedcdf560ad56e067753068ccd6bbb1145e65c9a0e /net/sctp
parent09fe45f3350270f0a7418d714f25c584de490ffc (diff)
sctp: Allow struct sctp_event_subscribe to grow without breaking binaries
BugLink: http://bugs.launchpad.net/bugs/990544 [ Upstream commit acdd5985364f8dc511a0762fab2e683f29d9d692 ] 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> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Diffstat (limited to 'net/sctp')
-rw-r--r--net/sctp/socket.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index fa9b5c7739a..4434853a9fe 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4009,9 +4009,10 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
4009static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval, 4009static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
4010 int __user *optlen) 4010 int __user *optlen)
4011{ 4011{
4012 if (len < sizeof(struct sctp_event_subscribe)) 4012 if (len <= 0)
4013 return -EINVAL; 4013 return -EINVAL;
4014 len = sizeof(struct sctp_event_subscribe); 4014 if (len > sizeof(struct sctp_event_subscribe))
4015 len = sizeof(struct sctp_event_subscribe);
4015 if (put_user(len, optlen)) 4016 if (put_user(len, optlen))
4016 return -EFAULT; 4017 return -EFAULT;
4017 if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len)) 4018 if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))