From patchwork Wed Dec 6 15:13:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 174631 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4171511vqy; Wed, 6 Dec 2023 07:13:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IG+fZFaB7LDG54mPgrBmVhzLFbTuzwPzsG1DMlfqABnQ1pktcwWU+YBQGessut8IwW8/a3m X-Received: by 2002:a17:90b:4a8f:b0:286:b6bf:e6d5 with SMTP id lp15-20020a17090b4a8f00b00286b6bfe6d5mr792282pjb.14.1701875604024; Wed, 06 Dec 2023 07:13:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701875603; cv=none; d=google.com; s=arc-20160816; b=Ih7XbRzWic7iQCDO2cJoeSmsquF8JawRZ2PgKP7LNnzimrceLmWDz8x4evT2Q9Ig3c bZv4BujkT4w1lEsoSsa9qtiPNfQ9JfZHqD0abfN2FOXQLKcEUgb6kQXUWWc99a8j9mWA rmVhniBEhurGhtXOwhhnwblaBy52socBnQoWOtn1N4CC8zsoSZu2K6sGPI8vLSpb1Bqw uuRyLhCShr7Vvgeqkts6677dBtF1YI5ZRPz/dZo4wrjrJ9k5DLEyEmS0soeB78tqrDrJ qIblSxU4of2WdvQU3DPtboQ9MTGB5Ca/+gdjYBZ79N0SiHdzC41QstpqyRl5Yo+cJvSM Rv3A== 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:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=F097v/jB8ZR21e/O3vd36dCK4gneA3BrFHtMeimQuV4=; fh=P7I85FIabZcM8ojWdeG8ABpTZepe/Xtte9jKWDfUHBM=; b=NfJaSY9kkPdpFSmN+lBSLaWaiQfsLIPBqEFnMiFnJ/LjW2IHuJ0+vOB3wHlD/RF2RO RewGFcPLhhBAnDOP3FjhrcF5VfbJqcH1T9xlmp9YHpDycNvrKvNhohROh6UrOQp2xCQw rMsbaG01o/+HYvlH+fh/Mga/L6gWoQcrI6w9s2ex/Qz+Ch6wUANSWBF6fL8kc0I6n8Lv MpZVw6SJJSITNqk0s1qeVzGFIDwwG2m0ek+je1n8C2E9MT2dRyleqGyYc/Rcfy1wj1fh TG6jqsH7UF3rIzUc4VbEupLFjdsL3p2DpBQ+E0usiU64tRr4K6g2ZUmynqjjZoAXJ7bW 4k3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b="m3/oqph8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id f8-20020a17090ace0800b00285864ca8a0si2924758pju.180.2023.12.06.07.13.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:13:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b="m3/oqph8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 57BBE8030A19; Wed, 6 Dec 2023 07:13:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442399AbjLFPNN (ORCPT + 99 others); Wed, 6 Dec 2023 10:13:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379228AbjLFPNL (ORCPT ); Wed, 6 Dec 2023 10:13:11 -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 CF039DE; Wed, 6 Dec 2023 07:13:17 -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 903201E1A; Wed, 6 Dec 2023 15:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1701875211; bh=F097v/jB8ZR21e/O3vd36dCK4gneA3BrFHtMeimQuV4=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=m3/oqph84dOfSvsyEUrnjup2sI052twZlQVgqAS6UOH+jafuQ1FPCmz6Fu7lGEQQi 2/82ZDbxioT09DRo45akAqbUhutD4t5bbxSm44sL5MnKUhvjmAyx/0IIaHypmgn1vm OEh6DBzuauAM8FnZ1RUItM5m01Y3W9cCWxkOJYF0= Received: from [172.16.192.129] (192.168.211.144) 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; Wed, 6 Dec 2023 18:13:15 +0300 Message-ID: <89861d9e-f3a4-483d-b88d-4085dc2e0a8b@paragon-software.com> Date: Wed, 6 Dec 2023 18:13:15 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 11/16] fs/ntfs3: Drop suid and sgid bits as a part of fpunch Content-Language: en-US From: Konstantin Komarovc To: CC: , References: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> In-Reply-To: <00fd1558-fda5-421b-be43-7de69e32cb4e@paragon-software.com> X-Originating-IP: [192.168.211.144] 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=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:13:21 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784545913792543516 X-GMAIL-MSGID: 1784545913792543516 Signed-off-by: Konstantin Komarov ---  fs/ntfs3/file.c | 9 +++++++++  1 file changed, 9 insertions(+)          end_a = end & ~mask; @@ -524,6 +528,8 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)              ni_lock(ni);              err = attr_punch_hole(ni, vbo_a, end_a - vbo_a, NULL);              ni_unlock(ni); +            if (err) +                goto out;          }      } else if (mode & FALLOC_FL_COLLAPSE_RANGE) {          /* @@ -563,6 +569,8 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)          ni_lock(ni);          err = attr_insert_range(ni, vbo, len);          ni_unlock(ni); +        if (err) +            goto out;      } else {          /* Check new size. */          u8 cluster_bits = sbi->cluster_bits; @@ -639,6 +647,7 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)          }      } +ok:      err = file_modified(file);      if (err)          goto out; diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index bb80ce2eec2f..0ff5d3af2889 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -498,10 +498,14 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)          ni_lock(ni);          err = attr_punch_hole(ni, vbo, len, &frame_size);          ni_unlock(ni); +        if (!err) +            goto ok; +          if (err != E_NTFS_NOTALIGNED)              goto out;          /* Process not aligned punch. */ +        err = 0;          mask = frame_size - 1;          vbo_a = (vbo + mask) & ~mask;