Received: by 10.223.185.116 with SMTP id b49csp5449918wrg; Wed, 7 Mar 2018 11:59:25 -0800 (PST) X-Google-Smtp-Source: AG47ELuuFENfAhJXlnIwV2OHN4ptoovyd7baHw9mKt4Qh2sQM1+ofiaCOeMScV9FzFGXwwh0cGlY X-Received: by 10.101.76.204 with SMTP id n12mr19228472pgt.249.1520452765554; Wed, 07 Mar 2018 11:59:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520452765; cv=none; d=google.com; s=arc-20160816; b=WX+pBz0l/PORIi9Fx5Zvqm8S0MXCvs/Tociidg8PU/Bq2Mz1BTz8NOB+VwsXbxK4cw Z8e5b2PSnDkSp5gYTFmLhWRuCyuyht6GZlUHbZeAlPthC4UaWpBEZYhvtno1s7ViZ1VP r77SgaZUSh6qLyetZ9r0idjxwL3O/j3u+GlIVB3pinBEtVuCfcgE7/4NWfbnwCu+H2tu 9Gw15tHLgdgisLpsgXhNyHUysnEEZpAz5ZhnZqYNJyFZsZJGkh9MHNPzOmWx23VoioDI ECEYqismz4JAvElmgxA/tLhGubobgAtp3nsBQl+5i96j3XzuIDi26HadpfWWPNXduXGA mqnA== 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=onZitOd7hAZgpZu5kJs3CVJjP77iiUpaejuvvtZZ1/M=; b=ONEd85D/lk0ZVToWmzw7ZFwQcLzot6utA8xhzPH93T1BumGqbqzx0Lrd5cqInk5iFy aDSSNm4cQn2JpZiP/kjYjXVrnb/v1ADoaQYLqUv4PZGMXr2qcPXO6NFbDtfggk0/sVuU 0v/QmvnMddCevNJQrDjAHBdiVSrlpogdeRFnm+vPS+l1Gi4hrk48BaQ49a6LipPGM2vi SioB4ckHoLlj+vv+vg4AeyjJGIyAQo10gf2nBB2e24z4gQ2g9lq4HsUCkPAHjevE9tZz tP21cZayOoOs9sTsnqUriBjOXBt1WbYvIUNwcSpSnZK2BIWtCgSXSfEBdSPaJk6xCNKb rJ8A== 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 97-v6si13550396pla.96.2018.03.07.11.59.11; Wed, 07 Mar 2018 11:59:25 -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 S1754931AbeCGTrO (ORCPT + 99 others); Wed, 7 Mar 2018 14:47:14 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44898 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965684AbeCGTrL (ORCPT ); Wed, 7 Mar 2018 14:47:11 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6B55810DB; Wed, 7 Mar 2018 19:47:10 +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.14 079/110] s390/qeth: fix double-free on IP add/remove race Date: Wed, 7 Mar 2018 11:39:02 -0800 Message-Id: <20180307191049.893684570@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180307191039.748351103@linuxfoundation.org> References: <20180307191039.748351103@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.14-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 @@ -319,7 +319,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 {