Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3122180pxv; Sun, 27 Jun 2021 19:46:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd+JzkTcCLJD7fQM6IHzBwFLQ8TYVohtcINdgDLeqYMr0UcF1Lmty4B/ImGZTZhPtrrHiu X-Received: by 2002:a92:1944:: with SMTP id e4mr16132835ilm.186.1624848406985; Sun, 27 Jun 2021 19:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624848406; cv=none; d=google.com; s=arc-20160816; b=GX1En0yYua0ZviAZtwOi69vV0uRgJS699G7dxFpWMncTiPL0/+2NqxMF0xUihQsYhB ucKRSKGGX1Lpby2VpGtwg7VnJV+mbwZsM/V+TZZNCtpJn9Lh52rFh6+WbF9IyPxJrPH2 sen3HKupHcW2MmGcawHYjfyCDGG+MCuzHeBZ43hMpBw5cE8fKAWY80jIp5L3jaXVzSJh oshZfngcRIRIAwxyIaSLWP7N4hapaH5GezLY6xv9xFPyT2T1i7MheezBp+288DLw18yf B69i10rcHUIbZVXN4E/jO1SVYdEKNT4cIqcpWOt3tsulJCffzr6eey51KbSrnScv3V1z 0g0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=/ZglMk5xEV7kqPnzl923s5w51WPieL3sLq9YmzBcALE=; b=w9BlALmeMSIks0WIHrrjYZAeWddWMUMUZSrYP9gB/+tSVpSlMI6YgUv4L1VzWud8b8 LiL/+9iBb8BRwgQX6PgPyfirqviN7Qmjx/M18KjD4R3PQLKZ/0iKqrwXmdYjiiiKo08e w3xzi2JC7LMGrUw4u8hRLJwHd9ALwvB412oc/O97zBi02yDtRFjZmj6KlJ799CZIirFW tnCwI6EgyY4CsQ+8EQSNZV0lJ6EJgk/T4mFf9OD3Y40UCugvaKxWPZ1SJL5pnnob44wD EQbt8ZMilrIOlw2MPTea6bXHTgPrDoFeX4oRuNsPQKcbKm5BmqwKXLNkps2joOSQqM2Z qJXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nUlOpiZd; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d198si15688658jac.70.2021.06.27.19.46.34; Sun, 27 Jun 2021 19:46:46 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nUlOpiZd; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231958AbhF1CsV (ORCPT + 99 others); Sun, 27 Jun 2021 22:48:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231678AbhF1CsU (ORCPT ); Sun, 27 Jun 2021 22:48:20 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1808EC061574 for ; Sun, 27 Jun 2021 19:45:56 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id h4so14137117pgp.5 for ; Sun, 27 Jun 2021 19:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=/ZglMk5xEV7kqPnzl923s5w51WPieL3sLq9YmzBcALE=; b=nUlOpiZdsURZNX3nXwrPK+lpBucURq3MdKAQtTyUnwKnkg7GvNT0HpVWB7Npvqk0lc J2yelxl+xiSaTC4As+derq954XeTRGPPldSVUofYHA3gs4bIdr3vQy+EomVFHj2kDaIh i01MYeGTLmrGifrVCvEetNzpWtfrEjRTYByTWGhhw9BA5LU3f6BagH91yjHD8+lV35in 7Q2krdV5Dre6o1fpocAdU1Az4ghMdA3aghNV9uau6s2kR8QO2gaZX+q7px9+SNDp46uJ tBGXas+0+fckhDeVeWzEgRzwuDu3msk/F6LzKeSp+1Ct825R41NfphxwazxJCYTSpnHg 3TmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/ZglMk5xEV7kqPnzl923s5w51WPieL3sLq9YmzBcALE=; b=Pcy654KW2zdfCNaSOz/ny76Ea0wd4UVHdx1ziYT+1mOPysF5OdbxmhQpZIf73ZcM// HrhcnBzTcT6uHqlddEY1W8539V2RAhE6OeuHTQ2NdrICpENthg7YgSldqPRr+YZrXEsQ N8McR30aT3jB/81KgAz1/1EaUQgHW1rN4o0hFjujmUmSNohXgehJiUBSr56LV7Dwrdjz J486YOnfQ+Z53H2r8xliYvvNUKQ9H4/YFvzFkFJs0RXielKzvo+VhEDW2mif/K4kW2Nd Ox9Fe4cAXAtHTLhJDWOtX4rJ8lExNsONgceUmiKkG6MoMU7EH/YS3bAs/rAwLC+ULSZ9 lJiA== X-Gm-Message-State: AOAM530n+cdmFwpdPQpnWDEnD0aD58jSzdPQIEmkb30KseR2OZ53SSsr PRHLx3eAMu1aednyPh6ktxY= X-Received: by 2002:a63:1841:: with SMTP id 1mr11515809pgy.377.1624848355530; Sun, 27 Jun 2021 19:45:55 -0700 (PDT) Received: from [192.168.1.237] ([118.200.190.93]) by smtp.gmail.com with ESMTPSA id n127sm1472443pga.58.2021.06.27.19.45.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 27 Jun 2021 19:45:54 -0700 (PDT) Subject: Re: [PATCH] ntfs: Fix validity check for file name attribute To: anton@tuxera.com 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 References: <20210614050540.289494-1-desmondcheongzx@gmail.com> From: Desmond Cheong Zhi Xi Message-ID: Date: Mon, 28 Jun 2021 10:45:51 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210614050540.289494-1-desmondcheongzx@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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