Re: thread permissions issue


Diego Sueiro
 

On Sat, 10 Nov 2018 at 16:59, Diego Sueiro <diego.sueiro@gmail.com> wrote:

Hello Zephyrs,

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[1])" I call the
"Z_SYSCALL_DRIVER_SENSOR(dev, sample_fetch)" and I get the following
error message:

thread 0x2000064c (1) does not have permission on sensor driver
0x20005ac8 [0000]
syscall cmd_get_sensor failed check: access denied


Some questions:

1 - How do I grant permission to the running thread to access the
sensor driver object?
I managed to solve this by calling
"k_thread_access_grant(k_current_get(), dev, NULL)" before calling the
"Z_SYSCALL_DRIVER_SENSOR" macro.

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?
This question remains open.

Join devel@lists.zephyrproject.org to automatically receive all group messages.