Skip to content

static keys: fix test/set races

[email protected] lkml netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 13 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3static_keys: Add a static_key_slow_set_true()/false() interfaceDocumentation/static-keys.txt include/linux/jump_label.h kernel/jump_label.c+78 -01 reply
2/3sched: fix static keys race in sched_featkernel/sched/core.c kernel/sched/sched.h+10 -121 reply
3/3udp: make use of static_key_slow_set_true() interfacenet/ipv4/udp.c net/ipv6/udp.c+8 -103 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] static keys: fix test/set races

Hi,

As pointed out by Andi Kleen, some static key users can be racy because they check the value of the key->enabled, and then subsequently update the branch direction. A number of call sites have 'higher' level locking that avoids this race, but the usage in the scheduler features does not. See:
http://lkml.indiana.edu/hypermail/linux/kernel/1304.2/01655.html

Thus, introduce a new API that does the check and set under the 'jump_label_mutex'. This should also allow to simplify call sites a bit.

Users of static keys should use either the inc/dec or the set_true/set_false API.

Thanks,

-Jason

Jason Baron (3):
static_keys: Add a static_key_slow_set_true()/false() interface
sched: fix static keys race in sched_feat
udp: make use of static_key_slow_set_true() interface

 Documentation/static-keys.txt |    8 ++++++++
 include/linux/jump_label.h    |   30 ++++++++++++++++++++++++++++++
 kernel/jump_label.c           |   40 ++++++++++++++++++++++++++++++++++++++++
 kernel/sched/core.c           |   12 +++++-------
 kernel/sched/sched.h          |   10 +++++-----
 net/ipv4/udp.c                |    9 ++++-----
 net/ipv6/udp.c                |    9 ++++-----
 7 files changed, 96 insertions(+), 22 deletions(-)
Signature · 1 line
1.7.9.5