Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selinux: Use simple_start_creating() / simple_done_creating()

Instead of explicitly locking the parent and performing a lookup in
selinux, use simple_start_creating(), and then use
simple_done_creating() to unlock.

This extends the region that the directory is locked for, and also
performs a lookup.
The lock extension is of no real consequence.
The lookup uses simple_lookup() and so always succeeds. Thus when
d_make_persistent() is called the dentry will already be hashed.
d_make_persistent() handles this case.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Acked-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: NeilBrown <neil@brown.name>
Link: https://patch.msgid.link/20260224222542.3458677-7-neilb@ownmail.net
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

NeilBrown and committed by
Christian Brauner
c4573e18 5c6c7ae9

+8 -9
+8 -9
security/selinux/selinuxfs.c
··· 1931 1931 static struct dentry *sel_make_swapover_dir(struct super_block *sb, 1932 1932 unsigned long *ino) 1933 1933 { 1934 - struct dentry *dentry = d_alloc_name(sb->s_root, ".swapover"); 1934 + struct dentry *dentry; 1935 1935 struct inode *inode; 1936 1936 1937 - if (!dentry) 1937 + inode = sel_make_inode(sb, S_IFDIR); 1938 + if (!inode) 1938 1939 return ERR_PTR(-ENOMEM); 1939 1940 1940 - inode = sel_make_inode(sb, S_IFDIR); 1941 - if (!inode) { 1942 - dput(dentry); 1943 - return ERR_PTR(-ENOMEM); 1941 + dentry = simple_start_creating(sb->s_root, ".swapover"); 1942 + if (IS_ERR(dentry)) { 1943 + iput(inode); 1944 + return dentry; 1944 1945 } 1945 1946 1946 1947 inode->i_op = &swapover_dir_inode_operations; 1947 1948 inode->i_ino = ++(*ino); 1948 1949 /* directory inodes start off with i_nlink == 2 (for "." entry) */ 1949 1950 inc_nlink(inode); 1950 - inode_lock(sb->s_root->d_inode); 1951 1951 d_make_persistent(dentry, inode); 1952 1952 inc_nlink(sb->s_root->d_inode); 1953 - inode_unlock(sb->s_root->d_inode); 1954 - dput(dentry); 1953 + simple_done_creating(dentry); 1955 1954 return dentry; // borrowed 1956 1955 } 1957 1956