Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2348060imu; Sat, 8 Dec 2018 22:37:14 -0800 (PST) X-Google-Smtp-Source: AFSGD/UXXmZK1Sw+uTl61/4LhqXwvhgYby4M00zzgYuhDrEB0E43r5M70Da18ebcODTY+UdRFv5z X-Received: by 2002:a17:902:4c85:: with SMTP id b5mr7496202ple.226.1544337434301; Sat, 08 Dec 2018 22:37:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544337434; cv=none; d=google.com; s=arc-20160816; b=qNiy658V6MjRm7ZfTvyRW9+VU2G/YWDdL6rh5YtJT+/oumeowR+S395uKJKDRMVzvV 0/2HjlmJLPe1w1g4KGGwCGY6jqnDR0scbgAHFD9KpV3rK6608AwnnUb8rbI+Xvmtg3F5 x6Y8mAiC6IVWyY+pWPCIj6V2jyrb96WruDTWvH8bBF5Jju5bT5/bMKA7St4b43RFX/lM 5Kr6a+1G06RLvrZjWSuJWcbVoMGZhQoIOHyxnYqrAR9MzMSnL3aYYm3Gy9KdQ5xFlYTs qYCrvHROEIQIZodw5JHxbyWJmZFT2KuYFpjcNFonxKZa2c4r9+/7qUhI6lg4lborYyM2 wIrg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject; bh=iCHWg50u+5KSxXcJ4KLu4BxxbHZvngUCE64WNw+8zUA=; b=oSewUbrNdYXIwMplO0aVkYe6oVXFpKhPMZfP2aImEUF7t1SBHTdzYxzM5taNwiqH/G mAaxV5iup968lYaSPQ1JRGiT9GYV87KT31g3Tgq/H9nJU+4271YTkdwfkZ1b/QD20h61 V8Iupp32lO6k104YR44ymFGQ6bCrlemECqKm97EJMNNncuFC+UOOoeoq4DBzPwYqvEit Of/x6vZ16y4h9WQi7gr2ZQlfn39cURGat8zFsMBRYcTbP02o0V75SE3lWiXIORNZv5vF yy7kSGYwqfTEZmrrit5+LAhOhQuFB0K9rMAvIdATrne4TMRX5pWorVy7toEBFLhjROmX IhjQ== 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 o89si7575370pfk.223.2018.12.08.22.36.58; Sat, 08 Dec 2018 22:37:14 -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 S1726205AbeLIGfP (ORCPT + 99 others); Sun, 9 Dec 2018 01:35:15 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:53501 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726066AbeLIGfO (ORCPT ); Sun, 9 Dec 2018 01:35:14 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B143E44CAEA85; Sun, 9 Dec 2018 14:35:09 +0800 (CST) Received: from [127.0.0.1] (10.177.31.14) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.408.0; Sun, 9 Dec 2018 14:35:09 +0800 Subject: Re: [PATCH] jffs2: ensure wbuf_verify is valid before using it. From: Hou Tao To: , CC: , , , References: <20181020120849.65708-1-houtao1@huawei.com> Message-ID: Date: Sun, 9 Dec 2018 14:35:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20181020120849.65708-1-houtao1@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.31.14] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ping ? On 2018/10/20 20:08, Hou Tao wrote: > Now MTD emulated by UBI volumn doesn't allocate wbuf_verify in > jffs2_ubivol_setup(), because UBI can do the verifcation itself, > so when CONFIG_JFFS2_FS_WBUF_VERIFY is enabled and a MTD device > emulated by UBI volumn is used, a Oops will occur as show in the > following trace: > > general protection fault: 0000 [#1] SMP KASAN PTI > CPU: 6 PID: 404 Comm: kworker/6:1 Not tainted 4.19.0-rc8 > Workqueue: events_long delayed_wbuf_sync > RIP: 0010:ubi_io_read+0x156/0x650 > Call Trace: > ubi_eba_read_leb+0x57d/0xba0 > ubi_leb_read+0xe5/0x1b0 > gluebi_read+0x10c/0x1a0 > mtd_read+0x112/0x340 > jffs2_verify_write+0xef/0x440 > __jffs2_flush_wbuf+0x3fa/0x3540 > jffs2_flush_wbuf_gc+0x1b1/0x2e0 > process_one_work+0x58b/0x11e0 > worker_thread+0x8f/0xfe0 > kthread+0x2ae/0x3a0 > ret_from_fork+0x35/0x40 > > Fix the problem by checking the validity of wbuf_verify before > using it in jffs2_verify_write(). > > Cc: stable@vger.kernel.org > Fixes: 0029da3bf430 ("JFFS2: add UBI support") > Signed-off-by: Hou Tao > --- > fs/jffs2/wbuf.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c > index c6821a509481..3de45f4559d1 100644 > --- a/fs/jffs2/wbuf.c > +++ b/fs/jffs2/wbuf.c > @@ -234,6 +234,13 @@ static int jffs2_verify_write(struct jffs2_sb_info *c, unsigned char *buf, > size_t retlen; > char *eccstr; > > + /* > + * MTD emulated by UBI volume doesn't allocate wbuf_verify, > + * because it can do the verification itself. > + */ > + if (!c->wbuf_verify) > + return 0; > + > ret = mtd_read(c->mtd, ofs, c->wbuf_pagesize, &retlen, c->wbuf_verify); > if (ret && ret != -EUCLEAN && ret != -EBADMSG) { > pr_warn("%s(): Read back of page at %08x failed: %d\n", >