Skip to content

Commit 0e326df

Browse files
committed
selinux: various sparse fixes
When running the SELinux code through sparse, there are a handful of warnings. This patch resolves some of these warnings caused by "__rcu" mismatches. % make W=1 C=1 security/selinux/ Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 6bc1968 commit 0e326df

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

security/selinux/hooks.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,21 +2553,21 @@ static void selinux_bprm_committed_creds(struct linux_binprm *bprm)
25532553
if (rc) {
25542554
clear_itimer();
25552555

2556-
spin_lock_irq(&current->sighand->siglock);
2556+
spin_lock_irq(&unrcu_pointer(current->sighand)->siglock);
25572557
if (!fatal_signal_pending(current)) {
25582558
flush_sigqueue(&current->pending);
25592559
flush_sigqueue(&current->signal->shared_pending);
25602560
flush_signal_handlers(current, 1);
25612561
sigemptyset(&current->blocked);
25622562
recalc_sigpending();
25632563
}
2564-
spin_unlock_irq(&current->sighand->siglock);
2564+
spin_unlock_irq(&unrcu_pointer(current->sighand)->siglock);
25652565
}
25662566

25672567
/* Wake up the parent if it is waiting so that it can recheck
25682568
* wait permission to the new task SID. */
25692569
read_lock(&tasklist_lock);
2570-
__wake_up_parent(current, current->real_parent);
2570+
__wake_up_parent(current, unrcu_pointer(current->real_parent));
25712571
read_unlock(&tasklist_lock);
25722572
}
25732573

security/selinux/ibpkey.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static void sel_ib_pkey_insert(struct sel_ib_pkey *pkey)
104104

105105
tail = list_entry(
106106
rcu_dereference_protected(
107-
sel_ib_pkey_hash[idx].list.prev,
107+
list_tail_rcu(&sel_ib_pkey_hash[idx].list),
108108
lockdep_is_held(&sel_ib_pkey_lock)),
109109
struct sel_ib_pkey, list);
110110
list_del_rcu(&tail->list);

security/selinux/netnode.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,9 @@ static void sel_netnode_insert(struct sel_netnode *node)
164164
if (sel_netnode_hash[idx].size == SEL_NETNODE_HASH_BKT_LIMIT) {
165165
struct sel_netnode *tail;
166166
tail = list_entry(
167-
rcu_dereference_protected(sel_netnode_hash[idx].list.prev,
168-
lockdep_is_held(&sel_netnode_lock)),
167+
rcu_dereference_protected(
168+
list_tail_rcu(&sel_netnode_hash[idx].list),
169+
lockdep_is_held(&sel_netnode_lock)),
169170
struct sel_netnode, list);
170171
list_del_rcu(&tail->list);
171172
kfree_rcu(tail, rcu);

security/selinux/netport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static void sel_netport_insert(struct sel_netport *port)
113113
struct sel_netport *tail;
114114
tail = list_entry(
115115
rcu_dereference_protected(
116-
sel_netport_hash[idx].list.prev,
116+
list_tail_rcu(&sel_netport_hash[idx].list),
117117
lockdep_is_held(&sel_netport_lock)),
118118
struct sel_netport, list);
119119
list_del_rcu(&tail->list);

0 commit comments

Comments
 (0)