# checking syscall variables from userland to kerneland



## eyebone (May 18, 2010)

hello folks,

i have written a module which takes userinput via a newly created syscall and progresses it. now, for sake of simplicity the syscall itself just uprintf() the string which was given on the syscall.

lets say i call the new syscall with:


```
syscall(210,"hi there");
```

my module shall print "hi there". all in all this is working ratherly perfect. sadly, i didn't come to a good idea how to *check* if:

1. there was an argument for the string
2. if it was a string

now, if i just call my nice syscall without any argument, i get a kernel trap.
what would be proper ways to check for such? :stud

regards,


----------



## trasz@ (May 18, 2010)

Looks like you're trying to use the argument in the kernel as-is, which is wrong.  Please see copyinstr(9) manual page.


----------



## eyebone (May 18, 2010)

hum. oh really? i can check with copy* family if the value was even specified in userland? this means if i get a null as return, something was wrong in userland. sounds good.
thanks trasz


----------



## trasz@ (May 18, 2010)

The copyinstr(9) function will return EFAULT if the value was invalid; then you can return this error to the userland.  However, the important thing is that in cases like this you cannot use the value without copying using proper function.  In other words, there is no point in just checking whether it's valid or not - you have to copy.


----------

