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]
Date:   Mon, 9 Nov 2020 17:23:31 +0000
From:   Mark Brown <broonie@...nel.org>
To:     Kefeng Wang <wangkefeng.wang@...wei.com>
Cc:     Marc Zyngier <maz@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] regmap: Properly free allocated name for regmap_config
 of syscon

On Mon, Nov 09, 2020 at 07:58:16PM +0800, Kefeng Wang wrote:

> syscon_config.name in of_syscon_register is allocated using kasprintf,
> which should be freed when it is not used after regmap_set_name, fix
> the following memory leak.

> unreferenced object 0xffffffe07fe8c150 (size 16):
>   comm "swapper/0", pid 1, jiffies 4294892540 (age 68.168s)
>   hex dump (first 16 bytes):
>     74 65 73 74 40 31 30 30 30 30 30 00 e0 ff ff ff  test@...000.....
>   backtrace:
>     [<0000000023d86736>] create_object+0xe8/0x348
>     [<00000000fe9d1b17>] kmemleak_alloc+0x20/0x2a

Please think hard before including complete backtraces in upstream
reports, they are very large and contain almost no useful information
relative to their size so often obscure the relevant content in your
message. If part of the backtrace is usefully illustrative (it often is
for search engines if nothing else) then it's usually better to pull out
the relevant sections.

> @@ -601,6 +601,7 @@ static int regmap_set_name(struct regmap *map, const struct regmap_config *confi
>  		if (!name)
>  			return -ENOMEM;
>  
> +		kfree_const(config->name);
>  		kfree_const(map->name);
>  		map->name = name;
>  	}

Why would we free the passed in name here?  The name wes passed in from
outside regmap in a const configuration struct, we've no idea within
regmap if it was dynamically allocted or not and it seems very
surprising that we'd go off and free it.  The whole reason we're
duplicating it in regmap_set_name() is that we don't know how long it's
going to be around so we don't want to reference it after having
returned to the caller.  If the caller has dynamically allocated it then
the caller should deal with freeing it.

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ