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: <778047e2-2b1d-ef8b-4fe3-aafba8fa2dba@gmail.com>
Date:   Fri, 4 Jun 2021 14:47:15 +0200
From:   Maximilian Luz <luzmaximilian@...il.com>
To:     Hans de Goede <hdegoede@...hat.com>
Cc:     Mark Gross <mgross@...ux.intel.com>,
        Jonathan Corbet <corbet@....net>,
        platform-driver-x86@...r.kernel.org, linux-doc@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/7] platform/surface: aggregator_cdev: Add support for
 forwarding events to user-space

On 6/4/21 1:32 PM, Hans de Goede wrote:
> Hi,
> 
> I've one review remark inline below.
> 
> On 6/4/21 1:45 AM, Maximilian Luz wrote:

[...]

>> +static int ssam_cdev_device_open(struct inode *inode, struct file *filp)
>> +{
>> +	struct miscdevice *mdev = filp->private_data;
>> +	struct ssam_cdev_client *client;
>> +	struct ssam_cdev *cdev = container_of(mdev, struct ssam_cdev, mdev);
>> +
>> +	/* Initialize client */
>> +	client = vzalloc(sizeof(*client));
>> +	if (!client)
>> +		return -ENOMEM;
>> +
>> +	client->cdev = ssam_cdev_get(cdev);
>> +
>> +	INIT_LIST_HEAD(&client->node);
>> +
>> +	mutex_init(&client->notifier_lock);
>> +
>> +	mutex_init(&client->read_lock);
>> +	mutex_init(&client->write_lock);
>> +	INIT_KFIFO(client->buffer);
>> +	init_waitqueue_head(&client->waitq);
>> +
>> +	filp->private_data = client;
>> +
>> +	/* Attach client. */
>> +	down_write(&cdev->client_lock);
>> +
>> +	if (test_bit(SSAM_CDEV_DEVICE_SHUTDOWN_BIT, &cdev->flags)) {
>> +		up_write(&cdev->client_lock);
>> +		ssam_cdev_put(client->cdev);
> 
> You are missing the mutex_destroy() calls here which you are
> doing in ssam_cdev_device_release().

Thank you for noticing this! This code is based on Surface DTX code
which has the same problem, I'll send in a fix for that shortly.

> Or maybe move the mutex_init calls below this check
> (before the up_write()) since I don't think the client can
> be accessed by any code until the up_write is done?

Yes, that would also be possible, but I'd prefer adding the
mutex_destroy() calls in the failure path. To me that seems a bit easier
to reason about.

Thanks,
Max

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ