lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240327.Zoo8Huo0eemo@digikod.net>
Date: Wed, 27 Mar 2024 11:45:21 +0100
From: Mickaël Salaün <mic@...ikod.net>
To: Ivanov Mikhail <ivanov.mikhail1@...wei-partners.com>
Cc: willemdebruijn.kernel@...il.com, gnoack3000@...il.com, 
	linux-security-module@...r.kernel.org, netdev@...r.kernel.org, netfilter-devel@...r.kernel.org, 
	yusongping@...wei.com, artem.kuzin@...wei.com, konstantin.meskhidze@...wei.com
Subject: Re: [PATCH] samples/landlock: Fix incorrect free in
 populate_ruleset_net

On Tue, Mar 26, 2024 at 05:56:25PM +0800, Ivanov Mikhail wrote:
> Pointer env_port_name changes after strsep(). Memory allocated via
> strdup() will not be freed if landlock_add_rule() returns non-zero value.
> 
> Fixes: 5e990dcef12e ("samples/landlock: Support TCP restrictions")
> Signed-off-by: Ivanov Mikhail <ivanov.mikhail1@...wei-partners.com>
> Reviewed-by: Konstantin Meskhidze <konstantin.meskhidze@...wei.com>

Thanks! Applied to my next branch.

> ---
>  samples/landlock/sandboxer.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/samples/landlock/sandboxer.c b/samples/landlock/sandboxer.c
> index 32e930c853bb..8b8ecd65c28c 100644
> --- a/samples/landlock/sandboxer.c
> +++ b/samples/landlock/sandboxer.c
> @@ -153,7 +153,7 @@ static int populate_ruleset_net(const char *const env_var, const int ruleset_fd,
>  				const __u64 allowed_access)
>  {
>  	int ret = 1;
> -	char *env_port_name, *strport;
> +	char *env_port_name, *env_port_name_next, *strport;
>  	struct landlock_net_port_attr net_port = {
>  		.allowed_access = allowed_access,
>  		.port = 0,
> @@ -165,7 +165,8 @@ static int populate_ruleset_net(const char *const env_var, const int ruleset_fd,
>  	env_port_name = strdup(env_port_name);
>  	unsetenv(env_var);
>  
> -	while ((strport = strsep(&env_port_name, ENV_DELIMITER))) {
> +	env_port_name_next = env_port_name;
> +	while ((strport = strsep(&env_port_name_next, ENV_DELIMITER))) {
>  		net_port.port = atoi(strport);
>  		if (landlock_add_rule(ruleset_fd, LANDLOCK_RULE_NET_PORT,
>  				      &net_port, 0)) {
> -- 
> 2.34.1
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ