Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6955489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:44:34+00:00 2026-05-27T14:44:34+00:00

I want to trace with a LKM the sys_connect and sys_accept right after these

  • 0

I want to trace with a LKM the sys_connect and sys_accept right after these system calls return.
I found that kprobes can give you access to the registers when a probed system call returns, by defining a post handler.

My problem is that I don’t know how to get the system call parameters from the data that I have in the post handler (i.e. the struct pt_regs)
The post handler is defined like that:

void post_handler(struct kprobe *p, struct pt_regs *regs, unsigned long flags);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:44:35+00:00Added an answer on May 27, 2026 at 2:44 pm

    This structure is architecture dependent so I will just assume you are on x86.

    On entry:

      orig_eax = syscall_nr;
      ebx = 1st argument of the function;
      ecx = 2nd arg...
      edx = 3rd arg...
      esi = 4th arg...
      edi = 5th arg... (you are lucky, on other arch this can be on the stack...)
    

    On exit:

      orig_eax = return value of the function
    

    You cannot assume that the value inside ebx,ecx,edx… still points to the argument of the function on exit (i.e. when your post_handler is called) so here you would need to register two handlers, one on entry, from which you can can save a pointer to the struct socket, and one on exit, from which you will actually inspect the content of the struct socket now that it’s been filled. To pass data between the two handlers, you can use the filed data of the kretprobe_instance structure. Don’t forget to increase the data_size filed of the struct kretprobe when you register your kretprobe.

    This might seem a little complex but it should be alright once you are a bit more familiar with it.

    Please also remember that if the only thing you need to do is trace those events, you might just use the ftrace infrastructure in sysfs and with minimum efforts get the trace that you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get a detailed log about my stack trace. I can get
When I run an SQL trace I want to see the TSQL statements that
now, if i want to trace the drupal sourcecode.how and which tool i can
Can child process use the ptrace system call to trace its parent? Os is
I want to trace all low-level output that the Jedis client sends via JedisCommands
I want to trace each path of function calls. For eg: int a() {
I want to trace the modification history of a specific file. Does linux have
I want to trace all the parent controls of a control (e.g) if i
I want to trace the source code , but when I set a breakpoint,
I have a my custom collection derived from List(.MyItem.) I want to trace if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.