This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 3df638971f448d77807656d86f6dbc927c0e7fa9 Author: guohao15 <[email protected]> AuthorDate: Thu Feb 1 16:45:41 2024 +0800 notify:do not noitfy when in signal context Some signal handler may opreate files, that will cause deadlock when the thread holding file system lock Signed-off-by: guohao15 <[email protected]> --- fs/notify/inotify.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/notify/inotify.c b/fs/notify/inotify.c index f74d15a087..b54226cdb8 100644 --- a/fs/notify/inotify.c +++ b/fs/notify/inotify.c @@ -40,6 +40,7 @@ #include <libgen.h> #include "inode/inode.h" +#include "sched/sched.h" /**************************************************************************** * Pre-processor Definitions @@ -879,11 +880,14 @@ static void notify_queue_path_event(FAR const char *path, uint32_t mask) static int notify_check_inode(FAR struct file *filep) { + FAR struct tcb_s *tcb = this_task(); + /* We only apply notify on mount points (f_inode won't be NULL). */ - if (!INODE_IS_MOUNTPT(filep->f_inode) && + if ((tcb->flags & TCB_FLAG_SIGNAL_ACTION) || + (!INODE_IS_MOUNTPT(filep->f_inode) && !INODE_IS_PSEUDODIR(filep->f_inode) && - !INODE_IS_DRIVER(filep->f_inode)) + !INODE_IS_DRIVER(filep->f_inode))) { return -EBADF; }
