Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1365028imu; Thu, 13 Dec 2018 13:54:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/VuBI9UZCbYtr8FhUVYsFL/QzM0gMhfd5uQ2ONzpYvFW6difdxI8euCSJOUtvKu/h9yRZee X-Received: by 2002:a17:902:4025:: with SMTP id b34mr456544pld.181.1544738080489; Thu, 13 Dec 2018 13:54:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544738080; cv=none; d=google.com; s=arc-20160816; b=Bz2wY0SxV+kCZ3ih98pECmHMEjgtyGDR+QhNvD7fLfjblEOsWCshD4XSPWBNud7efj 6o8umXrFTr/jJuW35VusA/GaElV2Xlo+cBPxgzbSF0vEVH5Oowyg3wC83SkoGxTdJpr8 ivvDNyPAKQoiq6WgcCIsWRDpmc2CPOM6y43IuxXNc4RPHbj89asyYycUUXRMkFp4lON0 noZMWH93dOw8GoWHixolmxnbBJbw/jbGJkjKkXGieThmSUjhZJxMx6fhuDUGm+RwX8A3 lvfMieucRUhBDLoREY1APEECPDttx68kpnlyGJwdPt8ElTAi2kjkAiBjcKveUBgZwnGf 4UHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=V98FXn7UfqNg7tuJqtNf1bNRYMrfTFPMN328XT4aSm4=; b=xy3p4Y+rNN1nsgdJMVjF2F7tBzHlynplxNeD4yb251drpwftcqOqJJNWOkVkFLbELw 6KfrOtSdBc8oX4dYsLwMa635+xwyYgVg3RZWKp9XTy5vfPbaQe3bXuW9TwhSmwNgG1AN wSp9dAijuocaJaWdnzvjVpBHftF3yZJ+USeKGCA8MkOjP3SQZUHdTBQuqQmn7MAfAsh6 4K4jwuD4MWsWkCt4coQfPmD9XdSYgj3v3EKGMx3BAZ9g8ulL7nskyKYrOGLS+MXgSwOd HABpEgS5AFdTkw5SIw0rali0+vzhB6odHwb389R7XRA2rSaO69XgYgrME0D++OkLpC5o t54w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AYf6S2ml; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f61si2401694plb.51.2018.12.13.13.54.25; Thu, 13 Dec 2018 13:54:40 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AYf6S2ml; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727682AbeLMVxS (ORCPT + 99 others); Thu, 13 Dec 2018 16:53:18 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46872 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbeLMVxP (ORCPT ); Thu, 13 Dec 2018 16:53:15 -0500 Received: by mail-wr1-f66.google.com with SMTP id l9so3495890wrt.13 for ; Thu, 13 Dec 2018 13:53:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=V98FXn7UfqNg7tuJqtNf1bNRYMrfTFPMN328XT4aSm4=; b=AYf6S2ml5VIBD3Wqg03HsTOmdKsvwZ4n0Kv6oYajtWMhVhB5s41FDdbS24/7eJLMgE hZcFf51wLznQLORlPwodhF3VYqvlmruVuQLUZV7WSmQwcHbQ70JfxHv6k1BBeE2mhGa+ i6KHxped6UGf2cW8fBQ9cEno2rvHgVS1m8QrNoryy6WHdFTYATev2zwPO2Gw1MT/bKcx KzyMcFx8/+X1o3GDghc0Sx4iOMveymdmMVHT9xJ7+VN2gnFHh6WAfyVnK371cb5AJe1Y Em2F0Z0zTVDwJXHO6uIbr48y6arTQlNpHDxZw2zLC7b+kLPt4DwG52VJ1VX44iGPs6R+ oTDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=V98FXn7UfqNg7tuJqtNf1bNRYMrfTFPMN328XT4aSm4=; b=oxBLmxvFV0aElSsbAl5Qb5UPiCxU5gcR7Z2v7/wT2nbOnkbWCUUaICYZmZGtrb/hhX xxuGxI1tNwGFRZJ6wb9h+P4jNWFodSyokYsxYGO6GW4hVSGzzUK/fyZadVaEigcKhuCj oFpntUkPZTvNGGPRfm9dsovxw5l2VLfL+8+dSoRicY1ccd8/qIYsH6v1b26ARNJRozgQ CHqL5UveC0X2xd52Q5Zzsle+tMIogpcxwZNe5K4FZpxrjEk6lHwX/W+2qn/KeBZ8PZJS N71vgoR0Hv42MyZomLwTw+4KJFqW5Qxkxo3Bn9YWFMTpRLwwFTW5TvSd7tijFyDvOFfS YDvw== X-Gm-Message-State: AA+aEWbsFGOvSc+NDm6hwPeaSqZSxafPqJJoRPNCgMF6vDXaZboL/AxX uCRY2Dr0Wb1x2eKzVFNHN7NCTDyFfIztlaYuE0dM87XR X-Received: by 2002:a5d:4e82:: with SMTP id e2mr386764wru.291.1544737994196; Thu, 13 Dec 2018 13:53:14 -0800 (PST) MIME-Version: 1.0 References: <20181020110753.98407-1-houtao1@huawei.com> <20181209075256.43ca759f@bbrezillon> In-Reply-To: <20181209075256.43ca759f@bbrezillon> From: Richard Weinberger Date: Thu, 13 Dec 2018 22:53:02 +0100 Message-ID: Subject: Re: [PATCH] jffs2: fix invocations of dbg_xattr() for dead jffs2_xattr_ref To: boris.brezillon@bootlin.com Cc: houtao1@huawei.com, linux-mtd@lists.infradead.org, David Woodhouse , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 9, 2018 at 7:52 AM Boris Brezillon wrote: > > 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); > Since is_xattr_ref_dead() is cheap, can you please add two macros. Something like: static inline uint32_t xattr_ref_ino(struct jffs2_xattr_ref *ref) { if (is_xattr_ref_dead(ref)) return ref>ino; else return ref->ic->ino; } Same for xid. -- Thanks, //richard