cve/icmp_rate_limit01: Lower icmp_msgs_per_sec for debug kernel reliability
PATCH 1/1 cve/icmp_rate_limit01: Lower icmp_msgs_per_sec for debug kernel reliability
On debug kernels with CONFIG_PROVE_LOCKING or PREEMPT_RT, each socket operation (bind, sendto) takes ~3-4ms instead of <0.5ms on a normal kernel. At the default icmp_msgs_per_sec=1000, the token bucket refills ~371 tokens during the 371ms it takes to send 100 packets, so rate limiting never engages and all batches return identical error counts, causing a false TFAIL.
Lower icmp_msgs_per_sec to 10 in both the global save_restore and the child network namespace. At 10/sec the bucket cannot meaningfully refill during the send loop regardless of kernel speed, while the 2s inter-batch sleep still allows full credit recovery (10 * 2 = 20 = burst).
Also add PATH_IPV4_ICMP_MSGS_PER_SEC to tst_path_defs.h alongside the existing PATH_IPV4_ICMP_MSGS_BURST macro.
--- include/tst_path_defs.h | 1 + testcases/cve/icmp_rate_limit01.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)
include/tst_path_defs.h +1 -0
@@ -79,6 +79,7 @@#define PATH_IPV4_ICMP_RATEMASK "/proc/sys/net/ipv4/icmp_ratemask"#define PATH_IPV4_ICMP_ECHO_IGNORE_ALL "/proc/sys/net/ipv4/icmp_echo_ignore_all"#define PATH_IPV4_ICMP_MSGS_BURST "/proc/sys/net/ipv4/icmp_msgs_burst" +#define PATH_IPV4_ICMP_MSGS_PER_SEC "/proc/sys/net/ipv4/icmp_msgs_per_sec"#define PATH_IPV4_TCP_PROBE_INTERVAL "/proc/sys/net/ipv4/tcp_probe_interval"#define PATH_IPV4_TCP_KEEPALIVE_TIME "/proc/sys/net/ipv4/tcp_keepalive_time"#define PATH_IPV4_TCP_NOTSENT_LOWAT "/proc/sys/net/ipv4/tcp_notsent_lowat"
testcases/cve/icmp_rate_limit01.c +8 -2
@@ -63,12 +63,17 @@ static void setup(void) childns =SAFE_OPEN ("/proc/self/ns/net" ,O_RDONLY );/* -* Set namespace local rate limit if needed. The global limit might -* be ignored otherwise. +* Set namespace local rate limits if needed. The global limits might +* be ignored otherwise. Lower icmp_msgs_per_sec to ensure rate limiting +* engages even on slow debug kernels where the send loop takes long +* enough that the token bucket refills mid-batch at the default 1000/sec. */ if (!access (PATH_IPV4_ICMP_MSGS_BURST ,F_OK ))SAFE_FILE_PRINTF (PATH_IPV4_ICMP_MSGS_BURST ,"50" ); +if (!access (PATH_IPV4_ICMP_MSGS_PER_SEC ,F_OK )) +SAFE_FILE_PRINTF (PATH_IPV4_ICMP_MSGS_PER_SEC ,"10" ); +/* Configure child namespace */ CREATE_VETH_PAIR ("ltp_veth1" ,"ltp_veth2" ); NETDEV_ADD_ADDRESS_INET("ltp_veth2", htonl(DSTADDR), NETMASK,
@@ -263,6 +268,7 @@ static struct tst_test test = { }, .save_restore = (const struct tst_path_val[]) { {PATH_IPV4_ICMP_MSGS_BURST ,"50" ,TST_SR_TBROK }, + {PATH_IPV4_ICMP_MSGS_PER_SEC ,"10" ,TST_SR_SKIP }, {PATH_USER_MAX_USER_NAMESPACES ,"1024" ,TST_SR_SKIP }, {} },
Signature · 5 lines
2.55.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Brian,
Quoted 8 lines · Brian Grech
cve/icmp_rate_limit01: Lower
icmp_msgs_per_secfor debug kernel reliabilityOn debug kernels with
CONFIG_PROVE_LOCKINGorPREEMPT_RT, each socket operation (bind, sendto) takes ~3-4ms instead of <0.5ms on a normal kernel. At the default icmp_msgs_per_sec=1000, the token bucket refills ~371 tokens during the 371ms it takes to send 100 packets, so rate limiting never engages and all batches return identical error counts, causing a false TFAIL.
Checking net/ipv4/icmp.c (net_init_ipv4_early() / icmp_sk_init()), the kernel default for icmp_msgs_per_sec has been 10000, not 1000, since the sysctl was introduced -- 1000 is actually the default of the unrelated icmp_ratelimit sysctl (a millisecond delay, not a rate). Is the "1000" default and the derived "~371 tokens in 371ms" figure meant to reference icmp_msgs_per_sec, or was this confused with icmp_ratelimit? The direction of the fix still holds either way, but the justification as written doesn't match the real default.
Quoted 4 lines
Lower
icmp_msgs_per_secto 10 in both the globalsave_restoreand the child network namespace. At 10/sec the bucket cannot meaningfully refill during the send loop regardless of kernel speed, while the 2s inter-batch sleep still allows full credit recovery (10 * 2 = 20 = burst).
Two things don't line up here:
icmp_msgs_burst is set to 50 by this same test ({PATH_IPV4_ICMP_MSGS_BURST, "50", TST_SR_TBROK}), not 20, so "20 = burst" doesn't hold regardless of rate.
Also, icmp_global_allow() caps the elapsed interval used for the refill calculation: delta = min_t(u32, now - oldstamp, HZ);, so at most one second's worth of credit (10 tokens at this rate) is ever added on a single check, no matter how long the real elapsed time was. After the 2s sleep, the achievable refill is capped at 10, not 20.
Neither burst (50) nor the achievable refill (10) match the "10 * 2 = 20 = burst" statement. This likely doesn't break the practical effect of the fix -- less refill only makes rate limiting engage more reliably -- but is the reasoning here intentional, or should the comment be corrected to reflect the actual kernel behavior?
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/1 cve/icmp_rate_limit01: Lower icmp_msgs_per_sec for debug kernel reliability
On debug kernels with CONFIG_PROVE_LOCKING or PREEMPT_RT, each socket operation (bind, sendto) takes ~3-4ms instead of <0.5ms on a normal kernel. The default icmp_msgs_per_sec is 10000; at that rate the token bucket (burst=50) refills ~37 tokens per 3.7ms inter-packet interval, so the bucket never drains during the slow send loop and all batches return identical error counts, causing a false TFAIL.
Lower icmp_msgs_per_sec to 10 so that at most ~0.037 tokens accumulate per inter-packet interval. The bucket drains during the batch regardless of kernel speed. Note that icmp_global_allow() caps the refill interval at HZ jiffies (1 second), so after the 2s inter-batch sleep at most 10 tokens are recovered -- well below the burst of 50 set by this test -- preserving the variability needed to distinguish vulnerable from patched kernels.
Also add PATH_IPV4_ICMP_MSGS_PER_SEC to tst_path_defs.h alongside the existing PATH_IPV4_ICMP_MSGS_BURST macro.
--- include/tst_path_defs.h | 1 + testcases/cve/icmp_rate_limit01.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)
include/tst_path_defs.h +1 -0
@@ -79,6 +79,7 @@#define PATH_IPV4_ICMP_RATEMASK "/proc/sys/net/ipv4/icmp_ratemask"#define PATH_IPV4_ICMP_ECHO_IGNORE_ALL "/proc/sys/net/ipv4/icmp_echo_ignore_all"#define PATH_IPV4_ICMP_MSGS_BURST "/proc/sys/net/ipv4/icmp_msgs_burst" +#define PATH_IPV4_ICMP_MSGS_PER_SEC "/proc/sys/net/ipv4/icmp_msgs_per_sec"#define PATH_IPV4_TCP_PROBE_INTERVAL "/proc/sys/net/ipv4/tcp_probe_interval"#define PATH_IPV4_TCP_KEEPALIVE_TIME "/proc/sys/net/ipv4/tcp_keepalive_time"#define PATH_IPV4_TCP_NOTSENT_LOWAT "/proc/sys/net/ipv4/tcp_notsent_lowat"
testcases/cve/icmp_rate_limit01.c +8 -2
@@ -63,12 +63,17 @@ static void setup(void) childns =SAFE_OPEN ("/proc/self/ns/net" ,O_RDONLY );/* -* Set namespace local rate limit if needed. The global limit might -* be ignored otherwise. +* Set namespace local rate limits if needed. The global limits might +* be ignored otherwise. Lower icmp_msgs_per_sec to ensure rate limiting +* engages even on slow debug kernels where the send loop takes long +* enough that the token bucket refills mid-batch at the default 1000/sec. */ if (!access (PATH_IPV4_ICMP_MSGS_BURST ,F_OK ))SAFE_FILE_PRINTF (PATH_IPV4_ICMP_MSGS_BURST ,"50" ); +if (!access (PATH_IPV4_ICMP_MSGS_PER_SEC ,F_OK )) +SAFE_FILE_PRINTF (PATH_IPV4_ICMP_MSGS_PER_SEC ,"10" ); +/* Configure child namespace */ CREATE_VETH_PAIR ("ltp_veth1" ,"ltp_veth2" ); NETDEV_ADD_ADDRESS_INET("ltp_veth2", htonl(DSTADDR), NETMASK,
@@ -263,6 +268,7 @@ static struct tst_test test = { }, .save_restore = (const struct tst_path_val[]) { {PATH_IPV4_ICMP_MSGS_BURST ,"50" ,TST_SR_TBROK }, + {PATH_IPV4_ICMP_MSGS_PER_SEC ,"10" ,TST_SR_SKIP }, {PATH_USER_MAX_USER_NAMESPACES ,"1024" ,TST_SR_SKIP }, {} },
Signature · 5 lines
2.55.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Brian,
Quoted 1 line · Brian Grech
cve/icmp_rate_limit01: Lower
icmp_msgs_per_secfor debug kernel reliability
Verdict - Reviewed
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Brian,
thank you, merged!
BTW you have wrong git send-email setup, therefore patches are sent with author:
'Brian Grech via ltp <[email protected]>'. You're not alone with this setup. I wonder what is causing it (it'd be nice to have it fixed).
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Petr,
Happy to contribute!
Thank you for letting me know, that is strange. On my system it's configured correctly. Digging a little deeper, I think it might be a corporate smtp issue.
Quoted 14 lines · Petr Vorel
Hi Brian,
thank you, merged!
BTW you have wrong git send-email setup, therefore patches are sent with author:
'Brian Grech via ltp <[email protected]>'. You're not alone with this setup.
I wonder what is causing it (it'd be nice to have it fixed).Kind regards,
Petr
Signature · 4 lines
-Brian -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Brian,
Quoted 3 lines
Hi Petr,
Happy to contribute!
We are happy to get new contributors :).
Quoted 3 lines
Thank you for letting me know, that is strange. On my system it's configured correctly. Digging a little deeper, I think it might be a corporate smtp issue.
FYI it's mangled "From:" mail header [1]: "From: Brian Grech via ltp <[email protected]>". It's probably DMARC + Mailman related.
BTW I thought it should not be on redhat.com side, because Jan Stancek does not have that problem, but actually he does have that problem as well [3] "From: Jan Stancek via ltp <[email protected]>". It's just he probably does merge these patches directly without first downloading them from the mailing list.
Anyway, very minor problem, but it'd be nice to get it fixed. Our list has
setup: from_is_list = no. I suppose this is correct (looking at the docs [4] and also check other projects setup [5]).
Kind regards,
Petr
[1] https://lore.kernel.org/ltp/[email protected]/raw
[2] https://wiki.list.org/DEV/DMARC
[3] https://lore.kernel.org/ltp/08c85cf64d703dfaba31398ab9d9b480488fe338.1747227481.git.jstancek@redhat.com/raw
[4] https://list.org/mailman-admin.txt
[5] https://sourceware.org/pipermail/binutils/2023-October/129852.html
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 12 lines · Petr Vorel
Hi Brian,
Quoted 3 lines
Hi Petr,
Happy to contribute!
We are happy to get new contributors :).
Quoted 3 lines
Thank you for letting me know, that is strange. On my system it's configured correctly. Digging a little deeper, I think it might be a corporate smtp issue.
Quoted 7 lines
FYI it's mangled "From:" mail header [1]: "From: Brian Grech via ltp <[email protected]>". It's probably DMARC + Mailman related.
BTW I thought it should not be on redhat.com side, because Jan Stancek does not have that problem, but actually he does have that problem as well [3] "From: Jan Stancek via ltp <[email protected]>". It's just he probably does merge these patches directly without first downloading them from the mailing list.
Hm interesting, it appears to be only LTP. The patch I sent last week to lkml appears to be OK,
and it's the same gitconfig setup:
https://lore.kernel.org/lkml/84a35e16f72330d6e7b2d6e969040f36959e2dad.1784630290.git.jstancek@redhat.com/raw
Quoted 14 lines
Anyway, very minor problem, but it'd be nice to get it fixed. Our list has
setup:from_is_list= no. I suppose this is correct (looking at the docs [4] and also check other projects setup [5]).Kind regards,
Petr[1] https://lore.kernel.org/ltp/[email protected]/raw
[2] https://wiki.list.org/DEV/DMARC
[3] https://lore.kernel.org/ltp/08c85cf64d703dfaba31398ab9d9b480488fe338.1747227481.git.jstancek@redhat.com/raw
[4] https://list.org/mailman-admin.txt
[5] https://sourceware.org/pipermail/binutils/2023-October/129852.html
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 21 lines · Petr Vorel
Quoted 12 lines
Hi Brian,
Quoted 3 lines
Hi Petr,
Happy to contribute!
We are happy to get new contributors :).
Quoted 3 lines
Thank you for letting me know, that is strange. On my system it's configured correctly. Digging a little deeper, I think it might be a corporate smtp issue.
Quoted 7 lines
FYI it's mangled "From:" mail header [1]: "From: Brian Grech via ltp <[email protected]>". It's probably DMARC + Mailman related.
BTW I thought it should not be on redhat.com side, because Jan Stancek does not have that problem, but actually he does have that problem as well [3] "From: Jan Stancek via ltp <[email protected]>". It's just he probably does merge these patches directly without first downloading them from the mailing list.
Quoted 4 lines
Hm interesting, it appears to be only LTP. The patch I sent last week to lkml appears to be OK,
and it's the same gitconfig setup:
https://lore.kernel.org/lkml/84a35e16f72330d6e7b2d6e969040f36959e2dad.1784630290.git.jstancek@redhat.com/raw
It looks something at least related to our old Mailman on lists.linux.it.
Kind regards,
Petr
Quoted 12 lines
Quoted 12 lines
Anyway, very minor problem, but it'd be nice to get it fixed. Our list has
setup:from_is_list= no. I suppose this is correct (looking at the docs [4] and also check other projects setup [5]).Kind regards,
Petr[1] https://lore.kernel.org/ltp/[email protected]/raw
[2] https://wiki.list.org/DEV/DMARC
[3] https://lore.kernel.org/ltp/08c85cf64d703dfaba31398ab9d9b480488fe338.1747227481.git.jstancek@redhat.com/raw
[4] https://list.org/mailman-admin.txt
[5] https://sourceware.org/pipermail/binutils/2023-October/129852.html
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 15 lines · Petr Vorel
Hi Brian,
Quoted 3 lines
Hi Petr,
Happy to contribute!
We are happy to get new contributors :).
Quoted 3 lines
Thank you for letting me know, that is strange. On my system it's configured correctly. Digging a little deeper, I think it might be a corporate smtp issue.
FYI it's mangled "From:" mail header [1]: "From: Brian Grech via ltp <[email protected]>". It's probably DMARC + Mailman related.
Quoted 8 lines
BTW I thought it should not be on redhat.com side, because Jan Stancek does not have that problem, but actually he does have that problem as well [3] "From: Jan Stancek via ltp <[email protected]>". It's just he probably does merge these patches directly without first downloading them from the mailing list.
Anyway, very minor problem, but it'd be nice to get it fixed. Our list has
setup:from_is_list= no. I suppose this is correct (looking at the docs [4] and also check other projects setup [5]).
Can you see also these two in our config?dmarc_moderation_action = Acceptdmarc_quarantine_moderation_action = No
Quoted 10 lines
Kind regards,
Petr[1] https://lore.kernel.org/ltp/[email protected]/raw
[2] https://wiki.list.org/DEV/DMARC
[3] https://lore.kernel.org/ltp/08c85cf64d703dfaba31398ab9d9b480488fe338.1747227481.git.jstancek@redhat.com/raw
[4] https://list.org/mailman-admin.txt
[5] https://sourceware.org/pipermail/binutils/2023-October/129852.html
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 21 lines · Petr Vorel
Quoted 19 lines
Hi Brian,
Quoted 3 lines
Hi Petr,
Happy to contribute!
We are happy to get new contributors :).
Quoted 3 lines
Thank you for letting me know, that is strange. On my system it's configured correctly. Digging a little deeper, I think it might be a corporate smtp issue.
FYI it's mangled "From:" mail header [1]: "From: Brian Grech via ltp <[email protected]>". It's probably DMARC + Mailman related.
BTW I thought it should not be on redhat.com side, because Jan Stancek does not have that problem, but actually he does have that problem as well [3] "From: Jan Stancek via ltp <[email protected]>". It's just he probably does merge these patches directly without first downloading them from the mailing list.
Quoted 6 lines
Quoted 3 lines
Anyway, very minor problem, but it'd be nice to get it fixed. Our list has
setup:from_is_list= no. I suppose this is correct (looking at the docs [4] and also check other projects setup [5]).Can you see also these two in our config?
dmarc_moderation_action= Accept
We have dmarc_moderation_action = Munge From (in privacy/sender/dmarc_moderation_action)
Quoted 1 line
dmarc_quarantine_moderation_action= No
We have dmarc_quarantine_moderation_action = yesdmarc_none_moderation_action = No
Too late to read the docs, I'll do it tomorrow.
Kind regards,
Petr
Quoted 8 lines
Quoted 8 lines
Kind regards,
Petr[1] https://lore.kernel.org/ltp/[email protected]/raw
[2] https://wiki.list.org/DEV/DMARC
[3] https://lore.kernel.org/ltp/08c85cf64d703dfaba31398ab9d9b480488fe338.1747227481.git.jstancek@redhat.com/raw
[4] https://list.org/mailman-admin.txt
[5] https://sourceware.org/pipermail/binutils/2023-October/129852.html
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp