netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antoine Tenart <atenart@kernel.org>
To: davem@davemloft.net, kuba@kernel.org, alexander.duyck@gmail.com
Cc: Antoine Tenart <atenart@kernel.org>,
	netdev@vger.kernel.org, pabeni@redhat.com
Subject: [PATCH net v2 0/3] net-sysfs: fix race conditions in the xps code
Date: Mon, 21 Dec 2020 20:36:41 +0100	[thread overview]
Message-ID: <20201221193644.1296933-1-atenart@kernel.org> (raw)

Hello all,

This series fixes race conditions in the xps code, where out of bound
accesses can occur when dev->num_tc is updated, triggering oops. The
root cause is linked to lock issues. An explanation is given in each of
the commit logs.

Reviews in v1 suggested to use the xps_map_mutex to protect the maps and
their related parameters instead of the rtnl lock. We followed this path
in v2 as it seems a better compromise than taking the rtnl lock.

As a result, patch 1 turned out to be less straight forward as some of
the locking logic in net/core/dev.c related to xps_map_mutex had to be
changed. Patches 2 and 3 are also larger in v2 as code had to be moved
from net/core/net-sysfs.c to net/core/dev.c to take the xps_map_mutex
(however maintainability is improved).

Also, while working on the v2 I stumbled upon another race condition. I
debugged it and the fix is the same as patch 1. I updated its commit log
to describe both races.

Thanks!
Antoine

Antoine Tenart (3):
  net: fix race conditions in xps by locking the maps and dev->tc_num
  net: move the xps cpus retrieval out of net-sysfs
  net: move the xps rxqs retrieval out of net-sysfs

 include/linux/netdevice.h |   9 ++
 net/core/dev.c            | 186 +++++++++++++++++++++++++++++---------
 net/core/net-sysfs.c      |  89 ++++--------------
 3 files changed, 171 insertions(+), 113 deletions(-)

-- 
2.29.2


             reply	other threads:[~2020-12-21 19:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-21 19:36 Antoine Tenart [this message]
2020-12-21 19:36 ` [PATCH net v2 1/3] net: fix race conditions in xps by locking the maps and dev->tc_num Antoine Tenart
2020-12-21 23:21   ` Alexander Duyck
2020-12-22  9:21     ` Antoine Tenart
2020-12-22 16:12       ` Alexander Duyck
2020-12-23 18:27         ` Jakub Kicinski
2020-12-23 19:36           ` Antoine Tenart
2020-12-23 20:11             ` Jakub Kicinski
2020-12-23 20:35               ` Antoine Tenart
2020-12-23 20:43                 ` Jakub Kicinski
2020-12-23 20:56                   ` Antoine Tenart
2020-12-23 20:59                     ` Jakub Kicinski
2020-12-21 19:36 ` [PATCH net v2 2/3] net: move the xps cpus retrieval out of net-sysfs Antoine Tenart
2020-12-21 22:33   ` Alexander Duyck
2020-12-22  9:10     ` Antoine Tenart
2020-12-21 19:36 ` [PATCH net v2 3/3] net: move the xps rxqs " Antoine Tenart

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=20201221193644.1296933-1-atenart@kernel.org \
    --to=atenart@kernel.org \
    --cc=alexander.duyck@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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).