Skip to content

Commit 93a2014

Browse files
congwangdavem330
authored andcommitted
atm: fix a UAF in lec_arp_clear_vccs()
Gengming reported a UAF in lec_arp_clear_vccs(), where we add a vcc socket to an entry in a per-device list but free the socket without removing it from the list when vcc->dev is NULL. We need to call lec_vcc_close() to search and remove those entries contain the vcc being destroyed. This can be done by calling vcc->push(vcc, NULL) unconditionally in vcc_destroy_socket(). Another issue discovered by Gengming's reproducer is the vcc->dev may point to the static device lecatm_dev, for which we don't need to register/unregister device, so we can just check for vcc->dev->ops->owner. Reported-by: Gengming Liu <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 44d95cc commit 93a2014

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

net/atm/common.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,18 @@ static void vcc_destroy_socket(struct sock *sk)
177177

178178
set_bit(ATM_VF_CLOSE, &vcc->flags);
179179
clear_bit(ATM_VF_READY, &vcc->flags);
180-
if (vcc->dev) {
181-
if (vcc->dev->ops->close)
182-
vcc->dev->ops->close(vcc);
183-
if (vcc->push)
184-
vcc->push(vcc, NULL); /* atmarpd has no push */
185-
module_put(vcc->owner);
186-
187-
while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
188-
atm_return(vcc, skb->truesize);
189-
kfree_skb(skb);
190-
}
180+
if (vcc->dev && vcc->dev->ops->close)
181+
vcc->dev->ops->close(vcc);
182+
if (vcc->push)
183+
vcc->push(vcc, NULL); /* atmarpd has no push */
184+
module_put(vcc->owner);
185+
186+
while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
187+
atm_return(vcc, skb->truesize);
188+
kfree_skb(skb);
189+
}
191190

191+
if (vcc->dev && vcc->dev->ops->owner) {
192192
module_put(vcc->dev->ops->owner);
193193
atm_dev_put(vcc->dev);
194194
}

0 commit comments

Comments
 (0)