linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stanislav Kozina <skozina@redhat.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-serial@vger.kernel.org
Subject: Re: Patch for panic in n_tty_read()
Date: Wed, 08 Aug 2012 09:58:40 +0200	[thread overview]
Message-ID: <50221C30.20607@redhat.com> (raw)
In-Reply-To: <20120720161123.58fc9703@pyramind.ukuu.org.uk>

[-- Attachment #1: Type: text/plain, Size: 641 bytes --]

Alan,

I am not sure if you got my last email, so I'm resending it now:

 > I am very sorry, but I don't see it. We didn't held the lock while 
calling tty_audit_push() before, and we don't hold it after the patch 
neither.
 > So what's the locking scheme change here? Is there some binding 
between n_tty_read() and tty_audit_push() I just don't see?

Please can you advice me why I should check this patch with audit folks?

Thanks a lot,
-Stanislav

 >> Looks good to me. However it changes the locking rules on
 >> tty_audit_push() so please check the audit folks are ok with it. I don't
 >> think that causes any problems.
 >>
 >> Alan

[-- Attachment #2: tty_panic_2.patch --]
[-- Type: text/plain, Size: 774 bytes --]

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index ee1c268..54d1fc5 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1832,13 +1832,13 @@ do_it_again:
 
 		if (tty->icanon && !L_EXTPROC(tty)) {
 			/* N.B. avoid overrun if nr == 0 */
+			spin_lock_irqsave(&tty->read_lock, flags);
 			while (nr && tty->read_cnt) {
 				int eol;
 
 				eol = test_and_clear_bit(tty->read_tail,
 						tty->read_flags);
 				c = tty->read_buf[tty->read_tail];
-				spin_lock_irqsave(&tty->read_lock, flags);
 				tty->read_tail = ((tty->read_tail+1) &
 						  (N_TTY_BUF_SIZE-1));
 				tty->read_cnt--;
@@ -1864,6 +1864,7 @@ do_it_again:
 					tty_audit_push(tty);
 					break;
 				}
+				spin_lock_irqsave(&tty->read_lock, flags);
 			}
 			if (retval)
 				break;


  parent reply	other threads:[~2012-08-08  7:58 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-25 15:41 Patch for panic in n_tty_read() Stanislav Kozina
2012-06-26 14:21 ` Alan Cox
2012-07-20 12:18   ` Stanislav Kozina
2012-07-20 15:11     ` Alan Cox
2012-07-27 12:05       ` Stanislav Kozina
2012-07-27 12:50         ` Alan Cox
2012-07-30 11:58           ` Stanislav Kozina
2012-08-08  7:58       ` Stanislav Kozina [this message]
2012-08-08  9:00         ` Alan Cox
2012-08-08 12:09           ` Stanislav Kozina
2012-08-08 12:26             ` Alan Cox
2012-08-08 14:32               ` Stanislav Kozina
2012-08-08 14:28             ` [PATCH V2] [tty] Fix possible race " Stanislav Kozina
2012-08-08 15:27               ` Alan Cox
2012-08-09 11:16                 ` Stanislaw Gruszka
2012-08-13 15:26                   ` Stanislaw Gruszka
2012-08-14 11:15                     ` Stanislav Kozina
2012-08-09 11:24                 ` Stanislav Kozina
2012-08-09 12:35                   ` Alan Cox
2012-08-10 10:52                     ` Stanislav Kozina
2012-08-10 10:51                   ` [PATCH] Remove BUG_ON from n_tty_read() Stanislav Kozina
2012-08-10 12:29                     ` Stanislaw Gruszka
2012-08-10 14:53                       ` Stanislav Kozina
2012-08-10 14:38                     ` [PATCH V2] " Stanislav Kozina
2012-08-16  7:52                       ` Stanislav Kozina

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=50221C30.20607@redhat.com \
    --to=skozina@redhat.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-serial@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;
as well as URLs for NNTP newsgroup(s).