Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp84406lqz; Fri, 29 Mar 2024 09:14:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVEj+YgSyk1Zk5HKZrYN5/ZdZtvep38qRA06YjKcDsRxNQ9DJ6p0YrVGbpoTR9WvcdiWQsy+TQToUkeAimVeeJMZcTNYY+0GdXsAk32fg== X-Google-Smtp-Source: AGHT+IFz7ACumfOj0a9TSni8q85sw9ARwYylzXJTzKjfoNXIslwNkcrWSL/DrJrYCHdgefeEzKB3 X-Received: by 2002:a17:90a:f298:b0:29b:68c:1779 with SMTP id fs24-20020a17090af29800b0029b068c1779mr2538532pjb.40.1711728846043; Fri, 29 Mar 2024 09:14:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711728846; cv=pass; d=google.com; s=arc-20160816; b=Npq8g+UEgCkRVFteD0MfwRaXEh87Q1oflK+Q57t3gTS5mytTXYsmq0PlQnzWzYZPO0 AN9ltxNnwf9I+xSokC9PTGhKTV6eIptj/4O0tnPavvkL7leO55eJeJKT3ggK+2a/bA5f WYNfLZ03m9HUuD8TwO7zPdSCn8VZE2MQmFdlRpaLgkdVjm98/j81DjFEn2qtO9N+6XYM Y2Q+JXyvlukq/IwqF2lsfbvO4Q6sJOZPXFQzpO1cLqZyA9PSRFcQyM9RfhdU0kOrN1i2 5iuYJAbTYe1sCLgugiChCeNhETEe2eLIhXi3EsTsnprKOFmHQblzY1PYDuz/fCMv5CLq tgTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=g+ENIHdShqwsDq8iCSWp4zm4/fE/0J9kqrrA/ykJ7CU=; fh=FkIAlR0GBfOqeBW/IW5kAOyX7GsML/A4rpwVqs0dqP8=; b=GGTKF103qaLmIq8ZL+UepG6qeXOausj/luF7sK+PqF7wtumqWqDc7ywHjm7BS7PXx4 J3wEQig3oUH+iQWo0bN2OhpDV4vVcD4EOT0PjvAtg5A8BVeHyjt2NcKbIDLBWakMFbww Cqkmm1rR+6XXhtBENM385q55ztdgWlZptvIa57nmhwF190xpnm/pKGvFd80m+EDX+gDp Uobx9gAkj9xddon/SlcYsIVhO4Prqd2yXcNcE9LAUnyqRRkRA3JSeXnYlSREsEMVhS+E MnG8QBVNiqZJRYrVM4VJTCyMYbyujltQjMFMLiccY/tAge1lgtxf6sko0kLLI7Z+Dw8m 63Zw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lAb271IH; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-125159-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125159-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id mq13-20020a17090b380d00b002a2074f8351si3984139pjb.63.2024.03.29.09.14.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 09:14:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-125159-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lAb271IH; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-125159-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125159-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 399DF2884F7 for ; Fri, 29 Mar 2024 16:13:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7DDB485C44; Fri, 29 Mar 2024 16:13:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lAb271IH" Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26D9617E; Fri, 29 Mar 2024 16:13:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711728806; cv=none; b=F2JVECFTrjYqAZqZN8JPXzNOZGZ/lufdUV745RzBS4/eGA8WQS1HscRokP0gd9niJPaBkMbk+jM6+mexJxJWL32vzQcnChpNGkm2iDCeMwSPBpTQWs/UmfTIP84I7bCILjbjHFI043AA0KBEbjTR0648VsgXAWYV5ZW9VjK2kHM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711728806; c=relaxed/simple; bh=I6FaA8lE1xu3cAiFmF8W7/Zh4WtxN7EK1Ev2dqCqEoE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TdzyUoXl+4HQ0UCL3cLzwG+aM4kpgUqJFMZmp3ledCMtyUnn3UbM0ecWe3oVoPMPSABF2BynfdD7/KkFdv3TXgxiDBBC+eQHiJUVhP+nfzMTywk3NLulf7hS7AH6Mc67EyiILHbP3HE6yzgGFn6BD0dvxAz0wegXcr8hnCxwUho= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lAb271IH; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-34261edaf7eso1434695f8f.1; Fri, 29 Mar 2024 09:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711728803; x=1712333603; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=g+ENIHdShqwsDq8iCSWp4zm4/fE/0J9kqrrA/ykJ7CU=; b=lAb271IHKTAfLugLDCj0uSeopS7vUiIP6f+KHAa1s9YE/57qq45AVuivO7ouIGOL+q YcrpI/yVeGTV22LRoH+L5qnbKqu2d5yUrzb2LlVTYR1Vbfn23Vjr97iiqNV490o9q5pv YjeKTyrN2LyUaEngnjt1yM1G6dScpXxwSjEWMSRDASzjOOHs/wZramX/ra5LcsZvcqBU /tv2bHoOnywNuzk89AP+t9fRDVwuTJ9Bi9HVXZQ8r54Cz3JEpIG8rzIb16U5k3JN2JLm 0s4LdFTBQAPU/bY2luB9Gybxh3yygEnOk8oqp2oseLUQibnyTDV/dAK3POpLIyWidUcm Pi8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711728803; x=1712333603; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=g+ENIHdShqwsDq8iCSWp4zm4/fE/0J9kqrrA/ykJ7CU=; b=BHUZXj5KK8eWDaI3sUNULxLDNCkDWFquxngBuR93BOQc74WuMY++tt6Srave+RTvOQ iYqde4jl0r9INElYR8ENgHURgXM0szkG1yKA0gmLn9IFLdOW+ab5bc0BKdA+WV1MNfPd 08dFadCybdu258APvfyOHq2m/MwdkKqdPrEjZHW6QcJELicDHt/F0/FFh2IThruNZj92 NcT4NITcp1nzumcQOivGwahTNZvHzReHRQyhJHtB5QlF5iHinwuVskd+AadEeOAsKW6V VYdv5p8quiZX994rslCrbUbAwzwRUl/ksQMwnuOcePkrcsAp0++xqi5BRDOGdFAk6EV8 vZBw== X-Forwarded-Encrypted: i=1; AJvYcCUXQqgLjUzf92nFDbin0oeaL2WLXMuLo2GCyiRsErp8QwIa+WwyCH5sA3K3HvOOLYFGE1kcw7iu/SVOPAhftL+sXvDmRYlQc9mNzH/wrE4c5myHY1jN0zvvC8lnzSbhPLMWLsyLisI4jGuJD8Ahwy9KWDPvpDY5oVNR X-Gm-Message-State: AOJu0YyiVWPnePk90XHoCh8Q/dcEE/f4CjMGaUGn91+lgu2JfT7z5WTG EiDXf1Zb9FeowjDWP6Z7/tp6vvqMz+XoaETmLhSnNt5yFaZ3tDnr X-Received: by 2002:adf:f982:0:b0:33e:c69f:2cae with SMTP id f2-20020adff982000000b0033ec69f2caemr1453465wrr.23.1711728803359; Fri, 29 Mar 2024 09:13:23 -0700 (PDT) Received: from localhost.localdomain ([82.84.234.137]) by smtp.gmail.com with ESMTPSA id u4-20020adff884000000b00341d9e8cc62sm4464208wrp.100.2024.03.29.09.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 09:13:22 -0700 (PDT) From: Marco Pinna To: stefanha@redhat.com, sgarzare@redhat.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, ggarcia@deic.uab.cat, jhansen@vmware.com, kvm@vger.kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Marco Pinna , stable@vge.kernel.org Subject: [PATCH net v2] vsock/virtio: fix packet delivery to tap device Date: Fri, 29 Mar 2024 17:12:59 +0100 Message-ID: <20240329161259.411751-1-marco.pinn95@gmail.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Commit 82dfb540aeb2 ("VSOCK: Add virtio vsock vsockmon hooks") added virtio_transport_deliver_tap_pkt() for handing packets to the vsockmon device. However, in virtio_transport_send_pkt_work(), the function is called before actually sending the packet (i.e. before placing it in the virtqueue with virtqueue_add_sgs() and checking whether it returned successfully). Queuing the packet in the virtqueue can fail even multiple times. However, in virtio_transport_deliver_tap_pkt() we deliver the packet to the monitoring tap interface only the first time we call it. This certainly avoids seeing the same packet replicated multiple times in the monitoring interface, but it can show the packet sent with the wrong timestamp or even before we succeed to queue it in the virtqueue. Move virtio_transport_deliver_tap_pkt() after calling virtqueue_add_sgs() and making sure it returned successfully. Fixes: 82dfb540aeb2 ("VSOCK: Add virtio vsock vsockmon hooks") Cc: stable@vge.kernel.org Signed-off-by: Marco Pinna --- net/vmw_vsock/virtio_transport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c index 1748268e0694..ee5d306a96d0 100644 --- a/net/vmw_vsock/virtio_transport.c +++ b/net/vmw_vsock/virtio_transport.c @@ -120,7 +120,6 @@ virtio_transport_send_pkt_work(struct work_struct *work) if (!skb) break; - virtio_transport_deliver_tap_pkt(skb); reply = virtio_vsock_skb_reply(skb); sgs = vsock->out_sgs; sg_init_one(sgs[out_sg], virtio_vsock_hdr(skb), @@ -170,6 +169,8 @@ virtio_transport_send_pkt_work(struct work_struct *work) break; } + virtio_transport_deliver_tap_pkt(skb); + if (reply) { struct virtqueue *rx_vq = vsock->vqs[VSOCK_VQ_RX]; int val; -- 2.44.0