linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: Linux-Sparse <linux-sparse@vger.kernel.org>
Subject: Re: sparse multiple address spaces?
Date: Wed, 19 Aug 2020 14:48:33 -0700	[thread overview]
Message-ID: <2bbeb226-8bd1-9e47-ecf1-ed69b4e5f08b@infradead.org> (raw)
In-Reply-To: <20200819205234.ulgeccdi4fsidwou@ltop.local>

On 8/19/20 1:52 PM, Luc Van Oostenryck wrote:
> On Wed, Aug 19, 2020 at 10:06:55PM +0200, Luc Van Oostenryck wrote:
>> On Wed, Aug 19, 2020 at 12:15:46PM -0700, Randy Dunlap wrote:
>>> On Linux kernel tree v5.9-rc1, with sparse v0.6.2-180-g49f7e13a,
>>> I see this sparse warning which I don't grok:
>>>
>>> ../include/uapi/asm-generic/signal-defs.h:19:29: CK: error: multiple address spaces given
>>>
>>> for this source code:
>>>
>>> typedef void __signalfn_t(int);
>>> typedef __signalfn_t __user *__sighandler_t; <<<<< line 19
>>>
>>> Are there multiple address spaces there?  What are they?
>>>
>>>
>>>
>>> or: is the warning related to the other nearby warnings?  (e.g.:)
>>>
>>> ../kernel/signal.c:541:53: CK: warning: incorrect type in initializer (different address spaces)
>>> ../kernel/signal.c:541:53: CK:    expected struct k_sigaction *ka
>>> ../kernel/signal.c:541:53: CK:    got struct k_sigaction [noderef] __rcu *
>>> ../include/uapi/asm-generic/signal-defs.h:19:29: CK: error: multiple address spaces given
>>> ../kernel/signal.c:694:33: CK: warning: incorrect type in argument 1 (different address spaces)
>>> ../kernel/signal.c:694:33: CK:    expected struct spinlock [usertype] *lock
>>> ../kernel/signal.c:694:33: CK:    got struct spinlock [noderef] __rcu *
>>
>> I would guess that this __sighandler_t is used somewhere in a
>> struct which is itself accessed via a __rcu pointer.
>> But that would not explain the level of dereference.
>>
>> I'll need to check this one.
> 
> The location of the warning should be the assignment in kernel/signal.c:69
> 
> 	static void __user *sig_handler(struct task_struct *t, int sig) 
> 	{
> 		return t->sighand->action[sig - 1].sa.sa_handler;
> 	}
>  
> There is a lot of type abuses in this file, between 'void __user *' and
> __sighandler_t, but the root cause of the warning is the '__rcu' in 
> 
> 	struct task_struct {
> 		...
> 		struct sighand_struct __rcu *sighand;
> 		...
> 	}

OK, thanks for all of your excavation work. :)

-- 
~Randy


      reply	other threads:[~2020-08-19 21:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-19 19:15 sparse multiple address spaces? Randy Dunlap
2020-08-19 20:06 ` Luc Van Oostenryck
2020-08-19 20:52   ` Luc Van Oostenryck
2020-08-19 21:48     ` Randy Dunlap [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2bbeb226-8bd1-9e47-ecf1-ed69b4e5f08b@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).