Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp707234pxb; Thu, 2 Sep 2021 13:08:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRGYfWHL/u1HzvQEVZ4x4Oo/psY2l4FZNI0ryPKBzIKNMx8mSAzMb8Cawd1SE5XtIPCwwi X-Received: by 2002:a17:907:6289:: with SMTP id nd9mr5772902ejc.384.1630613337998; Thu, 02 Sep 2021 13:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630613337; cv=none; d=google.com; s=arc-20160816; b=hpskXLIL297M5XqlMP3Z7nydyCmEKdRAw9KLvvu379GPhFZw5Uki2RPD+IMdkdoOVq WQIqFIKN1S13utT1V0LxSESCAOQskhnwyPboMRKOGF9zKPEX1yYC3uHIL3aEdaCQbX/j 5bYrep97eYoalFdfqEL4TZK0BA5DUv2klPty7z0TuXl5cowI2YBNT209aFgb2kv7r90v Jg0EDkpr7s33fGfr2MJdgPSWeVuLljDemH9a+dayP2HzcVWwY4aCXQ8pmgwdlUjz6h78 boj/Qz0iZ/aSrcc3sOSoU6HFeJLQxz4muhmfnLwdZ0aa+PgM8Z7NYTWyl6Qx49BVe62a si9Q== 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=Ww11h+RqvvW0Iq61oMI/lISDSXkK62zLJ93tmQ65jEY=; b=RsHwyTIdo+bUgaLejP/QdgiPb1l6KdeSy5XhVnkNFYklaflQAEFlRRUablAPVCOyGU W0ilMY2tjbe7ADy/0nsW3hZzWUSj/gwMIaVawL62BFGGJui95/I9yY0QjCxnx66TXl9w NnEKEC+4Y+Yff5nuuhnxmq3gxdGGBRgywvQspqpXhvhOHrVaQWCxqGwG+yQFV4JizJH3 1xkHwSpewvVKTPjZ9mMFhbSBcQoW76I3NEoQuH3bNSXE5jbRXhL81/Tu8PU5BFWiZmeF LzXdjeTwC9YaGAcVL8oBvSj//qAIQWzdiylzYlmu2ceQJH5YH4qpaCQwFyRUZGLM0jVh 2EYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=jSVGSMhM; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds17si804769ejc.371.2021.09.02.13.08.31; Thu, 02 Sep 2021 13:08:57 -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=@paragon-software.com header.s=mail header.b=jSVGSMhM; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346129AbhIBQYr (ORCPT + 99 others); Thu, 2 Sep 2021 12:24:47 -0400 Received: from relayfre-01.paragon-software.com ([176.12.100.13]:46678 "EHLO relayfre-01.paragon-software.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345998AbhIBQYq (ORCPT ); Thu, 2 Sep 2021 12:24:46 -0400 Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id D5B5E1D99; Thu, 2 Sep 2021 19:23:46 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1630599826; bh=Ww11h+RqvvW0Iq61oMI/lISDSXkK62zLJ93tmQ65jEY=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=jSVGSMhMduReMykkJZ6OHHyRFffjSs2Qwxa3mZfSZMyStbaA5LrANd+o0+SOrv43/ x72czLV9plqMZYKAptKMtDJeIk17qrlgGHXwh7MncFAr7i5h2L0WAf0+XUNwUB8PBj m9zYDacpnrtp3POPJAj3TkOvLs1O3tLIqbUDnSDM= Received: from [192.168.211.59] (192.168.211.59) 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.2176.2; Thu, 2 Sep 2021 19:23:46 +0300 Subject: Re: [PATCH] fs/ntfs3: Fix integer overflow in ni_fiemap with fiemap_prep() To: Kari Argillander , Dan Carpenter CC: , References: <20210825182435.1367530-1-kari.argillander@gmail.com> From: Konstantin Komarov Message-ID: Date: Thu, 2 Sep 2021 19:23:46 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210825182435.1367530-1-kari.argillander@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.211.59] X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25.08.2021 21:24, Kari Argillander wrote: > Use fiemap_prep() to check valid flags. It also shrink request scope > (@len) to what the fs can actually handle. > > This address following Smatch static checker warning: > fs/ntfs3/frecord.c:1894 ni_fiemap() > warn: potential integer overflow from user 'vbo + len' > > Because fiemap_prep() shrinks @len this cannot happened anymore. > > Reported-by Dan Carpenter > Link: lore.kernel.org/ntfs3/20210825080440.GA17407@kili/ > > Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation") > Signed-off-by: Kari Argillander > --- > fs/ntfs3/file.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c > index 59344985c2e8..cb736701f2cc 100644 > --- a/fs/ntfs3/file.c > +++ b/fs/ntfs3/file.c > @@ -1210,8 +1210,9 @@ int ntfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > int err; > struct ntfs_inode *ni = ntfs_i(inode); > > - if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) > - return -EOPNOTSUPP; > + err = fiemap_prep(inode, fieinfo, start, &len, ~FIEMAP_FLAG_XATTR); > + if (err) > + return err; > > ni_lock(ni); > > Hello, Dan, Kari! Thanks for finding and fixing this issue. Applied patch.