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  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]
Date:   Fri, 20 Nov 2020 09:00:00 +0100
From:   Cornelia Huck <cohuck@...hat.com>
To:     Qinglang Miao <miaoqinglang@...wei.com>
Cc:     Vineeth Vijayan <vneethv@...ux.ibm.com>,
        Peter Oberparleiter <oberpar@...ux.ibm.com>,
        Heiko Carstens <hca@...ux.ibm.com>,
        Vasily Gorbik <gor@...ux.ibm.com>,
        Christian Borntraeger <borntraeger@...ibm.com>,
        <linux-s390@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] s390: cmf: fix use-after-free in enable_cmf

On Fri, 20 Nov 2020 15:48:50 +0800
Qinglang Miao <miaoqinglang@...wei.com> wrote:

> kfree(cdev) is called in put_device in the error branch. So that
> device_unlock(&cdev->dev) would raise a use-after-free bug. In fact,
> there's no need to call device_unlock after put_device.
> 
> Fix it by adding simply return after put_device.
> 
> Fixes: a6ef15652d26 ("s390/cio: fix use after free in cmb processing")
> Reported-by: Hulk Robot <hulkci@...wei.com>
> Signed-off-by: Qinglang Miao <miaoqinglang@...wei.com>
> ---
>  drivers/s390/cio/cmf.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
> index 72dd2471e..e95ca476f 100644
> --- a/drivers/s390/cio/cmf.c
> +++ b/drivers/s390/cio/cmf.c
> @@ -1149,9 +1149,12 @@ int enable_cmf(struct ccw_device *cdev)
>  		sysfs_remove_group(&cdev->dev.kobj, cmbops->attr_group);
>  		cmbops->free(cdev);
>  	}
> +
>  out:
> -	if (ret)
> +	if (ret) {
>  		put_device(&cdev->dev);

The put_device() here undoes a get_device() further up in the function.
There is at least one more reference remaining, held by the caller of
enable_cmf(). Returning here would actually introduce a bug (missing
unlock).

> +		return ret;
> +	}
>  out_unlock:
>  	device_unlock(&cdev->dev);
>  	return ret;

Powered by blists - more mailing lists