diff options
author | Wei Wang <[email protected]> | 2017-10-06 12:06:06 -0700 |
---|---|---|
committer | David S. Miller <[email protected]> | 2017-10-07 21:22:58 +0100 |
commit | d3843fe5fd45be0e04a251a2cc68893c859a31bd (patch) | |
tree | 57ebae60cb5df226a1fe21c8655f767eedc41fb7 /lib/test-string_helpers.c | |
parent | 51e398e86d61b69b9a4be49ff7f6afeb87530df1 (diff) |
ipv6: replace dst_hold() with dst_hold_safe() in routing code
With rwlock, it is safe to call dst_hold() in the read thread because
read thread is guaranteed to be separated from write thread.
However, after we replace rwlock with rcu, it is no longer safe to use
dst_hold(). A dst might already have been deleted but is waiting for the
rcu grace period to pass before freeing the memory when a read thread is
trying to do dst_hold(). This could potentially cause double free issue.
So this commit replaces all dst_hold() with dst_hold_safe() in all read
thread to avoid this double free issue.
And in order to make the code more compact, a new function ip6_hold_safe()
is introduced. It calls dst_hold_safe() first, and if that fails, it will
either fall back to hold and return net->ipv6.ip6_null_entry or set rt to
NULL according to the caller's need.
Signed-off-by: Wei Wang <[email protected]>
Signed-off-by: Martin KaFai Lau <[email protected]>
Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Diffstat (limited to 'lib/test-string_helpers.c')
0 files changed, 0 insertions, 0 deletions