thread permissions issue
I'm developing a shell module for the sensor drivers and I want to
validate if the device name passed from the user is a sensor device.
I have the CONFIG_USERSAPCE=y.
After calling "dev = device_get_binding(argv)" I call the
"Z_SYSCALL_DRIVER_SENSOR(dev, sample_fetch)" and I get the following
thread 0x2000064c (1) does not have permission on sensor driver
syscall cmd_get_sensor failed check: access denied
1 - How do I grant permission to the running thread to access the
sensor driver object?
2 - Even having the CONFIG_USERSAPCE=y set when calling
"sensor_sample_fetch" it seems that it is calling the
"_impl_sensor_sample_fetch" directly instead of
"Z_SYSCALL_HANDLER(sensor_sample_fetch, dev)" defined in the
drivers/sensor/sensor_handlers.c file. How can I have the current
thread using the userspace syscalls?
On Sat, 10 Nov 2018 at 16:59, Diego Sueiro <diego.sueiro@...> wrote:
I managed to solve this by calling
"k_thread_access_grant(k_current_get(), dev, NULL)" before calling the
2 - Even having the CONFIG_USERSAPCE=y set when callingThis question remains open.
Boie, Andrew P
I'm developing a shell module for the sensor drivers and I want toThe userspace infrastructure has facilities for this, but as I commented in your patch, what you are doing is only intended for system call handlers. The Zephyr kernel running in supervisor mode is intended to be very lightweight and doesn't have features like this, it's a garbage-in-garbage-out type of situation.
The proper way to do this is have the shell main loop run in user mode, it's the only way to make robust assertions that malformed user input can't hose the system. I suggest just dropping the checks.