From: Ryan Arnold <rsa@us.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] hvc_console fix to protect hvc_write against ldisc write after hvc_close
Date: Wed, 15 Sep 2004 13:43:55 -0500 [thread overview]
Message-ID: <1095273835.3294.278.camel@localhost> (raw)
[-- Attachment #1: Type: text/plain, Size: 1064 bytes --]
Andrew,
Due to the tty ldisc code not stopping write operations against a driver
even after a tty has been closed I added a mechanism to hvc_console in
my previous patch to prevent this by nulling out the tty->driver_data in
hvc_close() but I forgot to check tty->driver_data in hvc_write().
Anton Blanchard got several oops'es from hvc_write() accessing NULL as
if it were a pointer to an hvc_struct usually stored in
tty->driver_data.
So this patch checks tty->driver_data in hvc_write() before it is used.
Hopefully once Alan Cox's patch is checked in ldisc writes won't
continue to happen after tty closes.
Anton Blanchard has tested this patch and is unable to reproduce the
oops with it applied.
Changelog:
drivers/char/hvc_console.c
-Added comment to hvc_close() to explain the reason for NULLing
tty->driver_data.
-Added check to hvc_write() to verify that tty->driver_data is valid
(NOT NULL) which would be the case if the write operation was invoked
after a tty close was initiated on the tty.
Thanks,
Ryan S. Arnold
IBM Linux Technology Center
[-- Attachment #2: hvc_console_write.patch --]
[-- Type: text/x-patch, Size: 783 bytes --]
Signed-off-by: Ryan S. Arnold <rsa@us.ibm.com>
--- linux-2.6.9-rc1/drivers/char/hvc_console.c Fri Sep 10 15:14:57 2004
+++ hvc_console_working_linux-2.6.9-rc1/drivers/char/hvc_console.c Mon Sep 13 10:29:53 2004
@@ -265,6 +265,11 @@
*/
tty_wait_until_sent(tty, HVC_CLOSE_WAIT);
+ /*
+ * Since the line disc doesn't block writes during tty close
+ * operations we'll set driver_data to NULL and then make sure
+ * to check tty->driver_data for NULL in hvc_write().
+ */
tty->driver_data = NULL;
if (irq != NO_IRQ)
@@ -418,6 +423,10 @@
struct hvc_struct *hp = tty->driver_data;
int written;
+ /* This write was probably executed during a tty close. */
+ if (!hp)
+ return -EPIPE;
+
if (from_user)
written = __hvc_write_user(hp, buf, count);
else
next reply other threads:[~2004-09-15 18:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-15 18:43 Ryan Arnold [this message]
2004-09-15 19:20 ` [PATCH] hvc_console fix to protect hvc_write against ldisc write after hvc_close Alan Cox
2004-09-15 21:23 ` Ryan Arnold
2004-09-15 20:41 ` Theodore Ts'o
2004-09-15 21:36 ` Alan Cox
2004-09-15 22:35 ` Ryan Arnold
2004-09-24 1:15 ` ldisc writes during tty release_dev() causing problems Ryan Arnold
2004-09-24 12:40 ` Alan Cox
2004-09-24 16:18 ` Ryan Arnold
2004-09-24 15:30 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1095273835.3294.278.camel@localhost \
--to=rsa@us.ibm.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox