From patchwork Sat Mar 25 22:09:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 74991 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp640443vqo; Sat, 25 Mar 2023 15:49:56 -0700 (PDT) X-Google-Smtp-Source: AKy350YmXbDTbQomclhJ0UgT8AbmpyL9N5bsI8QHX5EJjDVRJtYNQeFc3RP9fCSWM/VxrlGDi6b8 X-Received: by 2002:a17:903:210d:b0:1a0:53b3:ee87 with SMTP id o13-20020a170903210d00b001a053b3ee87mr5432053ple.62.1679784596102; Sat, 25 Mar 2023 15:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679784596; cv=none; d=google.com; s=arc-20160816; b=b6oGUG2dWm3odvs54khko16RYi7Eeo5W1IqTlvS3pxrz5EB8MqL+J4aRF1ziLIkR7y +rJyLLGQWQ3GAgbgXFBzOtROa+zw7IQ+CvMyjewEY9AQI6pH2kj4hgyonLQ3b8tRvFwo BK1+gJQWM/ocQBrN7X9OymSyw4qvZebzRcV2zcEWlXqMR/OYGtzIsqivHEZwxA5/t7FR m8S6pgh9f/g5exdcaatKh+IP9aWpvaztAhVTDh1UpKuIqSXEctL4uCXbfManYFm+mqLJ N4Ksry5iso8NHU73nG3QCyOtMEOaxo+yBs4gdAJJycHbF2r3CU786jZ05TjaHfZFqvHr 2DwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:from:cc:to :in-reply-to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=sApy1sk/eDYWsdjYPmVDEETHIACjQ0+qySU/8hKLXrM=; b=TTO+IfGWxsY8f5Jz+PV1D533gARNNS2D5oCPQ6EoQ2HEBhWcYaSLOE6AJC8VUwMz1h SgqkpKkzivIgiLgR+9Mxke3hgWFN0NmSg8DHgILy4lR//p+2T+2mjC/bx5IDtpQeYuDN Rhnn+Stnan6JMdDqUo6jSLlsTbAPnroBZhU3RHjJJogFiAUFICo9HgdClVBAFnl986ao g6nP1kVL7gLYe5ymWvO6UIJIheeKZ95bD+PJp6d+r6105oFaqxTG3Kf2Foq211B/d6vo HTIwLgTu3i1Ff1zeqOkWhSakHkT7CTirfzFu4tEDiVnjrDo0e7Cih6+0YqrNJYNPVulu 6/ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=ZwkFysTT; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a17090311cf00b0019e68e3d533si25322225plh.98.2023.03.25.15.49.43; Sat, 25 Mar 2023 15:49:56 -0700 (PDT) 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=@sberdevices.ru header.s=mail header.b=ZwkFysTT; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229882AbjCYWMr (ORCPT + 99 others); Sat, 25 Mar 2023 18:12:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjCYWMo (ORCPT ); Sat, 25 Mar 2023 18:12:44 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E89F40E3; Sat, 25 Mar 2023 15:12:43 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 8DFA15FD02; Sun, 26 Mar 2023 01:12:41 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1679782361; bh=sApy1sk/eDYWsdjYPmVDEETHIACjQ0+qySU/8hKLXrM=; h=Message-ID:Date:MIME-Version:To:From:Subject:Content-Type; b=ZwkFysTTwhpaGLxqNy1srOh0p0PcehA3Hbf3gm823p/EE1m1FUGtWZgO+vUbl2ybB 4Fn24zcr9ZumYlTooeOhkNu/oi7Rb/AJZppPomL9k9LGCZMCW6KM1vxvBnKERXF6Sl eqjeWai8LIFtNY6GSkzolihUMwz/EaIpRc4e0zFvSNTFdHDFPrItZqgyFnmEULoUG8 /TXYn+a2S1WgFBpnJHAn4h7gO0GQ4Kf4+C9KP/UJkweVFuZa50jtlAoogQQl/cnIRl C9DaJa+oa9gKSsTeCXm6jPDCLwohlAOpAP+o0iYweGAOii5z4U4tYhFhiYhaMUroS2 nHpgl/cqS+s7Q== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Sun, 26 Mar 2023 01:12:41 +0300 (MSK) Message-ID: <30aa2604-77c0-322e-44fd-ff99fc25e388@sberdevices.ru> Date: Sun, 26 Mar 2023 01:09:25 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Content-Language: en-US In-Reply-To: <728181e9-6b35-0092-3d01-3d7aff4521b6@sberdevices.ru> To: Stefan Hajnoczi , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Bobby Eshleman CC: , , , , , , From: Arseniy Krasnov Subject: [RFC PATCH v2 2/3] virtio/vsock: WARN_ONCE() for invalid state of socket X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH02.sberdevices.ru (172.16.1.5) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/03/25 20:38:00 #21009968 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761381812801464720?= X-GMAIL-MSGID: =?utf-8?q?1761381812801464720?= This adds WARN_ONCE() and return from stream dequeue callback when socket's queue is empty, but 'rx_bytes' still non-zero. Signed-off-by: Arseniy Krasnov Reviewed-by: Stefano Garzarella --- net/vmw_vsock/virtio_transport_common.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index b9144af71553..ad70531de133 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -398,6 +398,13 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk, u32 free_space; spin_lock_bh(&vvs->rx_lock); + + if (WARN_ONCE(skb_queue_empty(&vvs->rx_queue) && vvs->rx_bytes, + "No skbuffs with non-zero 'rx_bytes'\n")) { + spin_unlock_bh(&vvs->rx_lock); + return err; + } + while (total < len && !skb_queue_empty(&vvs->rx_queue)) { skb = skb_peek(&vvs->rx_queue);