Kernel Newbies archive on lore.kernel.org
 help / Atom feed
* In a process context kernel_read returns -EINTR, how to proceed?
@ 2018-12-20 10:33 Lev Olshvang
  2018-12-20 16:40 ` valdis.kletnieks
  0 siblings, 1 reply; 7+ messages in thread
From: Lev Olshvang @ 2018-12-20 10:33 UTC (permalink / raw)
  To: kernelnewbies

Hi All,

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

Then I repeated the attempt limited number of times but still on every read attempt I got -EINTR

I do not understand who may interrupt such a small read, I suppose these libraries are already mapped in other processes so no real I/O should be done.

In a user space it is recommended to repeat syscall, what is the proper course of action in kernel.
As I stated, this code is not in a kernel thread or atomic context, it is in a process context so a tried  before next attempt yield() but to no success.

Waiting for your advises.
Thx,
Lev


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: In a process context kernel_read returns -EINTR, how to proceed?
  2018-12-20 10:33 In a process context kernel_read returns -EINTR, how to proceed? Lev Olshvang
@ 2018-12-20 16:40 ` valdis.kletnieks
  2018-12-21 13:51   ` Lev Olshvang
  0 siblings, 1 reply; 7+ messages in thread
From: valdis.kletnieks @ 2018-12-20 16:40 UTC (permalink / raw)
  To: Lev Olshvang; +Cc: kernelnewbies

On Thu, 20 Dec 2018 13:33:09 +0300, Lev Olshvang said:
> I use kernel_read to read  file in chunks of 4K size in a process context
> On several files, like libc, libm,  I got -EINTR error.

What are you trying to accomplish?  This is not a recommended way to do things.

> I do not understand who may interrupt such a small read, I suppose these
> libraries are already mapped in other processes so no real I/O should be done.

That should be a hint....

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: In a process context kernel_read returns -EINTR, how to proceed?
  2018-12-20 16:40 ` valdis.kletnieks
@ 2018-12-21 13:51   ` Lev Olshvang
  2018-12-21 14:00     ` Greg KH
  2018-12-21 16:15     ` valdis.kletnieks
  0 siblings, 2 replies; 7+ messages in thread
From: Lev Olshvang @ 2018-12-21 13:51 UTC (permalink / raw)
  To: valdis.kletnieks; +Cc: kernelnewbies

Hi Valdis,

I need to read file  inside LSM hook and I can not do it in user space
I forgot o mention that same error occurried  both in 4.4 and 4.13 kernels
 What alternative you can recommend to read file in kernel and avoid -EINTR?
Is vfs_read() different from kernel_read() ?

ThanX
Lev

20.12.2018, 23:09, "valdis.kletnieks@vt.edu" <valdis.kletnieks@vt.edu>:
> On Thu, 20 Dec 2018 13:33:09 +0300, Lev Olshvang said:
>>  I use kernel_read to read file in chunks of 4K size in a process context
>>  On several files, like libc, libm, I got -EINTR error.
>
> What are you trying to accomplish? This is not a recommended way to do things.
>
>>  I do not understand who may interrupt such a small read, I suppose these
>>  libraries are already mapped in other processes so no real I/O should be done.
>
> That should be a hint....
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: In a process context kernel_read returns -EINTR, how to proceed?
  2018-12-21 13:51   ` Lev Olshvang
@ 2018-12-21 14:00     ` Greg KH
  2018-12-21 16:15     ` valdis.kletnieks
  1 sibling, 0 replies; 7+ messages in thread
From: Greg KH @ 2018-12-21 14:00 UTC (permalink / raw)
  To: Lev Olshvang; +Cc: valdis.kletnieks, kernelnewbies

On Fri, Dec 21, 2018 at 04:51:29PM +0300, Lev Olshvang wrote:
> Hi Valdis,
> 
> I need to read file  inside LSM hook and I can not do it in user space
> I forgot o mention that same error occurried  both in 4.4 and 4.13 kernels
>  What alternative you can recommend to read file in kernel and avoid -EINTR?
> Is vfs_read() different from kernel_read() ?

You should never try to read a file from within the kernel.

That way lies madness and lots and lots and lots of problems.

You really are on your own if you want to do that, you should step back
and reconsider exactly what you are trying to do and redesign your
system to not try to ever do this.

good luck!

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: In a process context kernel_read returns -EINTR, how to proceed?
  2018-12-21 13:51   ` Lev Olshvang
  2018-12-21 14:00     ` Greg KH
@ 2018-12-21 16:15     ` valdis.kletnieks
  2018-12-23  8:41       ` Lev Olshvang
  1 sibling, 1 reply; 7+ messages in thread
From: valdis.kletnieks @ 2018-12-21 16:15 UTC (permalink / raw)
  To: Lev Olshvang; +Cc: kernelnewbies

On Fri, 21 Dec 2018 16:51:29 +0300, Lev Olshvang said:

> I need to read file  inside LSM hook and I can not do it in user space

Why? And which LSM hook are you trying to do this?

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: In a process context kernel_read returns -EINTR, how to proceed?
  2018-12-21 16:15     ` valdis.kletnieks
@ 2018-12-23  8:41       ` Lev Olshvang
  2018-12-23  8:53         ` valdis.kletnieks
  0 siblings, 1 reply; 7+ messages in thread
From: Lev Olshvang @ 2018-12-23  8:41 UTC (permalink / raw)
  To: valdis.kletnieks; +Cc: kernelnewbies

I use  security_mmap_file hook.



21.12.2018, 19:15, "valdis.kletnieks@vt.edu" <valdis.kletnieks@vt.edu>:
> On Fri, 21 Dec 2018 16:51:29 +0300, Lev Olshvang said:
>
>>  I need to read file inside LSM hook and I can not do it in user space
>
> Why? And which LSM hook are you trying to do this?

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: In a process context kernel_read returns -EINTR, how to proceed?
  2018-12-23  8:41       ` Lev Olshvang
@ 2018-12-23  8:53         ` valdis.kletnieks
  0 siblings, 0 replies; 7+ messages in thread
From: valdis.kletnieks @ 2018-12-23  8:53 UTC (permalink / raw)
  To: Lev Olshvang; +Cc: kernelnewbies

On Sun, 23 Dec 2018 11:41:30 +0300, Lev Olshvang said:
> I use  security_mmap_file hook.

And what are you trying to accomplish in there?

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-20 10:33 In a process context kernel_read returns -EINTR, how to proceed? Lev Olshvang
2018-12-20 16:40 ` valdis.kletnieks
2018-12-21 13:51   ` Lev Olshvang
2018-12-21 14:00     ` Greg KH
2018-12-21 16:15     ` valdis.kletnieks
2018-12-23  8:41       ` Lev Olshvang
2018-12-23  8:53         ` valdis.kletnieks

Kernel Newbies archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernelnewbies/0 kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ https://lore.kernel.org/kernelnewbies \
		kernelnewbies@kernelnewbies.org kernelnewbies@archiver.kernel.org
	public-inbox-index kernelnewbies


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernelnewbies.kernelnewbies


AGPL code for this site: git clone https://public-inbox.org/ public-inbox