Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1486275rwd; Thu, 1 Jun 2023 16:56:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7xcTDOOoS5FJV1hgcKwC/JROKrwnv3myHlqf2x5MtE/KFSYy/ogzq5YD84xFgDAudKQBHT X-Received: by 2002:a05:6a21:1509:b0:10f:8b61:197c with SMTP id nq9-20020a056a21150900b0010f8b61197cmr7624329pzb.54.1685663792205; Thu, 01 Jun 2023 16:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685663792; cv=none; d=google.com; s=arc-20160816; b=QaUgiPsUt0JV2MoIL1dvc/2Z8htk7gvky5AmroQImF3mIazc6LykaQdi/XDg+DY90d UjMf/VlK1pengc8bH7ksJGiQdbZEznxW2pwDs/54WWnOFyKE2J1DQ1p/4Sd+xy+gNS82 1sf1dBHTzcHLwfM32MgAND2kDT/OpKEobE8gjdLSUU/if7M2dettjQThFj4kOpyN/UuL m8TRMF2FQUtM6/oXqAkXhTfVj/+nBbJDAtxqSRaNmI3GlI/fhR7QSL/WMNaLxbuWy9Ih oEFnYWW1CNo3qgPi21cZHvl/5cG7ivvHzTAo0M5/UbTeuxwY7U+0XoAPRKTbgfDQ/swA n6bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Y66S7nKcbyO9mw2veazWYNce7x29EbNWsEjy9gQwvT8=; b=qVUNdhVptLDaYPk60BWeoTvYcchYHH8OJ8aFAAziYkI2W/puFkBTvjfph4sr0BkPHs US04d0il5KXAl+6bwnhqoM2AU79cZQxrFKLzys1sM0OhvTg3MW02ldBtMSK+P8ZAohqi L2F7AQcRSd3Od+4oUjPkQijcrr5t19N55L176g9SR+gDOxJHQ2wuhf94cIvXlBrhfcSY /oQBW8HID0DitDsT9YNwtcoE2zphpq4ryRBIFcnVAcagtBFULFLDej14123tEshidwLi ZFCQowGkrlYgegoN2vBp85iuc6JlSGGxrZYovUGlzeZppUl78u2G5OR9g3dNxXai/zkz JjyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=JgN6bMOP; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p5-20020a170902eac500b001ac84f55591si3379065pld.293.2023.06.01.16.56.20; Thu, 01 Jun 2023 16:56:32 -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=@gmail.com header.s=20221208 header.b=JgN6bMOP; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232823AbjFAXj7 (ORCPT + 99 others); Thu, 1 Jun 2023 19:39:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232056AbjFAXjt (ORCPT ); Thu, 1 Jun 2023 19:39:49 -0400 Received: from mail-oo1-xc36.google.com (mail-oo1-xc36.google.com [IPv6:2607:f8b0:4864:20::c36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E178136; Thu, 1 Jun 2023 16:39:48 -0700 (PDT) Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-5584f8ec30cso1085378eaf.0; Thu, 01 Jun 2023 16:39:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685662788; x=1688254788; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Y66S7nKcbyO9mw2veazWYNce7x29EbNWsEjy9gQwvT8=; b=JgN6bMOPbZQQzmbjQOXjZR1MWbA658FbsmFwhmJTfIBw7YT4vVH5SbNbGOqDYNiykz NsONTUM1dbTRUtPmxQi/H2LhtTn0Gt6DO8HcjDTOBUhoGjYv59NWvC5TZ17iskx80o1o jZWxce7jFMBi1PMppTmfYEnMNSDmtgSD0HR7uL22/b+QOMO2srLfPklplvCwi4Zgpn/S +RyIJ/nq+QgwVgiZe0DQp6ybDulRm25BGxz2VtBmAV3+cM3FYgqFrIm/4tiHZjNDFj3/ NVhs4YEuF3+R+IYByMBWLDGjNsegbKB3nzBunHXSaJIZCWh9PVtdIWIC9DuBPSNL49Un OkfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685662788; x=1688254788; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Y66S7nKcbyO9mw2veazWYNce7x29EbNWsEjy9gQwvT8=; b=Kl6rnOXFgqoGrNqlLT8dnPnPlzHdmAVsxhGZhSVav0Wm46GJ6xbWllBqm5lNOhyCkD kBlB5IuFgqe0C4Ckulu1zs30gpFrzI45AphfoPTzHPxCvEh/rr7/JBiKroR9X0x9eSqd sxwBFRN2HfgxYvrcbEC/uQThpyvXsEhTq7Tco4jTgFgHJmkSfHxtBDUGq7wlbiymdSsM YzoylbgJAWOATl2u1QDAffsgzoI381z7GTbvDU7xShkObfyNWiO7A000GaD7FrQKXqeE tWXW4QvQE1Tv1Sft8mlgtuvy+NZqmUVpxCsLWIjdGZn+3kZrARd+6Fxzp4o3kWWKNJoA M7QQ== X-Gm-Message-State: AC+VfDxIN6DIPPB9/MltVaGZlKkw8AjMC8H7vFnhhs8QYYIqJhNQ5f+2 rkwQh0PjKFJ+dYhud7rfZBFaG7GgPa5zbfRq X-Received: by 2002:a05:6358:9896:b0:123:5c29:c39a with SMTP id q22-20020a056358989600b001235c29c39amr7109173rwa.31.1685662787613; Thu, 01 Jun 2023 16:39:47 -0700 (PDT) Received: from localhost (ec2-52-9-159-93.us-west-1.compute.amazonaws.com. [52.9.159.93]) by smtp.gmail.com with ESMTPSA id z15-20020aa791cf000000b0064d59e194c8sm5585299pfa.115.2023.06.01.16.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 16:39:47 -0700 (PDT) Date: Wed, 31 May 2023 03:35:30 +0000 From: Bobby Eshleman To: Stefano Garzarella Cc: Bobby Eshleman , kvm@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Eric Dumazet , Stefan Hajnoczi , Jakub Kicinski , Paolo Abeni , "David S. Miller" Subject: Re: [PATCH net] virtio/vsock: fix sock refcnt bug on owner set failure Message-ID: References: <20230531-b4-vsock-fix-refcnt-v1-1-0ed7b697cca5@bytedance.com> <35xlmp65lxd4eoal2oy3lwyjxd3v22aeo2nbuyknc4372eljct@vkilkppadayd> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <35xlmp65lxd4eoal2oy3lwyjxd3v22aeo2nbuyknc4372eljct@vkilkppadayd> X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DATE_IN_PAST_24_48, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Thu, Jun 01, 2023 at 09:58:47AM +0200, Stefano Garzarella wrote: > On Wed, May 31, 2023 at 07:47:32PM +0000, Bobby Eshleman wrote: > > Previous to setting the owner the socket is found via > > vsock_find_connected_socket(), which returns sk after a call to > > sock_hold(). > > > > If setting the owner fails, then sock_put() needs to be called. > > > > Fixes: f9d2b1e146e0 ("virtio/vsock: fix leaks due to missing skb owner") > > Signed-off-by: Bobby Eshleman > > --- > > net/vmw_vsock/virtio_transport_common.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c > > index b769fc258931..f01cd6adc5cb 100644 > > --- a/net/vmw_vsock/virtio_transport_common.c > > +++ b/net/vmw_vsock/virtio_transport_common.c > > @@ -1343,6 +1343,7 @@ void virtio_transport_recv_pkt(struct virtio_transport *t, > > > > if (!skb_set_owner_sk_safe(skb, sk)) { > > WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n"); > > + sock_put(sk); > > Did you have any warning, issue here? > > IIUC skb_set_owner_sk_safe() can return false only if the ref counter > is 0, so calling a sock_put() on it should have no effect except to > produce a warning. > Oh yeah, you're totally right. I did not recall how skb_set_owner_sk_safe() worked internally and thought I'd introduced an uneven hold/put count with that prior patch when reading through the code again. I haven't seen any live issue, just misread the code. Sorry about that, feel free to ignore this patch. Best, Bobby