Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1123936pxu; Wed, 2 Dec 2020 11:38:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+hMg1Oyge7cFd2EC9BPpPDogjct5qbnWBit3/6A95aTbIuuF6w/G9JxifjZmN9bW5V9b1 X-Received: by 2002:aa7:c558:: with SMTP id s24mr1513196edr.257.1606937899963; Wed, 02 Dec 2020 11:38:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606937899; cv=none; d=google.com; s=arc-20160816; b=XGY2c/+CFz8SF+R8qjVgesIC9GJn6Qf96twi6m1GonBFVAq7Ngnet2BIwRzOCqHAi0 o/MZw1TY9qQVWi/gNoQ+/+LqsoESoea7mRhq5Ol+VRHLkEi0uXz8SrsFdNrvLLaTNX7U c6OvhQ1iI/fvOIbaC40/f24xCP/1F9IxUNBqxibFo4RbybpCYw9vhvqkDrgcgKgRE+47 m92bvavxqaBDdSM3SQm36ideMn9EY2xCt5O9FPpD9NGUfbFyTCjPYPDfdEK73kG8lTjr +QRj4BSxSFLu/Pr2PDid8Hf+wVYC/I/qNqtCUwemZ9wyoesLeyNW/Ad4G3V3X2qQTA94 /MyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=Uw/G6EZJX4YmYr9zvI3PxyPsOjo4URTdPNU+xzFSpbI=; b=QmBberYgSTxJOgNcjpdLdyx1I7StP8rGElw7Ec52rQzFlYtRtFoCq4LgKGUJ82QBvl JmXDRob//+80v74Ba448a5bAAR1kK/gjtni3w9+isffGNc7eq0vcgLENGkMVTpA4fzV5 3CKiUd+aj9QeEtVT05ealGTepgDrdYMCBauoP5S/whOE6lFWmXsqoM8MW4IFblUXUUls 2ro+aRv221OBo7Q3D2i+EvePK2OAZi3pzSWl4wJXbPeZubcmI5Zsg8E7wNgcn2/L7AD9 9LFa4rmCbqJUd8JQ/1NZ5rhbqSKeXq6L/wfuZAM7Z3F+40SOy0dFRE4BrhjJb+asDd9+ EFTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=mUvVUxfU; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do13si569945ejc.286.2020.12.02.11.37.56; Wed, 02 Dec 2020 11:38:19 -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=@oracle.com header.s=corp-2020-01-29 header.b=mUvVUxfU; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729296AbgLBTgP (ORCPT + 99 others); Wed, 2 Dec 2020 14:36:15 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:49904 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726704AbgLBTgP (ORCPT ); Wed, 2 Dec 2020 14:36:15 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0B2JZJD5081809; Wed, 2 Dec 2020 19:35:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=Uw/G6EZJX4YmYr9zvI3PxyPsOjo4URTdPNU+xzFSpbI=; b=mUvVUxfUeAmdBNWskzbjHiey6o43hvXms+gLOXLAck+v0d7lt03gUQEaCOL640/LjciN +fneCgdzzmLW4Jq6t7nOF/itlITNpklr25XcjcL+xXlxJMLfXYs4hGnqN+aYVR+PGGO4 QWtUYfHQS+eV8mND3PD+VL74LMPoz5EW/q4rJ2a0hK3xcQwyhx0zHqNRumWMZPrj0PWM mDJdW3edyYHvc4r/axxNEergyug8lifElv204LI+vnQAGAsRITXKkOq772dQtKxAUJB7 2d4zR1/pR2jWo6j10RbOe3TXcsi9GGORoCJkb9KGrRyY9RNwIZN7wNTENNerFwJWoxSD hw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 353c2b2etx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 02 Dec 2020 19:35:19 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0B2JUTr0151963; Wed, 2 Dec 2020 19:35:19 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 35404psauy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 02 Dec 2020 19:35:19 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0B2JZIEV006449; Wed, 2 Dec 2020 19:35:18 GMT Received: from [20.15.0.202] (/73.88.28.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 02 Dec 2020 11:35:17 -0800 Subject: Re: [PATCH] scsi: iscsi: fix inappropriate use of put_device To: Qinglang Miao , Lee Duncan , Chris Leech , "James E.J. Bottomley" , "Martin K. Petersen" Cc: open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org References: <20201120074852.31658-1-miaoqinglang@huawei.com> From: Mike Christie Message-ID: <331a17b8-3219-cb73-90c8-4b814202a78f@oracle.com> Date: Wed, 2 Dec 2020 13:35:16 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: <20201120074852.31658-1-miaoqinglang@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9823 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 bulkscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012020115 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9823 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 lowpriorityscore=0 clxscore=1015 bulkscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012020115 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/20/20 1:48 AM, Qinglang Miao wrote: > kfree(conn) is called inside put_device(&conn->dev) so that > another one would cause use-after-free. Besides, device_unregister > should be used here rather than put_device. > > Fixes: f3c893e3dbb5 ("scsi: iscsi: Fail session and connection on transport registration failure") > Reported-by: Hulk Robot > Signed-off-by: Qinglang Miao > --- > drivers/scsi/scsi_transport_iscsi.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c > index 2eb3e4f93..2e68c0a87 100644 > --- a/drivers/scsi/scsi_transport_iscsi.c > +++ b/drivers/scsi/scsi_transport_iscsi.c > @@ -2313,7 +2313,9 @@ iscsi_create_conn(struct iscsi_cls_session *session, int dd_size, uint32_t cid) > return conn; > > release_conn_ref: > - put_device(&conn->dev); > + device_unregister(&conn->dev); > + put_device(&session->dev); > + return NULL; > release_parent_ref: > put_device(&session->dev); > free_conn: > Reviewed-by: Mike Christie