Message ID | 30aa2604-77c0-322e-44fd-ff99fc25e388@sberdevices.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;makky5685@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <stefanha@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Bobby Eshleman <bobby.eshleman@bytedance.com> CC: <kvm@vger.kernel.org>, <virtualization@lists.linux-foundation.org>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <kernel@sberdevices.ru>, <oxffffaa@gmail.com>, <avkrasnov@sberdevices.ru> From: Arseniy Krasnov <avkrasnov@sberdevices.ru> 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: <linux-kernel.vger.kernel.org> 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?= |
Series |
fix header length on skb merging
|
|
Commit Message
Arseniy Krasnov
March 25, 2023, 10:09 p.m. UTC
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 <AVKrasnov@sberdevices.ru>
---
net/vmw_vsock/virtio_transport_common.c | 7 +++++++
1 file changed, 7 insertions(+)
Comments
On Sun, Mar 26, 2023 at 01:09:25AM +0300, Arseniy Krasnov wrote: >This adds WARN_ONCE() and return from stream dequeue callback when >socket's queue is empty, but 'rx_bytes' still non-zero. Nit: I would explain why we add this, for example: This allows the detection of potential bugs due to packet merging (see previous patch). > >Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru> >--- > 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")) { Nit: I would rephrase it this way: "rx_queue is empty, but rx_bytes is non-zero" >+ 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 > Anyway the patch LGTM! Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
On 28.03.2023 12:29, Stefano Garzarella wrote: > On Sun, Mar 26, 2023 at 01:09:25AM +0300, Arseniy Krasnov wrote: >> This adds WARN_ONCE() and return from stream dequeue callback when >> socket's queue is empty, but 'rx_bytes' still non-zero. > > Nit: I would explain why we add this, for example: > > This allows the detection of potential bugs due to packet merging > (see previous patch). > >> >> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru> >> --- >> 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")) { > > Nit: I would rephrase it this way: > "rx_queue is empty, but rx_bytes is non-zero" > >> + 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 >> > > Anyway the patch LGTM! Thanks for review! Since only string value and commit message should be updated, i can resend it with 'net' (as it is fix) and update two thing above in 'net' version? Thanks, Arseniy > > Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> >
On Tue, Mar 28, 2023 at 11:35 AM Arseniy Krasnov <avkrasnov@sberdevices.ru> wrote: > > > > On 28.03.2023 12:29, Stefano Garzarella wrote: > > On Sun, Mar 26, 2023 at 01:09:25AM +0300, Arseniy Krasnov wrote: > >> This adds WARN_ONCE() and return from stream dequeue callback when > >> socket's queue is empty, but 'rx_bytes' still non-zero. > > > > Nit: I would explain why we add this, for example: > > > > This allows the detection of potential bugs due to packet merging > > (see previous patch). > > > >> > >> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru> > >> --- > >> 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")) { > > > > Nit: I would rephrase it this way: > > "rx_queue is empty, but rx_bytes is non-zero" > > > >> + 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 > >> > > > > Anyway the patch LGTM! > > Thanks for review! Since only string value and commit message should be > updated, i can resend it with 'net' (as it is fix) and update two thing > above in 'net' version? Yep, sure! And you can already add my R-b ;-) Thanks, Stefano > > Thanks, Arseniy > > > > Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> > > >
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);