mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Charley (Hao Chuan) Chu" <charley.chu@broadcom.com>
To: "Linus Torvalds" <torvalds@linux-foundation.org>,
	"Al Viro" <viro@zeniv.linux.org.uk>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] FS: Fixed buffer overflow issue in seq_read()
Date: Tue, 19 Nov 2013 21:22:58 +0000	[thread overview]
Message-ID: <FB8A4655DFD2B34DB16AE06DDDD6C0E21BDBB7CD@SJEXCHMB12.corp.ad.broadcom.com> (raw)
In-Reply-To: <alpine.LFD.2.10.1311181912090.7995@i7.linux-foundation.org>

> m->from is a red herring - it's not even looked at if m->count is 0.  

Then, shall the initialization here be removed too?

@@ -90,7 +90,7 @@ static int traverse(struct seq_file *m, loff_t offset)
 
        m->version = 0;
        index = 0;
-       m->count = m->from = 0;
+       m->count = 0;
        if (!offset) {
                m->index = index;
                return 0;

> What do you think about then just abstracing out that now common sequence 
> of re-allocating a larger buffer, while clearing m->count?

Following code is duplicated (slightly different) in both seq_read() and seq_lseek().
It would be nice to have them consolidated in traverse().

                while ((err = traverse(m, *ppos)) == -EAGAIN)
                        ;   
                if (err) {
                        /* With prejudice... */
                        m->read_pos = 0;
                        m->version = 0;
                        m->index = 0;
                        m->count = 0;
                        goto Done;
                } else {
                        m->read_pos = *ppos;
                }   

Thanks,
Charley


      parent reply	other threads:[~2013-11-19 21:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19  0:18 Charley (Hao Chuan) Chu
2013-11-19  0:38 ` Linus Torvalds
2013-11-19  1:26   ` Al Viro
2013-11-19  1:20 ` Al Viro
2013-11-19  3:13   ` Linus Torvalds
2013-11-19  3:28     ` Al Viro
2013-11-19  3:33       ` Linus Torvalds
2013-11-19 21:22     ` Charley (Hao Chuan) Chu [this message]

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=FB8A4655DFD2B34DB16AE06DDDD6C0E21BDBB7CD@SJEXCHMB12.corp.ad.broadcom.com \
    --to=charley.chu@broadcom.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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®