netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: "Gong, Sishuai" <sishuai@purdue.edu>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"yoshfuji@linux-ipv6.org" <yoshfuji@linux-ipv6.org>,
	"dsahern@kernel.org" <dsahern@kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: Data race on dev->mtu betwen __dev_set_mtu() and rawv6_send_hdrinc()
Date: Tue, 23 Feb 2021 10:25:36 -0500	[thread overview]
Message-ID: <CA+FuTSc0FRPJZubXrvojzNP9MvTp3rfJeH2zOQbETCNV80oOcA@mail.gmail.com> (raw)
In-Reply-To: <6D39040C-4C5E-4CF1-8594-221F0BB38E3E@purdue.edu>

On Mon, Feb 22, 2021 at 6:30 PM Gong, Sishuai <sishuai@purdue.edu> wrote:
>
> Hello,
>
> We found a data race on dev->mtu between function __dev_set_mtu() and rawv6_send_hdrinc(). It happens with the following interleaving.
>
> writer: __dev_set_mtu()                                                                         reader: rawv6_send_hdrinc()
>                                                                                                                 if (length > rt->dst.dev->mtu) {
>         WRITE_ONCE(dev->mtu, new_mtu);
>                                                                                                                         ipv6_local_error(sk, EMSGSIZE, fl6, rt->dst.dev->mtu);
>
> If the writer happens to change dev->mtu to a value that is bigger than the variable ‘length’, then ipv6_local_error will read a value that doesn’t satisfy this conditional statement. While there is no need to use lock to protect the read, it is probably better to only read dev->mtu once in rawv6_send_hdrinc().

Makes sense. The same would then apply to raw_send_hdrinc().

      reply	other threads:[~2021-02-23 15:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22 23:28 Data race on dev->mtu betwen __dev_set_mtu() and rawv6_send_hdrinc() Gong, Sishuai
2021-02-23 15:25 ` Willem de Bruijn [this message]

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=CA+FuTSc0FRPJZubXrvojzNP9MvTp3rfJeH2zOQbETCNV80oOcA@mail.gmail.com \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sishuai@purdue.edu \
    --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;
as well as URLs for NNTP newsgroup(s).