public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/15] Char: lp, protect LPGETSTATUS with port_mutex
@ 2013-05-07 14:18 Jiri Slaby
  2013-05-07 14:18 ` [PATCH 02/15] mISDN: Add support for group membership check Jiri Slaby
                   ` (14 more replies)
  0 siblings, 15 replies; 31+ messages in thread
From: Jiri Slaby @ 2013-05-07 14:18 UTC (permalink / raw)
  To: jirislaby
  Cc: linux-kernel, salina@us.ibm.com, okir, Jiri Slaby, Arnd Bergmann,
	Greg Kroah-Hartman

From: "salina@us.ibm.com" <salina@us.ibm.com>

The patch fixes a problem in the lp driver that can cause oopses as
follows:
process A:	calls lp_write, which in turn calls
		parport_ieee1284_write_compat, and that invokes
		parport_wait_peripheral
process B:	meanwhile does an ioctl(LPGETSTATUS), which call
		lp_release_parport when done. This function will set
		physport->cad = NULL.
process A:	parport_wait_peripheral tries to dereference
		physport->cad and dies

So, protect that code with the port_mutex in order to protect against
simultaneous calls to lp_read/lp_write.

Similar protection is probably required for ioctl(LPRESET)...

This patch was done by IBM a while back and we (at suse) have that
since at least 2004 in our repos. Let's make it upstream.

Signed-off-by: okir@suse.de
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/char/lp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index dafd9ac..0913d79 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -622,9 +622,12 @@ static int lp_do_ioctl(unsigned int minor, unsigned int cmd,
 				return -EFAULT;
 			break;
 		case LPGETSTATUS:
+			if (mutex_lock_interruptible(&lp_table[minor].port_mutex))
+				return -EINTR;
 			lp_claim_parport_or_block (&lp_table[minor]);
 			status = r_str(minor);
 			lp_release_parport (&lp_table[minor]);
+			mutex_unlock(&lp_table[minor].port_mutex);
 
 			if (copy_to_user(argp, &status, sizeof(int)))
 				return -EFAULT;
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2013-05-22 11:10 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-07 14:18 [PATCH 01/15] Char: lp, protect LPGETSTATUS with port_mutex Jiri Slaby
2013-05-07 14:18 ` [PATCH 02/15] mISDN: Add support for group membership check Jiri Slaby
2013-05-07 14:18 ` [PATCH 03/15] ehea: add alias entry for portN properties Jiri Slaby
2013-05-07 14:18 ` [PATCH 04/15] drm/cirrus: Correct register values for 16bpp Jiri Slaby
2013-05-07 14:18 ` [PATCH 05/15] connection tracking helper for SLP Jiri Slaby
2013-05-08  2:03   ` Pablo Neira Ayuso
2013-05-07 14:18 ` [PATCH 06/15] netfilter: Implement RFC 1123 for FTP conntrack Jiri Slaby
2013-05-07 14:18 ` [PATCH 07/15] hfs: avoid crash in hfs_bnode_create Jiri Slaby
2013-05-07 19:05   ` Vyacheslav Dubeyko
2013-05-08 15:26     ` [PATCH v2 07/14] " Jiri Slaby
2013-05-07 14:18 ` [PATCH 08/15] reiserfs: fix deadlock with nfs racing on create/lookup Jiri Slaby
2013-05-07 14:18 ` [PATCH 09/15] Make selection of 'readdir-plus' adapt to usage patterns Jiri Slaby
2013-05-07 14:27   ` Myklebust, Trond
2013-05-07 14:32     ` Jiri Slaby
2013-05-07 14:18 ` [PATCH 10/15] acpi: ec_sys: access user space with get_user()/put_user() Jiri Slaby
2013-05-07 14:18 ` [PATCH 11/15] nouveau: Make vga_switcheroo code depend on VGA_SWITCHEROO Jiri Slaby
2013-05-07 14:18 ` [PATCH 12/15] geodefb: Depend on X86_32 Jiri Slaby
2013-05-07 14:18 ` [PATCH 13/15] chipidea: Allow user to select PCI/IMX options Jiri Slaby
2013-05-08  9:07   ` Alexander Shishkin
2013-05-15 15:59     ` Jiri Slaby
2013-05-16  9:36       ` Alexander Shishkin
2013-05-22  8:51         ` Jiri Slaby
2013-05-22 11:10           ` Alexander Shishkin
2013-05-07 14:18 ` [PATCH 14/15] staging/sb105x: remove asm/segment.h dependency Jiri Slaby
2013-05-07 14:18 ` [PATCH 15/15] ptp: PTP_1588_CLOCK_PCH depends on x86 Jiri Slaby
2013-05-07 19:29   ` Richard Cochran
2013-05-14 14:20     ` Jiri Slaby
2013-05-14 18:12       ` Ben Hutchings
2013-05-20 22:31         ` Keller, Jacob E
2013-05-07 14:48 ` [PATCH 01/15] Char: lp, protect LPGETSTATUS with port_mutex Arnd Bergmann
2013-05-07 15:41   ` Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox