Re: tcp: Checking a kmemdup() call in tcp_time_wait()

From: Eric Dumazet
Date: Mon Oct 14 2019 - 08:33:20 EST




On 10/13/19 11:51 PM, Markus Elfring wrote:
>>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/ipv4/tcp_minisocks.c?id=1c0cc5f1ae5ee5a6913704c0d75a6e99604ee30a#n306
>>> https://elixir.bootlin.com/linux/v5.4-rc2/source/net/ipv4/tcp_minisocks.c#L306
> â
>> Presumably the BUG would trigger if a really disturbing bug happened.
>
> How âbuggyâ is this place if the function call âkmemdupâ failed?

It is not buggy. The BUG will not trigger.

BUG_ON(tcptw->tw_md5_key && !tcp_alloc_md5sig_pool());

This would be different if we had instead :

BUG_ON(!tcptw->tw_md5_key && !tcp_alloc_md5sig_pool());

>
> Can an other error reporting approach be nicer here?

There is no error reported if kmemdup() has failed.

timewait is best effort.