Re: Right way to start a lightweight kernel thread without copying open file descriptors?

2022-01-28 Thread Matthew Trescott
On Fri, Jan 28, 2022 at 7:43 PM Michael Jung wrote: > specific ioctl command implementation Creating a kernel thread in an ioctl "lower-half" would probably cause the file descriptors from the calling task to get copied. Might this be another case of https://github.com/apache/incubator-nuttx/iss

Re: register_driver with 0000 mode

2022-01-28 Thread Petro Karashchenko
I see. Thank you for the feedback. I will rework changes to get back read permissions. Best regards, Petro пт, 28 січ. 2022 р. о 14:41 Alan Carvalho de Assis пише: > > Hi Petro, > > The read permission is needed even when you just want to open a file: > > $ vim noreadfile > > $ chmod noread

Re: register_driver with 0000 mode

2022-01-28 Thread Alan Carvalho de Assis
Hi Petro, The read permission is needed even when you just want to open a file: $ vim noreadfile $ chmod noreadfile $ ls -l noreadfile -- 1 user user 5 jan 28 09:24 noreadfile $ cat noreadfile cat: noreadfile: Permission denied You can even try to create a C program just to open

Re: register_driver with 0000 mode

2022-01-28 Thread Xiang Xiao
On Fri, Jan 28, 2022 at 6:05 PM Petro Karashchenko < petro.karashche...@gmail.com> wrote: > Hello, > > Yes, but how does this relate to "" mode for "register_driver()"? > "" means no read/write/execute permission, I can't imagine any real driver could benefit from it. > Maybe you can de

Re: Right way to start a lightweight kernel thread without copying open file descriptors?

2022-01-28 Thread Xiang Xiao
In the kernel, you should call file_open(file_close...) instead open(close...) to avoid the problem you described below. On Fri, Jan 28, 2022 at 7:43 PM Michael Jung wrote: > Hello everybody, > > I am developing a device driver, which is exposed as a character device > (i.e. /dev/pcd) and which

Right way to start a lightweight kernel thread without copying open file descriptors?

2022-01-28 Thread Michael Jung
Hello everybody, I am developing a device driver, which is exposed as a character device (i.e. /dev/pcd) and which mostly uses ioctl for device control. Within a specific ioctl command implementation I am starting a new kernel thread via kthread_create_with_stack. Once this thread's main functio

Re: register_driver with 0000 mode

2022-01-28 Thread Petro Karashchenko
Hello, Yes, but how does this relate to "" mode for "register_driver()"? Maybe you can describe some use case so it will become more clear? Currently ioctl works fine if driver is registered with "" permission mode. Best regards, Petro пт, 28 січ. 2022 р. о 11:39 Xiang Xiao пише: > > If

Re: register_driver with 0000 mode

2022-01-28 Thread Xiang Xiao
If we want to do the correct permission check, the ioctl handler needs to check R/W bit by itself based on how the ioctl is implemented. Or follow up how Linux encode the needed permission into each IOCTL: https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/ioctl.h#L85-L91 and le

register_driver with 0000 mode

2022-01-28 Thread Petro Karashchenko
Hello team, Recently I have noticed that there are many places in code where register_driver() is called with non-zero mode with file operation structures that have neither read nor write APIs implemented. For example "ret = register_driver(path, &opamp_fops, 0444, dev);" while opamp_fops has only