Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sctp: not allow to set asoc prsctp_enable by sockopt

As rfc7496#section4.5 says about SCTP_PR_SUPPORTED:

This socket option allows the enabling or disabling of the
negotiation of PR-SCTP support for future associations. For existing
associations, it allows one to query whether or not PR-SCTP support
was negotiated on a particular association.

It means only sctp sock's prsctp_enable can be set.

Note that for the limitation of SCTP_{CURRENT|ALL}_ASSOC, we will
add it when introducing SCTP_{FUTURE|CURRENT|ALL}_ASSOC for linux
sctp in another patchset.

v1->v2:
- drop the params.assoc_id check as Neil suggested.

Fixes: 28aa4c26fce2 ("sctp: add SCTP_PR_SUPPORTED on sctp sockopt")
Reported-by: Ying Xu <yinxu@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Xin Long and committed by
David S. Miller
cc3ccf26 02968ccf

+5 -21
+5 -21
net/sctp/socket.c
··· 3940 3940 unsigned int optlen) 3941 3941 { 3942 3942 struct sctp_assoc_value params; 3943 - struct sctp_association *asoc; 3944 - int retval = -EINVAL; 3945 3943 3946 3944 if (optlen != sizeof(params)) 3947 - goto out; 3945 + return -EINVAL; 3948 3946 3949 - if (copy_from_user(&params, optval, optlen)) { 3950 - retval = -EFAULT; 3951 - goto out; 3952 - } 3947 + if (copy_from_user(&params, optval, optlen)) 3948 + return -EFAULT; 3953 3949 3954 - asoc = sctp_id2assoc(sk, params.assoc_id); 3955 - if (asoc) { 3956 - asoc->prsctp_enable = !!params.assoc_value; 3957 - } else if (!params.assoc_id) { 3958 - struct sctp_sock *sp = sctp_sk(sk); 3950 + sctp_sk(sk)->ep->prsctp_enable = !!params.assoc_value; 3959 3951 3960 - sp->ep->prsctp_enable = !!params.assoc_value; 3961 - } else { 3962 - goto out; 3963 - } 3964 - 3965 - retval = 0; 3966 - 3967 - out: 3968 - return retval; 3952 + return 0; 3969 3953 } 3970 3954 3971 3955 static int sctp_setsockopt_default_prinfo(struct sock *sk,