]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fs/ntfs3: Drop suid and sgid bits as a part of fpunch
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Fri, 24 Nov 2023 09:17:46 +0000 (12:17 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Mar 2024 12:34:53 +0000 (13:34 +0100)
[ Upstream commit e50f9560b8168a625703a3e7fe1fde9fa53f0837 ]

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ntfs3/file.c

index 6e1c456c9ae7f1f7b25a509cfd4caf6384ee7312..5530b4cf1ee52aa1ffe5f415f59ee73b840bf462 100644 (file)
@@ -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;
                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;