Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's some random ramblings, I'm far from sure any/all of it makes much sense, but it's getting late, and I'd rather write it down and get to bed than try to figure out exactly which (if any) is actually the problem. Hopefully something will help:</p> <p>I take it you have checked that your restore actually restores the pointer - e.g. print the content of <code>sys_call_table[__NR_read]</code>? </p> <p>I would definitely restore CR0 by or-ing back the bit you cleared, rather than restoring an old value - it may not matter most of the time, but there are other bits in CR0 that may change from time to time - probably only really the TS bit, but that's bad enough - getting some random restore of stale floating point or missing a floating point restore is a bad thing [and guess how easy it is to figure out that the reason some long-running math suddenly got completely incorrect results because your code unloaded a few hours earlier?]. That's almost certainly not why your code is crashing, but it will almost certainly cause problems at one point or another if you load/unload the module enough times. [Also, make sure you are not swapping between processors when you change CR0 - probably best to do some sort of locking to ensure you stay on the same processor whilst doing the whole update <code>sys_call_table</code> stuff].</p> <p>I think the reason your code is crashing, however, is lack of cache-flushing (the OS isn't expecting this memory to change - and the process sees it as read only, so it shouldn't need to be checked for invalidation]. You need to flush the caches on all processors for the sys_call_table entry. I'm not sure what the easiest/best way to do that is. I think <code>void flush_icache_range(unsigned long start, unsigned long end)</code> is the call you need - but I'm not sure if that's a current or an old function. From here: <a href="https://www.kernel.org/doc/Documentation/cachetlb.txt" rel="nofollow">https://www.kernel.org/doc/Documentation/cachetlb.txt</a></p> <p>As I said initially, this is more ramblings than actually looking into how things work deep inside the kernel, etc. Time for my beauty sleep - I need as much of that as I can get... ;)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload