mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 02:24:24 +02:00
xfrm: state: add xfrm_state_deref_prot to state_by* walk under lock
We're under xfrm_state_lock for all those walks, we can use xfrm_state_deref_prot to silence sparse warnings such as: net/xfrm/xfrm_state.c:933:17: warning: dereference of noderef expression Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
parent
55b5bc0314
commit
33cefb76a8
|
|
@ -870,7 +870,7 @@ xfrm_state_flush_secctx_check(struct net *net, u8 proto, bool task_valid)
|
|||
for (i = 0; i <= net->xfrm.state_hmask; i++) {
|
||||
struct xfrm_state *x;
|
||||
|
||||
hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) {
|
||||
hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + i, bydst) {
|
||||
if (xfrm_id_proto_match(x->id.proto, proto) &&
|
||||
(err = security_xfrm_state_delete(x)) != 0) {
|
||||
xfrm_audit_state_delete(x, 0, task_valid);
|
||||
|
|
@ -891,7 +891,7 @@ xfrm_dev_state_flush_secctx_check(struct net *net, struct net_device *dev, bool
|
|||
struct xfrm_state *x;
|
||||
struct xfrm_dev_offload *xso;
|
||||
|
||||
hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) {
|
||||
hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + i, bydst) {
|
||||
xso = &x->xso;
|
||||
|
||||
if (xso->dev == dev &&
|
||||
|
|
@ -931,7 +931,7 @@ int xfrm_state_flush(struct net *net, u8 proto, bool task_valid)
|
|||
for (i = 0; i <= net->xfrm.state_hmask; i++) {
|
||||
struct xfrm_state *x;
|
||||
restart:
|
||||
hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) {
|
||||
hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + i, bydst) {
|
||||
if (!xfrm_state_kern(x) &&
|
||||
xfrm_id_proto_match(x->id.proto, proto)) {
|
||||
xfrm_state_hold(x);
|
||||
|
|
@ -973,7 +973,7 @@ int xfrm_dev_state_flush(struct net *net, struct net_device *dev, bool task_vali
|
|||
err = -ESRCH;
|
||||
for (i = 0; i <= net->xfrm.state_hmask; i++) {
|
||||
restart:
|
||||
hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) {
|
||||
hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + i, bydst) {
|
||||
xso = &x->xso;
|
||||
|
||||
if (!xfrm_state_kern(x) && xso->dev == dev) {
|
||||
|
|
@ -1652,7 +1652,7 @@ xfrm_stateonly_find(struct net *net, u32 mark, u32 if_id,
|
|||
|
||||
spin_lock_bh(&net->xfrm.xfrm_state_lock);
|
||||
h = xfrm_dst_hash(net, daddr, saddr, reqid, family);
|
||||
hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) {
|
||||
hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + h, bydst) {
|
||||
if (x->props.family == family &&
|
||||
x->props.reqid == reqid &&
|
||||
(mark & x->mark.m) == x->mark.v &&
|
||||
|
|
@ -1779,7 +1779,7 @@ static void __xfrm_state_bump_genids(struct xfrm_state *xnew)
|
|||
u32 cpu_id = xnew->pcpu_num;
|
||||
|
||||
h = xfrm_dst_hash(net, &xnew->id.daddr, &xnew->props.saddr, reqid, family);
|
||||
hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) {
|
||||
hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + h, bydst) {
|
||||
if (x->props.family == family &&
|
||||
x->props.reqid == reqid &&
|
||||
x->if_id == if_id &&
|
||||
|
|
@ -1815,7 +1815,7 @@ static struct xfrm_state *__find_acq_core(struct net *net,
|
|||
struct xfrm_state *x;
|
||||
u32 mark = m->v & m->m;
|
||||
|
||||
hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) {
|
||||
hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + h, bydst) {
|
||||
if (x->props.reqid != reqid ||
|
||||
x->props.mode != mode ||
|
||||
x->props.family != family ||
|
||||
|
|
@ -2097,7 +2097,7 @@ struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *n
|
|||
if (m->reqid) {
|
||||
h = xfrm_dst_hash(net, &m->old_daddr, &m->old_saddr,
|
||||
m->reqid, m->old_family);
|
||||
hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) {
|
||||
hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + h, bydst) {
|
||||
if (x->props.mode != m->mode ||
|
||||
x->id.proto != m->proto)
|
||||
continue;
|
||||
|
|
@ -2116,7 +2116,7 @@ struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *n
|
|||
} else {
|
||||
h = xfrm_src_hash(net, &m->old_daddr, &m->old_saddr,
|
||||
m->old_family);
|
||||
hlist_for_each_entry(x, net->xfrm.state_bysrc+h, bysrc) {
|
||||
hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bysrc, net) + h, bysrc) {
|
||||
if (x->props.mode != m->mode ||
|
||||
x->id.proto != m->proto)
|
||||
continue;
|
||||
|
|
@ -2319,7 +2319,7 @@ void xfrm_state_update_stats(struct net *net)
|
|||
|
||||
spin_lock_bh(&net->xfrm.xfrm_state_lock);
|
||||
for (i = 0; i <= net->xfrm.state_hmask; i++) {
|
||||
hlist_for_each_entry(x, net->xfrm.state_bydst + i, bydst)
|
||||
hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_bydst, net) + i, bydst)
|
||||
xfrm_dev_state_update_stats(x);
|
||||
}
|
||||
spin_unlock_bh(&net->xfrm.xfrm_state_lock);
|
||||
|
|
@ -2510,7 +2510,7 @@ static struct xfrm_state *__xfrm_find_acq_byseq(struct net *net, u32 mark, u32 s
|
|||
unsigned int h = xfrm_seq_hash(net, seq);
|
||||
struct xfrm_state *x;
|
||||
|
||||
hlist_for_each_entry_rcu(x, net->xfrm.state_byseq + h, byseq) {
|
||||
hlist_for_each_entry(x, xfrm_state_deref_prot(net->xfrm.state_byseq, net) + h, byseq) {
|
||||
if (x->km.seq == seq &&
|
||||
(mark & x->mark.m) == x->mark.v &&
|
||||
x->pcpu_num == pcpu_num &&
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user