sctp: check the rto_min and rto_max
Subsystems (3)
v7 cover sctp: check the rto_min and rto_max
v6 -> v7:
-patch2: fix the whitespace issues which pointed out by Daniel
v5 -> v6:
split the v5' first patch to patch1 and patch2, and remove the macro in constants.h
-patch1: do rto_min/max socket option handling in its own patch, and
fix the check of rto_min/max.
-patch2: do rto_min/max sysctl handling in its own patch. -patch3: add Suggested-by Daniel.
v4 -> v5:
- patch1: add marco in constants.h and fix up spacing as suggested by Daniel
- patch2: add a patch for fix up do_hmac_alg for according to do_rto_min[max]
v3 -> v4:
-patch1: fix use init_net directly which suggested by Vlad.
v2 -> v3:
-patch1: add proc_handler for check rto_min and rto_max which suggested
by Vlad
v1 -> v2:
-patch1: fix the From Name which pointed out by David, and
add the ACK by Neil
Wang Weidong (3):
sctp: check the rto_min and rto_max in setsockopt
sctp: add check rto_min and rto_max in sysctl
sctp: fix up a spacing
net/sctp/socket.c | 32 +++++++++++++++-------- net/sctp/sysctl.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 89 insertions(+), 19 deletions(-)
Signature · 1 line
1.7.12
PATCH v7 1/3 sctp: check the rto_min and rto_max in setsockopt
When we set 0 to rto_min or rto_max, just not change the value. Also we should check the rto_min > rto_max.
--- net/sctp/socket.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
net/sctp/socket.c +22 -10
@@ -2811,6 +2811,8 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne {struct sctp_rtoinfo rtoinfo;struct sctp_association *asoc; +unsigned long rto_min, rto_max; +struct sctp_sock *sp =sctp_sk (sk);if (optlen !=sizeof (struct sctp_rtoinfo ))return -EINVAL ;
@@ -2824,26 +2826,36 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigneif (!asoc && rtoinfo.srto_assoc_id &&sctp_style (sk,UDP ))return -EINVAL ; + rto_max = rtoinfo.srto_max; + rto_min = rtoinfo.srto_min; + +if (rto_max) + rto_max = asoc ?msecs_to_jiffies (rto_max) : rto_max; +else + rto_max = asoc ? asoc->rto_max : sp->rtoinfo.srto_max; + +if (rto_min) + rto_min = asoc ?msecs_to_jiffies (rto_min) : rto_min; +else + rto_min = asoc ? asoc->rto_min : sp->rtoinfo.srto_min; + +if (rto_min > rto_max) +return -EINVAL ; +if (asoc) {if (rtoinfo.srto_initial !=0 ) asoc->rto_initial msecs_to_jiffies(rtoinfo.srto_initial); -if (rtoinfo.srto_max !=0 ) - asoc->rto_max =msecs_to_jiffies (rtoinfo.srto_max); -if (rtoinfo.srto_min !=0 ) - asoc->rto_min =msecs_to_jiffies (rtoinfo.srto_min); + asoc->rto_max = rto_max; + asoc->rto_min = rto_min; }else {/* If there is no association or the association-id = 0 * set the values to the endpoint. */ -struct sctp_sock *sp =sctp_sk (sk); -if (rtoinfo.srto_initial !=0 ) sp->rtoinfo.srto_initial = rtoinfo.srto_initial; -if (rtoinfo.srto_max !=0 ) - sp->rtoinfo.srto_max = rtoinfo.srto_max; -if (rtoinfo.srto_min !=0 ) - sp->rtoinfo.srto_min = rtoinfo.srto_min; + sp->rtoinfo.srto_max = rto_max; + sp->rtoinfo.srto_min = rto_min; }return 0 ;
Signature · 1 line
1.7.12
PATCH v7 2/3 sctp: add check rto_min and rto_max in sysctl
In reply to Wang Weidongrto_min should be smaller than rto_max while rto_max should be larger than rto_min. Add two proc_handler for the checking.
--- net/sctp/sysctl.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 4 deletions(-)
net/sctp/sysctl.c +65 -4
@@ -61,6 +61,13 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, void __user *buffer, size_t *lenp, loff_t *ppos); +static int proc_sctp_do_rto_min (struct ctl_table *ctl,int write, +void __user *buffer,size_t *lenp, +loff_t *ppos); +static int proc_sctp_do_rto_max (struct ctl_table *ctl,int write, +void __user *buffer,size_t *lenp, +loff_t *ppos); +static struct ctl_table sctp_table[] = { { .procname ="sctp_mem" ,
@@ -102,17 +109,17 @@ static struct ctl_table sctp_net_table[] = { .data = &init_net.sctp.rto_min, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec_minmax, + .proc_handler = proc_sctp_do_rto_min, .extra1 = &one, - .extra2 = &timer_max + .extra2 = &init_net.sctp.rto_max }, { .procname = "rto_max", .data = &init_net.sctp.rto_max, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = &one, + .proc_handler = proc_sctp_do_rto_max, + .extra1 = &init_net.sctp.rto_min, .extra2 = &timer_max }, {
@@ -342,6 +349,60 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,return ret; } +static int proc_sctp_do_rto_min (struct ctl_table *ctl,int write, +void __user *buffer,size_t *lenp, +loff_t *ppos) +{ +struct net *net = current->nsproxy->net_ns; +int new_value; +struct ctl_table tbl; +unsigned int min = *(unsigned int *) ctl->extra1; +unsigned int max = *(unsigned int *) ctl->extra2; +int ret; + +memset (&tbl,0 ,sizeof (struct ctl_table )); + tbl.maxlen =sizeof (unsigned int ); + +if (write) + tbl.data = &new_value; +else + tbl.data = &net->sctp.rto_min; + ret =proc_dointvec (&tbl, write, buffer, lenp, ppos); +if (write) { +if (ret || new_value > max || new_value < min) +return -EINVAL ; + net->sctp.rto_min = new_value; + } +return ret; +} + +static int proc_sctp_do_rto_max (struct ctl_table *ctl,int write, +void __user *buffer,size_t *lenp, +loff_t *ppos) +{ +struct net *net = current->nsproxy->net_ns; +int new_value; +struct ctl_table tbl; +unsigned int min = *(unsigned int *) ctl->extra1; +unsigned int max = *(unsigned int *) ctl->extra2; +int ret; + +memset (&tbl,0 ,sizeof (struct ctl_table )); + tbl.maxlen =sizeof (unsigned int ); + +if (write) + tbl.data = &new_value; +else + tbl.data = &net->sctp.rto_max; + ret =proc_dointvec (&tbl, write, buffer, lenp, ppos); +if (write) { +if (ret || new_value > max || new_value < min) +return -EINVAL ; + net->sctp.rto_max = new_value; + } +return ret; +} +int sctp_sysctl_net_register (struct net *net) {struct ctl_table *table;
Signature · 1 line
1.7.12
PATCH v7 3/3 sctp: fix up a spacing
In reply to Wang Weidongfix up spacing of proc_sctp_do_hmac_alg for according to the proc_sctp_do_rto_min[max] in sysctl.c
--- net/sctp/sysctl.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
net/sctp/sysctl.c +2 -5
@@ -56,10 +56,8 @@ extern long sysctl_sctp_mem[3];extern int sysctl_sctp_rmem[3 ];extern int sysctl_sctp_wmem[3 ]; -static int proc_sctp_do_hmac_alg (struct ctl_table *ctl, -int write, +static int proc_sctp_do_hmac_alg (struct ctl_table *ctl,int write,void __user *buffer,size_t *lenp, -loff_t *ppos); static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp,
@@ -301,8 +299,7 @@ static struct ctl_table sctp_net_table[] = { {/* sentinel */ } }; -static int proc_sctp_do_hmac_alg (struct ctl_table *ctl, -int write, +static int proc_sctp_do_hmac_alg (struct ctl_table *ctl,int write,void __user *buffer,size_t *lenp,loff_t *ppos) {
Signature · 1 line
1.7.12
Quoted 25 lines · Wang Weidong
v6 -> v7:
-patch2: fix the whitespace issues which pointed out by Danielv5 -> v6:
split the v5' first patch to patch1 and patch2, and remove the macro inconstants.h-patch1: do rto_min/max socket option handling in its own patch, and
fix the check of rto_min/max.
-patch2: do rto_min/max sysctl handling in its own patch. -patch3: add Suggested-by Daniel.v4 -> v5:
- patch1: add marco inconstants.hand fix up spacing as suggested by Daniel
- patch2: add a patch for fix updo_hmac_algfor according to do_rto_min[max]v3 -> v4:
-patch1: fix useinit_netdirectly which suggested by Vlad.v2 -> v3:
-patch1: addproc_handlerfor checkrto_minandrto_maxwhich suggested
by Vlad
Quoted 8 lines
v1 -> v2:
-patch1: fix the From Name which pointed out by David, and
add the ACK by NeilWang Weidong (3):
sctp: check therto_minandrto_maxin setsockopt
sctp: add checkrto_minandrto_maxin sysctl
sctp: fix up a spacing
Series
-vlad
Quoted 5 lines
net/sctp/socket.c | 32 +++++++++++++++-------- net/sctp/sysctl.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 89 insertions(+), 19 deletions(-)
David Miller
maintainerFrom: Vlad Yasevich <[email protected]>
Date: Tue, 10 Dec 2013 21:41:36 -0500
Quoted 30 lines · Wang Weidong
Quoted 29 lines
v6 -> v7:
-patch2: fix the whitespace issues which pointed out by Danielv5 -> v6:
split the v5' first patch to patch1 and patch2, and remove the macro inconstants.h-patch1: do rto_min/max socket option handling in its own patch, and
fix the check of rto_min/max.
-patch2: do rto_min/max sysctl handling in its own patch. -patch3: add Suggested-by Daniel.v4 -> v5:
- patch1: add marco inconstants.hand fix up spacing as suggested by Daniel
- patch2: add a patch for fix updo_hmac_algfor according to do_rto_min[max]v3 -> v4:
-patch1: fix useinit_netdirectly which suggested by Vlad.v2 -> v3:
-patch1: addproc_handlerfor checkrto_minandrto_maxwhich suggested
by Vladv1 -> v2:
-patch1: fix the From Name which pointed out by David, and
add the ACK by Neil
Quoted 7 lines
Quoted 4 lines
Wang Weidong (3):
sctp: check therto_minandrto_maxin setsockopt
sctp: add checkrto_minandrto_maxin sysctl
sctp: fix up a spacingSeries
Acked-by Vlad Yasevich <[email protected]>
Series applied, thanks.