Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp923990pxb; Fri, 22 Apr 2022 14:26:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzgE7riPY0vH5C8SksJjmDt6pO4uj3F8KRfORRpvlqp+V/xkh8xcZaPROp0cBRaXIe2EJj X-Received: by 2002:a17:90a:730c:b0:1d9:3f5:9a00 with SMTP id m12-20020a17090a730c00b001d903f59a00mr2317542pjk.109.1650662790103; Fri, 22 Apr 2022 14:26:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650662790; cv=none; d=google.com; s=arc-20160816; b=oP/tmUK3gOfUNSNs0eORiwylz4fex1RsGnuRUEylbLxmIQiT/OdxDmn85LYVM09oNH vFxAIv562ixB43BoIGeK4gctb+an9oSgsuSMVfPWJ0qVmCQ4vBAHogftCOkUMDgtzRvR jEeS0rJ03a1ugNcoscA6LOYe6Njx8TTn6tMZcgZt7TRu38HmYO2z0VzI8+AbSJxA7+Wb KwTR+yYhAJhM1IKCy0us4zLTntak/Gi0z9DbDhuXQICR4eGzx8CUadj1IPs6kKFtg+lv S3gvtCJBw45ZVjLq3VV134/QSUWMafXAprL+sDnvlAo1i6s53aQjJbyURJkH0S0Lxqlr 1zaA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MvexgkXKU4iAnrnVpFSK0y7PWvfl/2+Yu1E83Oh6AQI=; b=XaJRJm2K+p4JYH12VJg74pXKib2fVNyMuq2ITE/b6WV2TgNwb/mdkK2R2x+w9o3sxk 8h6sCTRXK4TfrAns0/Colcx42Ou3GSh9/eF3GKfrh16SU+fO1V5d4wd6VGcQaDB40luB 7TdTCRJ7/BBWed7i6PAUbVl/dnVs/UR2Dxdw39wSLRxnN5ZY7pU3IyCaa1pc4iXXVLCY 5LK37K+bWqbFId3h57GVE8SpOnLV3kKxHpB1HDfLc+YgOeXEzNfhI61hV9KRTh/FtENG KSPxVVymSlMdAYS0GZc2RwOSFVYnTp9l7FMS0398FjX3gQlCqDiSu2FfKT57opot1HIG vskg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GkIFyvBG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d19-20020a056a00199300b00505a42ba060si9428399pfl.22.2022.04.22.14.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 14:26:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GkIFyvBG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 56DF1128CCE; Fri, 22 Apr 2022 12:33:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245090AbiDRNwX (ORCPT + 99 others); Mon, 18 Apr 2022 09:52:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244830AbiDRNa5 (ORCPT ); Mon, 18 Apr 2022 09:30:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7171823173; Mon, 18 Apr 2022 05:55:40 -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 ams.source.kernel.org (Postfix) with ESMTPS id 2E625B80D9C; Mon, 18 Apr 2022 12:55:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87936C385A7; Mon, 18 Apr 2022 12:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286538; bh=ingGZxMaEc9r5alfLYbLed9tPRonczPlahQ4UPFgo+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GkIFyvBG9KI7FqCzDBNxvYNWeGfgG9wVcBv/mt9rdAVLK5HfdSfdQZd120kCR+hDi qiaAeXkFDwR5DQftDG0UhcCkHP9UGVP3cJ6UkBAhTRPUOQhWnvmmcpoD74r36gQz2q 5lFimwVuGe9Ob2OU4m7BX7D0Xn/BJbQJRW4d3gEI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+3c765c5248797356edaa@syzkaller.appspotmail.com, Dongliang Mu , Anton Altaparmakov , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 164/284] ntfs: add sanity check on allocation size Date: Mon, 18 Apr 2022 14:12:25 +0200 Message-Id: <20220418121216.408812730@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dongliang Mu [ Upstream commit 714fbf2647b1a33d914edd695d4da92029c7e7c0 ] 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 Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/ntfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 8cd134750ebb..4150b3633f77 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -1915,6 +1915,10 @@ int ntfs_read_inode_mount(struct inode *vi) } /* 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 " -- 2.34.1