sctp: fix ignoring asoc_id for tcp-style sockets on some setsockopts
Subsystems (3)
Xin Long
maintainercover sctp: fix ignoring asoc_id for tcp-style sockets on some setsockopts
This is a patchset to fix ignoring asoc_id for tcp-style sockets on some setsockopts, introduced by SCTP_CURRENT_ASSOC of the patchset:
[net-next,00/24] sctp: support SCTP_FUTURE/CURRENT/ALL_ASSOC
(https://patchwork.ozlabs.org/cover/1031706/)
As Marcelo suggested, we fix it on each setsockopt that is using SCTP_CURRENT_ASSOC one by one by adding the check:
if (sctp_style(sk, TCP))
xxx.xxx_assoc_id = SCTP_FUTURE_ASSOC;
so that assoc_id will be completely ingored for tcp-style socket on setsockopts, and works as SCTP_FUTURE_ASSOC.
Marcelo Ricardo Leitner (1):
sctp: fix ignoring asoc_id for tcp-style sockets on
SCTP_DEFAULT_SEND_PARAM sockopt
Xin Long (12):
sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DELAYED_SACK
sockopt
sctp: fix ignoring asoc_id for tcp-style sockets on
SCTP_DEFAULT_SNDINFO sockopt
sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_CONTEXT
sockopt
sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_MAX_BURST
sockopt
sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_AUTH_KEY
sockopt
sctp: fix ignoring asoc_id for tcp-style sockets on
SCTP_AUTH_ACTIVE_KEY sockopt
sctp: fix ignoring asoc_id for tcp-style sockets on
SCTP_AUTH_DELETE_KEY sockopt
sctp: fix ignoring asoc_id for tcp-style sockets on
SCTP_AUTH_DEACTIVATE_KEY sockopt
sctp: fix ignoring asoc_id for tcp-style sockets on
SCTP_DEFAULT_PRINFO sockopt
sctp: fix ignoring asoc_id for tcp-style sockets on
SCTP_ENABLE_STREAM_RESET sockopt
sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_EVENT sockopt
sctp: fix ignoring asoc_id for tcp-style sockets on
SCTP_STREAM_SCHEDULER sockopt
net/sctp/socket.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 1/13 sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockopt
From: Marcelo Ricardo Leitner <[email protected]>
Currently if the user pass an invalid asoc_id to SCTP_DEFAULT_SEND_PARAM on a TCP-style socket, it will silently ignore the new parameters. That's because after not finding an asoc, it is checking asoc_id against the known values of CURRENT/FUTURE/ALL values and that fails to match.
IOW, if the user supplies an invalid asoc id or not, it should either match the current asoc or the socket itself so that it will inherit these later. Fixes it by forcing asoc_id to SCTP_FUTURE_ASSOC in case it is a TCP-style socket without an asoc, so that the values get set on the socket.
--- net/sctp/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/sctp/socket.c +3 -0
@@ -3024,6 +3024,9 @@ static int sctp_setsockopt_default_send_param(struct sock *sk,return 0 ; } +if (sctp_style (sk,TCP )) + info.sinfo_assoc_id =SCTP_FUTURE_ASSOC ; +if (info.sinfo_assoc_id =SCTP_FUTURE_ASSOC || info.sinfo_assoc_id =SCTP_ALL_ASSOC ) { sp->default_stream = info.sinfo_stream;
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 2/13 sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DELAYED_SACK sockopt
A similar fix as Patch "sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockopt" on SCTP_DELAYED_SACK sockopt.
--- net/sctp/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/sctp/socket.c +3 -0
@@ -2920,6 +2920,9 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk,return 0 ; } +if (sctp_style (sk,TCP )) + params.sack_assoc_id =SCTP_FUTURE_ASSOC ; +if (params.sack_assoc_id =SCTP_FUTURE_ASSOC || params.sack_assoc_id =SCTP_ALL_ASSOC ) {if (params.sack_delay) {
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 3/13 sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SNDINFO sockopt
A similar fix as Patch "sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockopt" on SCTP_DEFAULT_SNDINFO sockopt.
--- net/sctp/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/sctp/socket.c +3 -0
@@ -3087,6 +3087,9 @@ static int sctp_setsockopt_default_sndinfo(struct sock *sk,return 0 ; } +if (sctp_style (sk,TCP )) + info.snd_assoc_id =SCTP_FUTURE_ASSOC ; +if (info.snd_assoc_id =SCTP_FUTURE_ASSOC || info.snd_assoc_id =SCTP_ALL_ASSOC ) { sp->default_stream = info.snd_sid;
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 4/13 sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_CONTEXT sockopt
A similar fix as Patch "sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockopt" on SCTP_CONTEXT sockopt.
--- net/sctp/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/sctp/socket.c +3 -0
@@ -3540,6 +3540,9 @@ static int sctp_setsockopt_context(struct sock *sk, char __user *optval,return 0 ; } +if (sctp_style (sk,TCP )) + params.assoc_id =SCTP_FUTURE_ASSOC ; +if (params.assoc_id =SCTP_FUTURE_ASSOC || params.assoc_id =SCTP_ALL_ASSOC ) sp->default_rcv_context = params.assoc_value;
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 5/13 sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_MAX_BURST sockopt
A similar fix as Patch "sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockopt" on SCTP_MAX_BURST sockopt.
--- net/sctp/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/sctp/socket.c +3 -0
@@ -3682,6 +3682,9 @@ static int sctp_setsockopt_maxburst(struct sock *sk,return 0 ; } +if (sctp_style (sk,TCP )) + params.assoc_id =SCTP_FUTURE_ASSOC ; +if (params.assoc_id =SCTP_FUTURE_ASSOC || params.assoc_id =SCTP_ALL_ASSOC ) sp->max_burst = params.assoc_value;
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 6/13 sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_AUTH_KEY sockopt
A similar fix as Patch "sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockopt" on SCTP_AUTH_KEY sockopt.
--- net/sctp/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/sctp/socket.c +3 -0
@@ -3813,6 +3813,9 @@ static int sctp_setsockopt_auth_key(struct sock *sk, goto out; } +if (sctp_style (sk,TCP )) + authkey->sca_assoc_id =SCTP_FUTURE_ASSOC ; +if (authkey->sca_assoc_id =SCTP_FUTURE_ASSOC || authkey->sca_assoc_id =SCTP_ALL_ASSOC ) { ret =sctp_auth_set_key (ep, asoc, authkey);
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 7/13 sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_AUTH_ACTIVE_KEY sockopt
A similar fix as Patch "sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockopt" on SCTP_AUTH_ACTIVE_KEY sockopt.
--- net/sctp/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/sctp/socket.c +3 -0
@@ -3871,6 +3871,9 @@ static int sctp_setsockopt_active_key(struct sock *sk,if (asoc)return sctp_auth_set_active_key (ep, asoc, val.scact_keynumber); +if (sctp_style (sk,TCP )) + val.scact_assoc_id =SCTP_FUTURE_ASSOC ; +if (val.scact_assoc_id =SCTP_FUTURE_ASSOC || val.scact_assoc_id =SCTP_ALL_ASSOC ) { ret =sctp_auth_set_active_key (ep, asoc, val.scact_keynumber);
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 8/13 sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_AUTH_DELETE_KEY sockopt
A similar fix as Patch "sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockopt" on SCTP_AUTH_DELETE_KEY sockopt.
--- net/sctp/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/sctp/socket.c +3 -0
@@ -3925,6 +3925,9 @@ static int sctp_setsockopt_del_key(struct sock *sk,if (asoc)return sctp_auth_del_key_id (ep, asoc, val.scact_keynumber); +if (sctp_style (sk,TCP )) + val.scact_assoc_id =SCTP_FUTURE_ASSOC ; +if (val.scact_assoc_id =SCTP_FUTURE_ASSOC || val.scact_assoc_id =SCTP_ALL_ASSOC ) { ret =sctp_auth_del_key_id (ep, asoc, val.scact_keynumber);
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 9/13 sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_AUTH_DEACTIVATE_KEY sockopt
A similar fix as Patch "sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockopt" on SCTP_AUTH_DEACTIVATE_KEY sockopt.
--- net/sctp/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/sctp/socket.c +3 -0
@@ -3978,6 +3978,9 @@ static int sctp_setsockopt_deactivate_key(struct sock *sk, char __user *optval,if (asoc)return sctp_auth_deact_key_id (ep, asoc, val.scact_keynumber); +if (sctp_style (sk,TCP )) + val.scact_assoc_id =SCTP_FUTURE_ASSOC ; +if (val.scact_assoc_id =SCTP_FUTURE_ASSOC || val.scact_assoc_id =SCTP_ALL_ASSOC ) { ret =sctp_auth_deact_key_id (ep, asoc, val.scact_keynumber);
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 10/13 sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_PRINFO sockopt
A similar fix as Patch "sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockopt" on SCTP_DEFAULT_PRINFO sockopt.
--- net/sctp/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/sctp/socket.c +3 -0
@@ -4196,6 +4196,9 @@ static int sctp_setsockopt_default_prinfo(struct sock *sk, goto out; } +if (sctp_style (sk,TCP )) + info.pr_assoc_id =SCTP_FUTURE_ASSOC ; +if (info.pr_assoc_id =SCTP_FUTURE_ASSOC || info.pr_assoc_id =SCTP_ALL_ASSOC ) {SCTP_PR_SET_POLICY (sp->default_flags, info.pr_policy);
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 11/13 sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_ENABLE_STREAM_RESET sockopt
A similar fix as Patch "sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockopt" on SCTP_ENABLE_STREAM_RESET sockopt.
--- net/sctp/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/sctp/socket.c +3 -0
@@ -4281,6 +4281,9 @@ static int sctp_setsockopt_enable_strreset(struct sock *sk, goto out; } +if (sctp_style (sk,TCP )) + params.assoc_id =SCTP_FUTURE_ASSOC ; +if (params.assoc_id =SCTP_FUTURE_ASSOC || params.assoc_id =SCTP_ALL_ASSOC ) ep->strreset_enable = params.assoc_value;
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 12/13 sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_EVENT sockopt
A similar fix as Patch "sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockopt" on SCTP_EVENT sockopt.
--- net/sctp/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/sctp/socket.c +3 -0
@@ -4574,6 +4574,9 @@ static int sctp_setsockopt_event(struct sock *sk, char __user *optval,if (asoc)return sctp_assoc_ulpevent_type_set (¶m, asoc); +if (sctp_style (sk,TCP )) + param.se_assoc_id =SCTP_FUTURE_ASSOC ; +if (param.se_assoc_id =SCTP_FUTURE_ASSOC || param.se_assoc_id =SCTP_ALL_ASSOC ) sctp_ulpevent_type_set(&sp->subscribe,
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH 13/13 sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_STREAM_SCHEDULER sockopt
A similar fix as Patch "sctp: fix ignoring asoc_id for tcp-style sockets on SCTP_DEFAULT_SEND_PARAM sockopt" on SCTP_STREAM_SCHEDULER sockopt.
--- net/sctp/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/sctp/socket.c +3 -0
@@ -4409,6 +4409,9 @@ static int sctp_setsockopt_scheduler(struct sock *sk,if (asoc)return sctp_sched_set_sched (asoc, params.assoc_value); +if (sctp_style (sk,TCP )) + params.assoc_id =SCTP_FUTURE_ASSOC ; +if (params.assoc_id =SCTP_FUTURE_ASSOC || params.assoc_id =SCTP_ALL_ASSOC ) sp->default_ss = params.assoc_value;
Signature · 1 line
2.1.0
David Miller
maintainerFrom: Xin Long <[email protected]>
Date: Mon, 18 Mar 2019 20:05:58 +0800
Quoted 6 lines
This is a patchset to fix ignoring
asoc_idfor tcp-style sockets on some setsockopts, introduced bySCTP_CURRENT_ASSOCof the patchset:[net-next,00/24] sctp: support SCTP_FUTURE/CURRENT/ALL_ASSOC
(https://patchwork.ozlabs.org/cover/1031706/)
Quoted 8 lines
As Marcelo suggested, we fix it on each setsockopt that is using
SCTP_CURRENT_ASSOCone by one by adding the check:if (
sctp_style(sk, TCP))
xxx.xxx_assoc_id =SCTP_FUTURE_ASSOC;so that
assoc_idwill be completely ingored for tcp-style socket on setsockopts, and works asSCTP_FUTURE_ASSOC.
Series applied, thanks Xin.