Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2356533imu; Sat, 8 Dec 2018 22:54:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/X0/WSMPcG+OADJkrozJ1XVIor2buYkKkeh1HSd9e5leDADagiui05Gd9MYjlDJXO9h/Jq5 X-Received: by 2002:a62:43c1:: with SMTP id l62mr8240408pfi.22.1544338466729; Sat, 08 Dec 2018 22:54:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544338466; cv=none; d=google.com; s=arc-20160816; b=QFRR/gNaraR/mULVZoYYOUqCzT+x2U1b4EbDo4KE/bQID/xZ0ZjD8pWUU7o91BtlhM 0UHbmCNjYK1QttJCzWKIN8gUczTBaWOpaioLZ3Wg+xoCOFJ6RDT0p/8GbRRdzKCRSbUn 9pXNy5W65bny4sLAlt+UyCWkZL9wvYMb0HAo/oLeXjZqCJNlflLmQVB0VNqJ99E7zuDQ mEKau4lmnndu4SKSTmafgCIvHZXmfqe0ceWLV2Cd/wzLNp4+xgZpjNpdlDmsat2A4Xk3 nfjjrMcgkwlVAywbgqeNiadONRzOh2c7x1VE16fPw7BiLdZdTrjjLUQq5jHwW9bo8xd3 ATwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=HBhEyqgaFHdY6eiGme78V102kUEuWvvzW6fEWNT4EOE=; b=yWgSgc3gV26j/gR2v9Zlql0IYQV/wcIu5V9xgiRjbQFhoPDy2wPXnmztUJ3MqMaP4s uz+/QFuxzl4ACAwynHYhbdQN79AvPboqYrXxYTcf1GolyAcdPnJWDMbZTpm1NLYG7LFf f1QgMnxrC8QWUYKL7goXQPv2Wi6kGQPOizpDzPmFuBf5Q85H5uuHbz/oA4FpIGNkIMNC ku7rH+NhrojM86URa/AwmykVTl1xKelfw5WhTkdiOEEvSsoR6/jr05osMJrvHUVWuji4 UNam/r6v603z+E4q8/jO0P8bjU1c8BDkJIj2G7cviRdqdRWTLLOP1nEKdUu7o1br7Uqh a4Vw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a26si6967901pgl.282.2018.12.08.22.53.55; Sat, 08 Dec 2018 22:54:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726096AbeLIGw7 (ORCPT + 99 others); Sun, 9 Dec 2018 01:52:59 -0500 Received: from mail.bootlin.com ([62.4.15.54]:38992 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbeLIGw7 (ORCPT ); Sun, 9 Dec 2018 01:52:59 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 2C67D2073D; Sun, 9 Dec 2018 07:52:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from bbrezillon (unknown [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id EFBC620618; Sun, 9 Dec 2018 07:52:55 +0100 (CET) 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> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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);