Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2199130iof; Tue, 7 Jun 2022 23:00:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnPKJDev/SUwTL/aAg2POSlKzi5kauSan/oGPZgkfGJVyksxRUZgLGYaEIjFz77sTfZ34y X-Received: by 2002:a05:6a00:1da6:b0:51b:fad1:c610 with SMTP id z38-20020a056a001da600b0051bfad1c610mr19483733pfw.25.1654668002904; Tue, 07 Jun 2022 23:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668002; cv=none; d=google.com; s=arc-20160816; b=Fe2vaHHjTHPD279KfJIrDdIs68yqQBsfEsog2Ntv96cc55yd3SEYYKnRuB2GS3OdvD tSabJBYsI8H4+i8vBDK4nC9noGxraABG73W25h7kDsJJoJ4yJpsa2ckawV1+cvCukQXz bR0F9PYTgSI220lLVJshqrBGXtOQjDZO5aNABU3cIgU8DhLjTu4wi2EL3o0G2nh0WUVg a6JJ1JVZ8kfCAC5WqfOjEfFfnbp7URcRxWpaFw9ca8hGDODQrIRGQYJDndUNKzU1zf+Y 6vhZWyjdlQwhB0WZjXoWX8dNdrluUN2uNKNYQ8DPZUuLzF38C+keQkqynb/FI4JgYKLB 9vow== 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=5bhPjADOw0O7WERzpVNhwi6QObSzaRP9EznibeoNr/o=; b=BTp3MJr6ZjQUBTTOOtn68OTyywWOuqGSlNlUPjps8udZANXYXh8SJ3c5z+y7EOyRDr fe68LFsEscfW6Nh+kDSnZ04Vhiq7O51yrYexMexN6SyWSWwe2z/TLYDK2yhz40+Ml/8w QxabzgsBVCH5ca8G6P2NnlQPgw+dCnJQc300pL5+XjTsirhM3DZLDjs6w8wHxgDHiYC5 S+/GidVSi//hhdJfAaITh5D7p4gRNSxzoIcWXG+lMaqPy7Okp0NNysv0jHLIZk9iKIrV R3eRHzz+jqoxdqj0wy36p4u+0t6b7KtiNi1MTgsRz1Ee+FBl2nJwD4Jz9VlAs0nPagsT 9HRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DP0Z5hoI; 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 82-20020a630555000000b003fc6682b1ebsi2561061pgf.223.2022.06.07.23.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:00:02 -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=DP0Z5hoI; 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 AD980471566; Tue, 7 Jun 2022 22:25:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1392222AbiFHAv7 (ORCPT + 99 others); Tue, 7 Jun 2022 20:51:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384080AbiFGVyH (ORCPT ); Tue, 7 Jun 2022 17:54:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D76FF07; Tue, 7 Jun 2022 12:12:55 -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 ams.source.kernel.org (Postfix) with ESMTPS id 4AAFBB823B1; Tue, 7 Jun 2022 19:12:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B625C385A2; Tue, 7 Jun 2022 19:12:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629139; bh=eQUZ+ey7/BLiW6pckJTv8Wved40zL6Bggxfybl1hKZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DP0Z5hoI8B6wdyUW6aI5qK6okKE8K8kBG14vnL8R/fT5aiXu6ISTUYlqfrTQjXa16 CKk5hAAXzYRWaHO0Ga2n3JXNW28vdyjz0dcI4Ey3zG1LVR4GoklVIgpc2EkZH7cWzB CXM+xuB6YzZFDHR2XRGT71MU3YjT26jK9kHt+qoY= 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.18 582/879] Drivers: hv: vmbus: Fix handling of messages with transaction ID of zero Date: Tue, 7 Jun 2022 19:01:40 +0200 Message-Id: <20220607165019.746812158@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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 dc5c35210c16..20fc8d50a039 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -1245,7 +1245,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; } @@ -1270,7 +1272,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