LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-29-2011, 08:33 AM   #1
alclub
LQ Newbie
 
Registered: Aug 2011
Posts: 1

Rep: Reputation: Disabled
Syscall stat64() returning EFAULT (bad address)...


Hi, I'm trying to call stat64() (from a kernel context) but it keeps returning errno EFAULT (bad address). I successfully vmalloc'ed some memory, but it doesn't accept it.

I'm not too experienced with kernel programming yet but I tried looking at the source and it seems when stat64() tries to use copy_to_user() and it fails, stat64 will return efault.

I'm guessing it want's user space memory. But I tried kmalloc(sizeof(my_statbuf),GFP_USER) as well and that fails. I also tried fstat64 which fails too.

Here's an example of what I'm trying to do:

Code:
...

extern struct stat64 __user *my_statbuf;

my_statbuf = vmalloc(sizeof(*my_statbuf)); /* I also tried kmalloc(sizeof(my_statbuf),GFP_USER) */
if(my_statbuf == NULL){printk(KERN_INFO "malloc failed"); return 1;}

unsigned long fd = open(filename, flags, mode); //Opening my file which works.

printk(KERN_INFO "fstat returned: %ld",real_fstat64(fd,my_statbuf)); // prints -14 (efault)

...

/* replacing fstat64 with stat64 (and the file descriptor with a filename) has the exact same result (efault). */

Thanks guys
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Box With 3 Dedicated IP's All Returning The Same Single IP Address onesikgypo Linux - Networking 2 01-21-2010 04:57 AM
shell prints bad code when returning message backpacker Linux - Software 14 06-29-2005 02:53 AM
gethostbyname() is not returning my IP address hal2000 Programming 5 10-11-2004 05:54 PM
kmalloc returning overlapped address dipakn Linux - General 4 10-29-2003 11:29 PM
Program returning ip-address? smellofsunshine Linux - Software 4 08-11-2003 05:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration