From patchwork Sun Mar 19 18:52:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 71842 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp835980wrt; Sun, 19 Mar 2023 12:00:08 -0700 (PDT) X-Google-Smtp-Source: AK7set+Hyai8Zs2fZrzeWoDJrOYLBZ4KjhnfPAbgicJjeWf7Jma88HP+9WLNrd+NVA2kTLgGfKwo X-Received: by 2002:a17:902:f34a:b0:1a0:44e7:59dc with SMTP id q10-20020a170902f34a00b001a044e759dcmr11507343ple.40.1679252408179; Sun, 19 Mar 2023 12:00:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679252408; cv=none; d=google.com; s=arc-20160816; b=ad0ibz1+vHrfQ8LNxOGp44kRoCSXLElgHTpgthgSiszHPQwgTK8CysrNs2J3gS3oh1 6BX1Zi4iKCAYWEaSaJJuMp+yBIo1AdO4FPYdH6gLx3oOvfd2hRuq+SC0QxMa232Y/do0 A1ceOYVoQWgva841FAQXMU+qjMd2h/Ss5+0o5tKKB3V1pEN70nHWJrOVgPvQ+tiEP/71 F0NhTAc3TX3mOMgu7DkUyINCHlNDMqGZLnYXUS8GPof/xsMfr3h62epvUENClILyflBr SdM9oFWb8y3M1c6p/yRevBQyNheHaJBXfg508qCDdyxAluLU0DS1pjGSDJ2wgJbhAN7A g6EA== 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=C781NWpzeOK41C9p67pG5T6Jta5orOVTpQeZsJpmG/8=; b=sLvgeGQuWwTsqBBae/2FCycNB2LLCvXyEu84aIttj/Cn5HExiC+MUCYPHuM75uvSRv lgcVPpwxooCoyqKWqm5F9nWLHBlryqiJnu/2I6iSjRLW0NjWLFKiaaym60lBxEmuLsEi Z2xp/3oVWPgGOrWWsI3+dQDjcAavsS7fTO1qmNi3PE+EpiKmw+beMPa0h/lRf7WSTjvx OYVqjYHaiBl7GmBioBr9J2A+yZt34PUJ1/uE3yxUzK1G31cVWK0Wb5iTSYEQ3TIyZVq1 hPwzbpp63IqWmkxF8nMIVSESE7OC8zozA8xGB58KN0d/HgR3pUwwM3JDpnYsvcHT+77y fCiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=Oy80ZgyH; 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 q12-20020a17090311cc00b0019cec510d4csi9539935plh.444.2023.03.19.11.59.52; Sun, 19 Mar 2023 12:00:08 -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=Oy80ZgyH; 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 S229901AbjCSSzn (ORCPT + 99 others); Sun, 19 Mar 2023 14:55:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbjCSSzl (ORCPT ); Sun, 19 Mar 2023 14:55:41 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CB934485; Sun, 19 Mar 2023 11:55:40 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 8A9995FD08; Sun, 19 Mar 2023 21:55:38 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1679252138; bh=C781NWpzeOK41C9p67pG5T6Jta5orOVTpQeZsJpmG/8=; h=Message-ID:Date:MIME-Version:To:From:Subject:Content-Type; b=Oy80ZgyHynh27XtVAJRm3hu4Pm8dP5oed2sCfK9E9/SIcnCtqyNHMWai0IXCAsd6E SDKEThUAF1BD6VQdWAIeXJFdjkp/czlQace9ewICsfAUJB71Z1xWgilOGAylEE0fLg ZiQV27pHtD5ziKQ8z/oijZSI+NVg1Y4JFQGqTmfjGt1VgkKMToSV+osLYP7QZydFgL lTrtlAkiKi00oDxCK17fZG5cZHpAKhg+oOJDqBwUEdFJFT4hlr4JY37vstNGStb7yX qsnxht7tReX2KI0nnCbA6HazNuiTTMT+OADc0oKcX5eIBdvdnwWqtJ+CZESVwjuXXy KXJFR3QAMvNlw== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Sun, 19 Mar 2023 21:55:38 +0300 (MSK) Message-ID: Date: Sun, 19 Mar 2023 21:52:19 +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: To: Stefan Hajnoczi , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Bobby Eshleman CC: , , , , , , From: Arseniy Krasnov Subject: [RFC PATCH v1 2/3] virtio/vsock: add WARN() 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/19 16:43:00 #20974059 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760823772898571259?= X-GMAIL-MSGID: =?utf-8?q?1760823772898571259?= This prints WARN() and returns from stream dequeue callback when socket's queue is empty, but 'rx_bytes' still non-zero. Signed-off-by: Arseniy Krasnov --- 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 3c75986e16c2..c35b03adad8d 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -388,6 +388,13 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk, u32 free_space; spin_lock_bh(&vvs->rx_lock); + + if (skb_queue_empty(&vvs->rx_queue) && vvs->rx_bytes) { + WARN(1, "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);