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]
Message-ID: <1391067307.11310.3.camel@linux-fkkt.site>
Date:	Thu, 30 Jan 2014 08:35:07 +0100
From:	Oliver Neukum <oneukum@...e.de>
To:	Joe Perches <joe@...ches.com>
Cc:	David Barksdale <dbarksdale@...ogix.com>,
	David Herrmann <dh.herrmann@...il.com>,
	Jiri Kosina <jkosina@...e.cz>,
	Benjamin Tissoires <benjamin.tissoires@...hat.com>,
	Jakub Kákona <kjakub@...il.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4] HID: New hid-cp2112 driver

On Wed, 2014-01-29 at 15:46 -0800, Joe Perches wrote:

> > +static int cp2112_hid_get(struct hid_device *hdev, unsigned char report_number,
> > +			  u8 *data, size_t count, unsigned char report_type)
> > +{
> > +	u8 *buf;
> > +	int ret;
> > +
> > +	buf = kmalloc(count, GFP_KERNEL);
> > +	if (!buf)
> > +		return -ENOMEM;
> > +
> > +	ret = hdev->hid_get_raw_report(hdev, report_number, buf, count,
> > +				       report_type);
> > +	memcpy(data, buf, count);
> > +	kfree(buf);
> > +	return ret;
> 
> if the data is going to be copied in data,
> why not just use data in hid_get_raw_report
> and avoid the malloc?

He must not. It would violate the DMA rules. This function is passed
pointers to parts of structures. Access to the structures may race
with a DMA to/from the buffer. That violates the DMA rules.

	Regards
		Oliver


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ