How to set breakpoint to obtain address of a function in fork.c , in the kernel sourc
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to set breakpoint to obtain address of a function in fork.c , in the kernel sourc
Good day to all. I have this query which I hope someone is able to help me with. I forward my gratitude and thanks in advance. I had done hours of search but unable to find a solution.
My problem overview:
1. I need to obtain the address of the " security_task_create(clone_flags)" function in the following code snippet (located in line 926 ,fork.c as per "/usr/src/linux-2.6.27/kernel/fork.c") :-
2. I need to acquire the address of the " security_task_create(clone_flags)" function when it is called while the function is in runtime operation, in the memory. The " security_task_create(clone_flags)" function is a LSM hook to the SELinux Security Hook selinux_task-create.
static struct task_struct *copy_process(unsigned long clone_flags,
unsigned long stack_start,
struct pt_regs *regs,
unsigned long stack_size,
int __user *child_tidptr,
struct pid *pid,
int trace)
{
int retval;
struct task_struct *p;
int cgroup_callbacks_done = 0;
if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
return ERR_PTR(-EINVAL);
/*
* Thread groups must share signals as well, and detached threads
* can only be started up within the thread group.
*/
if ((clone_flags & CLONE_THREAD) && !(clone_flags & CLONE_SIGHAND))
return ERR_PTR(-EINVAL);
/*
* Shared signal handlers imply shared VM. By way of the above,
* thread groups also imply shared VM. Blocking this case allows
* for various simplifications in other code.
*/
if ((clone_flags & CLONE_SIGHAND) && !(clone_flags & CLONE_VM))
return ERR_PTR(-EINVAL);
****retval = security_task_create(clone_flags);****
if (retval)
goto fork_out;
retval = -ENOMEM;
p = dup_task_struct(current);
if (!p)
goto fork_out;
1. I've enabled KDB access over keyboard in my Fedora Core 16 machine with kernel 3.1.7. Used "kdb[0]> bp security_task_create" to set breakpoints for obtaining the runtime address of " security_task_create(clone_flags)" function. But kdb says "unable to set breakpoint" after I typed go.
The " security_task_create(clone_flags)" function operates at kernel space.
My questions:
1. How do I obtain the address of the security_task_create() function when security_task_create() had been loaded to memory during runtime? (especially if its in the kernel space memory)
2. What functions or libraries do I use?
3. Would greatly appreciate if some example codes are available.
Have you tried printk()? Given that it's in fork() you'd need to detect the calling case unique to the one you wish to see debug for, but you ought to be able to print out more information in addition to that address. Like you might have to add some printk() statements before it calls copy_process() so as to identify the process name being cloned. There's an example calling printk() in my copy of the do_fork() function.
Thank you for your reply. Would it be possible if you could supplement me with the sample code of calling printk() in your copy of the do_fork() function?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.