Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1380832imm; Sat, 6 Oct 2018 02:07:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV60MlaeCi4fpxXczWIU/UMJEFNjuv3Av2EKlZDKqxf8iTP/QUHBB/C5Q13tPpxgSd58lA0qy X-Received: by 2002:a62:5887:: with SMTP id m129-v6mr11007776pfb.254.1538816869582; Sat, 06 Oct 2018 02:07:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538816869; cv=none; d=google.com; s=arc-20160816; b=ob6+kqV5cVRSy+yyJ96DjTFQF0h780sUIqR16w42X5LqzUgeze2ep8i1UuFn7rMddU f+MlTRw8cCveZzLvqs37kwcDsfgHxm8acOSl3gf1t8TA8Fl5HFize3QbCfh2jUz+7z3F Zp4FSr0+j29ARtKruy9iKDCsB5UcHXD3lLysURP/X4jaAIGx+eUq2uyOEj/F/8rwexvD 2fx61Qlyc5LH+s94uYdE3NXwAX9BRCRv8R5aWgBbQi8x+U03r/3lEd7pfUcQkYNNkcNm h1+WsRaJEYJ0FnlXPGF6bRwJjAv0NR8ZPyOzOSwoGti7IZ2Z7IMvpq0A8wGFb2+JBQdA 4c2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=4FcZZ7sEma+kvB0HWj1/dg033ddicOa2PRK7GT/v6c4=; b=nO6BhdQHlxVXyR6AwjcTgqpIxJ0g/D46a5GY569wSisEl7XXtCoHg2izy3/NXYdH01 mMFqWiMN3vsOUr9h2GcIwH5ykhAok0tnAlU2efviyV15tLezBLC2dNjGRHHE7+qmHm8W YAMsItPpUptHQxnYXYyOJGkp7BH9ieqdhN/3208SDBEu5Qn2xU/yrwLelNjqkSgByoUi qGGxLaJKVHFoGdTinMP2CugH1PFwMShOnIyZAVlOwJdlCpIOGBgZgvCS3MPpNbYLljal dq1L3qw+W6Dlyayb8H9evdmZxk9TucBiDk25o1s+9V1q6Rrn3R2xNTaMVZCGAKnJilYq 8Flg== 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 g12-v6si11886877pla.70.2018.10.06.02.07.17; Sat, 06 Oct 2018 02:07:49 -0700 (PDT) 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 S1727799AbeJFQJn (ORCPT + 99 others); Sat, 6 Oct 2018 12:09:43 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:13201 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727685AbeJFQJn (ORCPT ); Sat, 6 Oct 2018 12:09:43 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B0DBACC188F87; Sat, 6 Oct 2018 17:07:08 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.399.0; Sat, 6 Oct 2018 17:07:09 +0800 From: Hou Tao To: , CC: , Subject: [PATCH] jffs2: free jffs2_sb_info through jffs2_kill_sb() Date: Sat, 6 Oct 2018 17:09:35 +0800 Message-ID: <20181006090935.41714-1-houtao1@huawei.com> X-Mailer: git-send-email 2.16.2.dirty MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When an invalid mount option is passed to jffs2, jffs2_parse_options() will fail and jffs2_sb_info will be freed, but then jffs2_sb_info will be used (use-after-free) and freeed (double-free) in jffs2_kill_sb(). Fix it by removing the buggy invocation of kfree() when getting invalid mount options. Cc: stable@kernel.org Signed-off-by: Hou Tao --- fs/jffs2/super.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index 87bdf0f4cba1..902a7dd10e5c 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c @@ -285,10 +285,8 @@ static int jffs2_fill_super(struct super_block *sb, void *data, int silent) sb->s_fs_info = c; ret = jffs2_parse_options(c, data); - if (ret) { - kfree(c); + if (ret) return -EINVAL; - } /* Initialize JFFS2 superblock locks, the further initialization will * be done later */ -- 2.16.2.dirty