提交 b22978fa 编写于 作者: W Weilong Chen 提交者: Xie XiuQi

ipv4: Add support to disable icmp time stamp

ascend inclusion
category: feature
bugzilla: NA
CVE: NA

-------------------

Fix ICMP information such as netmask and timestamp is
allowed from arbitrary hosts
Default is disable.
enable:
	sysctl -w net.ipv4.icmp_timestamp_enable=1
disable
	sysctl -w net.ipv4.icmp_timestamp_enable=0
test:
	hping3 --icmp --icmp-ts -V $IPADDR
Signed-off-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NLI Heng <liheng40@huawei.com>
Signed-off-by: NLijun Fang <fanglijun3@huawei.com>
[fix-v2: define sysctl_icmp_timestamp_enable ifndef
CONFIG_ARCH_ASCEND
 fix-v3: ifndef CONFIG_ARCH_ASCEND, sysctl_icmp_timestamp_enable
should set 1]
Reviewed-by: NMao Wenan <maowenan@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 95ec8bc1
...@@ -685,6 +685,12 @@ bool icmp_global_allow(void); ...@@ -685,6 +685,12 @@ bool icmp_global_allow(void);
extern int sysctl_icmp_msgs_per_sec; extern int sysctl_icmp_msgs_per_sec;
extern int sysctl_icmp_msgs_burst; extern int sysctl_icmp_msgs_burst;
#ifdef CONFIG_ARCH_ASCEND
extern int sysctl_icmp_timestamp_enable;
#else
#define sysctl_icmp_timestamp_enable 1
#endif
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
int ip_misc_proc_init(void); int ip_misc_proc_init(void);
#endif #endif
......
...@@ -232,6 +232,9 @@ static inline void icmp_xmit_unlock(struct sock *sk) ...@@ -232,6 +232,9 @@ static inline void icmp_xmit_unlock(struct sock *sk)
int sysctl_icmp_msgs_per_sec __read_mostly = 1000; int sysctl_icmp_msgs_per_sec __read_mostly = 1000;
int sysctl_icmp_msgs_burst __read_mostly = 50; int sysctl_icmp_msgs_burst __read_mostly = 50;
#ifdef CONFIG_ARCH_ASCEND
int sysctl_icmp_timestamp_enable __read_mostly;
#endif
static struct { static struct {
spinlock_t lock; spinlock_t lock;
...@@ -959,6 +962,10 @@ static bool icmp_echo(struct sk_buff *skb) ...@@ -959,6 +962,10 @@ static bool icmp_echo(struct sk_buff *skb)
static bool icmp_timestamp(struct sk_buff *skb) static bool icmp_timestamp(struct sk_buff *skb)
{ {
struct icmp_bxm icmp_param; struct icmp_bxm icmp_param;
if (!sysctl_icmp_timestamp_enable)
goto out_err;
/* /*
* Too short. * Too short.
*/ */
......
...@@ -545,6 +545,16 @@ static struct ctl_table ipv4_table[] = { ...@@ -545,6 +545,16 @@ static struct ctl_table ipv4_table[] = {
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.extra1 = &zero, .extra1 = &zero,
}, },
#ifdef CONFIG_ARCH_ASCEND
{
.procname = "icmp_timestamp_enable",
.data = &sysctl_icmp_timestamp_enable,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
},
#endif
{ {
.procname = "udp_mem", .procname = "udp_mem",
.data = &sysctl_udp_mem, .data = &sysctl_udp_mem,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册