strncpy_from_user called from invalid context?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In order to learn the jprobes interface, I am a writing a fairly silly example 
jprobe. However, I'm having issues copying a string from userspace.... 
Basically somehow I wind up calling a function that may sleep from an invalid 
context (interrupts disabled or something).

I have the source of the function in question and the stack trace below. If 
anyone could give me a few pointers it would be greatly appreciated.

The function in question is:

(> 74 asmlinkage static int j_sys_open(const char __user * filename, int flags, 
int mode)
   75 {
0> 76     char tmp[1024];
.> 77 
   78     strncpy_from_user(tmp, filename, 1024);
   79 //    char * tmp = getname(filename);
   80 //    int fd = PTR_ERR(tmp);
   81 
   82     if (!IS_ERR(tmp))
   83     {
   84         if (strstr(tmp, ".exe"))
   85         {
   86 
   87             if (strcmp(current->comm, "wine"))
   88             {
   89                 goto out;
   90             }
   91 
   92             panic("PANIC: The file %s is virus infected. Self destruction 
imminent.\n", tmp);
   93 
   94         }
   95     }
   96 
   97 out:
   98     jprobe_return();
   99     return 0;
  100 }   

and the error in dmesg is:

[  421.250737] BUG: sleeping function called from invalid context at 
arch/x86/mm/fault.c:1074
[  421.250742] in_atomic(): 0, irqs_disabled(): 1, pid: 1718, name: dmesg
[  421.250745] Pid: 1718, comm: dmesg Not tainted 2.6.35.9-64.fc14.x86_64 #1
[  421.250748] Call Trace:
[  421.250756]  [<ffffffff8103d1d5>] __might_sleep+0xeb/0xf0
[  421.250761]  [<ffffffff8146cbf4>] do_page_fault+0x15c/0x265
[  421.250765]  [<ffffffff8146a075>] page_fault+0x25/0x30
[  421.250770]  [<ffffffff8121db83>] ? strncpy+0xc/0x27
[  421.250774]  [<ffffffffa000f049>] j_sys_open+0x37/0xc6 [exe_probe]
[  421.250779]  [<ffffffff810e6fa5>] ? zone_statistics+0x65/0x6a
[  421.250784]  [<ffffffff810d996b>] ? get_page_from_freelist+0x4c7/0x674
[  421.250787]  [<ffffffff810e6fa5>] ? zone_statistics+0x65/0x6a
[  421.250791]  [<ffffffff810d996b>] ? get_page_from_freelist+0x4c7/0x674
[  421.250795]  [<ffffffff81111cd8>] ? try_get_mem_cgroup_from_mm+0x33/0x3f
[  421.250798]  [<ffffffff81112709>] ? __mem_cgroup_try_charge+0x70/0x3bc
[  421.250802]  [<ffffffff8103c0ea>] ? need_resched+0x23/0x2d
[  421.250806]  [<ffffffff8103c102>] ? should_resched+0xe/0x2e
[  421.250809]  [<ffffffff81468375>] ? _cond_resched+0xe/0x22
[  421.250812]  [<ffffffff810d3672>] ? lock_page+0x31/0x42
[  421.250815]  [<ffffffff810d4185>] ? filemap_fault+0x1bb/0x30a
[  421.250818]  [<ffffffff810d3796>] ? unlock_page+0x27/0x2c
[  421.250822]  [<ffffffff810e9c16>] ? __do_fault+0x342/0x379
[  421.250826]  [<ffffffff810e929d>] ? pmd_offset+0x19/0x40
[  421.250829]  [<ffffffff810ebe02>] ? handle_mm_fault+0x3a9/0x84d
[  421.250832]  [<ffffffff810ef344>] ? remove_vma+0x7f/0x87
[  421.250836]  [<ffffffff8146ccd0>] ? do_page_fault+0x238/0x265
[  421.250840]  [<ffffffff81099961>] ? audit_syscall_entry+0x11c/0x148
[  421.250844]  [<ffffffff81009cf2>] system_call_fastpath+0x16/0x1b

Regards,

Greg Kerr

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux