Received: by 10.223.185.111 with SMTP id b44csp907193wrg; Fri, 9 Mar 2018 16:33:02 -0800 (PST) X-Google-Smtp-Source: AG47ELsEa/lnvWlkzNufDLC93zW/MDq56CCWBun1PcW3NAx3hwIh4Vm833B4lbqb+jH+41jn5eek X-Received: by 2002:a17:902:a5c2:: with SMTP id t2-v6mr359061plq.244.1520641982478; Fri, 09 Mar 2018 16:33:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520641982; cv=none; d=google.com; s=arc-20160816; b=WQQpuBoXFNPHeEQetR3fRfYztuZO6U8f3bm3EUNgW+yutJo/yi2ry2DS+R2DLyrGhR 1rKAGQCKrCvMqyetttSmdPj1mxRQGrbU+VWkyHW1nV4dscmyXvNLJLAMUTLIv+TZVRY/ 3fjbtMBYj//LBg+CWocTYLcdVqUUFshBMWS/+01edDmMxGuV1+s2qL3Ica7ROXlrd1mz WZowTe/23Zlbfz6NKlFhjuI3p2AUHaH8lJAqszOm7DAZDdIClBOhpz1Y4bRO3FYwCeuj fnfBRnGreb1n0J9G5f+FKV/PF01uVf69PMLumD80kwgit0bXeLpbkk49DikNpk2pyGN1 dXRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=iLbLU9T/oZHglQ+cXqGBKoA+oZDvfHNT2rdZK7rbPH0=; b=mYvMmxPeHjiulZCrIMP4Zm0v0fjU13nPdZ/DNwwQrRJ+cL+6G2qOz9/mQ8iSOPgHZ8 fum8ZWUG0cLNyg7l/BVWry8fqXqOmnrfzIVzZd5rcXuj3JiScwmqfOMapOkKMnAYpJgt hu8RXPMbJX9NZONOcSbZYltrxigNyDEC3OK+fUF5Gu6dogMh7t8ylqXYe5mD8qUbqC0m Wg7U5IMNBRB8S+AYWfYDyUVJ6mN9drXkkGqcy7h/mikOT0E9Qh5g/IPMbbahzO6wpRxL GxVqu4iIwf3/pfxwha9v/pEsi0aPbMHChnN8vlJw9HbIXZt+2Cj4Cm1YOPq2lIGop/NL dFWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s62si1513526pgc.184.2018.03.09.16.32.48; Fri, 09 Mar 2018 16:33:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933901AbeCJAWg (ORCPT + 99 others); Fri, 9 Mar 2018 19:22:36 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40050 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933886AbeCJAWe (ORCPT ); Fri, 9 Mar 2018 19:22:34 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id ABD3D115E; Sat, 10 Mar 2018 00:22:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julian Wiedmann , "David S. Miller" Subject: [PATCH 4.9 53/65] s390/qeth: fix double-free on IP add/remove race Date: Fri, 9 Mar 2018 16:18:53 -0800 Message-Id: <20180310001829.247586802@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001824.927996722@linuxfoundation.org> References: <20180310001824.927996722@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Julian Wiedmann [ Upstream commit 14d066c3531a87f727968cacd85bd95c75f59843 ] 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: 5f78e29ceebf ("qeth: optimize IP handling in rx_mode callback") Signed-off-by: Julian Wiedmann Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/s390/net/qeth_l3_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -323,7 +323,8 @@ int qeth_l3_add_ip(struct qeth_card *car (rc == IPA_RC_LAN_OFFLINE)) { addr->disp_flag = QETH_DISP_ADDR_DO_NOTHING; if (addr->ref_counter < 1) { - qeth_l3_delete_ip(card, addr); + qeth_l3_deregister_addr_entry(card, addr); + hash_del(&addr->hnode); kfree(addr); } } else {