Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp312312pxu; Wed, 14 Oct 2020 01:50:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIKpXjIBpTgoWNIySOyQxnEMRSG91AFexv9iCVehxr9wZtpZfRPjuypHmcUyjOyOfCqpm4 X-Received: by 2002:a17:906:1a04:: with SMTP id i4mr4459743ejf.24.1602665418295; Wed, 14 Oct 2020 01:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602665418; cv=none; d=google.com; s=arc-20160816; b=n1UveDMcqM/zqy+olQtQPj8Y3zyweWcYJdTPbC4Juw5atw9sjIzIptC7+s9f3gQ9ku quVONX6sgRgpI/Y6p+s20q+A2tShXw1IFADPgTE3jIKd4+fYATTH8I7vrPi8Pp9+POcR dSCEUQt6OFKXWZKTyvX3O/k5fUuz4AnbdBnZpqiEokkEiP1qP6H4pY+iz3BzUnK+BF+V o3QRe64ySbT82qk+Au9SjOwPtvRj8n7zuKYTMzBmfJG0a8ypuL8AbRLfXEm0Jc4i+F/g t3v7qeENKMXzBoAIgx7/hUTEcTpbOHO/4B4QSNBKay+y7GZoznNLsi2WJODRaQzdZpGb Glzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ZPPpWVpH62pUBa5iyJxGVymWzTfqwuTcYJHRLNbkyMA=; b=CfK3m9Y8YfMWT4q6nT7PPS2OMi9rYNhaUCQh9+WdsACHk/TrtpuFVMz96k8IalKLIt VxcIapTp15PQmcZ6ojz51WB2DEnMDI8DdkaFfXvZn6uTgwNUqB3sUe1ZosH6n+3zU/7t cdgKSGCJppV+ZvtEDGNteqkaA1UZFsJ9JkODxxmWWAY+wzBkpTx+iEaFaToVMZen3zhi r9Vzb97TYhL8BwTAIpHYchh3p4EUpyqUMf5c8iGorgrNFYJWBWjEX2J+8L9v32s3YMN3 WKlW6IYwFvmgweXMhqstZwxwRCZE7+YBaZrTGfdW4OzlFNpLzbPExIyF20CGXB/Wc+KC dr3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b25si1621800edw.586.2020.10.14.01.49.56; Wed, 14 Oct 2020 01:50:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727689AbgJNGy4 (ORCPT + 99 others); Wed, 14 Oct 2020 02:54:56 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:15286 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727536AbgJNGy4 (ORCPT ); Wed, 14 Oct 2020 02:54:56 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id CCA45DC261363107584A; Wed, 14 Oct 2020 14:54:51 +0800 (CST) Received: from DESKTOP-FKFNUOQ.china.huawei.com (10.67.101.50) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Wed, 14 Oct 2020 14:54:45 +0800 From: Zhe Li To: , CC: , , , , , , Subject: [PATCH 2/2] jffs2: fix can't set rp_size to zero during remounting Date: Wed, 14 Oct 2020 14:54:43 +0800 Message-ID: <20201014065443.18512-2-lizhe67@huawei.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20201014065443.18512-1-lizhe67@huawei.com> References: <20201014065443.18512-1-lizhe67@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.101.50] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: lizhe Set rp_size to zero will be ignore during remounting. The method to identify whether we input a remounting option of rp_size is to check if the rp_size input is zero. It can not work well if we pass "rp_size=0". This patch add a bool variable "set_rp_size" to fix this problem. By the way, the problem of NULL pointer dereference in rp_size fs option parsing showed at https://lore.kernel.org/linux-mtd/20201012131204.59102-1-jamie@nuviainc.com/T/#u should be applyed before this patch to make sure it works well. Reported-by: Jubin Zhong Signed-off-by: lizhe --- fs/jffs2/jffs2_fs_sb.h | 1 + fs/jffs2/super.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/jffs2/jffs2_fs_sb.h b/fs/jffs2/jffs2_fs_sb.h index 778275f48a87..5a7091746f68 100644 --- a/fs/jffs2/jffs2_fs_sb.h +++ b/fs/jffs2/jffs2_fs_sb.h @@ -38,6 +38,7 @@ struct jffs2_mount_opts { * users. This is implemented simply by means of not allowing the * latter users to write to the file system if the amount if the * available space is less then 'rp_size'. */ + bool set_rp_size; unsigned int rp_size; }; diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index 4fd297bdf0f3..c523adaca79f 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c @@ -88,7 +88,7 @@ static int jffs2_show_options(struct seq_file *s, struct dentry *root) if (opts->override_compr) seq_printf(s, ",compr=%s", jffs2_compr_name(opts->compr)); - if (opts->rp_size) + if (opts->set_rp_size) seq_printf(s, ",rp_size=%u", opts->rp_size / 1024); return 0; @@ -206,6 +206,7 @@ static int jffs2_parse_param(struct fs_context *fc, struct fs_parameter *param) if (opt > c->mtd->size) return invalf(fc, "jffs2: Too large reserve pool specified, max is %llu KB", c->mtd->size / 1024); + c->mount_opts.set_rp_size = true; c->mount_opts.rp_size = opt; break; default: @@ -225,8 +226,10 @@ static inline void jffs2_update_mount_opts(struct fs_context *fc) c->mount_opts.override_compr = new_c->mount_opts.override_compr; c->mount_opts.compr = new_c->mount_opts.compr; } - if (new_c->mount_opts.rp_size) + if (new_c->mount_opts.set_rp_size) { + c->mount_opts.set_rp_size = new_c->mount_opts.set_rp_size; c->mount_opts.rp_size = new_c->mount_opts.rp_size; + } mutex_unlock(&c->alloc_sem); } -- 2.12.3