From: "Jason A. Donenfeld" <Jason@zx2c4.com> Date: 2022-10-26 12:34:11
The `char` type with no explicit sign is sometimes signed and sometimes
unsigned. This code will break on platforms such as arm, where char is
unsigned. So mark it here as explicitly signed, so that the
todrop_counter decrement and subsequent comparison is correct.
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Julian Anastasov <ja@ssi.bg>
Cc: Simon Horman <horms@verge.net.au>
Cc: stable@vger.kernel.org
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
net/netfilter/ipvs/ip_vs_conn.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -1249,40 +1249,40 @@ static const struct seq_operations ip_vs_conn_sync_seq_ops = {.next=ip_vs_conn_seq_next,.stop=ip_vs_conn_seq_stop,.show=ip_vs_conn_sync_seq_show,};#endif/* Randomly drop connection entries before running out of memory*CanbeusedforDATAandCTLconns.ForTPLconnsthereareexceptions:*-trafficforservicesinOPSmodeincreasesct->in_pkts,soitissupported*-trafficforservicesnotinOPSmodedoesnotincreasect->in_pktsin*allcases,soitisnotsupported*/staticinlineinttodrop_entry(structip_vs_conn*cp){/**Thedropratearrayneedstuningforrealenvironments.*Calledfromtimerbhonly=>nolocking*/-staticconstchartodrop_rate[9]={0,1,2,3,4,5,6,7,8};-staticchartodrop_counter[9]={0};+staticconstsignedchartodrop_rate[9]={0,1,2,3,4,5,6,7,8};+staticsignedchartodrop_counter[9]={0};inti;/* if the conn entry hasn't lasted for 60 seconds, don't drop it.Thiswillleaveenoughtimefornormalconnectiontogetthrough.*/if(time_before(cp->timeout+jiffies,cp->timer.expires+60*HZ))return0;/* Don't drop the entry if its number of incoming packets is notlocatedin[0,8]*/i=atomic_read(&cp->in_pkts);if(i>8||i<0)return0;if(!todrop_rate[i])return0;if(--todrop_counter[i]>0)return0;todrop_counter[i]=todrop_rate[i];return1;}
Hello,
On Wed, 26 Oct 2022, Jason A. Donenfeld wrote:
The `char` type with no explicit sign is sometimes signed and sometimes
unsigned. This code will break on platforms such as arm, where char is
unsigned. So mark it here as explicitly signed, so that the
todrop_counter decrement and subsequent comparison is correct.
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Julian Anastasov <ja@ssi.bg>
Cc: Simon Horman <horms@verge.net.au>
Cc: stable@vger.kernel.org
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Looks good to me for -next, thanks!
Acked-by: Julian Anastasov <ja@ssi.bg>
@@ -1249,40 +1249,40 @@ static const struct seq_operations ip_vs_conn_sync_seq_ops = {.next=ip_vs_conn_seq_next,.stop=ip_vs_conn_seq_stop,.show=ip_vs_conn_sync_seq_show,};#endif/* Randomly drop connection entries before running out of memory*CanbeusedforDATAandCTLconns.ForTPLconnsthereareexceptions:*-trafficforservicesinOPSmodeincreasesct->in_pkts,soitissupported*-trafficforservicesnotinOPSmodedoesnotincreasect->in_pktsin*allcases,soitisnotsupported*/staticinlineinttodrop_entry(structip_vs_conn*cp){/**Thedropratearrayneedstuningforrealenvironments.*Calledfromtimerbhonly=>nolocking*/-staticconstchartodrop_rate[9]={0,1,2,3,4,5,6,7,8};-staticchartodrop_counter[9]={0};+staticconstsignedchartodrop_rate[9]={0,1,2,3,4,5,6,7,8};+staticsignedchartodrop_counter[9]={0};inti;/* if the conn entry hasn't lasted for 60 seconds, don't drop it.Thiswillleaveenoughtimefornormalconnectiontogetthrough.*/if(time_before(cp->timeout+jiffies,cp->timer.expires+60*HZ))return0;/* Don't drop the entry if its number of incoming packets is notlocatedin[0,8]*/i=atomic_read(&cp->in_pkts);if(i>8||i<0)return0;if(!todrop_rate[i])return0;if(--todrop_counter[i]>0)return0;todrop_counter[i]=todrop_rate[i];return1;}
From: "Jason A. Donenfeld" <Jason@zx2c4.com> Date: 2022-10-26 14:30:36
On Wed, Oct 26, 2022 at 05:20:03PM +0300, Julian Anastasov wrote:
Hello,
On Wed, 26 Oct 2022, Jason A. Donenfeld wrote:
quoted
The `char` type with no explicit sign is sometimes signed and sometimes
unsigned. This code will break on platforms such as arm, where char is
unsigned. So mark it here as explicitly signed, so that the
todrop_counter decrement and subsequent comparison is correct.
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Julian Anastasov <ja@ssi.bg>
Cc: Simon Horman <horms@verge.net.au>
Cc: stable@vger.kernel.org
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Looks good to me for -next, thanks!
This is actually net.git material, not net-next.git material,
considering it fixes a bug on arm and many other archs, and is marked
with a stable@ tag.
@@ -1249,40 +1249,40 @@ static const struct seq_operations ip_vs_conn_sync_seq_ops = {.next=ip_vs_conn_seq_next,.stop=ip_vs_conn_seq_stop,.show=ip_vs_conn_sync_seq_show,};#endif/* Randomly drop connection entries before running out of memory*CanbeusedforDATAandCTLconns.ForTPLconnsthereareexceptions:*-trafficforservicesinOPSmodeincreasesct->in_pkts,soitissupported*-trafficforservicesnotinOPSmodedoesnotincreasect->in_pktsin*allcases,soitisnotsupported*/staticinlineinttodrop_entry(structip_vs_conn*cp){/**Thedropratearrayneedstuningforrealenvironments.*Calledfromtimerbhonly=>nolocking*/-staticconstchartodrop_rate[9]={0,1,2,3,4,5,6,7,8};-staticchartodrop_counter[9]={0};+staticconstsignedchartodrop_rate[9]={0,1,2,3,4,5,6,7,8};+staticsignedchartodrop_counter[9]={0};inti;/* if the conn entry hasn't lasted for 60 seconds, don't drop it.Thiswillleaveenoughtimefornormalconnectiontogetthrough.*/if(time_before(cp->timeout+jiffies,cp->timer.expires+60*HZ))return0;/* Don't drop the entry if its number of incoming packets is notlocatedin[0,8]*/i=atomic_read(&cp->in_pkts);if(i>8||i<0)return0;if(!todrop_rate[i])return0;if(--todrop_counter[i]>0)return0;todrop_counter[i]=todrop_rate[i];return1;}
Hello,
On Wed, 26 Oct 2022, Jason A. Donenfeld wrote:
On Wed, Oct 26, 2022 at 05:20:03PM +0300, Julian Anastasov wrote:
quoted
Hello,
On Wed, 26 Oct 2022, Jason A. Donenfeld wrote:
quoted
The `char` type with no explicit sign is sometimes signed and sometimes
unsigned. This code will break on platforms such as arm, where char is
unsigned. So mark it here as explicitly signed, so that the
todrop_counter decrement and subsequent comparison is correct.
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Julian Anastasov <ja@ssi.bg>
Cc: Simon Horman <horms@verge.net.au>
Cc: stable@vger.kernel.org
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Looks good to me for -next, thanks!
This is actually net.git material, not net-next.git material,
considering it fixes a bug on arm and many other archs, and is marked
with a stable@ tag.
OK. As algorithm is not SMP safe, the problem is
not just for the first 256 packets on these platforms.
Regards
--
Julian Anastasov [off-list ref]
From: "Jason A. Donenfeld" <Jason@zx2c4.com> Date: 2022-11-02 02:45:00
Hi Pablo,
On Wed, Oct 26, 2022 at 2:34 PM Jason A. Donenfeld [off-list ref] wrote:
The `char` type with no explicit sign is sometimes signed and sometimes
unsigned. This code will break on platforms such as arm, where char is
unsigned. So mark it here as explicitly signed, so that the
todrop_counter decrement and subsequent comparison is correct.
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Julian Anastasov <ja@ssi.bg>
Cc: Simon Horman <horms@verge.net.au>
Cc: stable@vger.kernel.org
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Wondering if you planned on taking this into nf.git for 6.1?
Thanks,
Jason
From: Pablo Neira Ayuso <pablo@netfilter.org> Date: 2022-11-02 08:27:05
On Wed, Oct 26, 2022 at 02:32:16PM +0200, Jason A. Donenfeld wrote:
The `char` type with no explicit sign is sometimes signed and sometimes
unsigned. This code will break on platforms such as arm, where char is
unsigned. So mark it here as explicitly signed, so that the
todrop_counter decrement and subsequent comparison is correct.