Be informed when a specific vdso is run
up vote
2
down vote
favorite
I'm currently trying to implement my own VDSO. I have used this tutorial which explains how to do this for a 2.6 kernel.
I tested it and I got this working. (I succeeded in creating a kernel variable and accessing it from userland.)
Is there a way to be know in the kernel when the vdso has been called? I assume this can't be done synchronously (as the vdso is handled in userland). But is there any possibility (even dirty) from the kernel to know whether the function has been called (maybe with a hardware breakpoint or something)?
What I’d like to do is something like the function my_vdso_has_been_called()
) in this code:
void update_vsyscall(/* […] */) {
// […]
if(my_vdso_has_been_called())
do_something();
}
Note: the function update_vsyscall
can be found in arch/x86/kernel/vsyscall_64.c
linux kernel linux-kernel system-calls
migrated from unix.stackexchange.com Nov 22 at 20:02
This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems.
add a comment |
up vote
2
down vote
favorite
I'm currently trying to implement my own VDSO. I have used this tutorial which explains how to do this for a 2.6 kernel.
I tested it and I got this working. (I succeeded in creating a kernel variable and accessing it from userland.)
Is there a way to be know in the kernel when the vdso has been called? I assume this can't be done synchronously (as the vdso is handled in userland). But is there any possibility (even dirty) from the kernel to know whether the function has been called (maybe with a hardware breakpoint or something)?
What I’d like to do is something like the function my_vdso_has_been_called()
) in this code:
void update_vsyscall(/* […] */) {
// […]
if(my_vdso_has_been_called())
do_something();
}
Note: the function update_vsyscall
can be found in arch/x86/kernel/vsyscall_64.c
linux kernel linux-kernel system-calls
migrated from unix.stackexchange.com Nov 22 at 20:02
This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems.
can something likeSystemTap
react to your__vdso_myvdso
being called?
– thrig
Nov 22 at 14:20
If I understand well, SystemTap is a tool only called from outside the kernel. So unless there is an equivalent tool running in kernelmode, I don’t think so. But correct me if I'm wrong.
– Maxime B.
Nov 22 at 16:43
SystemTap compiles code into the kernel.
– thrig
Nov 22 at 17:44
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm currently trying to implement my own VDSO. I have used this tutorial which explains how to do this for a 2.6 kernel.
I tested it and I got this working. (I succeeded in creating a kernel variable and accessing it from userland.)
Is there a way to be know in the kernel when the vdso has been called? I assume this can't be done synchronously (as the vdso is handled in userland). But is there any possibility (even dirty) from the kernel to know whether the function has been called (maybe with a hardware breakpoint or something)?
What I’d like to do is something like the function my_vdso_has_been_called()
) in this code:
void update_vsyscall(/* […] */) {
// […]
if(my_vdso_has_been_called())
do_something();
}
Note: the function update_vsyscall
can be found in arch/x86/kernel/vsyscall_64.c
linux kernel linux-kernel system-calls
I'm currently trying to implement my own VDSO. I have used this tutorial which explains how to do this for a 2.6 kernel.
I tested it and I got this working. (I succeeded in creating a kernel variable and accessing it from userland.)
Is there a way to be know in the kernel when the vdso has been called? I assume this can't be done synchronously (as the vdso is handled in userland). But is there any possibility (even dirty) from the kernel to know whether the function has been called (maybe with a hardware breakpoint or something)?
What I’d like to do is something like the function my_vdso_has_been_called()
) in this code:
void update_vsyscall(/* […] */) {
// […]
if(my_vdso_has_been_called())
do_something();
}
Note: the function update_vsyscall
can be found in arch/x86/kernel/vsyscall_64.c
linux kernel linux-kernel system-calls
linux kernel linux-kernel system-calls
asked Nov 21 at 17:15
Maxime B.
324
324
migrated from unix.stackexchange.com Nov 22 at 20:02
This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems.
migrated from unix.stackexchange.com Nov 22 at 20:02
This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems.
can something likeSystemTap
react to your__vdso_myvdso
being called?
– thrig
Nov 22 at 14:20
If I understand well, SystemTap is a tool only called from outside the kernel. So unless there is an equivalent tool running in kernelmode, I don’t think so. But correct me if I'm wrong.
– Maxime B.
Nov 22 at 16:43
SystemTap compiles code into the kernel.
– thrig
Nov 22 at 17:44
add a comment |
can something likeSystemTap
react to your__vdso_myvdso
being called?
– thrig
Nov 22 at 14:20
If I understand well, SystemTap is a tool only called from outside the kernel. So unless there is an equivalent tool running in kernelmode, I don’t think so. But correct me if I'm wrong.
– Maxime B.
Nov 22 at 16:43
SystemTap compiles code into the kernel.
– thrig
Nov 22 at 17:44
can something like
SystemTap
react to your __vdso_myvdso
being called?– thrig
Nov 22 at 14:20
can something like
SystemTap
react to your __vdso_myvdso
being called?– thrig
Nov 22 at 14:20
If I understand well, SystemTap is a tool only called from outside the kernel. So unless there is an equivalent tool running in kernelmode, I don’t think so. But correct me if I'm wrong.
– Maxime B.
Nov 22 at 16:43
If I understand well, SystemTap is a tool only called from outside the kernel. So unless there is an equivalent tool running in kernelmode, I don’t think so. But correct me if I'm wrong.
– Maxime B.
Nov 22 at 16:43
SystemTap compiles code into the kernel.
– thrig
Nov 22 at 17:44
SystemTap compiles code into the kernel.
– thrig
Nov 22 at 17:44
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
Since you know how to declare a shared variable and access it from both the kernel and the vDSO, you can use that: declare a new variable, and increment it from the vDSO whenever it’s called.
In my understanding, theses shared variables are read-only from the userland. Thus, this code will compile but if I uncomment the incremenation I’m having a segfault.notrace int __vdso_myvdso(void) {
// ++*vmyvar; /* The program will crash if I uncomment this*/
` return *vmyvar;`}
Am I doing it wrong? Are there other variables I can modify? Or can I disable this read-only protection?
– Maxime B.
Nov 22 at 9:14
Sorry, you’re right,VVAR
only gives read-only access from the vDSO.
– Stephen Kitt
Nov 22 at 9:53
I’m trying to disable this read-only protection. Do you know how could I do that? I added theVM_WRITE
flag toinstall_special_mapping
inarch_setup_additional_pages(…)
fromvma.c
but this is not enough (I still get a segfault when I increment my variable). Do you know what the additional adaptations are?
– Maxime B.
Nov 22 at 14:19
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Since you know how to declare a shared variable and access it from both the kernel and the vDSO, you can use that: declare a new variable, and increment it from the vDSO whenever it’s called.
In my understanding, theses shared variables are read-only from the userland. Thus, this code will compile but if I uncomment the incremenation I’m having a segfault.notrace int __vdso_myvdso(void) {
// ++*vmyvar; /* The program will crash if I uncomment this*/
` return *vmyvar;`}
Am I doing it wrong? Are there other variables I can modify? Or can I disable this read-only protection?
– Maxime B.
Nov 22 at 9:14
Sorry, you’re right,VVAR
only gives read-only access from the vDSO.
– Stephen Kitt
Nov 22 at 9:53
I’m trying to disable this read-only protection. Do you know how could I do that? I added theVM_WRITE
flag toinstall_special_mapping
inarch_setup_additional_pages(…)
fromvma.c
but this is not enough (I still get a segfault when I increment my variable). Do you know what the additional adaptations are?
– Maxime B.
Nov 22 at 14:19
add a comment |
up vote
1
down vote
Since you know how to declare a shared variable and access it from both the kernel and the vDSO, you can use that: declare a new variable, and increment it from the vDSO whenever it’s called.
In my understanding, theses shared variables are read-only from the userland. Thus, this code will compile but if I uncomment the incremenation I’m having a segfault.notrace int __vdso_myvdso(void) {
// ++*vmyvar; /* The program will crash if I uncomment this*/
` return *vmyvar;`}
Am I doing it wrong? Are there other variables I can modify? Or can I disable this read-only protection?
– Maxime B.
Nov 22 at 9:14
Sorry, you’re right,VVAR
only gives read-only access from the vDSO.
– Stephen Kitt
Nov 22 at 9:53
I’m trying to disable this read-only protection. Do you know how could I do that? I added theVM_WRITE
flag toinstall_special_mapping
inarch_setup_additional_pages(…)
fromvma.c
but this is not enough (I still get a segfault when I increment my variable). Do you know what the additional adaptations are?
– Maxime B.
Nov 22 at 14:19
add a comment |
up vote
1
down vote
up vote
1
down vote
Since you know how to declare a shared variable and access it from both the kernel and the vDSO, you can use that: declare a new variable, and increment it from the vDSO whenever it’s called.
Since you know how to declare a shared variable and access it from both the kernel and the vDSO, you can use that: declare a new variable, and increment it from the vDSO whenever it’s called.
answered Nov 21 at 22:28
Stephen Kitt
1,2501020
1,2501020
In my understanding, theses shared variables are read-only from the userland. Thus, this code will compile but if I uncomment the incremenation I’m having a segfault.notrace int __vdso_myvdso(void) {
// ++*vmyvar; /* The program will crash if I uncomment this*/
` return *vmyvar;`}
Am I doing it wrong? Are there other variables I can modify? Or can I disable this read-only protection?
– Maxime B.
Nov 22 at 9:14
Sorry, you’re right,VVAR
only gives read-only access from the vDSO.
– Stephen Kitt
Nov 22 at 9:53
I’m trying to disable this read-only protection. Do you know how could I do that? I added theVM_WRITE
flag toinstall_special_mapping
inarch_setup_additional_pages(…)
fromvma.c
but this is not enough (I still get a segfault when I increment my variable). Do you know what the additional adaptations are?
– Maxime B.
Nov 22 at 14:19
add a comment |
In my understanding, theses shared variables are read-only from the userland. Thus, this code will compile but if I uncomment the incremenation I’m having a segfault.notrace int __vdso_myvdso(void) {
// ++*vmyvar; /* The program will crash if I uncomment this*/
` return *vmyvar;`}
Am I doing it wrong? Are there other variables I can modify? Or can I disable this read-only protection?
– Maxime B.
Nov 22 at 9:14
Sorry, you’re right,VVAR
only gives read-only access from the vDSO.
– Stephen Kitt
Nov 22 at 9:53
I’m trying to disable this read-only protection. Do you know how could I do that? I added theVM_WRITE
flag toinstall_special_mapping
inarch_setup_additional_pages(…)
fromvma.c
but this is not enough (I still get a segfault when I increment my variable). Do you know what the additional adaptations are?
– Maxime B.
Nov 22 at 14:19
In my understanding, theses shared variables are read-only from the userland. Thus, this code will compile but if I uncomment the incremenation I’m having a segfault.
notrace int __vdso_myvdso(void) {
// ++*vmyvar; /* The program will crash if I uncomment this*/
` return *vmyvar;` }
Am I doing it wrong? Are there other variables I can modify? Or can I disable this read-only protection?– Maxime B.
Nov 22 at 9:14
In my understanding, theses shared variables are read-only from the userland. Thus, this code will compile but if I uncomment the incremenation I’m having a segfault.
notrace int __vdso_myvdso(void) {
// ++*vmyvar; /* The program will crash if I uncomment this*/
` return *vmyvar;` }
Am I doing it wrong? Are there other variables I can modify? Or can I disable this read-only protection?– Maxime B.
Nov 22 at 9:14
Sorry, you’re right,
VVAR
only gives read-only access from the vDSO.– Stephen Kitt
Nov 22 at 9:53
Sorry, you’re right,
VVAR
only gives read-only access from the vDSO.– Stephen Kitt
Nov 22 at 9:53
I’m trying to disable this read-only protection. Do you know how could I do that? 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 a segfault when I increment my variable). Do you know what the additional adaptations are?– Maxime B.
Nov 22 at 14:19
I’m trying to disable this read-only protection. Do you know how could I do that? 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 a segfault when I increment my variable). Do you know what the additional adaptations are?– Maxime B.
Nov 22 at 14:19
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437433%2fbe-informed-when-a-specific-vdso-is-run%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
can something like
SystemTap
react to your__vdso_myvdso
being called?– thrig
Nov 22 at 14:20
If I understand well, SystemTap is a tool only called from outside the kernel. So unless there is an equivalent tool running in kernelmode, I don’t think so. But correct me if I'm wrong.
– Maxime B.
Nov 22 at 16:43
SystemTap compiles code into the kernel.
– thrig
Nov 22 at 17:44