Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1005750lqt; Fri, 7 Jun 2024 05:39:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVgrU4IywgaCeG6+Mb8EOr0tnvWpX73O1qczylmBa4j5Gn4MSL4EtVt6hiW+V8CdUPwgS24wi9L/ciYjz6hMILP+iqzc+QbZ2NDZ/tatA== X-Google-Smtp-Source: AGHT+IEfHuRkpKSQxLKRS2Fbe21suKVFy/ytzXvDcQ3DcIMmstKD/OdyHEJ83ifDN4xfVUsMv2SP X-Received: by 2002:aa7:88d4:0:b0:702:8b18:9fc3 with SMTP id d2e1a72fcca58-7040c680d12mr2422330b3a.15.1717763951378; Fri, 07 Jun 2024 05:39:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717763951; cv=pass; d=google.com; s=arc-20160816; b=LgVZ0oL4Kwy9Wy+eUtwuz3okF0MGK7ki4aY2My0yQ0teBGUvWJYi7RvRr4VURNnl1y 839+SUQsVMn9AxS/8015Ntn0+ERukc+nb7uliPf8nSsJYbOPYGqeixYaoF2PNwytjmSA 2DGZleKejJZvUBf/l+FWbtbFoUW1qzLXAjgmwZMmBNxOSvk1laLGkNeGT1TWIkJpooCw Zf2Lhi0XtpzIlKhjB+qt4hY5NumpHtdW8qiRzBrKyrKTWWF29s5t5HlLtwDLmDLI4P8r vKHlhw0t20fZvRGBgc559FsJ3AzRz7yLbwghZxWjWds39YktBPG83vpWT6ryGzQh/iLW Juhg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ELH+G0Zm1pE88bJbUOfJO5YDVH2GIcvzQWiyltb4lKk=; fh=xoZo938iZo6Zo9BQRi1y1Y/2pdszedQYQQiMhZQzvOk=; b=wEID9+D9j21w3CF6mDdUsl1b9ARbo609irIAhoxmMhyz/GTwnrpgQ5pyPeCesTfbQx dz4kVfBKmIV1j6aM9zIhzuySe7UwVKOrsZE1RmaKobfPgxUf2NIXXhYSrdEBKjT8WzQz 3h7YO7af0i8ABJ3OixYV6k0OHZ0aVfSgKGHrsByFjiV6GZybv52uRITWd08wCdGV1ya2 fmQdtpQQvh+3bsHGriEwABi+v1Cm2FuXfYjukQ8OlVqPx3VGBUpSdUex+yQ+JovGwmZj oPQNju7Me7qhmMqa7CSiMGJTnmpkh/l5F2y4civlHrmlPSZhBl/2Axizp4gZtu3SwfYW E2Lg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=CIoVlQ5S; arc=pass (i=1 spf=pass spfdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dmarc=pass fromdomain=paragon-software.com); spf=pass (google.com: domain of linux-kernel+bounces-205996-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205996-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-7041b6a312bsi304769b3a.277.2024.06.07.05.39.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 05:39:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205996-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=CIoVlQ5S; arc=pass (i=1 spf=pass spfdomain=paragon-software.com dkim=pass dkdomain=paragon-software.com dmarc=pass fromdomain=paragon-software.com); spf=pass (google.com: domain of linux-kernel+bounces-205996-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205996-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id F12A5B2262F for ; Fri, 7 Jun 2024 12:17:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 72EEE19068E; Fri, 7 Jun 2024 12:16:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b="CIoVlQ5S" Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E87A19308B; Fri, 7 Jun 2024 12:16:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.157.23.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717762577; cv=none; b=JFj63ht9wmt98L35DUY/KokyRpJJoADSKVTJZ/oPx5VcXP1dBzQVd67yMSTzH63DFG15UBnwEfyMirtIqpiGMv2s1hkvzZxuL4jZj5/f4qLgcJwlPSSvFQBOwLSVU7wIj0FIXWnWteKjRTr+cce+mbRKL0iBK4YVyNlGn/YAAIA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717762577; c=relaxed/simple; bh=lv2mztteK+Og30mLyHgcvpRF65hdo9t8lchl0OiTG0s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EUts1vDjs7tsmtXvOeQbj9m/ZhB5X0PmFj5iAPFMZAUoKISp41MqeH8e5MmOY7atO5ZZNGKzZuSJkkreV0biJIgKI+KDzO60o56U8vbvLJiTo518+ackKxfYYER95BGycbYdf1gz6Lo3vxsO/V/kWHHSwjje8uw5ivV4ZU/yy20= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com; spf=pass smtp.mailfrom=paragon-software.com; dkim=pass (1024-bit key) header.d=paragon-software.com header.i=@paragon-software.com header.b=CIoVlQ5S; arc=none smtp.client-ip=35.157.23.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=paragon-software.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paragon-software.com 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 594F52119; Fri, 7 Jun 2024 12:08:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1717762100; bh=ELH+G0Zm1pE88bJbUOfJO5YDVH2GIcvzQWiyltb4lKk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=CIoVlQ5SWv62BE94OkmrDIbLfXCdcbiJI9TEf+/hfPr0wUZcYgpBKUed03WbSe7uY jFeGpdlcLZWIFfW13lmnWkQBPZNlQNm6Jg5ift76cCmcG94WJo/K31hqPw80sAyR3Y 7SBkBiyByXbDFIXlSEyRuWV9fyO4dmYY7ejV6C1M= Received: from ntfs3vm.paragon-software.com (192.168.211.95) 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; Fri, 7 Jun 2024 15:16:13 +0300 From: Konstantin Komarov To: CC: , , Konstantin Komarov Subject: [PATCH 08/18] fs/ntfs3: Fix attr_insert_range at end of file Date: Fri, 7 Jun 2024 15:15:38 +0300 Message-ID: <20240607121548.18818-9-almaz.alexandrovich@paragon-software.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240607121548.18818-1-almaz.alexandrovich@paragon-software.com> References: <20240607121548.18818-1-almaz.alexandrovich@paragon-software.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) If the offset is equal to or greater than the end of file, an error is returned. For such operations (i.e., inserting a hole at the end of file), ftruncate(2) should be used. Signed-off-by: Konstantin Komarov --- fs/ntfs3/attrib.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 0d13da5523b1..68d1c61fe3b5 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -2373,8 +2373,13 @@ int attr_insert_range(struct ntfs_inode *ni, u64 vbo, u64 bytes) mask = (sbi->cluster_size << attr_b->nres.c_unit) - 1; } - if (vbo > data_size) { - /* Insert range after the file size is not allowed. */ + if (vbo >= data_size) { + /* + * Insert range after the file size is not allowed. + * If the offset is equal to or greater than the end of + * file, an error is returned. For such operations (i.e., inserting + * a hole at the end of file), ftruncate(2) should be used. + */ return -EINVAL; } -- 2.34.1