Skip to content

Commit 14d066c

Browse files
julianwiedmanndavem330
authored andcommitted
s390/qeth: fix double-free on IP add/remove race
Registering an IPv4 address with the HW takes quite a while, so we temporarily drop the ip_htable lock. Any concurrent add/remove of the same IP adjusts the IP's use count, and (on remove) is then blocked by addr->in_progress. After the register call has completed, we check the use count for concurrently attempted add/remove calls - and possibly straight-away deregister the IP again. This happens via l3_delete_ip(), which 1) looks up the queried IP in the htable (getting a reference to the *same* queried object), 2) deregisters the IP from the HW, and 3) frees the IP object. The caller in l3_add_ip() then does a second free on the same object. For this case, skip all the extra checks and lookups in l3_delete_ip() and just deregister & free the IP object ourselves. Fixes: 5f78e29 ("qeth: optimize IP handling in rx_mode callback") Signed-off-by: Julian Wiedmann <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 98d823a commit 14d066c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/s390/net/qeth_l3_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ int qeth_l3_add_ip(struct qeth_card *card, struct qeth_ipaddr *tmp_addr)
237237
(rc == IPA_RC_LAN_OFFLINE)) {
238238
addr->disp_flag = QETH_DISP_ADDR_DO_NOTHING;
239239
if (addr->ref_counter < 1) {
240-
qeth_l3_delete_ip(card, addr);
240+
qeth_l3_deregister_addr_entry(card, addr);
241+
hash_del(&addr->hnode);
241242
kfree(addr);
242243
}
243244
} else {

0 commit comments

Comments
 (0)