mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
net/sched: don't dereference a->goto_chain to read the chain index
[ Upstream commitfe384e2fa3] callers of tcf_gact_goto_chain_index() can potentially read an old value of the chain index, or even dereference a NULL 'goto_chain' pointer, because 'goto_chain' and 'tcfa_action' are read in the traffic path without caring of concurrent write in the control path. The most recent value of chain index can be read also from a->tcfa_action (it's encoded there together with TC_ACT_GOTO_CHAIN bits), so we don't really need to dereference 'goto_chain': just read the chain id from the control action. Fixes:e457d86ada("net: sched: add couple of goto_chain helpers") Signed-off-by: Davide Caratti <dcaratti@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
670588f2eb
commit
d2e7387e51
@@ -51,7 +51,7 @@ static inline bool is_tcf_gact_goto_chain(const struct tc_action *a)
|
||||
|
||||
static inline u32 tcf_gact_goto_chain_index(const struct tc_action *a)
|
||||
{
|
||||
return a->goto_chain->index;
|
||||
return READ_ONCE(a->tcfa_action) & TC_ACT_EXT_VAL_MASK;
|
||||
}
|
||||
|
||||
#endif /* __NET_TC_GACT_H */
|
||||
|
||||
Reference in New Issue
Block a user