aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
authorWei Yongjun <yjwei@cn.fujitsu.com>2008-12-25 19:59:03 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-25 19:59:03 -0500
commit8510b937ae1e23583abdeb828cad5c518295c61d (patch)
tree5ef0449bc7673c99a2134d8bba8e4f1dd4c79549 /net/sctp/socket.c
parent9fcb95a105758b81ef0131cd18e2db5149f13e95 (diff)
sctp: Add validity check for SCTP_PARTIAL_DELIVERY_POINT socket option
The latest ietf socket extensions API draft said: 8.1.21. Set or Get the SCTP Partial Delivery Point Note also that the call will fail if the user attempts to set this value larger than the socket receive buffer size. This patch add this validity check for SCTP_PARTIAL_DELIVERY_POINT socket option. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 9f5fe23773a9..b14a8f33e42d 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3010,14 +3010,21 @@ static int sctp_setsockopt_fragment_interleave(struct sock *sk,
3010} 3010}
3011 3011
3012/* 3012/*
3013 * 7.1.25. Set or Get the sctp partial delivery point 3013 * 8.1.21. Set or Get the SCTP Partial Delivery Point
3014 * (SCTP_PARTIAL_DELIVERY_POINT) 3014 * (SCTP_PARTIAL_DELIVERY_POINT)
3015 *
3015 * This option will set or get the SCTP partial delivery point. This 3016 * This option will set or get the SCTP partial delivery point. This
3016 * point is the size of a message where the partial delivery API will be 3017 * point is the size of a message where the partial delivery API will be
3017 * invoked to help free up rwnd space for the peer. Setting this to a 3018 * invoked to help free up rwnd space for the peer. Setting this to a
3018 * lower value will cause partial delivery's to happen more often. The 3019 * lower value will cause partial deliveries to happen more often. The
3019 * calls argument is an integer that sets or gets the partial delivery 3020 * calls argument is an integer that sets or gets the partial delivery
3020 * point. 3021 * point. Note also that the call will fail if the user attempts to set
3022 * this value larger than the socket receive buffer size.
3023 *
3024 * Note that any single message having a length smaller than or equal to
3025 * the SCTP partial delivery point will be delivered in one single read
3026 * call as long as the user provided buffer is large enough to hold the
3027 * message.
3021 */ 3028 */
3022static int sctp_setsockopt_partial_delivery_point(struct sock *sk, 3029static int sctp_setsockopt_partial_delivery_point(struct sock *sk,
3023 char __user *optval, 3030 char __user *optval,
@@ -3030,6 +3037,12 @@ static int sctp_setsockopt_partial_delivery_point(struct sock *sk,
3030 if (get_user(val, (int __user *)optval)) 3037 if (get_user(val, (int __user *)optval))
3031 return -EFAULT; 3038 return -EFAULT;
3032 3039
3040 /* Note: We double the receive buffer from what the user sets
3041 * it to be, also initial rwnd is based on rcvbuf/2.
3042 */
3043 if (val > (sk->sk_rcvbuf >> 1))
3044 return -EINVAL;
3045
3033 sctp_sk(sk)->pd_point = val; 3046 sctp_sk(sk)->pd_point = val;
3034 3047
3035 return 0; /* is this the right error code? */ 3048 return 0; /* is this the right error code? */