Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp910267pxb; Wed, 6 Apr 2022 04:02:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfmE+iIONG/Ramwp5EGbJKcqCqIqLf1qTepcH0smdffvxf+YTxyCAVoieHMwCHzWZTtZxT X-Received: by 2002:a05:6602:3281:b0:648:d45d:22e with SMTP id d1-20020a056602328100b00648d45d022emr3692556ioz.7.1649242951395; Wed, 06 Apr 2022 04:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649242951; cv=none; d=google.com; s=arc-20160816; b=lJE+h/W3lcarc9fHypxCYVnXdNyTIiDyDKIztdBBhZeEnSc6T59/IrmRHvN8h7J4s8 b2Vpo3aSHosxtHJOnC+3AhHdcMbZEFtGwdOni69hdcZKgPgwQvJgWFPPG/0YK9kgpWZ7 xMgDIF2ReYkLRAUibMSUx/FtSlaxEcjvT2UrIOs8TkV4sRYS6vSmLzYqwtk+ZrxK2Wdh +FEA5yq/B3djzZJBKHLa05sc0+NQ/HDnVwNaCDUxPYo7Btblkxqws5bCmjhtzDrhHIvI VsTUvyt5TM8KIkDg7p5wCiZ/l/ojMTwWm8ZFUrmM+BpsUC6jhqQtIdc8Ms/U9PnA14Hw ZkEg== 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=xrt2oo/bJSPSCGbuQxUiTNpdHH/aQDVUDXnAg9p2B2U=; b=J8LpKmddz+iNP69l3cSGxVKSymWCbaf2ofIzKlz0/rIzrf7zASk4k7FywlneMgo5mJ VXYq8N0q+WCQgT2IIK6ce1xAwEpgE4ZUavSMzdr/mHkC4WRu0F+lTx2UhXUXjQ5DlzWi Yt/ZSCiE4BVOlu6+6mUkFqd3j0Bt7ioIEv/X7lS5pABKnvau/v8lObRbrtCwhMLIbYDI kkWwEQMbWvjGkricAeb5RpxlGJM8AiNhRDKY/hXMRnliTcDW54Ds4ee5Pn/wy40RSfnI Gz40wpwmYAq7g/sbYPiOT72wDQFLQLVNDRrO9JTgiqhL/ei93kHQ8JMOBsyqWQBEclkC 6mng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dbw5IzyA; 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 b39-20020a05663838a700b003241aa56db9si80517jav.8.2022.04.06.04.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:02:31 -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=dbw5IzyA; 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 9A5A35B6DC0; Wed, 6 Apr 2022 02:25:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241953AbiDFAXx (ORCPT + 99 others); Tue, 5 Apr 2022 20:23:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351364AbiDEKCU (ORCPT ); Tue, 5 Apr 2022 06:02:20 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39F9F6CA7F; Tue, 5 Apr 2022 02:51:36 -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 sin.source.kernel.org (Postfix) with ESMTPS id 92E1CCE1C71; Tue, 5 Apr 2022 09:51:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A014AC385A2; Tue, 5 Apr 2022 09:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152293; bh=a3X9AFzHlu8+WSu53lKw4fxPUWErvt/B1kO6xdYwI7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dbw5IzyAiowIFAzaQ+IZ0bpUNQDol2rOkkDjD2ijL8JvKWPmfLbcQQA1fSyy80OYo b1epaYdB05/fyzLpYiaW46u9XIIjuFoO6j5ONHag8zsF+6omBc71P4P6NH/srcJ4bV 3YG9cvmfRfSswZ6Eqrfjrw8dB3tFDpdlWH3jOgtI= 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 5.15 724/913] ntfs: add sanity check on allocation size Date: Tue, 5 Apr 2022 09:29:46 +0200 Message-Id: <20220405070401.533638720@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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.0 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,T_SCC_BODY_TEXT_LINE autolearn=no 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 4474adb393ca..517b71c73aa9 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -1881,6 +1881,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