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] [thread-next>] [day] [month] [year] [list]
Message-ID: <1312152274.11635.8.camel@Joe-Laptop>
Date:	Sun, 31 Jul 2011 15:44:34 -0700
From:	Joe Perches <joe@...ches.com>
To:	Jesper Juhl <jj@...osbits.net>
Cc:	"Nicholas A. Bellinger" <nab@...ux-iscsi.org>,
	Andy Grover <agrover@...hat.com>,
	Roland Dreier <roland@...nel.org>,
	Christoph Hellwig <hch@....de>, linux-scsi@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Fix leak in
 drivers/target/iscsi/iscsi_target_parameters.c::iscsi_copy_param_list()

On Mon, 2011-08-01 at 00:28 +0200, Jesper Juhl wrote:
> We leak memory if the allocations for 'new_param->name' or 'new_param->value' fail.
> We also do a lot of variable assignments that are completely pointless
> if the allocations fail.
> So, let's move the allocations before the assignments and also make
> sure that we free whatever was allocated to one if the allocation for
> another fails.

> diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
[]
> +		new_param->name = kmalloc(strlen(param->name) + 1, GFP_KERNEL);
> +		new_param->value = kmalloc(strlen(param->value) + 1, GFP_KERNEL);
[]
>  		memcpy(new_param->name, param->name, strlen(param->name));
>  		new_param->name[strlen(param->name)] = '\0';
>  		memcpy(new_param->value, param->value, strlen(param->value));

kstrdup

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ