linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] n_tty: Protect minimum_to_wake reset for concurrent readers
@ 2013-11-07 19:01 Peter Hurley
  2013-11-25 16:36 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Hurley @ 2013-11-07 19:01 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-kernel, linux-serial, Peter Hurley

With multiple, concurrent readers (each waiting to acquire the
atomic_read_lock mutex), a departing reader may mistakenly reset
minimum_to_wake after a new reader has already set a new value.

Protect the minimum_to_wake reset with the atomic_read_lock critical
section.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/n_tty.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index ce11cd5..bf9650d 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -2253,12 +2253,12 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
 	n_tty_set_room(tty);
 	up_read(&tty->termios_rwsem);
 
-	mutex_unlock(&ldata->atomic_read_lock);
 	remove_wait_queue(&tty->read_wait, &wait);
-
 	if (!waitqueue_active(&tty->read_wait))
 		ldata->minimum_to_wake = minimum;
 
+	mutex_unlock(&ldata->atomic_read_lock);
+
 	__set_current_state(TASK_RUNNING);
 	if (b - buf)
 		retval = b - buf;
-- 
1.8.1.2


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

* Re: [PATCH] n_tty: Protect minimum_to_wake reset for concurrent readers
  2013-11-07 19:01 [PATCH] n_tty: Protect minimum_to_wake reset for concurrent readers Peter Hurley
@ 2013-11-25 16:36 ` Greg Kroah-Hartman
  2013-11-25 17:12   ` Peter Hurley
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2013-11-25 16:36 UTC (permalink / raw)
  To: Peter Hurley; +Cc: Jiri Slaby, linux-kernel, linux-serial

On Thu, Nov 07, 2013 at 02:01:57PM -0500, Peter Hurley wrote:
> With multiple, concurrent readers (each waiting to acquire the
> atomic_read_lock mutex), a departing reader may mistakenly reset
> minimum_to_wake after a new reader has already set a new value.
> 
> Protect the minimum_to_wake reset with the atomic_read_lock critical
> section.
> 
> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
> ---
>  drivers/tty/n_tty.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

This patch doesn't apply to Linus's tree anymore (and hence, mine.)  Is
it needed for 3.13-final?  Or just 3.14-rc1?  Either way, can you
refresh it and resend?

thanks,

greg k-h

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

* Re: [PATCH] n_tty: Protect minimum_to_wake reset for concurrent readers
  2013-11-25 16:36 ` Greg Kroah-Hartman
@ 2013-11-25 17:12   ` Peter Hurley
  2013-11-25 17:16     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Hurley @ 2013-11-25 17:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-kernel, linux-serial

On 11/25/2013 11:36 AM, Greg Kroah-Hartman wrote:
> On Thu, Nov 07, 2013 at 02:01:57PM -0500, Peter Hurley wrote:
>> With multiple, concurrent readers (each waiting to acquire the
>> atomic_read_lock mutex), a departing reader may mistakenly reset
>> minimum_to_wake after a new reader has already set a new value.
>>
>> Protect the minimum_to_wake reset with the atomic_read_lock critical
>> section.
>>
>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>> ---
>>   drivers/tty/n_tty.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> This patch doesn't apply to Linus's tree anymore (and hence, mine.)  Is
> it needed for 3.13-final?  Or just 3.14-rc1?  Either way, can you
> refresh it and resend?

Hmmm, for me this applies cleanly to your tty-linus branch:

peter@thor:~/src/kernels/tty$ git tree -10
* c7df628 (HEAD, tty-linus) n_tty: Protect minimum_to_wake reset for concurrent readers
* 3dcf344 (origin/tty-linus) TTY: amiserial, add missing platform check
* dc1dc2f TTY: pmac_zilog, check existence of ports in pmz_console_init()
* c284ee2 n_gsm: race between ld close and gsmtty open
* f301412 tty/serial/8250: fix typo in help text
* c77569d n_tty: Fix 4096-byte canonical reads
* 6f22253 n_tty: Fix echo overrun tail computation
* 42458f4 n_tty: Ensure reader restarts worker for next reader
* 6ce4eac (tag: v3.13-rc1, origin/tty-next, origin/master, origin/HEAD) Linux 3.13-rc1

I'll just resend it.

Regards,
Peter Hurley

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

* Re: [PATCH] n_tty: Protect minimum_to_wake reset for concurrent readers
  2013-11-25 17:12   ` Peter Hurley
@ 2013-11-25 17:16     ` Greg Kroah-Hartman
  2013-11-25 17:24       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2013-11-25 17:16 UTC (permalink / raw)
  To: Peter Hurley; +Cc: Jiri Slaby, linux-kernel, linux-serial

On Mon, Nov 25, 2013 at 12:12:52PM -0500, Peter Hurley wrote:
> On 11/25/2013 11:36 AM, Greg Kroah-Hartman wrote:
> >On Thu, Nov 07, 2013 at 02:01:57PM -0500, Peter Hurley wrote:
> >>With multiple, concurrent readers (each waiting to acquire the
> >>atomic_read_lock mutex), a departing reader may mistakenly reset
> >>minimum_to_wake after a new reader has already set a new value.
> >>
> >>Protect the minimum_to_wake reset with the atomic_read_lock critical
> >>section.
> >>
> >>Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
> >>---
> >>  drivers/tty/n_tty.c | 4 ++--
> >>  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> >This patch doesn't apply to Linus's tree anymore (and hence, mine.)  Is
> >it needed for 3.13-final?  Or just 3.14-rc1?  Either way, can you
> >refresh it and resend?
> 
> Hmmm, for me this applies cleanly to your tty-linus branch:
> 
> peter@thor:~/src/kernels/tty$ git tree -10
> * c7df628 (HEAD, tty-linus) n_tty: Protect minimum_to_wake reset for concurrent readers
> * 3dcf344 (origin/tty-linus) TTY: amiserial, add missing platform check
> * dc1dc2f TTY: pmac_zilog, check existence of ports in pmz_console_init()
> * c284ee2 n_gsm: race between ld close and gsmtty open
> * f301412 tty/serial/8250: fix typo in help text
> * c77569d n_tty: Fix 4096-byte canonical reads
> * 6f22253 n_tty: Fix echo overrun tail computation
> * 42458f4 n_tty: Ensure reader restarts worker for next reader
> * 6ce4eac (tag: v3.13-rc1, origin/tty-next, origin/master, origin/HEAD) Linux 3.13-rc1
> 
> I'll just resend it.

Oh nevermind, it has leading extra spaces, which something added, I'll
go edit it by hand and fix it up, sorry for not noticing.

greg k-h

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

* Re: [PATCH] n_tty: Protect minimum_to_wake reset for concurrent readers
  2013-11-25 17:16     ` Greg Kroah-Hartman
@ 2013-11-25 17:24       ` Greg Kroah-Hartman
  2013-11-25 17:45         ` Peter Hurley
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2013-11-25 17:24 UTC (permalink / raw)
  To: Peter Hurley; +Cc: Jiri Slaby, linux-kernel, linux-serial

On Mon, Nov 25, 2013 at 09:16:46AM -0800, Greg Kroah-Hartman wrote:
> On Mon, Nov 25, 2013 at 12:12:52PM -0500, Peter Hurley wrote:
> > On 11/25/2013 11:36 AM, Greg Kroah-Hartman wrote:
> > >On Thu, Nov 07, 2013 at 02:01:57PM -0500, Peter Hurley wrote:
> > >>With multiple, concurrent readers (each waiting to acquire the
> > >>atomic_read_lock mutex), a departing reader may mistakenly reset
> > >>minimum_to_wake after a new reader has already set a new value.
> > >>
> > >>Protect the minimum_to_wake reset with the atomic_read_lock critical
> > >>section.
> > >>
> > >>Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
> > >>---
> > >>  drivers/tty/n_tty.c | 4 ++--
> > >>  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > >This patch doesn't apply to Linus's tree anymore (and hence, mine.)  Is
> > >it needed for 3.13-final?  Or just 3.14-rc1?  Either way, can you
> > >refresh it and resend?
> > 
> > Hmmm, for me this applies cleanly to your tty-linus branch:
> > 
> > peter@thor:~/src/kernels/tty$ git tree -10
> > * c7df628 (HEAD, tty-linus) n_tty: Protect minimum_to_wake reset for concurrent readers
> > * 3dcf344 (origin/tty-linus) TTY: amiserial, add missing platform check
> > * dc1dc2f TTY: pmac_zilog, check existence of ports in pmz_console_init()
> > * c284ee2 n_gsm: race between ld close and gsmtty open
> > * f301412 tty/serial/8250: fix typo in help text
> > * c77569d n_tty: Fix 4096-byte canonical reads
> > * 6f22253 n_tty: Fix echo overrun tail computation
> > * 42458f4 n_tty: Ensure reader restarts worker for next reader
> > * 6ce4eac (tag: v3.13-rc1, origin/tty-next, origin/master, origin/HEAD) Linux 3.13-rc1
> > 
> > I'll just resend it.
> 
> Oh nevermind, it has leading extra spaces, which something added, I'll
> go edit it by hand and fix it up, sorry for not noticing.

And 'git am' handles this just fine, I was just testing it out first
using 'patch' which didn't like the extra spaces, my fault.

sorry for the noise,

greg k-h

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

* Re: [PATCH] n_tty: Protect minimum_to_wake reset for concurrent readers
  2013-11-25 17:24       ` Greg Kroah-Hartman
@ 2013-11-25 17:45         ` Peter Hurley
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Hurley @ 2013-11-25 17:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-kernel, linux-serial

On 11/25/2013 12:24 PM, Greg Kroah-Hartman wrote:
> On Mon, Nov 25, 2013 at 09:16:46AM -0800, Greg Kroah-Hartman wrote:
>> On Mon, Nov 25, 2013 at 12:12:52PM -0500, Peter Hurley wrote:
>>> On 11/25/2013 11:36 AM, Greg Kroah-Hartman wrote:
>>>> On Thu, Nov 07, 2013 at 02:01:57PM -0500, Peter Hurley wrote:
>>>>> With multiple, concurrent readers (each waiting to acquire the
>>>>> atomic_read_lock mutex), a departing reader may mistakenly reset
>>>>> minimum_to_wake after a new reader has already set a new value.
>>>>>
>>>>> Protect the minimum_to_wake reset with the atomic_read_lock critical
>>>>> section.
>>>>>
>>>>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>>>>> ---
>>>>>   drivers/tty/n_tty.c | 4 ++--
>>>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> This patch doesn't apply to Linus's tree anymore (and hence, mine.)  Is
>>>> it needed for 3.13-final?  Or just 3.14-rc1?  Either way, can you
>>>> refresh it and resend?
>>>
>>> Hmmm, for me this applies cleanly to your tty-linus branch:
>>>
>>> peter@thor:~/src/kernels/tty$ git tree -10
>>> * c7df628 (HEAD, tty-linus) n_tty: Protect minimum_to_wake reset for concurrent readers
>>> * 3dcf344 (origin/tty-linus) TTY: amiserial, add missing platform check
>>> * dc1dc2f TTY: pmac_zilog, check existence of ports in pmz_console_init()
>>> * c284ee2 n_gsm: race between ld close and gsmtty open
>>> * f301412 tty/serial/8250: fix typo in help text
>>> * c77569d n_tty: Fix 4096-byte canonical reads
>>> * 6f22253 n_tty: Fix echo overrun tail computation
>>> * 42458f4 n_tty: Ensure reader restarts worker for next reader
>>> * 6ce4eac (tag: v3.13-rc1, origin/tty-next, origin/master, origin/HEAD) Linux 3.13-rc1
>>>
>>> I'll just resend it.
>>
>> Oh nevermind, it has leading extra spaces, which something added, I'll
>> go edit it by hand and fix it up, sorry for not noticing.
>
> And 'git am' handles this just fine, I was just testing it out first
> using 'patch' which didn't like the extra spaces, my fault.
>
> sorry for the noise,

Not a problem.

In fact, the interruption was fortuitous because I was testing an
unsubmitted patch which I'd hoped would fix the readline() paste
bug & bugzilla #55991.  When I tried to resend this patch with
git send-email, the 'Password:' prompt looped until I killed it.

Thanks for the test vector :)

Regards,
Peter Hurley


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

end of thread, other threads:[~2013-11-25 17:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-07 19:01 [PATCH] n_tty: Protect minimum_to_wake reset for concurrent readers Peter Hurley
2013-11-25 16:36 ` Greg Kroah-Hartman
2013-11-25 17:12   ` Peter Hurley
2013-11-25 17:16     ` Greg Kroah-Hartman
2013-11-25 17:24       ` Greg Kroah-Hartman
2013-11-25 17:45         ` Peter Hurley

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).