Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2248262iof; Wed, 8 Jun 2022 00:26:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxz8Dqx/2RDro30r2mgUZeBfLDlcH0qzWIW02Gk+iqfNMWnkRcr8obDM8C4LQ1d1bgCXypF X-Received: by 2002:a17:90a:66c1:b0:1e8:43ae:f7c0 with SMTP id z1-20020a17090a66c100b001e843aef7c0mr26036567pjl.245.1654673176853; Wed, 08 Jun 2022 00:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654673176; cv=none; d=google.com; s=arc-20160816; b=VjCxLs6Lol+bByY38bacSkwIUQICMqH29C22IcLS5hsEBfFYUpPmhLYB7c0HEl6H1V O1pU3LyEWr/NowR3KIM80qVDk5lYa5RWECjPCWP8M/+TsoOd+bGehWQg4FbNZJApUKM7 I5g9T15q4b8BccestqLf68GPqgwALu6fP2v6sO0wb4YUx+69K2o+mGBuw3TPe41zzyeS BkfV9tlPgKEo0QSBrd0iWrGeOHECzLELN3DXfUbZvs1svopd5H7Zd7gnnP18zij8JyNm 03hOPzdAHV49pr18wNlXLS469tFKrE+qacRsCy0jqu48Sd0CbTB3HQwZFVd9IEmDGoL1 udMA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9xaqnmLvwTrqF7ezSKcZTIcwmQKHK6/2HGzwTORDVUc=; b=UEEB8pG5CTnsErCSIILXKL6g9aWIog4Mpu3h/H8Yrbqfs/W4JJAed+1f4qJQ1fOMJP wdtukN5KCQUB8DmtMeyUzHTMNQT7hSwlolTn0szQ+GGDUJyhhnM8bduoDzq6KdnBln43 6/sfDVrTm8l82wq4jMczqzje0wHlwD5uFAxCTYD+2l0nJyjLDnxx/51nwZvDBF1jYrdp xm2d5Ultdk4eSu4Tl1TN5u33D22Dd3QPHJPg4Mrcogz0qGuRx35orNdHMsVlcm+R0V0e LxmUDa2y0xjt90QN+OUUOSMdyktI7i55w0bc5AGotGarWfi8kW+cuYLSyU0Y1/32l2uU IMNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YJjbRUSV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id nn1-20020a17090b38c100b001d03c08b551si15450564pjb.190.2022.06.08.00.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 00:26:16 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YJjbRUSV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E80721E73D4; Tue, 7 Jun 2022 23:57:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355712AbiFGTak (ORCPT + 99 others); Tue, 7 Jun 2022 15:30:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344407AbiFGSiU (ORCPT ); Tue, 7 Jun 2022 14:38:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 820AA3B3E7; Tue, 7 Jun 2022 10:58:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 29533618D2; Tue, 7 Jun 2022 17:58:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A1B8C36B00; Tue, 7 Jun 2022 17:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654624692; bh=f+U1OkGMCasbcTsAbpK24GfUNZ9VX0StZI8RsX++zvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YJjbRUSVO5JJrqt6fS7Vqnv17OG1gpqNOK5FJdReqOxBu5WOlBeY60n3kVgzALDmh QwbGA6o0aGQrEsM6Ljtb2oSBYyYILABGknvaxkKYqV6TndjxcBMA5+08VJ0NMWOmJC SO0kCvoHyR746L3h/YN5Jis3pb4DLKQKcZTVO8Ps= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Andrea Parri (Microsoft)" , Michael Kelley , Wei Liu , Sasha Levin Subject: [PATCH 5.15 419/667] Drivers: hv: vmbus: Fix handling of messages with transaction ID of zero Date: Tue, 7 Jun 2022 19:01:24 +0200 Message-Id: <20220607164947.301937816@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164934.766888869@linuxfoundation.org> References: <20220607164934.766888869@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Andrea Parri (Microsoft) [ Upstream commit 82cd4bacff88a11e36f143e2cb950174b09c86c3 ] vmbus_request_addr() returns 0 (zero) if the transaction ID passed to as argument is 0. This is unfortunate for two reasons: first, netvsc_send_completion() does not check for a NULL cmd_rqst (before dereferencing the corresponding NVSP message); second, 0 is a *valid* value of cmd_rqst in netvsc_send_tx_complete(), cf. the call of vmbus_sendpacket() in netvsc_send_pkt(). vmbus_request_addr() has included the code in question since its introduction with commit e8b7db38449ac ("Drivers: hv: vmbus: Add vmbus_requestor data structure for VMBus hardening"); such code was motivated by the early use of vmbus_requestor by hv_storvsc. Since hv_storvsc moved to a tag-based mechanism to generate and retrieve transaction IDs with commit bf5fd8cae3c8f ("scsi: storvsc: Use blk_mq_unique_tag() to generate requestIDs"), vmbus_request_addr() can be modified to return VMBUS_RQST_ERROR if the ID is 0. This change solves the issues in hv_netvsc (and makes the handling of messages with transaction ID of 0 consistent with the semantics "the ID is not contained in the requestor/invalid ID"). vmbus_next_request_id(), vmbus_request_addr() should still reserve the ID of 0 for Hyper-V, because Hyper-V will "ignore" (not respond to) VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED packets/requests with transaction ID of 0 from the guest. Fixes: bf5fd8cae3c8f ("scsi: storvsc: Use blk_mq_unique_tag() to generate requestIDs") Signed-off-by: Andrea Parri (Microsoft) Reviewed-by: Michael Kelley Link: https://lore.kernel.org/r/20220419122325.10078-2-parri.andrea@gmail.com Signed-off-by: Wei Liu Signed-off-by: Sasha Levin --- drivers/hv/channel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index f3761c73b074..6b967bb38690 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -1221,7 +1221,9 @@ u64 vmbus_next_request_id(struct vmbus_channel *channel, u64 rqst_addr) /* * Cannot return an ID of 0, which is reserved for an unsolicited - * message from Hyper-V. + * message from Hyper-V; Hyper-V does not acknowledge (respond to) + * VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED requests with ID of + * 0 sent by the guest. */ return current_id + 1; } @@ -1246,7 +1248,7 @@ u64 vmbus_request_addr(struct vmbus_channel *channel, u64 trans_id) /* Hyper-V can send an unsolicited message with ID of 0 */ if (!trans_id) - return trans_id; + return VMBUS_RQST_ERROR; spin_lock_irqsave(&rqstor->req_lock, flags); -- 2.35.1