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: <d988a4b8698b20a151680cc98a6b7434efbaea55.camel@linux.intel.com>
Date:   Fri, 01 Oct 2021 03:38:23 -0700
From:   "David E. Box" <david.e.box@...ux.intel.com>
To:     Greg KH <gregkh@...uxfoundation.org>
Cc:     lee.jones@...aro.org, hdegoede@...hat.com, mgross@...ux.intel.com,
        bhelgaas@...gle.com, andriy.shevchenko@...ux.intel.com,
        srinivas.pandruvada@...el.com, linux-kernel@...r.kernel.org,
        linux-doc@...r.kernel.org, platform-driver-x86@...r.kernel.org,
        linux-pci@...r.kernel.org
Subject: Re: [PATCH 5/5] platform/x86: Add Intel Software Defined Silicon
 driver

On Fri, 2021-10-01 at 09:14 +0200, Greg KH wrote:
> On Thu, Sep 30, 2021 at 06:28:15PM -0700, David E. Box wrote:
> > +static int sdsi_device_open(struct inode *inode, struct file *file)
> > +{
> > +       struct miscdevice *miscdev = file->private_data;
> > +
> > +       get_device(miscdev->this_device);
> 
> Why do you think this is needed?  Shouldn't the misc core handle all of
> this for you already?
> 
> > +
> > +       return 0;
> > +}
> > +
> > +static int sdsi_device_release(struct inode *inode, struct file *file)
> > +{
> > +
> > +       struct miscdevice *miscdev = file->private_data;
> > +       struct sdsi_priv *priv = to_sdsi_priv(miscdev);
> > +
> > +       if (priv->akc_owner == file)
> > +               priv->akc_owner = NULL;
> 
> Why is this needed?
> 
> > +
> > +       put_device(miscdev->this_device);
> 
> I see this matches the open call, but if you do not have this in the
> open call, is it needed here as well?
> 
> > +       ret = devm_add_action_or_reset(priv->miscdev.this_device, sdsi_miscdev_remove, priv);
> > +       if (ret)
> > +               goto deregister_misc;
> 
> I think this is all you need to clean up your device memory, not the
> get/put device in open/release, right?

It does clean up the memory, but it does so immediately after the device has been unregistered, even
if a file is open. The get/put ensures that if files are open, the memory isn't cleaned up until the
files are closed.

I can show that this happens without the get/put,

	open()
	unbind device -> devm action called -> kfree(priv)
	ioctl() -> priv accessed

but it doesn't blow up. I guess because the former location of priv is accessible by container_of on
the miscdev. But that memory was freed right?

David

> 
> thanks,
> 
> greg k-h


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ