public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ia64: Pin controlling tty for unaligned fault message
@ 2014-10-16 19:10 Peter Hurley
  2014-10-16 19:12 ` Peter Hurley
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Hurley @ 2014-10-16 19:10 UTC (permalink / raw)
  To: Tony Luck, Fenghua Yu
  Cc: Greg Kroah-Hartman, linux-ia64, linux-kernel, Peter Hurley

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

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 arch/ia64/kernel/unaligned.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/ia64/kernel/unaligned.c b/arch/ia64/kernel/unaligned.c
index 622772b..e7ae608 100644
--- a/arch/ia64/kernel/unaligned.c
+++ b/arch/ia64/kernel/unaligned.c
@@ -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);
-- 
2.1.1


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

* Re: [PATCH] ia64: Pin controlling tty for unaligned fault message
  2014-10-16 19:10 [PATCH] ia64: Pin controlling tty for unaligned fault message Peter Hurley
@ 2014-10-16 19:12 ` Peter Hurley
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Hurley @ 2014-10-16 19:12 UTC (permalink / raw)
  To: Tony Luck, Fenghua Yu; +Cc: Greg Kroah-Hartman, linux-ia64, linux-kernel

On 10/16/2014 03:10 PM, Peter Hurley wrote:
> 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.


> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
> ---
>  arch/ia64/kernel/unaligned.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/ia64/kernel/unaligned.c b/arch/ia64/kernel/unaligned.c
> index 622772b..e7ae608 100644
> --- a/arch/ia64/kernel/unaligned.c
> +++ b/arch/ia64/kernel/unaligned.c
> @@ -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);
> 


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

end of thread, other threads:[~2014-10-16 19:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-16 19:10 [PATCH] ia64: Pin controlling tty for unaligned fault message Peter Hurley
2014-10-16 19:12 ` Peter Hurley

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