|
@@ -3498,6 +3498,8 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk,
|
|
|
|
|
|
if (optlen < sizeof(struct sctp_hmacalgo))
|
|
|
return -EINVAL;
|
|
|
+ optlen = min_t(unsigned int, optlen, sizeof(struct sctp_hmacalgo) +
|
|
|
+ SCTP_AUTH_NUM_HMACS * sizeof(u16));
|
|
|
|
|
|
hmacs = memdup_user(optval, optlen);
|
|
|
if (IS_ERR(hmacs))
|
|
@@ -3536,6 +3538,11 @@ static int sctp_setsockopt_auth_key(struct sock *sk,
|
|
|
|
|
|
if (optlen <= sizeof(struct sctp_authkey))
|
|
|
return -EINVAL;
|
|
|
+ /* authkey->sca_keylength is u16, so optlen can't be bigger than
|
|
|
+ * this.
|
|
|
+ */
|
|
|
+ optlen = min_t(unsigned int, optlen, USHRT_MAX +
|
|
|
+ sizeof(struct sctp_authkey));
|
|
|
|
|
|
authkey = memdup_user(optval, optlen);
|
|
|
if (IS_ERR(authkey))
|
|
@@ -3893,6 +3900,9 @@ static int sctp_setsockopt_reset_streams(struct sock *sk,
|
|
|
|
|
|
if (optlen < sizeof(*params))
|
|
|
return -EINVAL;
|
|
|
+ /* srs_number_streams is u16, so optlen can't be bigger than this. */
|
|
|
+ optlen = min_t(unsigned int, optlen, USHRT_MAX +
|
|
|
+ sizeof(__u16) * sizeof(*params));
|
|
|
|
|
|
params = memdup_user(optval, optlen);
|
|
|
if (IS_ERR(params))
|