Commit 8f14c99c authored by Tonghao Zhang's avatar Tonghao Zhang Committed by Pablo Neira Ayuso

netfilter: conntrack: limit sysctl setting for boolean options

We use the zero and one to limit the boolean options setting.
After this patch we only set 0 or 1 to boolean options for nf
conntrack sysctl.
Signed-off-by: default avatarTonghao Zhang <xiangxia.m.yue@gmail.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent a4cb98f3
...@@ -24,9 +24,9 @@ struct nf_generic_net { ...@@ -24,9 +24,9 @@ struct nf_generic_net {
struct nf_tcp_net { struct nf_tcp_net {
unsigned int timeouts[TCP_CONNTRACK_TIMEOUT_MAX]; unsigned int timeouts[TCP_CONNTRACK_TIMEOUT_MAX];
unsigned int tcp_loose; int tcp_loose;
unsigned int tcp_be_liberal; int tcp_be_liberal;
unsigned int tcp_max_retrans; int tcp_max_retrans;
}; };
enum udp_conntrack { enum udp_conntrack {
......
...@@ -511,6 +511,8 @@ static void nf_conntrack_standalone_fini_proc(struct net *net) ...@@ -511,6 +511,8 @@ static void nf_conntrack_standalone_fini_proc(struct net *net)
/* Log invalid packets of a given protocol */ /* Log invalid packets of a given protocol */
static int log_invalid_proto_min __read_mostly; static int log_invalid_proto_min __read_mostly;
static int log_invalid_proto_max __read_mostly = 255; static int log_invalid_proto_max __read_mostly = 255;
static int zero;
static int one = 1;
/* size the user *wants to set */ /* size the user *wants to set */
static unsigned int nf_conntrack_htable_size_user __read_mostly; static unsigned int nf_conntrack_htable_size_user __read_mostly;
...@@ -624,9 +626,11 @@ static struct ctl_table nf_ct_sysctl_table[] = { ...@@ -624,9 +626,11 @@ static struct ctl_table nf_ct_sysctl_table[] = {
[NF_SYSCTL_CT_CHECKSUM] = { [NF_SYSCTL_CT_CHECKSUM] = {
.procname = "nf_conntrack_checksum", .procname = "nf_conntrack_checksum",
.data = &init_net.ct.sysctl_checksum, .data = &init_net.ct.sysctl_checksum,
.maxlen = sizeof(unsigned int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
}, },
[NF_SYSCTL_CT_LOG_INVALID] = { [NF_SYSCTL_CT_LOG_INVALID] = {
.procname = "nf_conntrack_log_invalid", .procname = "nf_conntrack_log_invalid",
...@@ -647,33 +651,41 @@ static struct ctl_table nf_ct_sysctl_table[] = { ...@@ -647,33 +651,41 @@ static struct ctl_table nf_ct_sysctl_table[] = {
[NF_SYSCTL_CT_ACCT] = { [NF_SYSCTL_CT_ACCT] = {
.procname = "nf_conntrack_acct", .procname = "nf_conntrack_acct",
.data = &init_net.ct.sysctl_acct, .data = &init_net.ct.sysctl_acct,
.maxlen = sizeof(unsigned int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
}, },
[NF_SYSCTL_CT_HELPER] = { [NF_SYSCTL_CT_HELPER] = {
.procname = "nf_conntrack_helper", .procname = "nf_conntrack_helper",
.data = &init_net.ct.sysctl_auto_assign_helper, .data = &init_net.ct.sysctl_auto_assign_helper,
.maxlen = sizeof(unsigned int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
}, },
#ifdef CONFIG_NF_CONNTRACK_EVENTS #ifdef CONFIG_NF_CONNTRACK_EVENTS
[NF_SYSCTL_CT_EVENTS] = { [NF_SYSCTL_CT_EVENTS] = {
.procname = "nf_conntrack_events", .procname = "nf_conntrack_events",
.data = &init_net.ct.sysctl_events, .data = &init_net.ct.sysctl_events,
.maxlen = sizeof(unsigned int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
}, },
#endif #endif
#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
[NF_SYSCTL_CT_TIMESTAMP] = { [NF_SYSCTL_CT_TIMESTAMP] = {
.procname = "nf_conntrack_timestamp", .procname = "nf_conntrack_timestamp",
.data = &init_net.ct.sysctl_tstamp, .data = &init_net.ct.sysctl_tstamp,
.maxlen = sizeof(unsigned int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
}, },
#endif #endif
[NF_SYSCTL_CT_PROTO_TIMEOUT_GENERIC] = { [NF_SYSCTL_CT_PROTO_TIMEOUT_GENERIC] = {
...@@ -744,15 +756,19 @@ static struct ctl_table nf_ct_sysctl_table[] = { ...@@ -744,15 +756,19 @@ static struct ctl_table nf_ct_sysctl_table[] = {
}, },
[NF_SYSCTL_CT_PROTO_TCP_LOOSE] = { [NF_SYSCTL_CT_PROTO_TCP_LOOSE] = {
.procname = "nf_conntrack_tcp_loose", .procname = "nf_conntrack_tcp_loose",
.maxlen = sizeof(unsigned int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
}, },
[NF_SYSCTL_CT_PROTO_TCP_LIBERAL] = { [NF_SYSCTL_CT_PROTO_TCP_LIBERAL] = {
.procname = "nf_conntrack_tcp_be_liberal", .procname = "nf_conntrack_tcp_be_liberal",
.maxlen = sizeof(unsigned int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
}, },
[NF_SYSCTL_CT_PROTO_TCP_MAX_RETRANS] = { [NF_SYSCTL_CT_PROTO_TCP_MAX_RETRANS] = {
.procname = "nf_conntrack_tcp_max_retrans", .procname = "nf_conntrack_tcp_max_retrans",
...@@ -887,7 +903,9 @@ static struct ctl_table nf_ct_sysctl_table[] = { ...@@ -887,7 +903,9 @@ static struct ctl_table nf_ct_sysctl_table[] = {
.procname = "nf_conntrack_dccp_loose", .procname = "nf_conntrack_dccp_loose",
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
}, },
#endif #endif
#ifdef CONFIG_NF_CT_PROTO_GRE #ifdef CONFIG_NF_CT_PROTO_GRE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment