Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp590080pxm; Thu, 3 Mar 2022 00:01:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7lhq/kA/B343stDKCZa15Ckz3RLgaY0O//Fqw4l9YG8EIQx94J1mgbdME7sg4k5BrxA7U X-Received: by 2002:a17:90a:8e85:b0:1bc:429b:513d with SMTP id f5-20020a17090a8e8500b001bc429b513dmr3985953pjo.11.1646294485117; Thu, 03 Mar 2022 00:01:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646294485; cv=none; d=google.com; s=arc-20160816; b=Mg0V1Bw3Cg4bBV7FlyNcMXvToFg8pRhwwVueNBIzRyYhkItQ7hh7TLPN4rF/TsZmxp 9Va9SGg4AXbfHcZjesxcg1fnyybAdjtZke8lhiYd7z/Ewk6G1wGTG7MEpXmjSnAEiu4P wHj2mv1I3P9fMm4sbu7c2WeRdkmmONxPFmRIIOueG5D+EEbZ6uTwoh6DiZIsLHUch9xl 9gzGKklEhTDpVmIgKowzRBCHEbaODtfTHGxAJM9yQL7ZRuKtk1AlhwAaOWHU+Bc2ULfa 5+aqFieId2RlT0NOPFSuBla4fljyhMkZHBWSbFMiDws7hUe0IBNE1JLj16lwhCgjq/qH TSIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=hAm6aBODLiWVVxzqTP/nBuW3NSWlM2Lr77y8WTZdvaU=; b=mritigUNPC/6+mig2OcpsIiTfinKWwa8hJtpjiCJTScdeS0fMU1aRk2jEmp4LSwqRs qewTx/d/91ktLExjSuKn0De/kcSla7itHnwawbL/5ZNwRX174YLpV14IGvh9kUCs2Shg Z7/kiPQvRsyavK+exeVjzpUxvR4calC8wKuaY+vD3QI8fmoEoZzDTCyGaXZA87JIWhVI kmROsIi8cA4lOvWjN9rJfBevz622T7iG/LRyMqFH3Ib5KMbL2Ojdpz0Ai1IQPhB8VMXg SLtbTNzMbElzIJNQX9f5IKjA70f2yHsihjYBVJDal23ZZBVZQ7CFETaJbWYNNtM5+pFb PT5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=DnW0ZAcy; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d1-20020a170902cec100b00151a0697f5dsi1513624plg.80.2022.03.03.00.01.06; Thu, 03 Mar 2022 00:01:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=DnW0ZAcy; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230149AbiCCH0w (ORCPT + 99 others); Thu, 3 Mar 2022 02:26:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbiCCH0v (ORCPT ); Thu, 3 Mar 2022 02:26:51 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCE2C16A58E; Wed, 2 Mar 2022 23:26:05 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7E16B219A5; Thu, 3 Mar 2022 07:26:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1646292364; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hAm6aBODLiWVVxzqTP/nBuW3NSWlM2Lr77y8WTZdvaU=; b=DnW0ZAcybnZEocRHj1n7cOXGpRLWfnSFOpPjFwAxJ5tg0Syf8NqicRsiWkTPhHwiMDgDTD 8/eQmzFAxniqnt+UqV9aSokyIwbbZjrh2Bprk3JzDjzmR0ZxrMeABn1UsOPHd8i7L1Cf0t +Xh6FjIT3rdw7S94zsFjBAABh6159GY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1646292364; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hAm6aBODLiWVVxzqTP/nBuW3NSWlM2Lr77y8WTZdvaU=; b=x/7Tp3GxlfXUJIeaiasdPcvYNfLn+CakiVRjmdMLDIxcPy0zkRlYZUz+CZx71Z3KzYvDvi gX1rJQhpDNSUupDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5C2F013AB4; Thu, 3 Mar 2022 07:26:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id LiO/EoxtIGJWNQAAMHmgww (envelope-from ); Thu, 03 Mar 2022 07:26:04 +0000 Message-ID: <51943e86-e05c-8f3c-59de-e75af03a1efe@suse.de> Date: Thu, 3 Mar 2022 08:26:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH] scsi: libfc: Fix use after free in fc_exch_abts_resp() Content-Language: en-US To: Jianglei Nie , jejb@linux.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220303015115.459778-1-niejianglei2021@163.com> From: Hannes Reinecke In-Reply-To: <20220303015115.459778-1-niejianglei2021@163.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/3/22 02:51, Jianglei Nie wrote: > fc_exch_release(ep) will decrease the ep's reference count. When the > reference count reaches zero, it is freed. But ep is still used in the > following code, which will lead to a use after free. > > We should return the function after the call of fc_exch_release() to > avoid use after free. > > Signed-off-by: Jianglei Nie > --- > drivers/scsi/libfc/fc_exch.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c > index 841000445b9a..aa223db4cf53 100644 > --- a/drivers/scsi/libfc/fc_exch.c > +++ b/drivers/scsi/libfc/fc_exch.c > @@ -1701,6 +1701,7 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp) > if (cancel_delayed_work_sync(&ep->timeout_work)) { > FC_EXCH_DBG(ep, "Exchange timer canceled due to ABTS response\n"); > fc_exch_release(ep); /* release from pending timer hold */ > + return; > } > > spin_lock_bh(&ep->ex_lock); Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer