Received: by 10.192.165.148 with SMTP id m20csp4744510imm; Tue, 1 May 2018 03:02:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr+n4g6LLU9K/Xl6tjmu8j1AylCtMLVzxI9KwlbsN+O7eKp9lqraQPEUjQ3WF4azHDtc7N4 X-Received: by 2002:a17:902:704c:: with SMTP id h12-v6mr1261202plt.269.1525168962048; Tue, 01 May 2018 03:02:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525168962; cv=none; d=google.com; s=arc-20160816; b=puJMYhYDplIf3IICwmgf7EVrZvwSpp1wYgMKFPUHPLwXVwcj9UHlq6nhlGqAFub743 /GcIUnitddN+7RFqC9Z+9mHRZE5U3R0WICaP4/YvYk6ozbKdHCfX8gO/zIMXWSkX2UBV 3mrwECvT+3WZMr9+IMoyPcdEdqCALZq+dQWi/bfY3Ws9I3uLJNXXiwNK876sp3zsWYRo luM6QYbQeNmCE/YW6MAiBY554SDUYdDO5Wfxaq0fDDDt66o5mx+WeBOaFTGNsxmxUF/N XGNRaBVLYxHvuILhOFmsg3PqfnaJMCkxTXQDGJPETTwfhqFVegBAPtz0lA4d7YLuwzs9 0zUQ== 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:from:references:to:subject:arc-authentication-results; bh=HpcKgG3hfvxPDB+QSKig40+uQHTLGGqw3uWdYIOgrTY=; b=sbMA9h/KhE2+ojBnBX2rEaG50nDaNoPC/mpF6MAASZmApTFH8n2K3sfZ2gRUnUkCHL vRenJsxDA07J2l7Nz6/vRR1MeIH9TYqi2QmrnqRtxvoorfC159r+4yw5Pah1C1zf9eBc WMGueNBswGsr7Q4AgzaAyr0bYxBDdvIEwhCInMN8ZJHa5fD7kdV1sPWEPRDfyZ//3Rsj 4VbibxHejhvsmNOJLDtHYXtbuNYRTF9kQyjYuR2OxJRmrC71SBmbXSpQ12hW4RQ1q8xq RCXKJsQ6biHjdC8Se9wZG2K2K7sH+ZmjSoWkVt+D//PEVTmpbEwBoy1dJYB52cNGG35Q A0ZA== 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 b9-v6si2600790pgu.27.2018.05.01.03.02.28; Tue, 01 May 2018 03:02:42 -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 S1754271AbeEAKBY (ORCPT + 99 others); Tue, 1 May 2018 06:01:24 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:15194 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753423AbeEAKBX (ORCPT ); Tue, 1 May 2018 06:01:23 -0400 Received: from fsav304.sakura.ne.jp (fsav304.sakura.ne.jp [153.120.85.135]) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w41A1EVk082181; Tue, 1 May 2018 19:01:14 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav304.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav304.sakura.ne.jp); Tue, 01 May 2018 19:01:14 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav304.sakura.ne.jp) Received: from [192.168.1.8] (softbank126099184120.bbtec.net [126.99.184.120]) (authenticated bits=0) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w41A18fI082155 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 1 May 2018 19:01:14 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Subject: Re: WARNING: kmalloc bug in bfs_fill_super To: syzbot , aivazian.tigran@gmail.com, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com References: <0000000000001f05330568a6b369@google.com> From: Tetsuo Handa Message-ID: <32e853dd-3340-653e-a876-dce5de44d990@I-love.SAKURA.ne.jp> Date: Tue, 1 May 2018 19:01:08 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <0000000000001f05330568a6b369@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From 247cae4da0490c2e285e0a99e630ef963fabb6d5 Mon Sep 17 00:00:00 2001 From: Tetsuo Handa Date: Tue, 1 May 2018 14:15:19 +0900 Subject: [PATCH] bfs: add sanity check at bfs_fill_super(). syzbot is reporting too large memory allocation at bfs_fill_super() [1]. Since file system image is corrupted such that bfs_sb->s_start == 0, bfs_fill_super() is trying to allocate 8MB of continuous memory. Fix this by adding a sanity check on bfs_sb->s_start, __GFP_NOWARN and printf(). [1] https://syzkaller.appspot.com/bug?id=16a87c236b951351374a84c8a32f40edbc034e96 Signed-off-by: Tetsuo Handa Reported-by: syzbot Cc: Tigran A. Aivazian --- fs/bfs/inode.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index 9a69392..d81c148 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c @@ -350,7 +350,8 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) s->s_magic = BFS_MAGIC; - if (le32_to_cpu(bfs_sb->s_start) > le32_to_cpu(bfs_sb->s_end)) { + if (le32_to_cpu(bfs_sb->s_start) > le32_to_cpu(bfs_sb->s_end) || + le32_to_cpu(bfs_sb->s_start) < BFS_BSIZE) { printf("Superblock is corrupted\n"); goto out1; } @@ -359,9 +360,11 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) sizeof(struct bfs_inode) + BFS_ROOT_INO - 1; imap_len = (info->si_lasti / 8) + 1; - info->si_imap = kzalloc(imap_len, GFP_KERNEL); - if (!info->si_imap) + info->si_imap = kzalloc(imap_len, GFP_KERNEL | __GFP_NOWARN); + if (!info->si_imap) { + printf("Cannot allocate %u bytes\n", imap_len); goto out1; + } for (i = 0; i < BFS_ROOT_INO; i++) set_bit(i, info->si_imap); -- 1.8.3.1