From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7313B6453 for ; Tue, 22 Mar 2022 21:38:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3117DC340F4; Tue, 22 Mar 2022 21:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1647985120; bh=eZCt7nWQhmPEj1yw/elTFm+QXFc4QMWTtFkhJv31Mw8=; h=Date:To:From:In-Reply-To:Subject:From; b=T28KDiF5HERRVcy3OYX1F7iiNFkNwV8fUQsTTGIgawGjKBka5cm4AkPeAhTDSrf5k jdNiwGfWXrhzmNeLqzSKBP01uGhnmaUeWin+fajHJS+RM6WnvAkuKN0vUjd8wsEl0J OsMnWp89gMxzD7cUU7dLTkF6yS/m5WFuFvKB6XGg= Date: Tue, 22 Mar 2022 14:38:39 -0700 To: anton@tuxera.com,mudongliangabcd@gmail.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220322143803.04a5e59a07e48284f196a2f9@linux-foundation.org> Subject: [patch 003/227] ntfs: add sanity check on allocation size Message-Id: <20220322213840.3117DC340F4@smtp.kernel.org> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: From: Dongliang Mu Subject: ntfs: add sanity check on allocation size ntfs_read_inode_mount invokes ntfs_malloc_nofs with zero allocation size. It triggers one BUG in the __ntfs_malloc function. Fix this by adding sanity check on ni->attr_list_size. Link: https://lkml.kernel.org/r/20220120094914.47736-1-dzm91@hust.edu.cn Reported-by: syzbot+3c765c5248797356edaa@syzkaller.appspotmail.com Signed-off-by: Dongliang Mu Acked-by: Anton Altaparmakov Signed-off-by: Andrew Morton --- fs/ntfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/ntfs/inode.c~ntfs-add-sanity-check-on-allocation-size +++ a/fs/ntfs/inode.c @@ -1881,6 +1881,10 @@ int ntfs_read_inode_mount(struct inode * } /* Now allocate memory for the attribute list. */ ni->attr_list_size = (u32)ntfs_attr_size(a); + if (!ni->attr_list_size) { + ntfs_error(sb, "Attr_list_size is zero"); + goto put_err_out; + } ni->attr_list = ntfs_malloc_nofs(ni->attr_list_size); if (!ni->attr_list) { ntfs_error(sb, "Not enough memory to allocate buffer " _ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF77BC433EF for ; Tue, 22 Mar 2022 21:38:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235523AbiCVVkR (ORCPT ); Tue, 22 Mar 2022 17:40:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235789AbiCVVkJ (ORCPT ); Tue, 22 Mar 2022 17:40:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BFA7275ED for ; Tue, 22 Mar 2022 14:38:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CC7696174A for ; Tue, 22 Mar 2022 21:38:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3117DC340F4; Tue, 22 Mar 2022 21:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1647985120; bh=eZCt7nWQhmPEj1yw/elTFm+QXFc4QMWTtFkhJv31Mw8=; h=Date:To:From:In-Reply-To:Subject:From; b=T28KDiF5HERRVcy3OYX1F7iiNFkNwV8fUQsTTGIgawGjKBka5cm4AkPeAhTDSrf5k jdNiwGfWXrhzmNeLqzSKBP01uGhnmaUeWin+fajHJS+RM6WnvAkuKN0vUjd8wsEl0J OsMnWp89gMxzD7cUU7dLTkF6yS/m5WFuFvKB6XGg= Date: Tue, 22 Mar 2022 14:38:39 -0700 To: anton@tuxera.com, mudongliangabcd@gmail.com, akpm@linux-foundation.org, patches@lists.linux.dev, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220322143803.04a5e59a07e48284f196a2f9@linux-foundation.org> Subject: [patch 003/227] ntfs: add sanity check on allocation size Message-Id: <20220322213840.3117DC340F4@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org From: Dongliang Mu Subject: ntfs: add sanity check on allocation size ntfs_read_inode_mount invokes ntfs_malloc_nofs with zero allocation size. It triggers one BUG in the __ntfs_malloc function. Fix this by adding sanity check on ni->attr_list_size. Link: https://lkml.kernel.org/r/20220120094914.47736-1-dzm91@hust.edu.cn Reported-by: syzbot+3c765c5248797356edaa@syzkaller.appspotmail.com Signed-off-by: Dongliang Mu Acked-by: Anton Altaparmakov Signed-off-by: Andrew Morton --- fs/ntfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/ntfs/inode.c~ntfs-add-sanity-check-on-allocation-size +++ a/fs/ntfs/inode.c @@ -1881,6 +1881,10 @@ int ntfs_read_inode_mount(struct inode * } /* Now allocate memory for the attribute list. */ ni->attr_list_size = (u32)ntfs_attr_size(a); + if (!ni->attr_list_size) { + ntfs_error(sb, "Attr_list_size is zero"); + goto put_err_out; + } ni->attr_list = ntfs_malloc_nofs(ni->attr_list_size); if (!ni->attr_list) { ntfs_error(sb, "Not enough memory to allocate buffer " _