From 3df638971f448d77807656d86f6dbc927c0e7fa9 Mon Sep 17 00:00:00 2001 From: guohao15 Date: Thu, 1 Feb 2024 16:45:41 +0800 Subject: [PATCH] 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 --- 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 #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; }