Skip to content

Commit ab5fb73

Browse files
q2venkuba-moo
authored andcommitted
ping: Fix potentail NULL deref for /proc/net/icmp.
After commit dbca159 ("ping: convert to RCU lookups, get rid of rwlock"), we use RCU for ping sockets, but we should use spinlock for /proc/net/icmp to avoid a potential NULL deref mentioned in the previous patch. Let's go back to using spinlock there. Note we can convert ping sockets to use hlist instead of hlist_nulls because we do not use SLAB_TYPESAFE_BY_RCU for ping sockets. Fixes: dbca159 ("ping: convert to RCU lookups, get rid of rwlock") Signed-off-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0a78cf7 commit ab5fb73

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/ipv4/ping.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,13 +1089,13 @@ static struct sock *ping_get_idx(struct seq_file *seq, loff_t pos)
10891089
}
10901090

10911091
void *ping_seq_start(struct seq_file *seq, loff_t *pos, sa_family_t family)
1092-
__acquires(RCU)
1092+
__acquires(ping_table.lock)
10931093
{
10941094
struct ping_iter_state *state = seq->private;
10951095
state->bucket = 0;
10961096
state->family = family;
10971097

1098-
rcu_read_lock();
1098+
spin_lock(&ping_table.lock);
10991099

11001100
return *pos ? ping_get_idx(seq, *pos-1) : SEQ_START_TOKEN;
11011101
}
@@ -1121,9 +1121,9 @@ void *ping_seq_next(struct seq_file *seq, void *v, loff_t *pos)
11211121
EXPORT_SYMBOL_GPL(ping_seq_next);
11221122

11231123
void ping_seq_stop(struct seq_file *seq, void *v)
1124-
__releases(RCU)
1124+
__releases(ping_table.lock)
11251125
{
1126-
rcu_read_unlock();
1126+
spin_unlock(&ping_table.lock);
11271127
}
11281128
EXPORT_SYMBOL_GPL(ping_seq_stop);
11291129

0 commit comments

Comments
 (0)