In a Linux kernel module, I have defined some syscalls that are called from an external user code. The user code invokes (one of) the syscalls passing to it the first two arguments from command line, i.e. argv[1]
and argv[2]
.
As an example, if I run ./usercode first second
, i want first
and second
to be sent as arguments to the syscall.
I want to check the count of arguments and their validity in kernel-side (i.e., terminating the syscall with an error code if arguments are actually more than 2 or less than 2, argc
-like, or if some of the arguments are NULL
or somewhat invalid for my purpose) as it is more secure, but I think passing directly the argv
array to the syscall would be… a little insecure. What is a good practice to pass these arguments to the syscall? I thought of concatenating them in a string (separated by maybe), but it seems a bit an overkill.
(Obviously, once in kernel mode, copy_from_user()
is the first thing I do, for security checks)
1