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, 07 Apr 2010 19:11:12 +0200
From:	Michał Nazarewicz <m.nazarewicz@...sung.com>
To:	Michal Nazarewicz <m.nazarewicz@...sung.com>,
	linux-usb@...r.kernel.org
Cc:	Peter Korsgaard <jacmet@...site.dk>,
	Rupesh Gujare <rupeshgujare@...il.com>,
	linux-kernel@...r.kernel.org,
	David Brownell <dbrownell@...rs.sourceforge.net>,
	Kyungmin Park <kyungmin.park@...sung.com>,
	Marek Szyprowski <m.szyprowski@...sung.com>
Subject: Re: [PATCH 3/8] USB: f_fs: the FunctionFS driver

On Wed, 07 Apr 2010 15:41:30 +0200, Michal Nazarewicz <m.nazarewicz@...sung.com> wrote:
> +static ssize_t __ffs_ep0_read_events(struct ffs_data *ffs, char __user *buf,
> +				     size_t n)
> +{
> +	/* We are holding ffs->ev.waitq.lock and ffs->mutex and we need
> +	 * to release them. */
> +
> +	struct usb_functionfs_event events[n];
> +	unsigned i = 0;
> +
> +	memset(events, 0, sizeof events);
> +
> +	do {
> +		events[i].type = ffs->ev.types[i];
> +		if (events[i].type == FUNCTIONFS_SETUP) {
> +			events[i].u.setup = ffs->ev.setup;
> +			ffs->setup_state = FFS_SETUP_PENDING;
> +		}
> +	} while (++i < n);
> +
> +	ffs->ev.count = 0;

I've just noticed.  This line should instead read:

+	if (n < ffs->ev.count) {
+		ffs->ev.count -= n;
+		memmove(ffs->ev.types, ffs->ev.types + n,
+			ffs->ev.count * sizeof *ffs->ev.types);
+	} else {
+		ffs->ev.count = 0;
+	}

This is a minor bug which should be rather hard to observe (and only
if user-space reads() less then 4 * sizeof(struct usb_functionfs_event)
bytes when reading from "ep0") so posted code is good for testing.
(I'll post a fixed version later on with possibly other fixes and
changes.)

> +
> +	spin_unlock_irq(&ffs->ev.waitq.lock);
> +	mutex_unlock(&ffs->mutex);
> +
> +	return unlikely(__copy_to_user(buf, events, sizeof events))
> +		? -EFAULT : sizeof events;
> +}

-- 
Best regards,                                           _     _
  .o. | Liege of Serenely Enlightened Majesty of       o' \,=./ `o
  ..o | Computer Science,  Michał "mina86" Nazarewicz     (o o)
  ooo +---[mina86@...a86.com]---[mina86@...ber.org]---ooO--(_)--Ooo--
--
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