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:   Wed, 3 Nov 2021 17:47:37 +0100
From:   Matthias Brugger <mbrugger@...e.com>
To:     Charles Mirabile <cmirabil@...hat.com>,
        linux-kernel@...r.kernel.org
Cc:     Miguel Ojeda <ojeda@...nel.org>,
        Serge Schneider <serge@...pberrypi.org>,
        Stefan Wahren <stefan.wahren@...e.com>,
        Nicolas Saenz Julienne <nsaenzju@...hat.com>,
        linux-rpi-kernel@...ts.infradead.org, fedora-rpi@...glegroups.com,
        Mwesigwa Guma <mguma@...hat.com>,
        Joel Savitz <jsavitz@...hat.com>
Subject: Re: [PATCH 3/5] drivers/auxdisplay: senshat: Raspberry Pi Sense HAT
 display driver



On 29/10/2021 23:55, Charles Mirabile wrote:
> This patch implements control of the 8x8 RGB LED matrix display.
> 
> Signed-off-by: Charles Mirabile <cmirabil@...hat.com>
> Signed-off-by: Mwesigwa Guma <mguma@...hat.com>
> Signed-off-by: Joel Savitz <jsavitz@...hat.com>
> ---
>   drivers/auxdisplay/Kconfig            |   7 +
>   drivers/auxdisplay/Makefile           |   1 +
>   drivers/auxdisplay/sensehat-display.c | 258 ++++++++++++++++++++++++++
>   3 files changed, 266 insertions(+)
>   create mode 100644 drivers/auxdisplay/sensehat-display.c
> 
[....]
> diff --git a/drivers/auxdisplay/sensehat-display.c b/drivers/auxdisplay/sensehat-display.c
> new file mode 100644
> index 000000000000..5980ad23fd4f
> --- /dev/null
> +++ b/drivers/auxdisplay/sensehat-display.c
[...]
> +
> +static ssize_t
> +sensehat_display_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos)
> +{
> +	struct sensehat *sensehat = container_of(filp->private_data, struct sensehat, display.mdev);
> +	struct sensehat_display *sensehat_display = &sensehat->display;
> +	u8 temp[VMEM_SIZE];
> +
> +	if (*f_pos >= VMEM_SIZE)
> +		return -EFBIG;
> +	if (*f_pos + count > VMEM_SIZE)
> +		count = VMEM_SIZE - *f_pos;
> +	if (copy_from_user(temp, buf, count))
> +		return -EFAULT;
> +	if (mutex_lock_interruptible(&sensehat_display->rw_mtx))
> +		return -ERESTARTSYS;
> +	memcpy(sensehat_display->vmem + *f_pos, temp, count);

So we copy from buf into temp, from temp into vmem and then we 'transform' vmem 
into the representation of pixel_data.

As you are implementing the user-space interface, couldn't we just change the 
pixel representation there and get rid of the transformation?

> +	sensehat_update_display(sensehat);
> +	*f_pos += count;
> +	mutex_unlock(&sensehat_display->rw_mtx);
> +	return count;
> +}
> +
> +static long sensehat_display_ioctl(struct file *filp, unsigned int cmd,
> +			     unsigned long arg)
> +{
> +	struct sensehat *sensehat = container_of(filp->private_data, struct sensehat, display.mdev);
> +	struct sensehat_display *sensehat_display = &sensehat->display;
> +	void __user *user_ptr = (void __user *)arg;
> +	u8 temp[GAMMA_SIZE];
> +	int ret;
> +
> +	if (mutex_lock_interruptible(&sensehat_display->rw_mtx))
> +		return -ERESTARTSYS;
> +	switch (cmd) {
> +	case SENSEDISP_IOGET_GAMMA:
> +		if (copy_to_user(user_ptr, sensehat_display->gamma, GAMMA_SIZE)) {
> +			ret = -EFAULT;
> +			goto out_unlock;
> +		}
> +		ret = 0;
> +		goto out_unlock;
> +	case SENSEDISP_IOSET_GAMMA:
> +		if (copy_from_user(temp, user_ptr, GAMMA_SIZE)) {
> +			ret = -EFAULT;
> +			goto out_unlock;
> +		}
> +		ret = 0;
> +		goto out_update;

That's just a 'break;' correct?

Regards,
Matthias

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ