Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3693919imu; Mon, 28 Jan 2019 09:10:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN41vR/MXFgcomoN/5Ll+rYFcEfvTaGuiX5W1Rs3thpU/YdecehERL8QufW3BlzeJdkr5WWn X-Received: by 2002:a62:c185:: with SMTP id i127mr22853725pfg.43.1548695407059; Mon, 28 Jan 2019 09:10:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548695407; cv=none; d=google.com; s=arc-20160816; b=tYILk/wfrt+s1v1YpvQYdFRYD356+SlEi4PFmIF3t5id4g39AdT5JZUOldwvSFkCbl NW7nHw4hxdBIu2CiNtqiVfPLrzwMT3hZJgiUrS+0/pPuYBKaiAD1DyTHRBR49auAj/kl gi1LRu2H9q5GI5R+Lp7E7z/UK8HltnerJ4WZu1mW08DKAwECKqspydizMuH4HIfoqGQH 1bgFYIr5wp5N3ISqM1rX+1D6fri7qp67FEiHoJ31Zgp5downriA2SONFtNS/fzo/i+Rf fqx598abBjTbyTE52pjyin+pqmxCruWb1OLsXlHqtiPdEzQIOX9YxLv+gt1XwFeIjC6a 3Z/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bTzbIJZK1noO4VUhD2P07+7tS0fxhSu7E9TQr1wdsOs=; b=U8Pg257le+U6WOs6jKcwQK1e15ivbdlAKfdZhDtOqryw+seLxxvFYs+2auNwRIp9jb cbJ77XDj0cuwaZw+mf83Z+5nZwSMxq3rfKmusaSe5SrG8NpX7FWv5Quu11mePl6swVTF PF5wzHMjdoFikJPkZWbhcFuFMtZroCqpvZwF7Df/jcophOXOZ5O60xEWt5EAwT8lZv+D LXr3cgQoNPNRZevqBvgTZ0fL77Zz7osuv7QWJXTkBy/BC4W2rOAQf0tJeVqgQcv2ohi/ Sk/q/R+ALguC2Q1G7ks/BD3FKaU3GYdM/oJWvF3PLh6V+r8IvnGuiWuE7+0n7yYwyuCe f+Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=odDwNeIh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s5si32824026plr.211.2019.01.28.09.09.51; Mon, 28 Jan 2019 09:10:07 -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; dkim=pass header.i=@kernel.org header.s=default header.b=odDwNeIh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732490AbfA1QLK (ORCPT + 99 others); Mon, 28 Jan 2019 11:11:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:37766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732458AbfA1QLE (ORCPT ); Mon, 28 Jan 2019 11:11:04 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 87F332147A; Mon, 28 Jan 2019 16:11:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691863; bh=Dzb8swYORe+ZNnHtgCCCNHB/2f/v7Z28FNv+XAIXqYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=odDwNeIhE5we/iCSB+o825e+ed5bshTT6fBJfsbbxYZkAOsAniVqzZRfegHKdrRrG uF+95ZpkelCeLXuiM3BoOiWTvvfcE3tXNiVxaBz6rttd8kUwtWFEmlC5gVFyMRe878 SZ3iHO5rExJJzlcTx7BzoZsfPUvaNJmcji1kbwuw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jia-Ju Bai , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 240/258] isdn: hisax: hfc_pci: Fix a possible concurrency use-after-free bug in HFCPCI_l1hw() Date: Mon, 28 Jan 2019 10:59:06 -0500 Message-Id: <20190128155924.51521-240-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia-Ju Bai [ Upstream commit 7418e6520f22a2e35815122fa5a53d5bbfa2c10f ] In drivers/isdn/hisax/hfc_pci.c, the functions hfcpci_interrupt() and HFCPCI_l1hw() may be concurrently executed. HFCPCI_l1hw() line 1173: if (!cs->tx_skb) hfcpci_interrupt() line 942: spin_lock_irqsave(); line 1066: dev_kfree_skb_irq(cs->tx_skb); Thus, a possible concurrency use-after-free bug may occur in HFCPCI_l1hw(). To fix these bugs, the calls to spin_lock_irqsave() and spin_unlock_irqrestore() are added in HFCPCI_l1hw(), to protect the access to cs->tx_skb. Signed-off-by: Jia-Ju Bai Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/isdn/hisax/hfc_pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c index 8e5b03161b2f..64a63711fd95 100644 --- a/drivers/isdn/hisax/hfc_pci.c +++ b/drivers/isdn/hisax/hfc_pci.c @@ -1170,11 +1170,13 @@ HFCPCI_l1hw(struct PStack *st, int pr, void *arg) if (cs->debug & L1_DEB_LAPD) debugl1(cs, "-> PH_REQUEST_PULL"); #endif + spin_lock_irqsave(&cs->lock, flags); if (!cs->tx_skb) { test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags); st->l1.l1l2(st, PH_PULL | CONFIRM, NULL); } else test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags); + spin_unlock_irqrestore(&cs->lock, flags); break; case (HW_RESET | REQUEST): spin_lock_irqsave(&cs->lock, flags); -- 2.19.1