Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1520245

Re: [srcu] Can we suppress sparse warning?

From Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Newsgroups linux.kernel
Subject Re: [srcu] Can we suppress sparse warning?
Date 2016-11-12 15:30 +0100
Message-ID <sCHtD-3dB-11@gated-at.bofh.it> (permalink)
References <sBzov-6GJ-75@gated-at.bofh.it> <sBGgh-2DN-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Paul E. McKenney wrote:
> Notwithstanding my confusion about what your self-referential
> srcu_dereference() is intended to achieve, what happens if you change the
> "void *ptr = srcu_dereference(ptr, &srcu);" to add __rcu?

Sorry, I wrote this code for only showing warning message.
This self-referential has no intention.

Well, you can reproduce this warning with current linux.git by running
make C=1 security/tomoyo/ with CONFIG_SECURITY_TOMOYO=y .

security/tomoyo/common.c:896:9: error: incompatible types in comparison expression (different address spaces)
security/tomoyo/common.c:896:9: error: incompatible types in comparison expression (different address spaces)

---------- security/tomoyo/common.c ----------
896:        list_for_each_cookie(head->r.acl, &tomoyo_kernel_namespace.
897:                             policy_list[TOMOYO_ID_MANAGER]) {

---------- security/tomoyo/common.h ----------
1320: /**
1321:  * list_for_each_cookie - iterate over a list with cookie.
1322:  * @pos:        the &struct list_head to use as a loop cursor.
1323:  * @head:       the head for your list.
1324:  */
1325: #define list_for_each_cookie(pos, head)                                 \
1326:         if (!pos)                                                       \
1327:                 pos =  srcu_dereference((head)->next, &tomoyo_ss);      \
1328:         for ( ; pos != (head); pos = srcu_dereference(pos->next, &tomoyo_ss))

Both head->r.acl and &tomoyo_kernel_namespace.policy_list[TOMOYO_ID_MANAGER]->next
refer normal kernel address space. Thus, I think that this warning is a false positive.

This warning goes away if I disable rcu_dereference_sparse() call in
__rcu_dereference_check() from srcu_dereference_check() from srcu_dereference().

--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -605,7 +605,7 @@ static inline void rcu_preempt_sleep_check(void)
        /* Dependency order vs. p above. */ \
        typeof(*p) *________p1 = (typeof(*p) *__force)lockless_dereference(p); \
        RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_check() usage"); \
-       rcu_dereference_sparse(p, space); \
+       /*rcu_dereference_sparse(p, space); */                          \
        ((typeof(*p) __force __kernel *)(________p1)); \
 })
 #define __rcu_dereference_protected(p, c, space) \

Regards.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[srcu] Can we suppress sparse warning? Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-11-09 12:40 +0100
  Re: [srcu] Can we suppress sparse warning? "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-11-09 20:00 +0100
    Re: [srcu] Can we suppress sparse warning? Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-11-12 15:30 +0100
      Re: [srcu] Can we suppress sparse warning? "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-11-12 20:20 +0100
        Re: [srcu] Can we suppress sparse warning? Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-11-13 14:00 +0100

csiph-web