From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C7C4C433FF for ; Thu, 15 Aug 2019 02:01:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3755D208C2 for ; Thu, 15 Aug 2019 02:01:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="RAkQDj39" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729579AbfHOCBH (ORCPT ); Wed, 14 Aug 2019 22:01:07 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:40108 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729535AbfHOCBH (ORCPT ); Wed, 14 Aug 2019 22:01:07 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7F1wTKc090726; Thu, 15 Aug 2019 02:00:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : subject : from : references : date : in-reply-to : message-id : mime-version : content-type; s=corp-2019-08-05; bh=n7cI/XsyQNd7RoCC8BGyinBMzfjV2rc+26ktA+Sq9tI=; b=RAkQDj39ZTEUFMuFyTCmRxVJftAqKe7GKEda/INYK+KBqmcv1daMfC7kSF7timLR3ktb wKFYnE+WEwv8rFTq5ms6hT7ZjWbf+EZ47eyEfK2l/I3XOmu4LXo1ZZIL/zQtum+MjrqR olW2IDmWygW+eRp6oSdkW4d34+w+h/Fu/lovBmUsidmrMtFCRXV5BJaGI+4cD/WeMO5+ EpWpgDBHU3h8cPxpOqmRmuoTVoEoylJKiQ6oTrCoU7zlQPNPexzIp+puoQIp2gAfBffJ m8+UuIRsM4PJwVm+vE8R8VN8G7vvyn/GbTKEVJBC5lg73AWB5limnwJv/GFMBmtY9iA0 Yw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2u9pjqr2sp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Aug 2019 02:00:53 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7F1vomJ074673; Thu, 15 Aug 2019 02:00:53 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2ucgf0fujp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Aug 2019 02:00:53 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7F20pf5003284; Thu, 15 Aug 2019 02:00:51 GMT Received: from ca-mkp.ca.oracle.com (/10.159.214.123) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 14 Aug 2019 19:00:51 -0700 To: Dmitry Fomichev Cc: linux-scsi@vger.kernel.org, "Martin K . Petersen" , target-devel@vger.kernel.org, Mike Christie , Bart Van Assche , Damien Le Moal Subject: Re: [PATCH v2] tcmu: avoid use-after-free after command timeout From: "Martin K. Petersen" Organization: Oracle Corporation References: <20190811182510.1706-1-dmitry.fomichev@wdc.com> Date: Wed, 14 Aug 2019 22:00:49 -0400 In-Reply-To: <20190811182510.1706-1-dmitry.fomichev@wdc.com> (Dmitry Fomichev's message of "Sun, 11 Aug 2019 11:25:10 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.92 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9349 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=728 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908150019 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9349 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=785 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908150020 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Dmitry, > In tcmu_handle_completion() function, the variable called read_len is > always initialized with a value taken from se_cmd structure. If this > function is called to complete an expired (timed out) out command, the > session command pointed by se_cmd is likely to be already deallocated > by the target core at that moment. As the result, this access triggers > a use-after-free warning from KASAN. Applied to 5.3/scsi-fixes, thanks! -- Martin K. Petersen Oracle Linux Engineering