Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp540057imu; Tue, 27 Nov 2018 16:56:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/WD6ik6inoWKAZAscqKyolfqnCX9tuOB0cPbO3pXY8JDAd5LrdJt3LOjfXQctIDJU94jOUh X-Received: by 2002:a63:66c6:: with SMTP id a189mr31329989pgc.167.1543366602903; Tue, 27 Nov 2018 16:56:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543366602; cv=none; d=google.com; s=arc-20160816; b=E2ZQm428iYOONHntQZ6uVYvfF1+1Vg+jQhvEsxJJn4bds4xikxfIDM1D/rCF2Dn4pi NmHVWJewJ0uLAbyk+cBXYq8uSrv6ABuOjenkQU+crvZBEt64tcVv2+i1wqWwjoakM1ZD fIOc8FkxfBaZLOq9iQnTyA967rWw+aYUBh43efrgLRVBYcgc1uGuOkLrlG6Pcwnn+nQ2 e+MRWa1w93lbLYK0SBG1hA4rasTJgNBSxiKFl1mr5X8o1evl9vZe3nRpAwlPXqOuQwWc ZiYgPniHTL9QSUXt602/3CpVmyJZdv6dHiDSyVa3xtfiRC+gfyJZ4hT8MTUSyDIioylw gq2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=kr1v9j9sNHqtJwDizzBzO5O23+o4sg+9l5iPrfz+Os0=; b=TkBbb5jmBDwTydvS4JI0Mw6Ffjd8C87ZxTkf47WpsaDdxsOsc+v9rmmA/vIUvKZ7dC UE5Y5SbKlwqetI3T42LdMyiPrYmVzsvUc8z3GTv1N2S13c311N1UNqdp6c/YVHrMIUmT Wsg8znLjRixijiFXZaOlrcLQQjDYOGQqaQGIsf6K4+B2ArzU/J5N4/Oj0knRwBNMPJSz FjUsvtDAlgfXzYX0lggwahurHtnVWrh9cqNLk8GOkFX+tZahqtEMxTJSTyuqvOZOiNt1 i3ngjxyD7j8gjjOx9mOKiYdU2hs4ufMjjVV+7/etmbaNxIdIfoNkTXI86rtZNA6gdoul Uu0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=f273KR74; 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 f32-v6si5538079plf.65.2018.11.27.16.56.28; Tue, 27 Nov 2018 16:56:42 -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=@163.com header.s=s110527 header.b=f273KR74; 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 S1727107AbeK1LzR (ORCPT + 99 others); Wed, 28 Nov 2018 06:55:17 -0500 Received: from m12-12.163.com ([220.181.12.12]:49098 "EHLO m12-12.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726418AbeK1LzR (ORCPT ); Wed, 28 Nov 2018 06:55:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=kr1v9j9sNHqtJwDizz BzO5O23+o4sg+9l5iPrfz+Os0=; b=f273KR74kLelBDWxGPLDima+y4HCcho1DF u1tmvGG008g4jU5tLzEL4Ze79NFDkxaSlquheoNtzFJDksokc5xzq3hqBR7rgOdB QVA8wbWjhsq8LZOujSbiAmgiwCkDZgVbqLN78TZqJRzJh9acI0st7bO4UDG/60ia FakJp8j7I= Received: from bp.localdomain (unknown [106.120.213.96]) by smtp8 (Coremail) with SMTP id DMCowADnDuB95_1bijY1CQ--.34027S3; Wed, 28 Nov 2018 08:55:30 +0800 (CST) From: Pan Bian To: "David S. Miller" Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH] sis5513: fix potential use after free Date: Wed, 28 Nov 2018 08:55:26 +0800 Message-Id: <1543366526-46767-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: DMCowADnDuB95_1bijY1CQ--.34027S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7JFWUXF1DGw1kCF4xur4fGrg_yoWDZwb_CF yvy397Ga1rZryUuw47Gr4SvrZIg3Wqgr48WFs7tr9I934Yv3Z5Wrykurn5JrW7u34xJrW3 Kw42vr4UAryjyjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0ubyJUUUUU== X-Originating-IP: [106.120.213.96] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBzwINclaD0cJA3gAAsq Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The function sis_find_family drops lpc_bridge reference via pci_dev_put, however, after that, field lpc_bridge->revision is read. This may result in a use after free bug. The patch moves the put operation after the condition check. Signed-off-by: Pan Bian --- drivers/ide/sis5513.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/ide/sis5513.c b/drivers/ide/sis5513.c index 024bc7b..69f9889 100644 --- a/drivers/ide/sis5513.c +++ b/drivers/ide/sis5513.c @@ -434,7 +434,6 @@ static int sis_find_family(struct pci_dev *dev) lpc_bridge = pci_get_slot(dev->bus, 0x10); /* Bus 0, Dev 2, Fn 0 */ pci_read_config_byte(dev, 0x49, &prefctl); - pci_dev_put(lpc_bridge); if (lpc_bridge->revision == 0x10 && (prefctl & 0x80)) { printk(KERN_INFO DRV_NAME " %s: SiS 961B MuTIOL IDE UDMA133 controller\n", @@ -445,6 +444,8 @@ static int sis_find_family(struct pci_dev *dev) pci_name(dev)); chipset_family = ATA_100; } + + pci_dev_put(lpc_bridge); } } -- 2.7.4