mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-05 22:12:16 +00:00
locks: fix locks_mandatory_locked to respect file-private locks
As Trond pointed out, you can currently deadlock yourself by setting a file-private lock on a file that requires mandatory locking and then trying to do I/O on it. Avoid this problem by plumbing some knowledge of file-private locks into the mandatory locking code. In order to do this, we must pass down information about the struct file that's being used to locks_verify_locked. Reported-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
90478939dc
commit
d7a06983a0
5 changed files with 18 additions and 17 deletions
|
@ -1912,6 +1912,11 @@ extern int current_umask(void);
|
|||
extern void ihold(struct inode * inode);
|
||||
extern void iput(struct inode *);
|
||||
|
||||
static inline struct inode *file_inode(struct file *f)
|
||||
{
|
||||
return f->f_inode;
|
||||
}
|
||||
|
||||
/* /sys/fs */
|
||||
extern struct kobject *fs_kobj;
|
||||
|
||||
|
@ -1921,7 +1926,7 @@ extern struct kobject *fs_kobj;
|
|||
#define FLOCK_VERIFY_WRITE 2
|
||||
|
||||
#ifdef CONFIG_FILE_LOCKING
|
||||
extern int locks_mandatory_locked(struct inode *);
|
||||
extern int locks_mandatory_locked(struct file *);
|
||||
extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);
|
||||
|
||||
/*
|
||||
|
@ -1944,10 +1949,10 @@ static inline int mandatory_lock(struct inode *ino)
|
|||
return IS_MANDLOCK(ino) && __mandatory_lock(ino);
|
||||
}
|
||||
|
||||
static inline int locks_verify_locked(struct inode *inode)
|
||||
static inline int locks_verify_locked(struct file *file)
|
||||
{
|
||||
if (mandatory_lock(inode))
|
||||
return locks_mandatory_locked(inode);
|
||||
if (mandatory_lock(file_inode(file)))
|
||||
return locks_mandatory_locked(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2008,7 +2013,7 @@ static inline int break_deleg_wait(struct inode **delegated_inode)
|
|||
}
|
||||
|
||||
#else /* !CONFIG_FILE_LOCKING */
|
||||
static inline int locks_mandatory_locked(struct inode *inode)
|
||||
static inline int locks_mandatory_locked(struct file *file)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -2030,7 +2035,7 @@ static inline int mandatory_lock(struct inode *inode)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int locks_verify_locked(struct inode *inode)
|
||||
static inline int locks_verify_locked(struct file *file)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -2297,11 +2302,6 @@ static inline bool execute_ok(struct inode *inode)
|
|||
return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);
|
||||
}
|
||||
|
||||
static inline struct inode *file_inode(struct file *f)
|
||||
{
|
||||
return f->f_inode;
|
||||
}
|
||||
|
||||
static inline void file_start_write(struct file *file)
|
||||
{
|
||||
if (!S_ISREG(file_inode(file)->i_mode))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue