2001-03-23 10:42:50

by Junfeng Yang

[permalink] [raw]
Subject: [CHECKER] 4 warnings in kernel/module.c

Hi, we modified the block checker and run it again on linux 2.4.1. (The
block checker flags an error when blocking functions are called with
either interrupts disabled or a spin lock held. )

It gave us 4 warnings in kernel/module.c. Because we are unaware of the
contexts where these functions are called, we are not sure if these 4
warnings are real errors or false positives. Please help us to verify them
or show that they are false positives.

As usual, please CC us at [email protected]. Any help will be
appreciated.

---------------------------------------------------------

[UNKNOWN] get_mod_name->__get_free_page(GFP_KERNEL). This is in the
KERNEL. Definitely need to verify

/u2/acc/oses/linux/2.4.1/kernel/module.c:290:sys_create_module:
ERROR:BLOCK:289:290:calling blocking fn 'get_mod_name' w/ spin lock held
[type=GLOBAL]:289

Start --->
lock_kernel();

Error --->
if ((namelen = get_mod_name(name_user, &name)) < 0) {
error = namelen;
---------------------------------------------------------

[UNKNOWN] get_mod_name->__get_free_page(GFP_KERNEL) This is in the KERNEL.
Definitely need to verify

/u2/acc/oses/linux/2.4.1/kernel/module.c:599:sys_delete_module:
ERROR:BLOCK:597:599:calling blocking fn 'get_mod_name' w/ spin lock held
[type=GLOBAL]:597

Start --->
lock_kernel();
if (name_user) {
Error --->
if ((error = get_mod_name(name_user, &name)) < 0)
goto out;
---------------------------------------------------------

[UNKNOWN] need to verify. in the KERNEL!

/u2/acc/oses/linux/2.4.1/kernel/module.c:376:sys_init_module:
ERROR:BLOCK:342:376:calling blocking fn 'copy_from_user' w/ spin lock held
[type=LOCAL]:342

Start --->
lock_kernel();
Error --->
if ((namelen = get_mod_name(name_user, &name)) < 0) {
error = namelen;
goto err0;
}

... DELETED 26 lines ...

goto err1;
}
strcpy(name_tmp, mod->name);

Error --->
error = copy_from_user(mod, mod_user, mod_user_size);
if (error) {
---------------------------------------------------------

[UNKNOWN] need to verify. in the KERNEL!

/u2/acc/oses/linux/2.4.1/kernel/module.c:888:sys_query_module:
ERROR:BLOCK:881:888:calling blocking fn 'get_mod_name' w/ spin lock held
[type=GLOBAL]:881

Start --->
lock_kernel();
if (name_user == NULL)
mod = &kernel_module;
else {
long namelen;
char *name;

Error --->
if ((namelen = get_mod_name(name_user, &name)) < 0) {
err = namelen;
---------------------------------------------------------

A few questions:

1. Is it OK to call blocking functions in the functions like
/init/main.c:init and init/main.c:start_kernel with a spin lock held? It
seems OK because the system is booting when these functions are called.

2. Can functions like kmem_cache_create, kmem_cache_alloc, alloc_page
block?







2001-03-23 11:02:10

by Alan

[permalink] [raw]
Subject: Re: [CHECKER] 4 warnings in kernel/module.c

> Hi, we modified the block checker and run it again on linux 2.4.1. (The
> block checker flags an error when blocking functions are called with
> either interrupts disabled or a spin lock held. )

lock_kernel() isnt a spinlock as such.

> 2. Can functions like kmem_cache_create, kmem_cache_alloc, alloc_page
> block?

They may block unless GFP_ATOMIC is specified in the arguments.

Alan

2001-03-23 11:06:40

by Keith Owens

[permalink] [raw]
Subject: Re: [CHECKER] 4 warnings in kernel/module.c

On Fri, 23 Mar 2001 02:41:40 -0800 (PST),
Junfeng Yang <[email protected]> wrote:
>Hi, we modified the block checker and run it again on linux 2.4.1. (The
>block checker flags an error when blocking functions are called with
>either interrupts disabled or a spin lock held. )
>
>It gave us 4 warnings in kernel/module.c. Because we are unaware of the
>contexts where these functions are called, we are not sure if these 4
>warnings are real errors or false positives. Please help us to verify them
>or show that they are false positives.

All false positives. The big kernel lock is a special case, you are
allowed to sleep while holding that lock. See release_kernel_lock()
and reacquire_kernel_lock() in sched().

2001-03-23 19:51:11

by Junfeng Yang

[permalink] [raw]
Subject: Re: [CHECKER] 4 warnings in kernel/module.c

On Fri, 23 Mar 2001, Alan Cox wrote:

> > Hi, we modified the block checker and run it again on linux 2.4.1. (The
> > block checker flags an error when blocking functions are called with
> > either interrupts disabled or a spin lock held. )
>
> lock_kernel() isnt a spinlock as such.

Thanks a lot. We just figured out that it is ok to block within
lock_kernel() unlock_kernel() scope. That will help us to eliminate
some false positives.


2001-03-23 19:58:01

by Junfeng Yang

[permalink] [raw]
Subject: Re: [CHECKER] 4 warnings in kernel/module.c

On Fri, 23 Mar 2001, Keith Owens wrote:

> On Fri, 23 Mar 2001 02:41:40 -0800 (PST),
> Junfeng Yang <[email protected]> wrote:
> >Hi, we modified the block checker and run it again on linux 2.4.1. (The
> >block checker flags an error when blocking functions are called with
> >either interrupts disabled or a spin lock held. )
> >
> >It gave us 4 warnings in kernel/module.c. Because we are unaware of the
> >contexts where these functions are called, we are not sure if these 4
> >warnings are real errors or false positives. Please help us to verify them
> >or show that they are false positives.
>
> All false positives. The big kernel lock is a special case, you are
> allowed to sleep while holding that lock. See release_kernel_lock()
> and reacquire_kernel_lock() in sched().

Thanks for pointing this out. We'll modify the checker again and remove
"lock_kernel" from the patterns.