lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 23 Jun 2021 23:14:32 +0200
From:   Eric Dumazet <eric.dumazet@...il.com>
To:     Jesper Dangaard Brouer <brouer@...hat.com>,
        Jakub Kicinski <kuba@...nel.org>
Cc:     davem@...emloft.net, netdev@...r.kernel.org, willemb@...gle.com,
        eric.dumazet@...il.com, dsahern@...il.com, yoshfuji@...ux-ipv6.org,
        Dave Jones <dsj@...com>
Subject: Re: [PATCH net-next v3] net: ip: avoid OOM kills with large UDP sends
 over loopback



On 6/23/21 9:45 PM, Jesper Dangaard Brouer wrote:
> On Wed, 23 Jun 2021 09:23:28 -0700
> Jakub Kicinski <kuba@...nel.org> wrote:
> 
>> Dave observed number of machines hitting OOM on the UDP send
>> path. The workload seems to be sending large UDP packets over
>> loopback. Since loopback has MTU of 64k kernel will try to
>> allocate an skb with up to 64k of head space. This has a good
>> chance of failing under memory pressure. What's worse if
>> the message length is <32k the allocation may trigger an
>> OOM killer.
>>
>> This is entirely avoidable, we can use an skb with page frags.
>>
>> af_unix solves a similar problem by limiting the head
>> length to SKB_MAX_ALLOC. This seems like a good and simple
>> approach. It means that UDP messages > 16kB will now
>> use fragments if underlying device supports SG, if extra
>> allocator pressure causes regressions in real workloads
>> we can switch to trying the large allocation first and
>> falling back.
>>
>> Reported-by: Dave Jones <dsj@...com>
>> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
>> ---
>>  net/ipv4/ip_output.c  | 4 +++-
>>  net/ipv6/ip6_output.c | 4 +++-
>>  2 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
>> index c3efc7d658f6..790dd28fd198 100644
>> --- a/net/ipv4/ip_output.c
>> +++ b/net/ipv4/ip_output.c
>> @@ -1077,7 +1077,9 @@ static int __ip_append_data(struct sock *sk,
>>  			if ((flags & MSG_MORE) &&
>>  			    !(rt->dst.dev->features&NETIF_F_SG))
>>  				alloclen = mtu;
>> -			else if (!paged)
>> +			else if (!paged &&
>> +				 (fraglen + hh_len + 15 < SKB_MAX_ALLOC ||
> 
> What does the number 15 represent here?

Just look at the existing code, few lines below

skb = alloc_skb(alloclen + hh_len + 15, ...


> 
>> +				  !(rt->dst.dev->features & NETIF_F_SG)))
>>  				alloclen = fraglen;
>>  			else {
>>  				alloclen = min_t(int, fraglen, MAX_HEADER);
>> diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
>> index ff4f9ebcf7f6..ae8dbd6cdab1 100644
>> --- a/net/ipv6/ip6_output.c
>> +++ b/net/ipv6/ip6_output.c
>> @@ -1585,7 +1585,9 @@ static int __ip6_append_data(struct sock *sk,
>>  			if ((flags & MSG_MORE) &&
>>  			    !(rt->dst.dev->features&NETIF_F_SG))
>>  				alloclen = mtu;
>> -			else if (!paged)
>> +			else if (!paged &&
>> +				 (fraglen + hh_len < SKB_MAX_ALLOC ||
> 
> The number 15 is not use here.

Because the alloc_skb() done later does not use + 15



> 
>> +				  !(rt->dst.dev->features & NETIF_F_SG)))
>>  				alloclen = fraglen;
>>  			else {
>>  				alloclen = min_t(int, fraglen, MAX_HEADER);
> 
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ