From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVsxh-0005rj-LJ for linux-mtd@lists.infradead.org; Sun, 09 Dec 2018 06:53:11 +0000 Date: Sun, 9 Dec 2018 07:52:56 +0100 From: Boris Brezillon To: Hou Tao Cc: , , , Subject: Re: [PATCH] jffs2: fix invocations of dbg_xattr() for dead jffs2_xattr_ref Message-ID: <20181209075256.43ca759f@bbrezillon> In-Reply-To: <20181020110753.98407-1-houtao1@huawei.com> References: <20181020110753.98407-1-houtao1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Sat, 20 Oct 2018 19:07:53 +0800 Hou Tao wrote: > When jffs2_xattr_ref is dead, xref->ic or xref->xd will be invalid > because these fields will be reused as xref->ino or xref->xid, > so access xref->ic->ino or xref->xd->xid will lead to Oops. > > Fix the problem by checking whether or not it is a dead xref. > > Signed-off-by: Hou Tao > --- > fs/jffs2/xattr.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c > index 3d40fe02b003..0c4c7891556d 100644 > --- a/fs/jffs2/xattr.c > +++ b/fs/jffs2/xattr.c > @@ -550,7 +550,8 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref) > ref->xseqno = xseqno; > jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, PAD(sizeof(rr)), (void *)ref); > > - dbg_xattr("success on saving xref (ino=%u, xid=%u)\n", ref->ic->ino, ref->xd->xid); > + dbg_xattr("success on saving xref (ino=%u, xid=%u)\n", > + je32_to_cpu(rr.ino), je32_to_cpu(rr.xid)); Nit: align the second line on the open parens (same applies to the other chunk). Sorry, I can't comment on the actual change. I'll let Richard look at it. > > return 0; > } > @@ -1329,7 +1330,11 @@ int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ > rc = save_xattr_ref(c, ref); > if (!rc) > dbg_xattr("xref (ino=%u, xid=%u) GC'ed from %#08x to %08x\n", > - ref->ic->ino, ref->xd->xid, old_ofs, ref_offset(ref->node)); > + is_xattr_ref_dead(ref) ? > + ref->ino : ref->ic->ino, > + is_xattr_ref_dead(ref) ? > + ref->xid : ref->xd->xid, > + old_ofs, ref_offset(ref->node)); > out: > if (!rc) > jffs2_mark_node_obsolete(c, raw);