Skip to contentSkip to conversation

sctp: check the rto_min and rto_max

PATCH Superseded Wang Weidong 4 participants 10 messages Dec 5, 2013 – Dec 6, 2013

Subsystems (3)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 sctp: check the rto_min and rto_max

rto_min should be smaller than rto_max while rto_max should be larger than rto_min. Add two proc_handler for the checking. Add the check in sctp_setsockopt_rtoinfo.
delete a blank line in proc_sctp_do_hmac_alg() declaration.

---
 net/sctp/socket.c |  5 ++++
 net/sctp/sysctl.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 74 insertions(+), 5 deletions(-)
net/sctp/socket.c +5 -0
index 72046b9..2e1af1b 100644
@@ -2818,6 +2818,11 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne
 	if (copy_from_user(&rtoinfo, optval, optlen))
 		return -EFAULT;
 
+	if (rtoinfo.srto_min < 1 ||
+	    rtoinfo.srto_max > 86400000 ||
+	    rtoinfo.srto_max < rtoinfo.srto_min)
+		return -EINVAL;
+
 	asoc = sctp_id2assoc(sk, rtoinfo.srto_assoc_id);
 
 	/* Set the values to the specific association */
net/sctp/sysctl.c +69 -5

100 lines not on this page · raw message

Signature · 1 line
1.7.12
#1 lore raw
Quoted 17 lines · Wang Weidong

rto_min should be smaller than rto_max while rto_max should be larger than rto_min. Add two proc_handler for the checking. Add the check in sctp_setsockopt_rtoinfo.
delete a blank line in proc_sctp_do_hmac_alg() declaration.

---
 net/sctp/socket.c |  5 ++++
 net/sctp/sysctl.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 74 insertions(+), 5 deletions(-)
net/sctp/socket.c +0 -0
index 72046b9..2e1af1b 100644

net/sctp/socket.c static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne · line 2822

Quoted 5 lines
net/sctp/socket.c +2 -0
@@ -2818,6 +2818,11 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne
 	if (copy_from_user(&rtoinfo, optval, optlen))
 		return -EFAULT;
 
+	if (rtoinfo.srto_min < 1 ||
+	    rtoinfo.srto_max > 86400000 ||

These should be defiend to some descriptive value.

#2 lore raw

From: Wang Weidong <[email protected]>

Quoted 21 lines · Neil Horman
Quoted 20 lines · Wang Weidong

rto_min should be smaller than rto_max while rto_max should be larger than rto_min. Add two proc_handler for the checking. Add the check in sctp_setsockopt_rtoinfo.
delete a blank line in proc_sctp_do_hmac_alg() declaration.

---
  net/sctp/socket.c |  5 ++++
  net/sctp/sysctl.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++----
  2 files changed, 74 insertions(+), 5 deletions(-)
net/sctp/socket.c +0 -0
index 72046b9..2e1af1b 100644
@@ -2818,6 +2818,11 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne
  	if (copy_from_user(&rtoinfo, optval, optlen))
  		return -EFAULT;
 
Quoted 4 lines

net/sctp/socket.c static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne · line 2822

Quoted 2 lines
net/sctp/socket.c +2 -0
+	if (rtoinfo.srto_min < 1 ||
+	    rtoinfo.srto_max > 86400000 ||

These should be defiend to some descriptive value.

Thanks for your suggestion. I will fix it in v5.

Regards.

#3 lore raw
Quoted 23 lines · Wang Weidong

From: Wang Weidong <[email protected]>

Quoted 21 lines · Neil Horman
Quoted 20 lines · Wang Weidong

rto_min should be smaller than rto_max while rto_max should be larger than rto_min. Add two proc_handler for the checking. Add the check in sctp_setsockopt_rtoinfo.
delete a blank line in proc_sctp_do_hmac_alg() declaration.

---
  net/sctp/socket.c |  5 ++++
  net/sctp/sysctl.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++----
  2 files changed, 74 insertions(+), 5 deletions(-)
net/sctp/socket.c +0 -0
index 72046b9..2e1af1b 100644
@@ -2818,6 +2818,11 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne
      if (copy_from_user(&rtoinfo, optval, optlen))
          return -EFAULT;
 
Quoted 5 lines
Quoted 4 lines

net/sctp/socket.c static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne · line 2822

Quoted 2 lines
net/sctp/socket.c +2 -0
+    if (rtoinfo.srto_min < 1 ||
+        rtoinfo.srto_max > 86400000 ||

These should be defiend to some descriptive value.

Thanks for your suggestion. I will fix it in v5.

While you're on v5 anyway, please also fix up spacing in your commit from ...

static int proc_sctp_do_rto_min(struct ctl_table *ctl,
int write,
void __user*buffer, size_t *lenp, loff_t *ppos)

... to something like ...

static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)

Thanks !

#4 lore raw
Quoted 38 lines · Daniel Borkmann
Quoted 23 lines · Wang Weidong

From: Wang Weidong <[email protected]>

Quoted 21 lines · Neil Horman
Quoted 20 lines · Wang Weidong

rto_min should be smaller than rto_max while rto_max should be larger than rto_min. Add two proc_handler for the checking. Add the check in sctp_setsockopt_rtoinfo.
delete a blank line in proc_sctp_do_hmac_alg() declaration.

---
  net/sctp/socket.c |  5 ++++
  net/sctp/sysctl.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++----
  2 files changed, 74 insertions(+), 5 deletions(-)
net/sctp/socket.c +0 -0
index 72046b9..2e1af1b 100644
@@ -2818,6 +2818,11 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne
      if (copy_from_user(&rtoinfo, optval, optlen))
          return -EFAULT;
 
Quoted 5 lines
Quoted 4 lines

net/sctp/socket.c static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne · line 2822

Quoted 2 lines
net/sctp/socket.c +2 -0
+    if (rtoinfo.srto_min < 1 ||
+        rtoinfo.srto_max > 86400000 ||

These should be defiend to some descriptive value.

Thanks for your suggestion. I will fix it in v5.

While you're on v5 anyway, please also fix up spacing in your commit from ...

static int proc_sctp_do_rto_min(struct ctl_table *ctl,
int write,
void __user*buffer, size_t *lenp, loff_t *ppos)

Quoted 7 lines

... to something like ...

static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)

Thanks !

Hm, I do it for according to the proc_sctp_do_hmac_alg which is in the same file. If I fix this, I think it is better to fix the proc_sctp_do_hmac_alg as well. Should I do it a patch or another patch?

Thanks!

Quoted 6 lines
Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
Quoted 3 lines · Wang Weidong

Hm, I do it for according to the proc_sctp_do_hmac_alg which is in the same file. If I fix this, I think it is better to fix the proc_sctp_do_hmac_alg as well. Should I do it a patch or another patch?

Sure, feel free.

#6 lore raw
In reply to Neil Horman
Quoted 21 lines · Neil Horman
Quoted 20 lines · Wang Weidong

rto_min should be smaller than rto_max while rto_max should be larger than rto_min. Add two proc_handler for the checking. Add the check in sctp_setsockopt_rtoinfo.
delete a blank line in proc_sctp_do_hmac_alg() declaration.

---
 net/sctp/socket.c |  5 ++++
 net/sctp/sysctl.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 74 insertions(+), 5 deletions(-)
net/sctp/socket.c +0 -0
index 72046b9..2e1af1b 100644
@@ -2818,6 +2818,11 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne
 	if (copy_from_user(&rtoinfo, optval, optlen))
 		return -EFAULT;
 
Quoted 5 lines

net/sctp/socket.c static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne · line 2822

Quoted 2 lines
net/sctp/socket.c +2 -0
+	if (rtoinfo.srto_min < 1 ||
+	    rtoinfo.srto_max > 86400000 ||

These should be defiend to some descriptive value.

Hi Neil,

Should I define it in net/sctp/sctp.h, so sysctl.c can use it as well. Or I just define it in the socket.c same as the definition in sysctl.c?

Regards.
Wang

Quoted 1 line
#7 lore raw
Quoted 2 lines · Wang Weidong

Should I define it in net/sctp/sctp.h, so sysctl.c can use it as well. Or I just define it in the socket.c same as the definition in sysctl.c?

Preferably in include/net/sctp/constants.h where we already have most other constants anyway.

#8 lore raw
Quoted 8 lines · Daniel Borkmann
Quoted 2 lines · Wang Weidong

Should I define it in net/sctp/sctp.h, so sysctl.c can use it as well. Or I just define it in the socket.c same as the definition in sysctl.c?

Preferably in include/net/sctp/constants.h where we already have most other constants anyway.

Nice, Thanks for your suggestion.

Regards.
Wang

Quoted 1 line
#9 lore raw
In reply to Daniel Borkmann
Quoted 9 lines · Daniel Borkmann
Quoted 2 lines · Wang Weidong

Should I define it in net/sctp/sctp.h, so sysctl.c can use it as well. Or I just define it in the socket.c same as the definition in sysctl.c?

Preferably in include/net/sctp/constants.h where we already have most other constants anyway.

Hi Daniel,

in sysctl.c it will use a point to the value while the socket.c use the value. So if I define macros SCTP_ONE or SCTP_TIMER_MAX in include/net/sctp/constants.h which only used by socket.c. Is it OK?

Regards.
Wang