tipc: set sysctl_tipc_rmem and named_timeout right range [Linux 5.1]

tipc: set sysctl_tipc_rmem and named_timeout right range [Linux 5.1]

This Linux kernel change "tipc: set sysctl_tipc_rmem and named_timeout right range" is included in the Linux 5.1 release. This change is authored by Jie Liu <liujie165 [at] huawei.com> on Tue Apr 16 13:10:09 2019 +0800. The commit for this change in Linux stable tree is 4bcd4ec (patch).

tipc: set sysctl_tipc_rmem and named_timeout right range

We find that sysctl_tipc_rmem and named_timeout do not have the right minimum
setting. sysctl_tipc_rmem should be larger than zero, like sysctl_tcp_rmem.
And named_timeout as a timeout setting should be not less than zero.

Fixes: cc79dd1ba9c10 ("tipc: change socket buffer overflow control to respect sk_rcvbuf")
Fixes: a5325ae5b8bff ("tipc: add name distributor resiliency queue")
Signed-off-by: Jie Liu <liujie165@huawei.com>
Reported-by: Qiang Ning <ningqiang1@huawei.com>
Reviewed-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

There are 8 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 net/tipc/sysctl.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/tipc/sysctl.c b/net/tipc/sysctl.c
index 3481e49..9df82a5 100644
--- a/net/tipc/sysctl.c
+++ b/net/tipc/sysctl.c
@@ -38,6 +38,8 @@

 #include <linux/sysctl.h>

+static int zero;
+static int one = 1;
 static struct ctl_table_header *tipc_ctl_hdr;

 static struct ctl_table tipc_table[] = {
@@ -46,14 +48,16 @@
        .data       = &sysctl_tipc_rmem,
        .maxlen     = sizeof(sysctl_tipc_rmem),
        .mode       = 0644,
-       .proc_handler   = proc_dointvec,
+       .proc_handler   = proc_dointvec_minmax,
+       .extra1         = &one,
    },
    {
        .procname   = "named_timeout",
        .data       = &sysctl_tipc_named_timeout,
        .maxlen     = sizeof(sysctl_tipc_named_timeout),
        .mode       = 0644,
-       .proc_handler   = proc_dointvec,
+       .proc_handler   = proc_dointvec_minmax,
+       .extra1         = &zero,
    },
    {
        .procname       = "sk_filter",

Leave a Reply

Your email address will not be published. Required fields are marked *