Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1072842pxb; Thu, 19 Nov 2020 23:47:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrZFtYeYJQ/tY8eec47g34e5BF4UD7JNHTn6zYS3NOXRoWSC8t9eegJ8c2lWYahUfWmwDz X-Received: by 2002:a17:906:af8b:: with SMTP id mj11mr32401682ejb.129.1605858426111; Thu, 19 Nov 2020 23:47:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605858426; cv=none; d=google.com; s=arc-20160816; b=vDKozj3K7R+xj6AjqxDMFweg10CXhqucHbZAMDd8GUVjw935QwVsdhonSbARiT/eHV 0zEUnlCooOuFhDOULbOxOWAd1J3OZhsX0OKvv/TGJ5cxpGbD8VU09aW+4l8cmDMJwqtY dser8N2pvLxDxd0vbZImIXXA3ifgLzFstyWlDyTX8pshIq5tnYQ/tBr2VofadSmFS5Ko OJs1IvKhsrHTtpNDbZhD8Ck9UIMeV+SthPJMlKyWDmTQXH8Da+Vc69+O7rv4GABWWyHJ /QmULKvwPZLFFEXrxHHUK844eEbKdLQTTcUIwQWMgWpyKnaGjNaPu5Vg7XLqc5G76BX1 adbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Ct2rclOkGuvbOLvzxw/xEjYC6RJpMqY5gKkrpJ+7Pig=; b=kjvi8/T77Z2ZesLtPyQfjTSjQXMoR90T+cAUUcQunuZLUwLSoPdAV43eXZC06rMcAs 1RBNzfQ03MDZGa9350ho0Kwkw7JImUwCGMMRhthaiCRNvfXwIH8uUZyY/38rOUFFaXy2 XKr0JzsCqYtnkmFczR0aEHnyRtDsORN3oSCxY/KTbyQ9G3NBOca06svKJoX/fUi/6czi w5YKeweoDNXovlWruXjNjR9hpBw8/HOOna4iqpACAEH4MT5LOoFRr5Es0KTS4IBEl3bh wNupLx9Mo5AM0cSKfpasR+yMftM4i0vix1uzgc90cVz9o/tLjn8xiyGhQwhLHuU5gsSM p3xA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si1511005edq.549.2020.11.19.23.46.43; Thu, 19 Nov 2020 23:47:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727156AbgKTHo3 (ORCPT + 99 others); Fri, 20 Nov 2020 02:44:29 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:7959 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726786AbgKTHoV (ORCPT ); Fri, 20 Nov 2020 02:44:21 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4CcpTN2g3pzhbl3; Fri, 20 Nov 2020 15:44:08 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Fri, 20 Nov 2020 15:44:13 +0800 From: Qinglang Miao To: Steffen Maier , Benjamin Block , Heiko Carstens , Vasily Gorbik , Christian Borntraeger CC: , , "Qinglang Miao" Subject: [PATCH] scsi: zfcp: fix use-after-free in zfcp_sysfs_port_remove_store Date: Fri, 20 Nov 2020 15:48:53 +0800 Message-ID: <20201120074853.31706-1-miaoqinglang@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kfree(port) is called in put_device(&port->dev) so that following use would cause use-after-free bug. the former put_device is redundant for device_unregister contains put_device already. So just remove it to fix this. Fixes: 83d4e1c33d93 ("[SCSI] zfcp: cleanup port sysfs attribute usage") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao --- drivers/s390/scsi/zfcp_sysfs.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c index 8d9662e8b..06285e452 100644 --- a/drivers/s390/scsi/zfcp_sysfs.c +++ b/drivers/s390/scsi/zfcp_sysfs.c @@ -327,8 +327,6 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev, list_del(&port->list); write_unlock_irq(&adapter->port_list_lock); - put_device(&port->dev); - zfcp_erp_port_shutdown(port, 0, "syprs_1"); device_unregister(&port->dev); out: -- 2.23.0