Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp534741pxu; Wed, 25 Nov 2020 09:10:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqXQoyQJ6iOw+YqT9CKQNGlSZly80pH/PcX4kOgjeeXBKcVSLhEQSEP91blWGCXN4zq4v6 X-Received: by 2002:a17:906:4154:: with SMTP id l20mr3868948ejk.96.1606324230285; Wed, 25 Nov 2020 09:10:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606324230; cv=none; d=google.com; s=arc-20160816; b=iMxoCnAX4lqkUGWpqLaOAgf2pTbg0iR80BBD/BgjmNH+I7/25MHyS8zcSm+BJOeLTJ Qrzf7ibIFpIuBh6mGe8bIuwe/IlQXVloXh/y55UNPQF55a0lGZKaYArMYS06MxR0oeY6 PnTh8OfDkvHZipCkuqzlTpU0FHNVx6DknnXu+HoUcZnw6nl4am21BSUOXZQcCq2I0WOn GA+LJquAlNNuZUEESDuUPQz/IwoXZuc2XuBpduhM/d3u4kvFePE0Ohbie+RpodVdmc5r WMxXbWPRAKhuLvGBzoVll1rmqarHQtXfUDD0bnlxxelKhCQ5m5YwavCPehUytwhA3v9v OEqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Ncy3un7Mk9a3HgaKgU8ECzla06RPArkUvrBxSyMW5XY=; b=kGWgfbQPm3e3llfNh/uxf2FN5gvjtIMrRYVjttPwC+4aAJCm0vodbhCdRcYCsiOn8I jpUBJ1YOx4Xq9ktpsiNN4G+BgsVHbw0SH4Rlrb7BENOFKVt8siXsKhs3Wog2p+loF2bK /2rlTXeb5kbYLKrO2hyM4MJ7z4UJaDhfoTQarIX38P7kYf8ooxxApjtMFIUqNKXpiTkS wmARjdIvNgs5JKdwhm5BMXjeiA122v63sRrrHnIJKGiiE2C4C+xT3r0vxAnYjGo8JFEd kvlS6BhaHzvdSCIoOdsdLGR0B3cIiiR7eOHpKLN3kp5+6OKWqp8ExB0rnYueK6CgdF3S T2oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=JiqWRQ60; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t7si1534235edv.378.2020.11.25.09.10.02; Wed, 25 Nov 2020 09:10:30 -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; dkim=pass header.i=@ibm.com header.s=pp1 header.b=JiqWRQ60; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732644AbgKYRHT (ORCPT + 99 others); Wed, 25 Nov 2020 12:07:19 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33246 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730293AbgKYRHT (ORCPT ); Wed, 25 Nov 2020 12:07:19 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0APH2VtP006630; Wed, 25 Nov 2020 12:07:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : content-transfer-encoding : in-reply-to : sender; s=pp1; bh=Ncy3un7Mk9a3HgaKgU8ECzla06RPArkUvrBxSyMW5XY=; b=JiqWRQ60w9cLeWy2x6vGrY7NghfRzqVmMbhO7bX0PiXjJeKgzlbC8I5zZlY2y8Nj/boH 8YBKACvOPWNprD8LySyw1e7387fWZa2l5QTbEptoamAfmBgKL3Oc43oWxh+OTr46cFUG 2KFORErbyAGPqzW2+5JbMf7kSIqydZaZKaUaEUhdEQaKewdcM/32iGWtX3fAAhxEQ0Kf n9aYkyINkrhNbz8JfI1LhX2XxfyZfFItUoXXObLu56SPGld+UpMAzFKqCThXQDZdSbkG YavD23vpflCN0EQandNmrZ+Lzt4tcZgN/DLqjVX2WHcgAzVSTwmPkj8Qexdbck207sFz /Q== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 351u5q8dsm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Nov 2020 12:07:04 -0500 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0APH2qlK010586; Wed, 25 Nov 2020 17:07:02 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06ams.nl.ibm.com with ESMTP id 34xt5hcw10-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Nov 2020 17:07:02 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0APH6x7M18874716 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Nov 2020 17:06:59 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 966704C04E; Wed, 25 Nov 2020 17:06:59 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 843324C040; Wed, 25 Nov 2020 17:06:59 +0000 (GMT) Received: from t480-pf1aa2c2 (unknown [9.145.2.194]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 25 Nov 2020 17:06:59 +0000 (GMT) Received: from bblock by t480-pf1aa2c2 with local (Exim 4.94) (envelope-from ) id 1khyFu-002ZXe-FD; Wed, 25 Nov 2020 18:06:58 +0100 Date: Wed, 25 Nov 2020 18:06:58 +0100 From: Benjamin Block To: Qinglang Miao Cc: Steffen Maier , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org Subject: Re: [PATCH] scsi: zfcp: fix use-after-free in zfcp_unit_remove Message-ID: <20201125170658.GB8578@t480-pf1aa2c2> References: <20201120074854.31754-1-miaoqinglang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20201120074854.31754-1-miaoqinglang@huawei.com> Sender: Benjamin Block X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-11-25_10:2020-11-25,2020-11-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=946 suspectscore=0 malwarescore=0 clxscore=1015 impostorscore=0 priorityscore=1501 bulkscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011250104 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 20, 2020 at 03:48:54PM +0800, Qinglang Miao wrote: > 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: 86bdf218a717 ("[SCSI] zfcp: cleanup unit sysfs attribute usage") > Reported-by: Hulk Robot > Signed-off-by: Qinglang Miao > --- > drivers/s390/scsi/zfcp_unit.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/s390/scsi/zfcp_unit.c b/drivers/s390/scsi/zfcp_unit.c > index e67bf7388..664b77853 100644 > --- a/drivers/s390/scsi/zfcp_unit.c > +++ b/drivers/s390/scsi/zfcp_unit.c > @@ -255,8 +255,6 @@ int zfcp_unit_remove(struct zfcp_port *port, u64 fcp_lun) > scsi_device_put(sdev); > } > > - put_device(&unit->dev); > - > device_unregister(&unit->dev); > > return 0; Same as in the other mail for `zfcp_sysfs_port_remove_store()`. We explicitly get a new ref in `_zfcp_unit_find()`, so we also need to put that away again. -- Best Regards, Benjamin Block / Linux on IBM Z Kernel Development / IBM Systems IBM Deutschland Research & Development GmbH / https://www.ibm.com/privacy Vorsitz. AufsR.: Gregor Pillen / Gesch?ftsf?hrung: Dirk Wittkopp Sitz der Gesellschaft: B?blingen / Registergericht: AmtsG Stuttgart, HRB 243294