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

  • Home
  • SEARCH
  • 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 7048821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:56:15+00:00 2026-05-28T02:56:15+00:00

I’m playing with kretprobes and I am facing a problem. I would like, in

  • 0

I’m playing with kretprobes and I am facing a problem. I would like, in response to certain events from a user process (e.g. specific syscalls), read data from that process address space. Since in the kretprobe entry handler we’re in interrupt context, I can’t possibly get the user pages from here (it may sleep) so I defer the work in the system_rq (schedule_work()).

To be sure that the user process won’t change its memory before my deferred work is done, I put it in TASK_INTERRUPTIBLE and use set_tsk_need_resched(). I was expecting that during the iret, the flag would be tested and the scheduler would elect another task. It seems like it does not work like that and the user task is back on the cpu right after the interrupt, changing its memory before I had a chance to look at it.

Is there something else to do to ensure the task switch occurs directly after the iret?

Thanks in advance

  • 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-28T02:56:16+00:00Added an answer on May 28, 2026 at 2:56 am

    Well I found today that it is actually the good way to do this. The problem I had with the process carrying on running was because I was not in interrupt context: the kprobe was optimized (i.e. a jmp instruction instead of an int3 on x86) which caused my code to be executed in user context in kernel land. This should have been handled smoothly if the kprobe_optimized() function had worked correctly, in which case we can call schedule() directly after setting the task to INTERRUPTIBLE instead of ireturning and letting the prologue of the interrupt handler check the flag TIF_NEED_RESCHED. Indeed the kprobe_optimized() returns false in any cases if it is a kretprobe, which is due to the way a kretprobe is handled internally: it uses an aggregator of kprobes, which flag for optimized is set correctly for the aggregator but not for the kprobes within the list. I workarounded this by exporting the function get_kprobe() and using it to retrieve the address of the kprobe aggregator, from which I am finally able to check correctly if it is optimized or not.

    I think the best way (performance wise) to fix this in the kernel is to replicate the optimized flag from the aggregator to each kprobe it lists. This way the kprobe_optimized() will return the proper value. Another way to do this would be to add more code in kprobe_optimized() to check if this kprobe is part of an aggregator list and check the aggregator rather than the actual kprobe.

    Anyway this was fun!

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

Sidebar

Related Questions

I would like to run a str_replace or preg_replace which looks for certain words
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am currently running into a problem where an element is coming back from
I am trying to render a haml file in a javascript response like so:
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.