Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp657447pxb; Tue, 5 Apr 2022 17:35:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhJMrTGCU21YG85HyUgGRBoE83YFFXykbZR76/figCbIPlyuaJjx8l2bMZy5FYosFBjuMV X-Received: by 2002:a17:906:730e:b0:6e0:2ad8:12c8 with SMTP id di14-20020a170906730e00b006e02ad812c8mr5818407ejc.623.1649205333613; Tue, 05 Apr 2022 17:35:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649205333; cv=none; d=google.com; s=arc-20160816; b=Ee5qOr8xRksKTasphF924MD2lI8tLokX43jEIzwIJF8+/No6oJwo6bQ/T56C9KMd9Z S0Kkip+gAa5ITvLBGXOlHTklo9e5n6U/SdyxOV39RnTqB16mTGkFM9MyN5uX9QGbRCgV ek/iaP6iAfXK9g6fLcCPqeaPX19kh66GcWP+6dCyMUq/00mgxm9ZmDfF7VYw+0x29i/w cEGfYBoZ8gkFXp6PAnA5mH8yMudUi+oLNgQVvDz1Ngs+5uh7mrKNpRQz1bP6NQg4alNt nT/FoGhB20Tteu1n/rkKForzB4uatks7YXoEZVmBJ9naBc7yJ4jOdPNNlvsNtAFC+Fph rIyQ== 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=A9/7/141o3jJUokIlxShlRjYM4Quw465Ov9glhzWb52Zs3EKzgoMrfG1BsucvKcne4 MT6RobGnYlTrg2rqrj2ZDeO+4VXesVUQHTeWKJHaMx/Xo9a7T0I3v7YxJsgffmveNOK2 GA6jJm0ZGzhWEygbZowmH/CasHC8Scfyqidg79jZg19EoF0ltQrAlvV8o0lGsN26Mngi xPdgg7Nufg6OsPNTm2f32ustuC5pDeFcNOW7+N7ifYhjoPFxr4yISq8FvYvgo1Azjdeb YbTBdBz2uTUJuZx88Acw860skGXQoU3/JMXtU3/n7xxrn/CCjUACMQEJCplYKHom/mjl gmkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UW92J+oD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a056402084f00b004198b4add36si13304002edz.604.2022.04.05.17.35.09; Tue, 05 Apr 2022 17:35:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UW92J+oD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390509AbiDENmQ (ORCPT + 99 others); Tue, 5 Apr 2022 09:42:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345235AbiDEJWW (ORCPT ); Tue, 5 Apr 2022 05:22:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 293E62A726; Tue, 5 Apr 2022 02:09:48 -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 8A078B81A22; Tue, 5 Apr 2022 09:09:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6C8EC385A0; Tue, 5 Apr 2022 09:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149785; bh=a3X9AFzHlu8+WSu53lKw4fxPUWErvt/B1kO6xdYwI7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UW92J+oDxrW2ONOSE52ob5AhL71QMbCjwWn6p7LHJMLxeykMO8SlvbXMfvoPgqLPd VvSP0RX0rFapKTRwUwfpv9gLpeZ2GNeE30P7JlQbmOhJD3bFc7upUj2da9mYxgOx8G QKX7eALckNG3IUax/mycU6Wr192ZXmA/DH08m8jg= 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.16 0802/1017] ntfs: add sanity check on allocation size Date: Tue, 5 Apr 2022 09:28:35 +0200 Message-Id: <20220405070418.055812793@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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