Skip to content

Commit 2a3db83

Browse files
julianwiedmanngregkh
authored andcommitted
s390/qeth: fix double-free on IP add/remove race
[ Upstream commit 14d066c ] 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 <jwi@linux.vnet.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1537f14 commit 2a3db83

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/s390/net/qeth_l3_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ int qeth_l3_add_ip(struct qeth_card *card, struct qeth_ipaddr *tmp_addr)
323323
(rc == IPA_RC_LAN_OFFLINE)) {
324324
addr->disp_flag = QETH_DISP_ADDR_DO_NOTHING;
325325
if (addr->ref_counter < 1) {
326-
qeth_l3_delete_ip(card, addr);
326+
qeth_l3_deregister_addr_entry(card, addr);
327+
hash_del(&addr->hnode);
327328
kfree(addr);
328329
}
329330
} else {

0 commit comments

Comments
 (0)