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:	Fri, 27 Mar 2015 15:13:04 +0000
From:	Ian Abbott <abbotti@....co.uk>
To:	<driverdev-devel@...uxdriverproject.org>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Ian Abbott <abbotti@....co.uk>,
	H Hartley Sweeten <hartleys@...ionengravers.com>,
	<linux-kernel@...r.kernel.org>
Subject: [PATCH 5/7] staging: comedi: comedi_fops: always clear events

`comedi_event()` is called from low-level drivers to handle asynchronous
command event flags that are stored in `s->async->events` for subdevice
`s`.  It normally clears the event flags as well.  As a safety check, it
does nothing if no asynchronous command is running, but it leaves
`s->async->events` unchanged in this case.  For additional safety,
change it to always clear the event flags to avoid leaving stale event
flags set when another asynchronous command is set up.

Signed-off-by: Ian Abbott <abbotti@....co.uk>
---
 drivers/staging/comedi/comedi_fops.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 999e7d0..68ced20 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -2648,18 +2648,20 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
 	struct comedi_async *async = s->async;
 	unsigned runflags = 0;
 	unsigned runflags_mask = 0;
+	unsigned int events = async->events;
 
+	async->events = 0;
 	if (!comedi_is_subdevice_running(s))
 		return;
 
-	if (async->events & COMEDI_CB_CANCEL_MASK)
+	if (events & COMEDI_CB_CANCEL_MASK)
 		runflags_mask |= COMEDI_SRF_RUNNING;
 
 	/*
 	 * Remember if an error event has occurred, so an error
 	 * can be returned the next time the user does a read().
 	 */
-	if (async->events & COMEDI_CB_ERROR_MASK) {
+	if (events & COMEDI_CB_ERROR_MASK) {
 		runflags_mask |= COMEDI_SRF_ERROR;
 		runflags |= COMEDI_SRF_ERROR;
 	}
@@ -2671,14 +2673,13 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
 		comedi_update_subdevice_runflags(s, runflags_mask, runflags);
 	}
 
-	if (async->cb_mask & async->events) {
+	if (async->cb_mask & events) {
 		wake_up_interruptible(&async->wait_head);
 		if (s->subdev_flags & SDF_CMD_READ)
 			kill_fasync(&dev->async_queue, SIGIO, POLL_IN);
 		if (s->subdev_flags & SDF_CMD_WRITE)
 			kill_fasync(&dev->async_queue, SIGIO, POLL_OUT);
 	}
-	async->events = 0;
 }
 EXPORT_SYMBOL_GPL(comedi_event);
 
-- 
2.1.4

--
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