From abec971f7c42d118d4d841995afc1ccf629296cc Mon Sep 17 00:00:00 2001 From: Mark Poliakov Date: Fri, 30 Apr 2021 01:15:20 +0300 Subject: [PATCH] fs: check access for unlinkat() --- fs/vfs_ops.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/vfs_ops.c b/fs/vfs_ops.c index f1bd35f..4d1cdb3 100644 --- a/fs/vfs_ops.c +++ b/fs/vfs_ops.c @@ -341,6 +341,12 @@ int vfs_unlinkat(struct vfs_ioctx *ctx, struct vnode *at, const char *pathname, } } + _assert(node->parent != NULL); + // Must have write access to remove entries + if ((res = vfs_access_node(ctx, node->parent, W_OK)) != 0) { + return res; + } + if ((res = node->op->unlink(node)) != 0) { return res; }