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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5c02fbac130941a1a8578965975116b5@huawei.com>
Date:   Tue, 2 Nov 2021 02:55:16 +0000
From:   huangguobin <huangguobin4@...wei.com>
To:     Julian Wiedmann <jwi@...ux.ibm.com>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH -next] bonding: Fix a use-after-free problem when
 bond_sysfs_slave_add() failed

I think bond_sysfs_slave_del should not be used in the error handling process, because bond_sysfs_slave_del will traverse all slave_attrs and release them. When sysfs_create_file fails, only some attributes may be created successfully.
-----Original Message-----
From: Julian Wiedmann [mailto:jwi@...ux.ibm.com] 
Sent: Tuesday, November 2, 2021 3:31 AM
To: huangguobin <huangguobin4@...wei.com>; j.vosburgh@...il.com; vfalico@...il.com; andy@...yhouse.net; davem@...emloft.net; kuba@...nel.org
Cc: netdev@...r.kernel.org; linux-kernel@...r.kernel.org
Subject: Re: [PATCH -next] bonding: Fix a use-after-free problem when bond_sysfs_slave_add() failed

On 01.11.21 15:34, Huang Guobin wrote:
> When I do fuzz test for bonding device interface, I got the following 
> use-after-free Calltrace:
> 

[...]

> Fixes: 7afcaec49696 (bonding: use kobject_put instead of _del after 
> kobject_add)
> Signed-off-by: Huang Guobin <huangguobin4@...wei.com>
> ---
>  drivers/net/bonding/bond_sysfs_slave.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/bonding/bond_sysfs_slave.c 
> b/drivers/net/bonding/bond_sysfs_slave.c
> index fd07561..d1a5b3f 100644
> --- a/drivers/net/bonding/bond_sysfs_slave.c
> +++ b/drivers/net/bonding/bond_sysfs_slave.c
> @@ -137,18 +137,23 @@ static ssize_t slave_show(struct kobject *kobj,
>  
>  int bond_sysfs_slave_add(struct slave *slave)  {
> -	const struct slave_attribute **a;
> +	const struct slave_attribute **a, **b;
>  	int err;
>  
>  	for (a = slave_attrs; *a; ++a) {
>  		err = sysfs_create_file(&slave->kobj, &((*a)->attr));
>  		if (err) {
> -			kobject_put(&slave->kobj);
> -			return err;
> +			goto err_remove_file;
>  		}
>  	}
>  
>  	return 0;
> +
> +err_remove_file:
> +	for (b = slave_attrs; b < a; ++b)
> +		sysfs_remove_file(&slave->kobj, &((*b)->attr));
> +
> +	return err;
>  }
>  

This looks like a candidate for sysfs_create_files(), no?

>  void bond_sysfs_slave_del(struct slave *slave)
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ