From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) (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 7BE05421A19 for ; Fri, 22 May 2026 13:44:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779457463; cv=none; b=dMd9g/Oi72reU0TNruLsgrK1p90NHCyzuKjfi341yHi8nULZESD1Yqo3AZFsNhfnMGhH3MLDVSoG5L5Uan2ZViALKgXreAnhup8P7uGutaT7k/gNwPdELfEaQfpyR6asM+OeaP2rLkvh8/zZuBFT3CCUmLWLpyPxK4bsqtbtJ/o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779457463; c=relaxed/simple; bh=5la0D/R7CJ4PfmB6OsvL8OiyVTJizo/jhlIOOzkCkEY=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: Mime-Version:Content-Type; b=fJkC2GINQlALGLm42acCG+jwDjU7g3mKQPDR84kYg6PYipPx3x1WGuG5JwNPbO/2SUChh5Bp9MyjDg5o7hZd+ltM3DIs4y7gM/DMYgRBcDrNr4dNLkKAKR6YnuUFHpZAJnF403CMLZcS8wmmlX3WLRHKyFJ/KcJO/7UgWDCwYXI= 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=fTVqZKX6; arc=none smtp.client-ip=209.85.128.173 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fTVqZKX6" Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-7cb343d343fso67700077b3.2 for ; Fri, 22 May 2026 06:44:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779457457; x=1780062257; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=1nuM9CpdZSF4/7l72HqNTMm6D+ZaatVl7iUT+72HqVk=; b=fTVqZKX6cGQ95OYWvmMRir96F0BGBHvwmQPKD7PFC30MdYJziLi+5+F/93w444J7o6 Bo0xik+GDGaYfWmAjaNvExZCyJvqN+MW6lTg6HFq3uPyfUk2ZgbxDp9xFoREzDUzrzZi Tq3yBUKHS57pe/8JXyYyQsF2Tt8EUXbLXlMt03SH/joXu0jM+tT3Tm5wu5sa2iOsmlNo 2RLpH5fWsvlxpn5BzFG1MtoHISh+4HcvEN6cXeOI+GrG5/Uvucj3ENpu6VvjmwjWm2xk bhS7K6UAGvNYR1BX6R8MTl6x9NKeALGgs/RHj3LqBTUKyT2ty52DI6HMpzxN9cyuyjgZ /3fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779457457; x=1780062257; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=1nuM9CpdZSF4/7l72HqNTMm6D+ZaatVl7iUT+72HqVk=; b=tEcPH9yJy9dUR+ojMFMvejlocgL4zNYck6Bzxxe6hb6fLYncsqFIU2NClf8qoFGQqS VwdgT0SQB+rTtyQd+f2ykqHFk4woBzX7voMJ2+pa8c1OIg0I5SrFHWZaIesDRbk4pihn utmRPyhhkJm37qV4GZTrGTyetj1/Dhd5lETPvHSqaGa1kViHovb/83vHGvlLnA9wOxjh NDgjm4rnSvvz9uTf9TaPbWxddS4z4sM6rQbJ+yU/X+pXckiDB1zSu+Oa0zEEREsnPbxg RPQxrbjDrsG67yrJUgO1BQJYjcV0gyzYA31pi/v4XtVMLEqW1hCer5tgVIuauesP9WRP ILCQ== X-Forwarded-Encrypted: i=1; AFNElJ/4sZ6p3kFA+oHH0o1NIW9cyuB7DgW+5daFlS83Vd2uaN44AybT/4x7pfRJgEuMLj1Jc1dMdJx0Grlxst0=@vger.kernel.org X-Gm-Message-State: AOJu0Yz5GDuLuveBu4mhdcmVF8Qy6bUBkA5K+5RdLMR1ixQ110mYJeFv YyPe8gcUNvRJ/ZNDzQlRMrlP/oEjiWwfvCqVjAqZOtL2Gk1PGfdUx2ME X-Gm-Gg: Acq92OGSUceAQIllP8rAVtM4LGooRLTRUVJsWuTdA7qaweJJfTlOoCKWcTB/Hglo5F9 ez9Z5T6HEmgHl/wUVKXCb7x3gzkwRgFc+jPOuraj4VKdnmzX31FVMtpdYIldzLKsONHy4pNLG2z Rki0gYxPLI9zEYYAiNvhM65jFSdbCMaWChX4uTKjcZqqqXorBSC0YpdrMS0Q8vca6NFWOvIf2c7 4zFyOglb9UE4xAlOtTQ23PlUH9cZY6RsMLUFvKU6yOHu0M9m7FDgXxS22KiAcTiRcSCnby0xItp WeSGOhzz2//S2KmRqj4LbFbTTihwq85/N6W/XrnvI2kcihz1GQ19WW/p03CAcoVw798btsUGHs8 PQHJmTFZozBb5LeNbl3GMeT2fg6CPZ5zERPgar6pbJKvwmGFDb0dkqw4WzXvLFX5SoqssnllITa f0VXZ/uYJbhJqlMrrVZpaMZE6EMJMS2on9RdfMI1S10bPrCK13rF6lXCvp7/FqZgNvB5KFZotp4 XNLWJqLokLUz4XH/Q== X-Received: by 2002:a05:690c:d0f:b0:7bd:9899:f904 with SMTP id 00721157ae682-7d3368b4ec8mr41250927b3.39.1779457456882; Fri, 22 May 2026 06:44:16 -0700 (PDT) Received: from gmail.com (141.139.145.34.bc.googleusercontent.com. [34.145.139.141]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7d389819068sm8218937b3.3.2026.05.22.06.44.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 06:44:16 -0700 (PDT) Date: Fri, 22 May 2026 09:44:16 -0400 From: Willem de Bruijn To: Weiming Shi , netdev@vger.kernel.org Cc: willemdebruijn.kernel@gmail.com, jasowang@redhat.com, pabeni@redhat.com, kuba@kernel.org, edumazet@google.com, dongli.zhang@oracle.com, xmei5@asu.edu, linux-kernel@vger.kernel.org, Weiming Shi Message-ID: In-Reply-To: <20260521163230.1478627-2-bestswngs@gmail.com> References: <20260521163230.1478627-2-bestswngs@gmail.com> Subject: Re: [PATCH net] tap: free page on error paths in tap_get_user_xdp() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Weiming Shi wrote: > tap_get_user_xdp() rejects a frame shorter than ETH_HLEN with -EINVAL, > and returns -ENOMEM when build_skb() fails. Both paths jump to the err > label without freeing the page that vhost_net_build_xdp() allocated for > the frame. tap_sendmsg() discards the per-buffer return value and always > returns 0, so vhost_tx_batch() takes the success path and never frees > the page; each rejected frame in a batch leaks one page-frag chunk. > > Free the page on both error paths, before the skb is built. This is the > tap counterpart of the same leak in tun_xdp_one(). > > Fixes: 0efac27791ee ("tap: accept an array of XDP buffs through sendmsg()") > Fixes: ed7f2afdd0e0 ("tap: add missing verification for short frame") > Reported-by: Xiang Mei > Assisted-by: Claude:claude-opus-4-7 > Signed-off-by: Weiming Shi Reviewed-by: Willem de Bruijn