What to do if kernel_read() returns -EINTR?

What to do if kernel_read() returns -EINTR?

Lev Olshvang levonshe at yandex.com
Fri Dec 21 17:21:08 IST 2018


Hi All,

I need to do some calculation of file contents inside LSM hook.

This LSM hook is in a process context, so I hope I can do I/O.
( I put might_sleep() inside hook to confirm I can sleep)

I use kernel_read() to read  file in chunks of 4K size.
On several files, like libc, libm,  I got -EINTR error.

I  tried to insert mdelay() or yield() before repeating  kernel_read but still on every read attempt I got -EINTR.
According to timestamp of printk, mdelay or yield() do not have any affect, next read happens 2-3 nsecs later.

This error happens on libc, libm, ld-linux on 4.4 and 4.13 kernels.
It did not happen on other libraries.

What might be the solution for this problem ?
ThnX,
Lev 






More information about the Linux-il mailing list