mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Markus Elfring <Markus.Elfring@web.de>,
	netdev@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
	Daniel Borkmann <daniel@iogearbox.net>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Hideaki Yoshifuji <yoshfuji@linux-ipv6.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org, Aditya Pakki <pakki001@umn.edu>,
	Kangjie Lu <kjlu@umn.edu>, Navid Emamdoost <emamd001@umn.edu>,
	Stephen McCamant <smccaman@umn.edu>
Subject: Re: tcp: Checking a kmemdup() call in tcp_time_wait()
Date: Sun, 13 Oct 2019 12:45:53 -0700	[thread overview]
Message-ID: <124b41aa-7ba5-f00c-ab73-cb8e6a2ae75f@gmail.com> (raw)
In-Reply-To: <a219235e-bad5-8a9d-0f3e-c05d5cb11df1@web.de>



On 10/12/19 7:51 AM, Markus Elfring wrote:
> Hello,
> 
> I tried another script for the semantic patch language out.
> This source code analysis approach points out that the implementation
> of the function “tcp_time_wait” contains also a call of the function “kmemdup”.
> 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
> 
> * Do you find the usage of the macro call “BUG_ON” still appropriate at this place?
>   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/checkpatch.pl?id=1c0cc5f1ae5ee5a6913704c0d75a6e99604ee30a#n4080
> 
> * Is there a need to adjust the error handling here?

Presumably the BUG would trigger if a really disturbing bug happened.

There is no chance a timewait socket could be created with a MD5 key, 
if the established socket that is the 'parent' of the timewait
has not a MD5 context itself.

The parent socket only could have MD5 context if tcp_md5sig_pool_populated
could have been set to true.

Once tcp_md5sig_pool_populated is true it can never go back to false.

So the bug here would be that a socket  had a successful MD5 context,
and following tcp_alloc_md5sig_pool() would return false.

We can discuss of all BUG() in general, some people simply disable
all of them (cf CONFIG_BUG), but this particular one does not seem
specially bad to me, compared to others.


  reply	other threads:[~2019-10-13 19:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-12 14:51 Markus Elfring
2019-10-13 19:45 ` Eric Dumazet [this message]
2019-10-14  6:51   ` Markus Elfring
2019-10-14 12:33     ` Eric Dumazet
2019-10-14 12:50       ` Markus Elfring
2019-10-14 13:15         ` Eric Dumazet
2019-10-14 17:19           ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=124b41aa-7ba5-f00c-ab73-cb8e6a2ae75f@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=Markus.Elfring@web.de \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=emamd001@umn.edu \
    --cc=kafai@fb.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kjlu@umn.edu \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pakki001@umn.edu \
    --cc=smccaman@umn.edu \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®