Skip to content

Commit 85791b6

Browse files
YeXingchenNipaLocal
authored andcommitted
icmp: Add icmp_timestamp_ignore_all to control ICMP_TIMESTAMP
The CVE-1999-0524 vulnerability is associated with ICMP timestamp messages, which can be exploited to conduct a denial-of-service (DoS) attack. In the Vulnerability Priority Rating (VPR) system, this vulnerability was rated as a medium risk in May of this year. Link:https://www.tenable.com/plugins/nessus/10113 To protect embedded systems that cannot run firewalls from attacks exploiting the CVE-1999-0524 vulnerability, the icmp_timestamp_ignore_all sysctl is offered as an easy solution, which allows all ICMP timestamp messages to be ignored, effectively bypassing the potential exploitation through the CVE-1999-0524 vulnerability. It enables these resource-constrained systems to disregard all ICMP timestamp messages, preventing potential DoS attacks, making it an ideal lightweight solution for such environments. Signed-off-by: YeXingchen <[email protected]> Reviewed-by: xu xin <[email protected]> Reviewed-by: zhang yunkai <[email protected]> Reviewed-by: Fan Yu <[email protected]> CC: he peilin <[email protected]> Cc: Yang Yang <[email protected]> Cc: Yang Guang <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent b7418ae commit 85791b6

File tree

6 files changed

+28
-0
lines changed

6 files changed

+28
-0
lines changed

Documentation/networking/ip-sysctl.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,12 @@ icmp_ratelimit - INTEGER
14411441

14421442
Default: 1000
14431443

1444+
icmp_timestamp_ignore_all - BOOLEAN
1445+
If set non-zero, then the kernel will ignore all ICMP TIMESTAMP
1446+
requests sent to it.
1447+
1448+
Default: 0
1449+
14441450
icmp_msgs_per_sec - INTEGER
14451451
Limit maximal number of ICMP packets sent per second from this host.
14461452
Only messages whose type matches icmp_ratemask (see below) are

Documentation/networking/net_cachelines/netns_ipv4_sysctl.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ u8 sysctl_icmp_ignore_bogus_error_responses
3838
u8 sysctl_icmp_errors_use_inbound_ifaddr
3939
int sysctl_icmp_ratelimit
4040
int sysctl_icmp_ratemask
41+
u8 sysctl_icmp_timestamp_ignore_all
4142
u32 ip_rt_min_pmtu - -
4243
int ip_rt_mtu_expires - -
4344
int ip_rt_min_advmss - -

include/net/netns/ipv4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ struct netns_ipv4 {
113113
u8 sysctl_icmp_echo_ignore_broadcasts;
114114
u8 sysctl_icmp_ignore_bogus_error_responses;
115115
u8 sysctl_icmp_errors_use_inbound_ifaddr;
116+
u8 sysctl_icmp_timestamp_ignore_all;
116117
int sysctl_icmp_ratelimit;
117118
int sysctl_icmp_ratemask;
118119

include/uapi/linux/sysctl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ enum
426426
NET_TCP_ALLOWED_CONG_CONTROL=123,
427427
NET_TCP_MAX_SSTHRESH=124,
428428
NET_TCP_FRTO_RESPONSE=125,
429+
NET_IPV4_ICMP_TIMESTAMP_IGNORE_ALL = 126,
429430
};
430431

431432
enum {

net/ipv4/icmp.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,13 @@ EXPORT_SYMBOL_GPL(icmp_build_probe);
11521152
static enum skb_drop_reason icmp_timestamp(struct sk_buff *skb)
11531153
{
11541154
struct icmp_bxm icmp_param;
1155+
struct net *net;
1156+
1157+
net = dev_net(skb_dst(skb)->dev);
1158+
1159+
if (READ_ONCE(net->ipv4.sysctl_icmp_timestamp_ignore_all))
1160+
return SKB_NOT_DROPPED_YET;
1161+
11551162
/*
11561163
* Too short.
11571164
*/
@@ -1469,6 +1476,9 @@ static int __net_init icmp_sk_init(struct net *net)
14691476
net->ipv4.sysctl_icmp_echo_enable_probe = 0;
14701477
net->ipv4.sysctl_icmp_echo_ignore_broadcasts = 1;
14711478

1479+
/* Control parameters for TIMESTAMP replies. */
1480+
net->ipv4.sysctl_icmp_timestamp_ignore_all = 0;
1481+
14721482
/* Control parameter - ignore bogus broadcast responses? */
14731483
net->ipv4.sysctl_icmp_ignore_bogus_error_responses = 1;
14741484

net/ipv4/sysctl_net_ipv4.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,15 @@ static struct ctl_table ipv4_net_table[] = {
651651
.mode = 0644,
652652
.proc_handler = ipv4_ping_group_range,
653653
},
654+
{
655+
.procname = "icmp_timestamp_ignore_all",
656+
.data = &init_net.ipv4.sysctl_icmp_timestamp_ignore_all,
657+
.maxlen = sizeof(u8),
658+
.mode = 0644,
659+
.proc_handler = proc_dou8vec_minmax,
660+
.extra1 = SYSCTL_ZERO,
661+
.extra2 = SYSCTL_ONE
662+
},
654663
#ifdef CONFIG_NET_L3_MASTER_DEV
655664
{
656665
.procname = "raw_l3mdev_accept",

0 commit comments

Comments
 (0)