Netdev List
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@openvpn.net>
To: Qingshuang Fu <fffsqian@163.com>,
	Sabrina Dubroca <sd@queasysnail.net>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>
Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Qingshuang Fu <fuqingshuang@kylinos.cn>
Subject: Re: [PATCH] selftests/net: ovpn: fix socket leak in ovpn_socket() error paths
Date: Fri, 7 Aug 2026 09:07:51 +0200	[thread overview]
Message-ID: <9f20537c-a737-4bf0-b9b7-d2ce57c5fe11@openvpn.net> (raw)
In-Reply-To: <20260807064816.53811-1-fffsqian@163.com>

Hi there,

On 07/08/2026 08:48, Qingshuang Fu wrote:
> From: Qingshuang Fu <fuqingshuang@kylinos.cn>
> 
> The ovpn_socket() function creates a socket but fails to close it on
> several error paths, leading to a file descriptor leak:
> 
> 1. When the address family is neither AF_INET nor AF_INET6, the socket
>     is leaked in the switch default case.
> 2. When setsockopt() for SO_REUSEADDR, SO_REUSEPORT, or SO_MARK fails,
>     the socket is leaked.
> 3. When setsockopt() for IPV6_V6ONLY fails, the socket is leaked.
> 
> The existing err_socket label already handles closing the socket for
> the bind() failure path. Fix all other error paths to use goto
> err_socket instead of returning directly, ensuring the socket is
> properly closed on every error path.
> 
> Fixes: 959bc330a439 ("testing/selftests: add test tool and scripts for ovpn module")

We'd rather send changes like this to net-next, so no Fixes tag required.

> Signed-off-by: Qingshuang Fu <fuqingshuang@kylinos.cn>

This said, we already have a patch reworking this part of the selftest 
with, which is also addressing this issue:

https://patchwork.openvpn.net/project/ovpn/patch/20260512144358.419599-4-a@unstable.cc/

It is pending to be sent to net-next as soon as we're finished with the 
fixes in our pipe.

Thanks for your contribution in any case!


Regards,



-- 
Antonio Quartulli
OpenVPN Inc.


  reply	other threads:[~2026-08-07  7:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07  6:48 [PATCH] selftests/net: ovpn: fix socket leak in ovpn_socket() error paths Qingshuang Fu
2026-08-07  7:07 ` Antonio Quartulli [this message]
2026-08-07  7:23   ` Qingshuang Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9f20537c-a737-4bf0-b9b7-d2ce57c5fe11@openvpn.net \
    --to=antonio@openvpn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fffsqian@163.com \
    --cc=fuqingshuang@kylinos.cn \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sd@queasysnail.net \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox