]> git.baikalelectronics.ru Git - kernel.git/commit
net: xfrm: Use sequence counter with associated spinlock
authorAhmed S. Darwish <a.darwish@linutronix.de>
Tue, 16 Mar 2021 10:56:30 +0000 (11:56 +0100)
committerSteffen Klassert <steffen.klassert@secunet.com>
Mon, 22 Mar 2021 06:38:08 +0000 (07:38 +0100)
commit1a80518d92cc8ebbb680e95a851c2981d0102f55
tree4845b0b91b017a9a7533312696baad9393699b54
parent5aadac6e7b2f89425dc9c05b4ea4b56e303b735f
net: xfrm: Use sequence counter with associated spinlock

A sequence counter write section must be serialized or its internal
state can get corrupted. A plain seqcount_t does not contain the
information of which lock must be held to guaranteee write side
serialization.

For xfrm_state_hash_generation, use seqcount_spinlock_t instead of plain
seqcount_t.  This allows to associate the spinlock used for write
serialization with the sequence counter. It thus enables lockdep to
verify that the write serialization lock is indeed held before entering
the sequence counter write section.

If lockdep is disabled, this lock association is compiled out and has
neither storage size nor runtime overhead.

Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
include/net/netns/xfrm.h
net/xfrm/xfrm_state.c