mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.cz>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] seq_file: Fix seq_putc() to be consistent with seq_puts()
Date: Mon, 29 Sep 2014 18:23:34 +0200	[thread overview]
Message-ID: <20140929162334.GB30562@pathway.suse.cz> (raw)
In-Reply-To: <20140929112538.3929a9a2@gandalf.local.home>

On Mon 2014-09-29 11:25:38, Steven Rostedt wrote:
> On Mon, 29 Sep 2014 16:41:22 +0200
> Petr Mladek <pmladek@suse.cz> wrote:
> 
> 
> > This patch moves set_putc() from b) to c) because it leaves mess in the
> > last byte.
> 
> Which removes the "b" section, and makes seq_putc() and seq_puts()
> function the same.
> 
> > 
> > 
> > The semantic looks weird in all categories:
> > 
> > add a) They report error even when there was not a real overflow.
> >     Well, they do not know if there was overflow because
> >     bitmap_scnprintf() does not report if it shrunk
> >     the data or not.
> > 
> > add b) It does not report error even when seq_overflow() might later
> >     report overflow.
> > 
> > add c) Any overflow invalidates the whole buffer because there might
> >     be mess at the end. The overflow is not checked by read functions,
> >     so they allow to read the mess.
> > 
> > 
> > I think that reasonable semantic would be:
> > 
> >   + either signalize overflow another way (extra struct member and
> >     leave count to point to the valid data) or always fill valid
> >     data until the end of the buffer.
> > 
> >     The second variant might be problem if we add only half of
> >     an escape sequence.

Do you prefer:

      + the extra struct member?
      + or always filling some valid data?
      + or invalidating the buffer when the overflow is set?

> > 
> >   + always return error when seq_overflow() would return overflow;
> >     in fact, the full buffer means that the last write operation
> >     was most likely incomplete
> 
> I think this is probably the best option.

> 
> > 
> >     Also we might rename it from "overflow" to "full" or "filled"
> >     or "sealed" or "complete" that might describe the state more
> >     precisely because there is not a real overflow in some situations
> 
> We could make overflow be m->count > m->size, which would mean that
> m->count == m->size (full) isn't a problem. Although, I would have to
> audit the kernel to see if anything just assumes that m->count is
> always less than m->size.

I am not sure if it is a good idea. I think that having
m->count > m->size is prone to buffer overflow errors in
the buffer reading code. I vote for adding extra flag to
the struct :-)

> This would mean overflow is the correct term, and wouldn't have to
> change it.
> 
> Anyway, that should be a second patch, and we should get my current
> patch (the one to make putc and puts the same) in first, as that
> actually fixes the inconsistency between the two.

Feel free to add

Acked-by: Petr Mladek <pmladek@suse.cz>

for this patch. The question is if it is really really needed in the
final patch set. It might get even partly reverted with the follow
up changes.

Best Regards,
Petr

  parent reply	other threads:[~2014-09-29 16:23 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-26 18:37 Steven Rostedt
2014-09-29 14:41 ` Petr Mladek
2014-09-29 15:25   ` Steven Rostedt
2014-09-29 15:46     ` Joe Perches
2014-09-29 16:11       ` Steven Rostedt
2014-09-29 16:23     ` Petr Mladek [this message]
2014-09-29 16:40       ` Steven Rostedt
2014-09-29 15:47   ` Al Viro
2014-09-29 16:08     ` Joe Perches
2014-09-29 16:15       ` Steven Rostedt
2014-09-29 16:30         ` Joe Perches
2014-09-29 16:42           ` Steven Rostedt
2014-09-29 16:55             ` Joe Perches
2014-09-29 23:08             ` [PATCH 0/7] seq_printf cleanups Joe Perches
2014-09-29 23:08               ` [PATCH 1/7] seq_file: Rename static bool seq_overflow to public bool seq_is_full Joe Perches
2014-09-29 23:44                 ` Steven Rostedt
2014-09-29 23:48                   ` Joe Perches
2014-09-30 10:06                 ` Petr Mladek
2014-09-29 23:08               ` [PATCH 2/7] netfilter: Convert print_tuple functions to return void Joe Perches
2014-09-30 10:22                 ` Petr Mladek
2014-09-30 13:04                   ` Joe Perches
2014-09-29 23:08               ` [PATCH 3/7] dlm: Use seq_is_full - remove seq_printf returns Joe Perches
2014-09-30 10:34                 ` Petr Mladek
2014-10-27 20:17                   ` Steven Rostedt
2014-10-27 20:25                     ` Joe Perches
2014-10-29 12:21                     ` Petr Mladek
2014-09-29 23:08               ` [PATCH 4/7] dlm: Use seq_puts, remove unnecessary trailing spaces Joe Perches
2014-09-29 23:08               ` [PATCH 5/7] fs: Convert show_fdinfo functions to void Joe Perches
2014-10-28 14:11                 ` Steven Rostedt
2014-10-28 14:31                   ` Joe Perches
2014-10-28 14:43                     ` Steven Rostedt
2014-09-29 23:08               ` [PATCH 6/7] debugfs: Fix misuse of seq_printf return value Joe Perches
2014-10-28 14:58                 ` Steven Rostedt
2014-10-28 15:25                   ` Joe Perches
2014-10-28 15:42                     ` Steven Rostedt
2014-10-28 15:59                       ` Joe Perches
2014-11-07 19:03                 ` Greg Kroah-Hartman
2014-09-29 23:08               ` [PATCH 7/7] docg3: Fix miuse " Joe Perches
2014-10-22  8:29                 ` Brian Norris
2014-10-28 15:13                   ` Steven Rostedt
2014-10-28 15:57                     ` Joe Perches
2014-10-28 16:05                       ` Steven Rostedt
2014-10-28 17:14                         ` Brian Norris
2014-10-28 17:26                           ` Steven Rostedt
2014-10-28 17:27                         ` Joe Perches
2014-10-28 17:32                           ` Steven Rostedt
2014-10-28 17:36                             ` Brian Norris
2014-10-28 17:38                             ` Joe Perches
2014-10-28 15:32               ` [PATCH 0/7] seq_printf cleanups Steven Rostedt
2014-10-28 15:51                 ` Joe Perches
2014-10-06  3:33       ` [PATCH] seq_file: Fix seq_putc() to be consistent with seq_puts() Joe Perches
2014-09-29 16:09     ` Steven Rostedt
2014-09-29 16:41       ` Al Viro

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=20140929162334.GB30562@pathway.suse.cz \
    --to=pmladek@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®