OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 10, 2024 12:29 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Pass data from userland to kernel using VDSO
PostPosted: Fri Nov 23, 2018 4:46 am 
Offline

Joined: Tue Nov 20, 2018 8:02 am
Posts: 2
Hello,

For research purpose, I added some custom VDSO in my 2.6 kernel following this tutorial https://www.linuxjournal.com/content/creating-vdso-colonels-other-chicken. I'm trying to pass data from the userland to the kernel. (Yes, in this direction. I know this is extremely bad from a security perspective but that's intentional. I'm literally trying to break the vdso’s security).

So I'm trying to do one of the following:
1) Disable the read-only protection of the userland variable to be able to modify this (as the kernel variable points on the same location than the user one, I will just have to check for modification in the kernel).

=> To make this work I added the VM_WRITE flag to install_special_mapping in arch_setup_additional_pages(…) from vma.c but this is not enough. I still get an unpleasant segfault when i try to increment my variable in my vdso.

2) Be notified in the kernel when the vdso have been called (maybe using an hardware breakpoint or something like that) so I can execute some code only in this case

=> I’m not sure that it is possible to create in kernelmode a breakpoint running a specific callback when ANY process executes the vdso function.

3) Maybe there is a simpler way?

I would gladly appreciate any thoughts on this problem

Thanks for your help.


Top
 Profile  
 
 Post subject: Re: Pass data from userland to kernel using VDSO
PostPosted: Wed Nov 28, 2018 2:24 am 
Offline
Member
Member
User avatar

Joined: Wed Aug 08, 2012 6:39 am
Posts: 42
Location: New York, NY
Hi,

Note that this forum isn't for Linux development, it's for people writing their own operating systems.

To stay on topic, why are you trying to do this on an ancient 2.6 Linux?

_________________
Cheers,

Lev


Top
 Profile  
 
 Post subject: Re: Pass data from userland to kernel using VDSO
PostPosted: Sat Dec 01, 2018 6:52 am 
Offline

Joined: Tue Nov 20, 2018 8:02 am
Posts: 2
Hi,

Quote:
Note that this forum isn't for Linux development, it's for people writing their own operating systems.


I thought this forum was appropriated as I'm trying to build a custom kernel. Sorry if it's not the case.

[quote]To stay on topic, why are you trying to do this on an ancient 2.6 Linux?[quote]

The tutorial I used about VDSO is quite old and made for Linux 2.6. But since this time, the way to declare a vdso changed a lot and is quite under documented. As it’s just a PoC I’ve chosen to make it work first in a 2.6 kernel then try to “reverse enginer” the changes to make it work on a 4.x kernel. But if you think that I’ll solve my problem more easily on a recent Kernel, I can make the adaptations now.

To come back to my problem, I’m more and more convinced that the best way would be to let modify the variable from the userland. But as stated in my first post when I remove the protection (by adding VM_WRITE) I still segfault with code 7 when executing my vdso. I tried to change several other variables unsuccessfully.

I looked for a const like VM_MAYNOTWRITE in the code but this one is not defined in my version and I did not find any equivalent.

Do you have an idea how to remove write protection on that specific area?


Top
 Profile  
 
 Post subject: Re: Pass data from userland to kernel using VDSO
PostPosted: Sat Dec 01, 2018 4:49 pm 
Offline
Member
Member
User avatar

Joined: Wed Aug 05, 2015 5:33 pm
Posts: 159
Location: Drenthe, Netherlands
emixam wrote:
Quote:
Note that this forum isn't for Linux development, it's for people writing their own operating systems.
I thought this forum was appropriated as I'm trying to build a custom kernel. Sorry if it's not the case.
It's not so much that it's inapprocriate to ask this question here. But agree this forum isn't the best place because you have a better chance to find someone with this specific skillset in a linux kernel related dev forum.

_________________
"Always code as if the guy who ends up maintaining it will be a violent psychopath who knows where you live." - John F. Woods

Failed project: GoOS - https://github.com/nutterts/GoOS


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 130 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group