diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c index a91d1233..6e5170a8 100644 --- a/src/lowntfs-3g.c +++ b/src/lowntfs-3g.c @@ -2147,6 +2147,11 @@ static int ntfs_fuse_create(fuse_req_t req, fuse_ino_t parent, const char *name, res = -errno; goto exit; } + /* Deny creating into $Extend */ + if (parent == FILE_Extend) { + res = -EPERM; + goto exit; + } /* Open parent directory. */ dir_ni = ntfs_inode_open(ctx->vol, INODE(parent)); if (!dir_ni) { @@ -2438,6 +2443,11 @@ static int ntfs_fuse_rm(fuse_req_t req, fuse_ino_t parent, const char *name, struct SECURITY_CONTEXT security; #endif + /* Deny removing from $Extend */ + if (parent == FILE_Extend) { + res = -EPERM; + goto exit; + } /* Open parent directory. */ dir_ni = ntfs_inode_open(ctx->vol, INODE(parent)); if (!dir_ni) { diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index 702d6765..68cfcb3d 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -1945,9 +1945,12 @@ static int ntfs_fuse_create(const char *org_path, mode_t typemode, dev_t dev, /* Open parent directory. */ *--name = 0; dir_ni = ntfs_pathname_to_inode(ctx->vol, NULL, dir_path); - if (!dir_ni) { + /* Deny creating files in $Extend */ + if (!dir_ni || (dir_ni->mft_no == FILE_Extend)) { free(path); res = -errno; + if (dir_ni->mft_no == FILE_Extend) + res = -EPERM; goto exit; } #if !KERNELPERMS | (POSIXACLS & !KERNELACLS) @@ -2290,8 +2293,11 @@ static int ntfs_fuse_rm(const char *org_path) /* Open parent directory. */ *--name = 0; dir_ni = ntfs_pathname_to_inode(ctx->vol, NULL, path); - if (!dir_ni) { + /* deny unlinking metadata files from $Extend */ + if (!dir_ni || (dir_ni->mft_no == FILE_Extend)) { res = -errno; + if (dir_ni->mft_no == FILE_Extend) + res = -EPERM; goto exit; }