]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fs/ntfs3: Do not allow to change label if volume is read-only
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Mon, 25 Sep 2023 07:56:15 +0000 (10:56 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Nov 2023 13:08:58 +0000 (14:08 +0100)
[ Upstream commit e52dce610a2d53bf2b5e94a8843c71cb73a91ea5 ]

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

index d699819c70a14435b4294077d7cbce4cf4086b0f..32c5de569992933652dde501a5adec8eae328268 100644 (file)
@@ -498,7 +498,12 @@ static ssize_t ntfs3_label_write(struct file *file, const char __user *buffer,
        struct super_block *sb = pde_data(file_inode(file));
        struct ntfs_sb_info *sbi = sb->s_fs_info;
        ssize_t ret = count;
-       u8 *label = kmalloc(count, GFP_NOFS);
+       u8 *label;
+
+       if (sb_rdonly(sb))
+               return -EROFS;
+
+       label = kmalloc(count, GFP_NOFS);
 
        if (!label)
                return -ENOMEM;