From 4b6743591a524aeb00a263d9e4b37ad0c5451d90 Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Fri, 8 Apr 2022 12:06:17 +0800 Subject: [PATCH] fs/vfs: fix st_mode mask check The full mask for st_mode is 0177777 Now modify any file permissions in hostfs and all will fail --- fs/vfs/fs_chstat.c | 2 +- fs/vfs/fs_fchstat.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/vfs/fs_chstat.c b/fs/vfs/fs_chstat.c index 93c4db7e60..38c0fb44f8 100644 --- a/fs/vfs/fs_chstat.c +++ b/fs/vfs/fs_chstat.c @@ -118,7 +118,7 @@ static int chstat(FAR const char *path, /* Adjust and check buf and flags */ - if ((flags & CH_STAT_MODE) && (buf->st_mode & ~07777)) + if ((flags & CH_STAT_MODE) && (buf->st_mode & ~0177777)) { goto errout; } diff --git a/fs/vfs/fs_fchstat.c b/fs/vfs/fs_fchstat.c index df9a6b87d1..44d8306988 100644 --- a/fs/vfs/fs_fchstat.c +++ b/fs/vfs/fs_fchstat.c @@ -112,7 +112,7 @@ int file_fchstat(FAR struct file *filep, FAR struct stat *buf, int flags) /* Adjust and check buf and flags */ - if ((flags & CH_STAT_MODE) && (buf->st_mode & ~07777)) + if ((flags & CH_STAT_MODE) && (buf->st_mode & ~0177777)) { return -EINVAL; }