lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CABkLOboD+sEtPgft2Gpm6EGfVHzdkyUORntqjNBkCLSPH3Mb8w@mail.gmail.com>
Date:	Wed, 12 Nov 2014 21:03:16 +0100
From:	Christian Riesch <christian.riesch@...cron.at>
To:	Måns Rullgård <mans@...sr.com>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Peter Hurley <peter@...leysoftware.com>,
	stable <stable@...r.kernel.org>
Subject: Re: [PATCH v2] n_tty: Fix read_buf race condition, increment
 read_head after pushing data

On Wed, Nov 12, 2014 at 12:53 PM, Måns Rullgård <mans@...sr.com> wrote:
> Christian Riesch <christian.riesch@...cron.at> writes:
>
>> On Tue, Nov 11, 2014 at 2:04 PM, Måns Rullgård <mans@...sr.com> wrote:
>>> Christian Riesch <christian.riesch@...cron.at> writes:
>> [...]>> diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
>>>> index 2e900a9..b09f326 100644
>>>> --- a/drivers/tty/n_tty.c
>>>> +++ b/drivers/tty/n_tty.c
>>>> @@ -321,7 +321,9 @@ static void n_tty_check_unthrottle(struct tty_struct *tty)
>>>>
>>>>  static inline void put_tty_queue(unsigned char c, struct n_tty_data *ldata)
>>>>  {
>>>> -     *read_buf_addr(ldata, ldata->read_head++) = c;
>>>> +     *read_buf_addr(ldata, ldata->read_head) = c;
>>>> +     /* increment read_head _after_ placing the character in the buffer */
>>>> +     ldata->read_head++;
>>>>  }
>>>
>>> Is that comment really necessary?
>>
>> No, I am pretty sure that removing the comment would not break the code ;-)
>>
>> I just thought it would be good to have some kind of reminder here.
>> Otherwise someone may think: Hey, it would be a good idea to do the
>> increment right in the first line. And submit a patch for it.
>
> The intent all along was to increment after the write.  Nobody needs
> reminding of that.  The problem was a misunderstanding of when the
> post-increment takes effect.  As much as we'd like for everybody to have
> a thorough knowledge of C, a random tty driver doesn't seem the place to
> educate them.

Ok. I will send a new patch without the comment.
Thanks, Christian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ