- Subject: Re: [PATCH 02/11] persistent_ram: Fix buffer size clamping during writes
- From: Anton Vorontsov <anton.vorontsov@xxxxxxxxxx>
- Date: Sun, 13 May 2012 13:38:36 -0700
- Cc: devel@xxxxxxxxxxxxxxxxxxxx, linaro-kernel@xxxxxxxxxxxxxxxx, Kees Cook <keescook@xxxxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, patches@xxxxxxxxxx, Marco Stornelli <marco.stornelli@xxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Stephen Boyd <sboyd@xxxxxxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, arve@xxxxxxxxxxx, Jesper Juhl <jj@xxxxxxxxxxxxx>, John Stultz <john.stultz@xxxxxxxxxx>, Colin Cross <ccross@xxxxxxxxxxx>, Rebecca Schultz Zavin <rebecca@xxxxxxxxxxx>, WANG Cong <xiyou.wangcong@xxxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, kernel-team@xxxxxxxxxxx, Thomas Meyer <thomas@xxxxxxxx>
- Delivered-to: devel@xxxxxxxxxxxxxxxxxxxx
- In-reply-to: <20120513165601.GC16984@mwanda>
- User-agent: Mutt/1.5.21 (2010-09-15)
On Sun, May 13, 2012 at 07:56:01PM +0300, Dan Carpenter wrote:
> On Fri, May 11, 2012 at 05:17:17PM -0700, Anton Vorontsov wrote:
> > This is a longstanding bug, almost unnoticeable when calling
> > persistent_ram_write() for small buffers.
> >
> > But when called for large data buffers, the write routine behaves
> > incorrectly, as the size may never update: instead of clamping
> > the size to the maximum buffer size, buffer_size_add_clamp() returns
> > an error (which is never checked by the write routine, btw).
> >
> > To fix this, we now use buffer_size_add() that actually clamps the
> > size to the max value.
> >
> > Also remove buffer_size_add_clamp(), it is no longer needed.
> >
>
> Say if you did notice it, what would that look like? It's just that
> something gets lost instead of written to the screen right?
Yep. Suppose the ring buffer size is 4096 bytes, when somebody tries to
write a data in a 2000 bytes chunk, the first write will succeed (buffer
size will be 2000), but the second now 3000-bytes write will left the
size equal to 2000, instead of clamping it to 4096.
When we had a large buffer but a small writes (e.g. ram_console usage
scenario), this is almost unnoticeable. But when we started using large
writes the bug showed up.
Thanks,
--
Anton Vorontsov
Email: cbouatmailru@xxxxxxxxx
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel
[Video for Linux]
[Mplayer Users]
[Linux USB Devel]
[Linux Audio Users]
[Photos]
[Yosemite Photos]
[Free Singles Community]
[Linux Kernel]
[Linux SCSI]
[XFree86]
[Devices]
[Yosemite Backpacking]