ClangBuiltLinux / thread-safety-analysis

A research project into applying Clang's Thread Safety Analysis to the Linux Kernel
Other
6 stars 0 forks source link

fs/dcache.c: conditional unlocking in dput #119

Open himanshujha199640 opened 5 years ago

himanshujha199640 commented 5 years ago
/home/himanshu/clang-thread-safety-analysis/fs/dcache.c:856:4: warning: releasing mutex '->d_lockref...lock' that was not held [-Wthread-safety-analysis]
                        spin_unlock(&dentry->d_lock);
                        ^

Interestingly, I don't understand why don't we get a warning like: Mutex is not locked on every path through here.. ?

himanshujha199640 commented 5 years ago

Note: marking the function with __releases_spinlock() produces weird warnings(which seems reasonable because we are annotating it wrong):

/home/himanshu/clang-thread-safety-analysis/fs/dcache.c:862:1: warning: mutex '->d_lockref...lock' is not held on every path through
      here [-Wthread-safety-analysis]
}
^
/home/himanshu/clang-thread-safety-analysis/fs/dcache.c:841:34: note: mutex acquired here
void dput(struct dentry *dentry) __releases_spinlock(dentry->d_lock)
                                 ^
/home/himanshu/clang-thread-safety-analysis/include/linux/compiler_attributes.h:264:50: note: expanded from macro '__releases_spinlock'
# define __releases_spinlock(x)                 __attribute__((release_capability(x)))
                                                               ^