Re: Working with user space file descriptor in kernel thread

2025-03-11 Thread Peter Skvarka
... You can then use the socket directly in the kernel... Is this valid also when this socket is used by separate kernel thread ? It is different than thread which runs in ioctl and provides socket. Peter

Re: Working with user space file descriptor in kernel thread

2025-03-11 Thread Martin Husemann
On Tue, Mar 11, 2025 at 03:08:15PM +0100, Peter Skvarka wrote: > > ... You can then use the socket directly in the kernel... > > Is this valid also when this socket is used by separate kernel thread ? > It is different than thread which runs in ioctl and provides socket. There is nothing thread-l

Working with user space file descriptor in kernel thread

2025-03-11 Thread Peter Skvarka
Hello, I have created two sockets with socketpair() and one of them is put into kernel module through ioctl. I need to work with passed socket in separate kernel thread. In my module ioctl handler I am able to retrieve file descriptor from user mode descriptor (int user_sock) : file_fd = fd_ge

Re: ataraid(4) missing disk handling

2025-03-11 Thread Andrius V
On Tue, Mar 11, 2025 at 2:17 AM Christoph Badura wrote: > > On Mon, Mar 10, 2025 at 04:43:30PM +0200, Andrius V wrote: > > Taylor has a good analysis and explanation of the issue > > https://mail-index.netbsd.org/netbsd-bugs/2024/03/26/msg082202.html, > > which I also noticed by testing ATA RAID s

Re: Working with user space file descriptor in kernel thread

2025-03-11 Thread Mouse
> I have created two sockets with socketpair() and one of them is put > into kernel module through ioctl. [...] I am able to retrieve file > descriptor from user mode descriptor (int user_sock) : > file_fd = fd_getfile2(lewepe->l_proc, user_sock); Minor terminological point: the term "file descr

Re: Working with user space file descriptor in kernel thread

2025-03-11 Thread Jason Thorpe
> On Mar 11, 2025, at 2:20 AM, Peter Skvarka wrote: > > Hello, > I have created two sockets with socketpair() and one of them is put into > kernel module through ioctl. > I need to work with passed socket in separate kernel thread. > In my module ioctl handler I am able to retrieve file descr

Re: Working with user space file descriptor in kernel thread

2025-03-11 Thread Michael van Elst
mo...@rodents-montreal.org (Mouse) writes: >> My question is: >> Can I use such retrieved file_fd or struct socket* so in separate >> kernel thread ? >I see no reason why not - but that is not at all the same as "yes". I >do not work with multiple threads often enough to feel confident of my >an

Re: Interface for communicating from kernel to user mode

2025-03-11 Thread Peter Skvarka
Resolved, vmspace initialization was missing. I used uio_setup_sysspace(&my_uio); Now I am seeing message in kernel which was sent through socket pair from user space. Thanks for all your detailed answers. Peter

ataraid(4) missing disk handling

2025-03-11 Thread Andrius V
Hi, For the last week I am working on the fix for the ataraid(4) related to the bug reported in kern/43986 and partially to kern/59130 (hits same issue due to different bug). Taylor has a good analysis and explanation of the issue https://mail-index.netbsd.org/netbsd-bugs/2024/03/26/msg082202.htm

Re: Interface for communicating from kernel to user mode

2025-03-11 Thread Peter Skvarka
Thanks for detailed answer. With help of your description I reached valid file_t* file_fd in kernel module. In kernel module I used file_fd = fd_getfile2(lwp_ptr->l_proc, user_fd); which encapsulates your older code. Also test for descriptor type: if(file_fd->f_type != DTYPE_SOCKET) {...} is o

Re: Interface for communicating from kernel to user mode

2025-03-11 Thread Mouse
> [...reached the point of having the struct socket *...] > What I cannot resolve is which function to use for receiving data > sent from user mode on retrieved file_fd in kernel module. When I > tried soo_read(file_fd,...) then OS freezes and need to reboot. I > call soo_read() in kernel thread

Re: Interface for communicating from kernel to user mode

2025-03-11 Thread Peter Skvarka
Could you break into ddb? A stack trace of the freeze might be useful. Two things: 1. I have NetBSD 10.1. I found crash dump: crash> bt __kernel_end() at 0 kern_reboot() at sys_reboot vpanic() at vpanic+0x192 panic() at device_printf trap() at startlwp --- trap (number 6) --- uiomove() at u

Re: GSOC - Emulating missing linux syscalls

2025-03-11 Thread Emmanuel Dreyfus
On Tue, Mar 11, 2025 at 07:21:47PM +0100, Vasyl Maksym Lanko wrote: > 1. Is this mostly correct? It is. In my opinion your second scenario is the path of least resistance. > 2. Is this project mostly about identifying the missing syscall used in a > Linux Binary and porting it to NetBSD? That is

lwp_create()

2025-03-11 Thread Peter Skvarka
Hello, I need to add kernel thread which starts in kernel module after modload and finishes on modunload. I am looking into sys/lwp.h and kern/kern_lwp.c. on lwp..() prototypes and I have many questions on it. Does exist any example which can help to understand how to properly use this inte

Re: Interface for communicating from kernel to user mode

2025-03-11 Thread Mouse
>> Could you break into ddb? A stack trace of the freeze might be useful. > 1. I have NetBSD 10.1. Okay. That limits the amount I can help with details, since I don't run it. (Even at work, the latest NetBSD I use is 9.1.) > I found crash dump: > crash> bt > __kernel_end() at 0 > kern_reboot(

GSOC - Emulating missing linux syscalls

2025-03-11 Thread Vasyl Maksym Lanko
Hello! I have some questions about GSOC - Emulating missing linux syscalls ( https://wiki.netbsd.org/projects/project/linux_timer/ ). I have been using Linux for some years but never touched NetBSD, so I'm going to describe the project using Linux names/tools instead. "Not all Linux syscalls a