Skip to contentSkip to conversation

ia64: Pin controlling tty for unaligned fault message

PATCH Superseded Peter Hurley 1 participant 2 messages Oct 16, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ia64: Pin controlling tty for unaligned fault message

Prevent destruction of the controlling tty before tty_write_message() can determine if the tty is safe to use.

---
 arch/ia64/kernel/unaligned.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/ia64/kernel/unaligned.c +5 -2
index 622772b..e7ae608 100644
@@ -1336,8 +1336,11 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
 			 * Don't call tty_write_message() if we're in the kernel; we might
 			 * be holding locks...
 			 */
-			if (user_mode(regs))
-				tty_write_message(current->signal->tty, buf);
+			if (user_mode(regs)) {
+				struct tty_struct *tty = get_current_tty();
+				tty_write_message(tty, buf);
+				tty_kref_put(tty);
+			}
 			buf[len-1] = '\0';	/* drop '\r' */
 			/* watch for command names containing %s */
 			printk(KERN_WARNING "%s", buf);
Signature · 1 line
2.1.1
#1 lore raw
Quoted 2 lines · Peter Hurley

Prevent destruction of the controlling tty before tty_write_message() can determine if the tty is safe to use.

This does not make tty_write_message() bulletproof from concurrent teardown, but that's on my todo list.

Quoted 24 lines
---
 arch/ia64/kernel/unaligned.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/ia64/kernel/unaligned.c +5 -2
index 622772b..e7ae608 100644
@@ -1336,8 +1336,11 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
 			 * Don't call tty_write_message() if we're in the kernel; we might
 			 * be holding locks...
 			 */
-			if (user_mode(regs))
-				tty_write_message(current->signal->tty, buf);
+			if (user_mode(regs)) {
+				struct tty_struct *tty = get_current_tty();
+				tty_write_message(tty, buf);
+				tty_kref_put(tty);
+			}
 			buf[len-1] = '\0';	/* drop '\r' */
 			/* watch for command names containing %s */
 			printk(KERN_WARNING "%s", buf);