From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AFF73AB287 for ; Wed, 22 Apr 2026 09:40:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776850815; cv=none; b=Md6UtWgC1g072NxRkxYuQ36L+8R2bcE8W+5kHtekf6gGuLsSXm2UEy2h9hebtrEe6Qt8mYcjtTFHubCjO3+u8JBU8g4RtFHmRZVAdau56d/x2opsjbP8eCZzusf2BrSyuKROOcI/wzlzCMZ5+nwhSvtwHlA0XjIVSajUvYe8848= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776850815; c=relaxed/simple; bh=zAkck15aRQTZ1Q05U2YBuMYW04iQrWlQkMLWra0PA3Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hrLOHECLtceRhuc7aqYG7bbaGrUYwCKjd2opQSVxm1IuB+BEaXXe2Fhz+iyrSicFsfP6EZybQvhg3smhA9p7BSkfAo6l7UnaE/g1Wq33Hxa7hKic+PwUU3mudEzWxhBA3wtF757witEor2WF4h9I1++oHZ0qrh/0OS2guzCDTDs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=N3k0dS/X; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=MDtauj7Y; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="N3k0dS/X"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="MDtauj7Y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776850812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8cr/tWxIjPFzBjhqZCt4BN4Fwf/3ahvnB9QHJ9ZKhqw=; b=N3k0dS/X0YuqP/AeNdbBuVQ8iC74LTlPLUl042kqQ/ZUmecg/f3Dpx3qN1Ozti8hb+NMdY bTCvXC17LdPpcZySl3OtTU4BQcEG025vY9olEYkXT0Nwn6aA+m3KYqf3tLpYoD0Kk4hRvu /FI9EIvfnqyGplUwQjq60szKkMDyIT8= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-219-RFvjhfGINCK8bpz7zdJoEQ-1; Wed, 22 Apr 2026 05:40:10 -0400 X-MC-Unique: RFvjhfGINCK8bpz7zdJoEQ-1 X-Mimecast-MFC-AGG-ID: RFvjhfGINCK8bpz7zdJoEQ_1776850810 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-488c2cc0cbaso34506855e9.3 for ; Wed, 22 Apr 2026 02:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776850810; x=1777455610; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=8cr/tWxIjPFzBjhqZCt4BN4Fwf/3ahvnB9QHJ9ZKhqw=; b=MDtauj7Yi8djQfouSEoFrmucKQOWy2Ex3r4LineA/9nuq4jaefYztLFddh95hq4A8Y z3wO0kAejCwOTlyy9Ri2yNplyqW0OIiT6ZAsuF4NoDMUHB2edCdlpSswBDrv6VzZgcTW HkbpdnkcqMSORUPpZ9ZhXD9AdK9vkWcXJCf8nM2IeG0RzpFkJ4YQkptCHlafgbMSTpbp sjmvJ2BsJLfvVVH3ehxYRdBJ4TBtt2ZWgKlzi+YMRhJz5diOwPnlA6XzWuZeu7RMT2HX /KKlQ3sqy8oZkkbNHROokiVA/hWNjMPl/AYuuE4dOjbhsXxNThjaSb1YNbLw2JOSgS+n CrjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776850810; x=1777455610; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8cr/tWxIjPFzBjhqZCt4BN4Fwf/3ahvnB9QHJ9ZKhqw=; b=YG0ER3wDxqcZRRh3Z8uVLL70uXryhitBsmRjd+OUK4m7kPnqQU0UWxu8TmWVNXiIYB ebajFyJda4ToXXcIc39kZqDbGVVSccFiNCdY2mJI0WiJ8uaKiHx6HJ2fpMKNQhYV3eSQ EKFjWrQ5A+A22Cqqb1kUmV+KNOkZ4Ni2H2qyqLko7ovUhsIpTqlhqn/XNvgtPbThodyn gFuJMs2TV0i+nFIJqbqZxT5n0RsNgomlSejd7Wf3Th91UVuZOMNmsWiQZ9JqxdGUgEQh FLwH3F/WXBxBf75QR9EbdaJOoNECkhdMPNZ6SbEhBb8bbYWIIKzqDjPWWnN28az94O6S pQ+Q== X-Forwarded-Encrypted: i=1; AFNElJ97XWEKRWgksw6JOTfp/unsZ7W+xIyHU0kyUrjiDmk+8mGvc7w5aNT/JjbhCuMM8iN5qQfDsmI=@vger.kernel.org X-Gm-Message-State: AOJu0YxKs/lGff2VJkJ3JRnpO8Ix63+tIv6etqNVL1bjOL8dSrt5JpLr 0kWzVvEPvf2Q8quHml0MOSaMGxMRb7J2pDJP0mzGWc+y7lHY1lyNvWE4yIAqzr9lNTouMzuLE/w lrSdUZJNjKXRJ3CxOYB67agTGfwJ/N77E4XVFZeQvPemjFxIVl4LRhN8Ngg== X-Gm-Gg: AeBDiev/WEkDgy90R9ov55gE8yYjpWCaVy6lW3eVLhAXH/rARhzE4rgRDY8smgWsovk uE9PqbG7/8QHX3zzkB+NkFWQfFkaAHGhmPKio/E45eeQvk6GZYKSx6F8+hSvt+oAgdX8dsjpL1s AOzvhmI21jlcThepn9Zvf296lNtxX9UiCOCW/F+oB9jehHjuS5j5uemIo6rtX2ITLz39afcEW5b n42+7sXUm/NfVjrUvoT7YoS5R4YBFqCSFSa/SN4SHsb8L44c8Q9uyB+7R6cuRWTFweB30vf/C0m fn0mHYuCDtYsynjgr3h2FpRHkHdXuAUM7NXsQtT9SiSJy8d0dAAegBAmjPSUwCnzmjUAxMyF2HO Da7gp/hVOOAYEOGPGtmcuY74oyHy/dazOQD4Ag4dHqKWWGRxhYm7RAP9ZVchWDte3nt/9SULTmP Cf3XXD2w== X-Received: by 2002:a05:600c:5294:b0:48a:563c:c8d6 with SMTP id 5b1f17b1804b1-48a563cd0eemr82211725e9.7.1776850809634; Wed, 22 Apr 2026 02:40:09 -0700 (PDT) X-Received: by 2002:a05:600c:5294:b0:48a:563c:c8d6 with SMTP id 5b1f17b1804b1-48a563cd0eemr82211215e9.7.1776850809081; Wed, 22 Apr 2026 02:40:09 -0700 (PDT) Received: from sgarzare-redhat (host-87-16-204-83.retail.telecomitalia.it. [87.16.204.83]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fc18bccfsm396567715e9.8.2026.04.22.02.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2026 02:40:08 -0700 (PDT) Date: Wed, 22 Apr 2026 11:40:00 +0200 From: Stefano Garzarella To: Dexuan Cui Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, longli@microsoft.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, niuxuewei.nxw@antgroup.com, linux-hyperv@vger.kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH net] hv_sock: Return -EIO for malformed/short packets Message-ID: References: <20260421174931.1152238-1-decui@microsoft.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20260421174931.1152238-1-decui@microsoft.com> On Tue, Apr 21, 2026 at 10:49:31AM -0700, Dexuan Cui wrote: >Commit f63152958994 fixes a regression, however it fails to report an >error for malformed/short packets -- normally we should never see such >packets, but let's report an error for them just in case. > >Fixes: f63152958994 ("hv_sock: Report EOF instead of -EIO for FIN") >Cc: stable@vger.kernel.org >Signed-off-by: Dexuan Cui >--- > >Commit f63152958994 is currently only in net.git's master branch. > > net/vmw_vsock/hyperv_transport.c | 29 +++++++++++++++++++---------- > 1 file changed, 19 insertions(+), 10 deletions(-) > >diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c >index 76e78c83fdbc..8faaa14bccda 100644 >--- a/net/vmw_vsock/hyperv_transport.c >+++ b/net/vmw_vsock/hyperv_transport.c >@@ -704,18 +704,27 @@ static s64 hvs_stream_has_data(struct vsock_sock *vsk) > if (hvs->recv_desc) { > /* Here hvs->recv_data_len is 0, so hvs->recv_desc must > * be NULL unless it points to the 0-byte-payload FIN >- * packet: see hvs_update_recv_data(). >+ * packet or a malformed/short packet: see >+ * hvs_update_recv_data(). > * >- * Here all the payload has been dequeued, but >- * hvs_channel_readable_payload() still returns 1, >- * because the VMBus ringbuffer's read_index is not >- * updated for the FIN packet: hvs_stream_dequeue() -> >- * hv_pkt_iter_next() updates the cached priv_read_index >- * but has no opportunity to update the read_index in >- * hv_pkt_iter_close() as hvs_stream_has_data() returns >- * 0 for the FIN packet, so it won't get dequeued. >+ * If hvs->recv_desc points to the FIN packet, here all >+ * the payload has been dequeued and the peer_shutdown >+ * flag is set, but hvs_channel_readable_payload() still >+ * returns 1, because the VMBus ringbuffer's read_index >+ * is not updated for the FIN packet: >+ * hvs_stream_dequeue() -> hv_pkt_iter_next() updates >+ * the cached priv_read_index but has no opportunity to >+ * update the read_index in hv_pkt_iter_close() as >+ * hvs_stream_has_data() returns 0 for the FIN packet, >+ * so it won't get dequeued. >+ * >+ * In case hvs->recv_desc points to a malformed/short >+ * packet, return -EIO. > */ >- return 0; >+ if (hvs->vsk->peer_shutdown & SEND_SHUTDOWN) We can access `vsk` directly, I mean `vsk->peer_shutdown`. >+ return 0; >+ else nit: we usually avoid the `else` if the other branch returns early, and maybe have the error returned first, so it's more clear when reading the comment on top. I mean something like this: if (!(vsk->peer_shutdown & SEND_SHUTDOWN)) return -EIO; return 0; BTW, not a strong opinion on that. The rest, LGTM! Thanks, Stefano