From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (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 18D5F4028FD for ; Fri, 22 May 2026 13:40:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779457212; cv=none; b=Kl6NuDACrzLKwx3kkCUSi+AM6N1k1He43wTG/TIAXIRJpM/V4aCbVpkF8byh6Zlwx+ASwz+PvKzqb434GAH6hwyCqVF6GYamEs5ZvP+ltje4VN9ED8koG1jNNTrzQzMEsVRb8jfxeWgPzwGnJOyvngtdLWqKn25cYWl3ecLZhTE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779457212; c=relaxed/simple; bh=ErCSwgQgXtBcXou94NTTw1Cmt5/A1R0k3ZRWfKQ8dw0=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: Mime-Version:Content-Type; b=OzRhDjy44jn70dgYYXBQQk3h0AftG5Ouc1Gc36rmU2nEnjnMXoGHrK5fz+RoN8i8HXS06bRd2atGvX5gonxHSNoyYZCLxq55jUmw1V0ImaOyv3ZKFgCD7hDtBp8QX2sfjnLZqZA1oErvOmFSklFPnTpOCZLLOTPMgRs76m3fyG0= 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=QZTKx2ex; arc=none smtp.client-ip=209.85.128.172 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="QZTKx2ex" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-7b6ae2ea4a1so74519467b3.2 for ; Fri, 22 May 2026 06:40:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779457207; x=1780062007; 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=swBrvw+ex4GMCF0ISIs7kUEUPhpY9o/EJ/ELsD9/dRw=; b=QZTKx2exCbXZLk9BCCfXCjBDTg9fziwhBcOpMKt7jEgFH6CF2r7E9kr8FqgBzRpOFA JN6oUIZqzOVZe4SzkXDeBMruG+SXrqAIDJfyOLOXcOvbGCNhLo4QiQrTFMW3sfJSpgMM /dW6s/82yfyDu4z/ncKZXsKTiWFZD+U4cDo/Z15/8fWorAWGwRmENkkWLnxUhu4LHVxL Dw0libzzuv+gNPdopfdA8ITyab+4+3Q84n9AbzCjZhgz09/Bc9WcI06biizpbAtmQHmm iG7k70/+CdMqvfgBwJRPEuNQe4FXnH459gLbApzFKMiy6IAlL1a3oUX27Z+6q48e4aVR t9LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779457207; x=1780062007; 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=swBrvw+ex4GMCF0ISIs7kUEUPhpY9o/EJ/ELsD9/dRw=; b=WijGpXSuGadd/kZW2PPdWRMqsFonMTR6yqGaoQtr0Tw1KKIxccMyo5kmKI0JooGaFC 3oioTy/Q8RKnO+m7OCRKC+Ab8V5TCurB9iE87Nmq9csbzJv88Mko7sgY5WiuXCZRcXHp D7RCnOkTzDkFBsUyixtl5CUUwVXcGGnBx2tCIy+pNFzlWv1K9S/nR2jRzMZk2gDsELfv zRGYX/e6kAWsnY3IL5YC3u4OWHJdMQ9XTFRXCCm2ZhbVCEbF+V78w0lxYPbQ3Ip+okh6 +Tsz351lBP60z93JmNj11y/b8hzTPiOXPyn8wtzybHl2uFA++KpGCmTyluIXvxFiqSIK edLw== X-Forwarded-Encrypted: i=1; AFNElJ+0ViPqhspjj3xgaFTremVUi2iT5RhzVM3L7fV3lYaVz/2uX75RJXPsEfmsLjGI2qfpJwlcAtd9HOncQDc=@vger.kernel.org X-Gm-Message-State: AOJu0YxXFsCnOwu4ovM49ELigVd7h2udynR+yXy1DdPx8Gv1rWWBn5sl Ag2I+mL7IhtaeEkQ1fabmReDD0YJu4sj1M1FgeUxp2itySIkCeJmGkLY X-Gm-Gg: Acq92OEWWki5f0gCsqvghM95LGJPxKfbaitxC2e8+qtHGBEIt75mEP7kjp1HPYYi63d bm28e6XmFrgSbsJCJ1d5g66YhpbvT7eIbL+v1uz2t8SF0hCBHe8AL5qNRSVdBxYR9juqbA3qzQn laAKzxl2NZ3xanS/MW1NUiCFKF8HaBYx72dEGy/XF7UsQWNVfO5U1ZSoi9p4GGsTjficZTBE1iU fXypXA/HMOLtdBgTLSxEv29QmNzRa9ssYz4A+3ZTPOTNOoHaqNpcwAhzbxuTolO4heFjFehdHmq DB+3bMKVyn9NvqMg/rlx1X5lI+amZA5l4nrfnmPbJm1JzuvPp516Kd7Dbj1U+XT1GRB7H+VWQph egYR5E/7mmk7Wgvd21KPrGVKIqA8xomZ7rSTi2xXXBj5ZWnIWw+/8BvoJty51FhItGcCv2VdRAw jcTsc+BAXa6IfSnhkz/kRrIqk7kd9ZT5ifv19TdM4PHMaRwS8kjbsorURO/2GsqPABqYktHXk1u UJFoiE= X-Received: by 2002:a05:690c:7402:b0:7d0:261a:692 with SMTP id 00721157ae682-7d3368b80bcmr42586287b3.44.1779457206675; Fri, 22 May 2026 06:40:06 -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-7d38c335164sm8173877b3.33.2026.05.22.06.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 06:40:06 -0700 (PDT) Date: Fri, 22 May 2026 09:40:05 -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: <20260521163312.1479805-2-bestswngs@gmail.com> References: <20260521163312.1479805-2-bestswngs@gmail.com> Subject: Re: [PATCH net] tun: free page on build_skb failure in tun_xdp_one() 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: > When build_skb() fails in tun_xdp_one(), the function sets ret to > -ENOMEM and jumps to the out label, which returns without freeing the > page that vhost_net_build_xdp() allocated for the frame. As with the > short-frame rejection path, tun_sendmsg() discards the per-buffer error > and still returns total_len, so vhost_tx_batch() takes the success path > and never frees the page. Each build_skb() failure in a batch leaks one > page-frag chunk. > > Free the page before taking the error path, matching the put_page() the > other error exits of tun_xdp_one() already perform. > > Fixes: 043d222f93ab ("tuntap: accept an array of XDP buffs through sendmsg()") > Reported-by: Xiang Mei > Assisted-by: Claude:claude-opus-4-7 > Signed-off-by: Weiming Shi Reviewed-by: Willem de Bruijn