Skip to contentSkip to conversation

net: sched: Fix warnings from xchg() on RCU'd cookie pointer.

PATCH In review David Miller 3 participants 3 messages Jul 8, 2018 – Jul 9, 2018

Subsystems (3)
lore
Share & tools
lore

David Miller

author maintainer
#0 lore raw

PATCH 1/1 net: sched: Fix warnings from xchg() on RCU'd cookie pointer.

The kbuild test robot reports:

Quoted 1 line
Quoted 1 line

net/sched/act_api.c:71:15: sparse: incorrect type in initializer (different address spaces) @@ expected struct tc_cookie [noderef] <asn:4>*__ret @@ got [noderef] <asn:4>*__ret @@

net/sched/act_api.c:71:15: expected struct tc_cookie [noderef] <asn:4>*__ret
net/sched/act_api.c:71:15: got struct tc_cookie *new_cookie

Quoted 1 line
Quoted 1 line

net/sched/act_api.c:71:13: sparse: incorrect type in assignment (different address spaces) @@ expected struct tc_cookie *old @@ got struct tc_cookie [noderef] <struct tc_cookie *old @@

net/sched/act_api.c:71:13: expected struct tc_cookie *old
net/sched/act_api.c:71:13: got struct tc_cookie [noderef] <asn:4>*[assigned] __ret

Quoted 1 line
Quoted 1 line

net/sched/act_api.c:132:48: sparse: dereference of noderef expression

Handle this in the usual way by force casting away the __rcu annotation when we are using xchg() on it.

Fixes eec94fdb0480 ("net: sched: use rcu for action cookie update")
---
 net/sched/act_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/act_api.c +1 -1
index bf1c35f3deb6..66dc19746c63 100644
@@ -68,7 +68,7 @@ static void tcf_set_action_cookie(struct tc_cookie __rcu **old_cookie,
 {
 	struct tc_cookie *old;
 
-	old = xchg(old_cookie, new_cookie);
+	old = xchg((__force struct tc_cookie **)old_cookie, new_cookie);
 	if (old)
 		call_rcu(&old->rcu, tcf_free_cookie_rcu);
 }
Signature · 1 line
2.17.1
#1 lore raw
Quoted 9 lines · David Miller

The kbuild test robot reports:

Quoted 1 line
Quoted 1 line

net/sched/act_api.c:71:15: sparse: incorrect type in initializer (different address spaces) @@ expected struct tc_cookie [noderef] <asn:4>*__ret @@ got [noderef] <asn:4>*__ret @@

net/sched/act_api.c:71:15: expected struct tc_cookie [noderef] <asn:4>*__ret
net/sched/act_api.c:71:15: got struct tc_cookie *new_cookie

Quoted 1 line
Quoted 1 line

net/sched/act_api.c:71:13: sparse: incorrect type in assignment (different address spaces) @@ expected struct tc_cookie *old @@ got struct tc_cookie [noderef] <struct tc_cookie *old @@

net/sched/act_api.c:71:13: expected struct tc_cookie *old
net/sched/act_api.c:71:13: got struct tc_cookie [noderef] <asn:4>*[assigned] __ret

This one:

Quoted 1 line
Quoted 1 line
Quoted 1 line

net/sched/act_api.c:132:48: sparse: dereference of noderef expression

Actually belongs to a different issue, that was reported in the same email, but which wasn't handled in this patch.

Marcelo

#2 lore raw
Quoted 11 lines · Marcelo Ricardo Leitner
Quoted 9 lines · David Miller

The kbuild test robot reports:

Quoted 1 line
Quoted 1 line

net/sched/act_api.c:71:15: sparse: incorrect type in initializer (different address spaces) @@ expected struct tc_cookie [noderef] <asn:4>*__ret @@ got [noderef] <asn:4>*__ret @@

net/sched/act_api.c:71:15: expected struct tc_cookie [noderef] <asn:4>*__ret
net/sched/act_api.c:71:15: got struct tc_cookie *new_cookie

Quoted 1 line
Quoted 1 line

net/sched/act_api.c:71:13: sparse: incorrect type in assignment (different address spaces) @@ expected struct tc_cookie *old @@ got struct tc_cookie [noderef] <struct tc_cookie *old @@

net/sched/act_api.c:71:13: expected struct tc_cookie *old
net/sched/act_api.c:71:13: got struct tc_cookie [noderef] <asn:4>*[assigned] __ret

Quoted 8 lines

This one:

Quoted 1 line
Quoted 1 line
Quoted 1 line

net/sched/act_api.c:132:48: sparse: dereference of noderef expression

Actually belongs to a different issue, that was reported in the same email, but which wasn't handled in this patch.

Marcelo

Thanks,

I've sent the fix.

Vlad