From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Neil Brown <neilb@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] jffs2: Fix memory corruption in jffs2_read_inode_range()
Date: Mon, 23 Nov 2009 16:16:13 +0300 [thread overview]
Message-ID: <20091123131613.GA14619@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <1258885259.1127.80.camel@macbook.infradead.org>
On Sun, Nov 22, 2009 at 10:20:59AM +0000, David Woodhouse wrote:
> On Fri, 2009-11-20 at 12:45 -0700, Anton Vorontsov wrote:
> > + if (pg->index > ((i_size_read(inode) - 1) >> PAGE_CACHE_SHIFT)) {
> > + ret = 0;
> > + memset(pg_buf, 0, PAGE_CACHE_SIZE);
> > + } else {
> > + ret = jffs2_read_inode_range(c, f, pg_buf,
> > + pg->index << PAGE_CACHE_SHIFT, PAGE_CACHE_SIZE);
> > + }
>
> Thank you for the excellent diagnosis and the patch.
>
> I think I'd prefer to fix it a little differently though -- I would be
> happier to make jffs2_read_inode_range() cope with out-of-file reads,
> rather than adding this special case where we don't call it.
>
> That way we aren't at all susceptible to potential races between the
> VFS-maintained i_size and our own internal fragtree handling. And
> jffs2_read_inode_range() already handles the memset to zero for various
> other reasons anyway.
>
> Does this patch look OK to you? It seems to work on the test cases I've
> tried.
Yep, it looks good (and works).
Thanks David!
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
WARNING: multiple messages have this Message-ID (diff)
From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Neil Brown <neilb@suse.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>
Subject: Re: [PATCH] jffs2: Fix memory corruption in jffs2_read_inode_range()
Date: Mon, 23 Nov 2009 16:16:13 +0300 [thread overview]
Message-ID: <20091123131613.GA14619@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <1258885259.1127.80.camel@macbook.infradead.org>
On Sun, Nov 22, 2009 at 10:20:59AM +0000, David Woodhouse wrote:
> On Fri, 2009-11-20 at 12:45 -0700, Anton Vorontsov wrote:
> > + if (pg->index > ((i_size_read(inode) - 1) >> PAGE_CACHE_SHIFT)) {
> > + ret = 0;
> > + memset(pg_buf, 0, PAGE_CACHE_SIZE);
> > + } else {
> > + ret = jffs2_read_inode_range(c, f, pg_buf,
> > + pg->index << PAGE_CACHE_SHIFT, PAGE_CACHE_SIZE);
> > + }
>
> Thank you for the excellent diagnosis and the patch.
>
> I think I'd prefer to fix it a little differently though -- I would be
> happier to make jffs2_read_inode_range() cope with out-of-file reads,
> rather than adding this special case where we don't call it.
>
> That way we aren't at all susceptible to potential races between the
> VFS-maintained i_size and our own internal fragtree handling. And
> jffs2_read_inode_range() already handles the memset to zero for various
> other reasons anyway.
>
> Does this patch look OK to you? It seems to work on the test cases I've
> tried.
Yep, it looks good (and works).
Thanks David!
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
next prev parent reply other threads:[~2009-11-23 13:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-20 19:45 [PATCH] jffs2: Fix memory corruption in jffs2_read_inode_range() Anton Vorontsov
2009-11-20 19:45 ` Anton Vorontsov
2009-11-22 10:20 ` David Woodhouse
2009-11-22 10:20 ` David Woodhouse
2009-11-23 13:16 ` Anton Vorontsov [this message]
2009-11-23 13:16 ` Anton Vorontsov
2009-11-23 13:47 ` David Woodhouse
2009-11-23 13:47 ` David Woodhouse
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=20091123131613.GA14619@oksana.dev.rtsoft.ru \
--to=avorontsov@ru.mvista.com \
--cc=akpm@linux-foundation.org \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=neilb@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.