@@ -533,7 +533,7 @@ static ssize_t ns_revision_read(struct file *file, char __user *buf,
533533 long last_read ;
534534 int avail ;
535535
536- mutex_lock (& rev -> ns -> lock );
536+ mutex_lock_nested (& rev -> ns -> lock , rev -> ns -> level );
537537 last_read = rev -> last_read ;
538538 if (last_read == rev -> ns -> revision ) {
539539 mutex_unlock (& rev -> ns -> lock );
@@ -543,7 +543,7 @@ static ssize_t ns_revision_read(struct file *file, char __user *buf,
543543 last_read !=
544544 READ_ONCE (rev -> ns -> revision )))
545545 return - ERESTARTSYS ;
546- mutex_lock (& rev -> ns -> lock );
546+ mutex_lock_nested (& rev -> ns -> lock , rev -> ns -> level );
547547 }
548548
549549 avail = sprintf (buffer , "%ld\n" , rev -> ns -> revision );
@@ -577,7 +577,7 @@ static unsigned int ns_revision_poll(struct file *file, poll_table *pt)
577577 unsigned int mask = 0 ;
578578
579579 if (rev ) {
580- mutex_lock (& rev -> ns -> lock );
580+ mutex_lock_nested (& rev -> ns -> lock , rev -> ns -> level );
581581 poll_wait (file , & rev -> ns -> wait , pt );
582582 if (rev -> last_read < rev -> ns -> revision )
583583 mask |= POLLIN | POLLRDNORM ;
@@ -1643,7 +1643,7 @@ static int ns_mkdir_op(struct inode *dir, struct dentry *dentry, umode_t mode)
16431643 */
16441644 inode_unlock (dir );
16451645 error = simple_pin_fs (& aafs_ops , & aafs_mnt , & aafs_count );
1646- mutex_lock (& parent -> lock );
1646+ mutex_lock_nested (& parent -> lock , parent -> level );
16471647 inode_lock_nested (dir , I_MUTEX_PARENT );
16481648 if (error )
16491649 goto out ;
@@ -1692,7 +1692,7 @@ static int ns_rmdir_op(struct inode *dir, struct dentry *dentry)
16921692 inode_unlock (dir );
16931693 inode_unlock (dentry -> d_inode );
16941694
1695- mutex_lock (& parent -> lock );
1695+ mutex_lock_nested (& parent -> lock , parent -> level );
16961696 ns = aa_get_ns (__aa_findn_ns (& parent -> sub_ns , dentry -> d_name .name ,
16971697 dentry -> d_name .len ));
16981698 if (!ns ) {
@@ -1747,7 +1747,7 @@ void __aafs_ns_rmdir(struct aa_ns *ns)
17471747 __aafs_profile_rmdir (child );
17481748
17491749 list_for_each_entry (sub , & ns -> sub_ns , base .list ) {
1750- mutex_lock (& sub -> lock );
1750+ mutex_lock_nested (& sub -> lock , sub -> level );
17511751 __aafs_ns_rmdir (sub );
17521752 mutex_unlock (& sub -> lock );
17531753 }
@@ -1877,7 +1877,7 @@ int __aafs_ns_mkdir(struct aa_ns *ns, struct dentry *parent, const char *name,
18771877
18781878 /* subnamespaces */
18791879 list_for_each_entry (sub , & ns -> sub_ns , base .list ) {
1880- mutex_lock (& sub -> lock );
1880+ mutex_lock_nested (& sub -> lock , sub -> level );
18811881 error = __aafs_ns_mkdir (sub , ns_subns_dir (ns ), NULL , NULL );
18821882 mutex_unlock (& sub -> lock );
18831883 if (error )
@@ -1921,7 +1921,7 @@ static struct aa_ns *__next_ns(struct aa_ns *root, struct aa_ns *ns)
19211921 /* is next namespace a child */
19221922 if (!list_empty (& ns -> sub_ns )) {
19231923 next = list_first_entry (& ns -> sub_ns , typeof (* ns ), base .list );
1924- mutex_lock (& next -> lock );
1924+ mutex_lock_nested (& next -> lock , next -> level );
19251925 return next ;
19261926 }
19271927
@@ -1931,7 +1931,7 @@ static struct aa_ns *__next_ns(struct aa_ns *root, struct aa_ns *ns)
19311931 mutex_unlock (& ns -> lock );
19321932 next = list_next_entry (ns , base .list );
19331933 if (!list_entry_is_head (next , & parent -> sub_ns , base .list )) {
1934- mutex_lock (& next -> lock );
1934+ mutex_lock_nested (& next -> lock , next -> level );
19351935 return next ;
19361936 }
19371937 ns = parent ;
@@ -2039,7 +2039,7 @@ static void *p_start(struct seq_file *f, loff_t *pos)
20392039 f -> private = root ;
20402040
20412041 /* find the first profile */
2042- mutex_lock (& root -> lock );
2042+ mutex_lock_nested (& root -> lock , root -> level );
20432043 profile = __first_profile (root , root );
20442044
20452045 /* skip to position */
@@ -2491,7 +2491,7 @@ static int __init aa_create_aafs(void)
24912491 ns_subrevision (root_ns ) = dent ;
24922492
24932493 /* policy tree referenced by magic policy symlink */
2494- mutex_lock (& root_ns -> lock );
2494+ mutex_lock_nested (& root_ns -> lock , root_ns -> level );
24952495 error = __aafs_ns_mkdir (root_ns , aafs_mnt -> mnt_root , ".policy" ,
24962496 aafs_mnt -> mnt_root );
24972497 mutex_unlock (& root_ns -> lock );
0 commit comments