Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3355068pxv; Mon, 28 Jun 2021 02:46:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXC6KGYtG6NzdbtNeskioaDuvyi7crmEtuf/bUaR6gzMAebzBZkrTLBu5RlYax281eLOoP X-Received: by 2002:a05:6e02:1be3:: with SMTP id y3mr11065674ilv.142.1624873574803; Mon, 28 Jun 2021 02:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624873574; cv=none; d=google.com; s=arc-20160816; b=DW6xjTnAddzOXD2OPtBDhiuloVliaLvyGysFUi+4dmO5i6wbd1ZDhvafAtHQUSl1vC qsTW0uray077eUADNgCKOc4CE1FZJVixhW3L3aiBI4FF5crOGVTm+nmwwmQfWRbU/q37 OzJFPXf5pweAdDJ+fyrqQcYtNSe8wXOgM0KIJ1jV4rjhrj0g0rzslmB0kqT5yAOuxR6y dxdsrWlael5DUoKJe96m6cTQZ8vfHWxDkFXhuVvpg/d6Wij0XHLIM+12rfhxYg5rgek8 HuEYzi7pvRcI5TQ1g0Wv8cxgXJYA4f6EFPOtVv1G0Htwp4GxQm9zYAlpkVyGzseb/RnE kpOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from; bh=WVLIvvqGOEMaEEXWRhb7EiVrxcwna1hGhChoaHCcxDk=; b=wz3XBNQkAG6yIJ9wHYYhCwIZYMpjgfy19WOu9J7kri8Jc72I+Z2UoHJ502KykjfrIi gAS75N4pXQ362+aY1Mlb2P+lzeFKzeusT5qrqt/sMBR80JjiGkBiodC12vqnLEZ81Hj0 1rjaaPr2Iir5r0dRNfdgevhR5qO1PWupur1mqh4Wv+lmAvyy4cZR/HzOfUF2A3fdipyn EfuW2PXS+5n2eVD5tRg1Bc2wvXfewR3iQNnsNMvFhYsu4HEgdpYZxvRJkEXtE6l6/V7A 2SkqUGyyW4UwRR/d4lwsM43Cq/ZJ4eGCWCjZizKyv7vAkhKjLXObG9GClGu1yBtVxuIo kL5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x99si16424402jah.122.2021.06.28.02.46.02; Mon, 28 Jun 2021 02:46:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232559AbhF1Jp6 convert rfc822-to-8bit (ORCPT + 99 others); Mon, 28 Jun 2021 05:45:58 -0400 Received: from mgw-02.mpynet.fi ([82.197.21.91]:50160 "EHLO mgw-02.mpynet.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232552AbhF1Jp5 (ORCPT ); Mon, 28 Jun 2021 05:45:57 -0400 Received: from pps.filterd (mgw-02.mpynet.fi [127.0.0.1]) by mgw-02.mpynet.fi (8.16.0.43/8.16.0.43) with SMTP id 15S9MlX9115831; Mon, 28 Jun 2021 12:22:55 +0300 Received: from ex13.tuxera.com (ex13.tuxera.com [178.16.184.72]) by mgw-02.mpynet.fi with ESMTP id 39f9xh82u4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 28 Jun 2021 12:22:55 +0300 Received: from tuxera-exch.ad.tuxera.com (10.20.48.11) by tuxera-exch.ad.tuxera.com (10.20.48.11) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 28 Jun 2021 12:22:54 +0300 Received: from tuxera-exch.ad.tuxera.com ([fe80::552a:f9f0:68c3:d789]) by tuxera-exch.ad.tuxera.com ([fe80::552a:f9f0:68c3:d789%12]) with mapi id 15.00.1497.018; Mon, 28 Jun 2021 12:22:54 +0300 From: Anton Altaparmakov To: Desmond Cheong Zhi Xi CC: "linux-ntfs-dev@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" , "skhan@linuxfoundation.org" , "gregkh@linuxfoundation.org" , "linux-kernel-mentees@lists.linuxfoundation.org" , "syzbot+213ac8bb98f7f4420840@syzkaller.appspotmail.com" Subject: Re: [PATCH] ntfs: Fix validity check for file name attribute Thread-Topic: [PATCH] ntfs: Fix validity check for file name attribute Thread-Index: AQHXYNr9xtdXtYfpBEGmty8mpcDGlasom2mAgABu7oA= Date: Mon, 28 Jun 2021 09:22:53 +0000 Message-ID: References: <20210614050540.289494-1-desmondcheongzx@gmail.com> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [86.134.197.70] Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Proofpoint-GUID: bS1-7ry4khBlczmL-2VT3CuiwRDQWvHJ X-Proofpoint-ORIG-GUID: bS1-7ry4khBlczmL-2VT3CuiwRDQWvHJ X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-06-28_07:2021-06-25,2021-06-28 signatures=0 X-Proofpoint-Spam-Details: rule=mpy_notspam policy=mpy score=0 phishscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106280065 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Thanks for the patch! Have asked Andrew to merge it. Best regards, Anton > On 28 Jun 2021, at 03:45, Desmond Cheong Zhi Xi wrote: > > On 14/6/21 1:05 pm, Desmond Cheong Zhi Xi wrote: >> When checking the file name attribute, we want to ensure that it fits >> within the bounds of ATTR_RECORD. To do this, we should check >> that (attr record + file name offset + file name length) < (attr >> record + attr record length). >> However, the original check did not include the file name offset in >> the calculation. This means that corrupted on-disk metadata might not >> caught by the incorrect file name check, and lead to an invalid memory >> access. >> An example can be seen in the crash report of a memory corruption >> error found by Syzbot: >> https://syzkaller.appspot.com/bug?id=a1a1e379b225812688566745c3e2f7242bffc246 >> Adding the file name offset to the validity check fixes this error and >> passes the Syzbot reproducer test. >> Reported-by: syzbot+213ac8bb98f7f4420840@syzkaller.appspotmail.com >> Tested-by: syzbot+213ac8bb98f7f4420840@syzkaller.appspotmail.com >> Signed-off-by: Desmond Cheong Zhi Xi >> --- >> fs/ntfs/inode.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c >> index f5c058b3192c..4474adb393ca 100644 >> --- a/fs/ntfs/inode.c >> +++ b/fs/ntfs/inode.c >> @@ -477,7 +477,7 @@ static int ntfs_is_extended_system_file(ntfs_attr_search_ctx *ctx) >> } >> file_name_attr = (FILE_NAME_ATTR*)((u8*)attr + >> le16_to_cpu(attr->data.resident.value_offset)); >> - p2 = (u8*)attr + le32_to_cpu(attr->data.resident.value_length); >> + p2 = (u8 *)file_name_attr + le32_to_cpu(attr->data.resident.value_length); >> if (p2 < (u8*)attr || p2 > p) >> goto err_corrupt_attr; >> /* This attribute is ok, but is it in the $Extend directory? */ > > Hi Anton, > > Any chance to review this patch? > > Best wishes, > Desmond -- Anton Altaparmakov (replace at with @) Lead in File System Development, Tuxera Inc., http://www.tuxera.com/ Linux NTFS maintainer