Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2022146rwl; Mon, 26 Dec 2022 07:52:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXuUJT10LyUMAWUvsueySlrUxYf31MYHAkx/+s1lQJBZjQ52ASmYHFlfxqoagHyPMQAXsGUo X-Received: by 2002:a17:90b:124b:b0:220:7147:c981 with SMTP id gx11-20020a17090b124b00b002207147c981mr35495146pjb.29.1672069978542; Mon, 26 Dec 2022 07:52:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672069978; cv=none; d=google.com; s=arc-20160816; b=HaAHBi9TUe7r4Ism9piGe0t6UVIbq1vSNeCO7MuiwyIFjlz/dVGJc+iLE5/+R2f9ot EbYC8RAS8PfZbP25Ox9UuwoXa1fvuUlENVdjunZs3yIv+d7MuFZIry2T5vRPNCqEdWGF 0yISSalpxtW2ilPUQziDyrBdAll+gTDxlYLwddHlYYWNlnPLQagoowUlGm2l3g4wOyvS j8zHshglHFoKz7mpQCJGKGzTC+26lhg+anzUOVO4gJP/jdTvVsqC9g1ozxSD1j4WkW4c fhP/UnoSXVeudf4urSiJS+Yhg9kgjDZ7uyugmStra1d4wELUtD35tkJptqekn++Dp3nU czuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=WT35hMT9jxm/IKBWPqha2GgcIHPteMyxzD8d33LTOfg=; b=IMuMhcfcvGiMmYMuqEE2Srtn7yv8PLkFzIx/Cwzfpy0RblF2k5pJAbCTnB+yMlHTXy WEHSKaHxQL0SgDLUd54u/77yXx13ykg8TNMNs3TET8EMNwp9nKeKrqbxDJNJSihCAOoX TAI/JG4HzKdwUXLsgcLet26509SEbeKhbhvHklHQhDIUDMgtMxH1S4AKGNyycttVJQoI UY4Ua2uEvpGGY95xXKh6MOeGqKf/uVtP2WW/hp/6IAMaQ3axMDRtgf84Yv5nS8fbwCN6 cxLSgoPn94L0HPUQfCC2ByzhkpclIhpbUTfcVNJ91Aa/OE1LMv4DI6FLabp5n8MrACdv yh9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=Ank7OaIW; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f8-20020a6547c8000000b004785ae0770dsi12403771pgs.327.2022.12.26.07.52.49; Mon, 26 Dec 2022 07:52:58 -0800 (PST) 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=@paragon-software.com header.s=mail header.b=Ank7OaIW; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232098AbiLZPc4 (ORCPT + 67 others); Mon, 26 Dec 2022 10:32:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbiLZPcy (ORCPT ); Mon, 26 Dec 2022 10:32:54 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F9B3135 for ; Mon, 26 Dec 2022 07:32:54 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 066941B7; Mon, 26 Dec 2022 15:29:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1672068563; bh=WT35hMT9jxm/IKBWPqha2GgcIHPteMyxzD8d33LTOfg=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=Ank7OaIWU+Nt6zYsbdvQ7WhrLjhQkfxE48OhiX1xNQt0vwJATLuvbxwHgLRqZihKf Uos3vniVdQc9dLyH+tCN15pm4+xMz0APXAmNTXFbuPcP3rkyb9nNoxoJI5NSbRqY80 1TrbWKeUciT/ThC2RyrAfPWu9H44E7JbyH4dSsas= Received: from [192.168.211.153] (192.168.211.153) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Mon, 26 Dec 2022 18:32:51 +0300 Message-ID: Date: Mon, 26 Dec 2022 19:32:50 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH v2] fs/ntfs3: Validate attribute data and valid sizes Content-Language: en-US To: Abdun Nihaal CC: , , , , References: <20221114115314.183818-1-abdun.nihaal@gmail.com> From: Konstantin Komarov In-Reply-To: <20221114115314.183818-1-abdun.nihaal@gmail.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.211.153] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS 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 On 14.11.2022 15:53, Abdun Nihaal wrote: > The data_size and valid_size fields of non resident attributes should be > less than the its alloc_size field, but this is not checked in > ntfs_read_mft function. > > Syzbot reports a allocation order warning due to a large unchecked value > of data_size getting assigned to inode->i_size which is then passed to > kcalloc. > > Add sanity check for ensuring that the data_size and valid_size fields > are not larger than alloc_size field. > > Link: https://syzkaller.appspot.com/bug?extid=fa4648a5446460b7b963 > Reported-and-tested-by: syzbot+fa4648a5446460b7b963@syzkaller.appspotmail.com > Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block") > Signed-off-by: Abdun Nihaal > --- > > Please apply this instead of my previous patch. > > Changes in v2: > Correct the format used for the Fixes tag. > > fs/ntfs3/inode.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c > index 970bb7c357c7..763dd982a43a 100644 > --- a/fs/ntfs3/inode.c > +++ b/fs/ntfs3/inode.c > @@ -132,6 +132,13 @@ static struct inode *ntfs_read_mft(struct inode *inode, > if (le16_to_cpu(attr->name_off) + attr->name_len > asize) > goto out; > > + if (attr->non_res) { > + t64 = le64_to_cpu(attr->nres.alloc_size); > + if (le64_to_cpu(attr->nres.data_size) > t64 || > + le64_to_cpu(attr->nres.valid_size) > t64) > + goto out; > + } > + > switch (attr->type) { > case ATTR_STD: > if (attr->non_res || Hello. Your patch has been already applied.