Re: 2.4.39 "Sleeping function called from illegal context at slab.c:1374"

From: Andrew Morton (akpm@digeo.com)
Date: Tue Oct 01 2002 - 13:54:26 EST


Helge Hafting wrote:
>
> ..
> [<c01146c4>]__might_sleep+0x54/0x60
> [<c012dca0>]kmalloc+0x4c/0x130
> [<c010b6b2>]sys_ioperm+0x82/0x11c
> [<c0106fbb>]syscall_call+0x7/0xb
>

You up to trying this fix?

--- 2.5.40/arch/i386/kernel/ioport.c~ioperm-fix Tue Oct 1 02:17:51 2002
+++ 2.5.40-akpm/arch/i386/kernel/ioport.c Tue Oct 1 02:17:51 2002
@@ -56,6 +56,7 @@ asmlinkage int sys_ioperm(unsigned long
 {
         struct thread_struct * t = &current->thread;
         struct tss_struct * tss;
+ unsigned long *bitmap = NULL;
         int ret = 0;
 
         if ((from + num <= from) || (from + num > IO_BITMAP_SIZE*32))
@@ -63,15 +64,12 @@ asmlinkage int sys_ioperm(unsigned long
         if (turn_on && !capable(CAP_SYS_RAWIO))
                 return -EPERM;
 
- tss = init_tss + get_cpu();
-
         /*
          * If it's the first ioperm() call in this thread's lifetime, set the
          * IO bitmap up. ioperm() is much less timing critical than clone(),
          * this is why we delay this operation until now:
          */
         if (!t->ts_io_bitmap) {
- unsigned long *bitmap;
                 bitmap = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL);
                 if (!bitmap) {
                         ret = -ENOMEM;
@@ -83,20 +81,19 @@ asmlinkage int sys_ioperm(unsigned long
                  */
                 memset(bitmap, 0xff, IO_BITMAP_BYTES);
                 t->ts_io_bitmap = bitmap;
- /*
- * this activates it in the TSS
- */
- tss->bitmap = IO_BITMAP_OFFSET;
         }
 
+ tss = init_tss + get_cpu();
+ if (bitmap)
+ tss->bitmap = IO_BITMAP_OFFSET; /* Activate it in the TSS */
+
         /*
          * do it in the per-thread copy and in the TSS ...
          */
         set_bitmap(t->ts_io_bitmap, from, num, !turn_on);
         set_bitmap(tss->io_bitmap, from, num, !turn_on);
-
-out:
         put_cpu();
+out:
         return ret;
 }
 

.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Oct 07 2002 - 22:00:28 EST