Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp986877rwl; Sat, 25 Mar 2023 15:16:18 -0700 (PDT) X-Google-Smtp-Source: AKy350arIxAk44eAgD+ltcUwK9UOAZVg1i4WBC4SJAT12A1I2YQXXSKvF72JyML7Z0beW9DSV1D6 X-Received: by 2002:aa7:d314:0:b0:502:62:7c with SMTP id p20-20020aa7d314000000b005020062007cmr6652865edq.24.1679782578284; Sat, 25 Mar 2023 15:16:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679782578; cv=none; d=google.com; s=arc-20160816; b=UK1zSrfOlLmbdFI8fVcxho6XeWk6+PfNRP0WFpzGvHIEeV5U/zoZH4/usx7JAyefBo lxazw8L3nWsFj88FddK65PpTnUtkR6y96ga/LIQePTvkgUb1nB4vVugSy2uE2f77Jt/E WciNzbesMDiRxjoc1lwW2Qhy1evrm1TGlklm7w7qB3ZhUC4CW9xY6/8zJ2rSrGVgOOww QezlFQdALBa589+4l0QrUKo6na1UTL7AlywGGSeM+YvYargmnvNH1vxgtGUt2RFMkxRc 7MAbXoVVxeRfNRafiIFPGa90kjfbysKTZSFW9FQ4TzPmAMysDTlKxrupG27XriygP8jP dfUw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c10-20020aa7df0a000000b004fe1ad4197dsi23202527edy.412.2023.03.25.15.15.53; Sat, 25 Mar 2023 15:16:18 -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 S231786AbjCYWMr (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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit 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 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 --- 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); -- 2.25.1