netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gong, Sishuai" <sishuai@purdue.edu>
To: "davem@davemloft.net" <davem@davemloft.net>,
	"yoshfuji@linux-ipv6.org" <yoshfuji@linux-ipv6.org>,
	"dsahern@kernel.org" <dsahern@kernel.org>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Data race on dev->mtu betwen __dev_set_mtu() and rawv6_send_hdrinc()
Date: Mon, 22 Feb 2021 23:28:23 +0000	[thread overview]
Message-ID: <6D39040C-4C5E-4CF1-8594-221F0BB38E3E@purdue.edu> (raw)

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().


Thanks,
Sishuai


             reply	other threads:[~2021-02-22 23:29 UTC|newest]

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

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=6D39040C-4C5E-4CF1-8594-221F0BB38E3E@purdue.edu \
    --to=sishuai@purdue.edu \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=netdev@vger.kernel.org \
    --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).