lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250102135750.GA30778@redhat.com>
Date: Thu, 2 Jan 2025 14:57:50 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Manfred Spraul <manfred@...orfullife.com>,
	WangYuli <wangyuli@...ontech.com>,
	linux-fsdevel <linux-fsdevel@...r.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Christian Brauner <brauner@...nel.org>, 1vier1@....de
Subject: Re: [RESEND PATCH] fs/pipe: Introduce a check to skip sleeping
 processes during pipe read/write

On 12/31, Linus Torvalds wrote:
>
> On Tue, 31 Dec 2024 at 12:25, Oleg Nesterov <oleg@...hat.com> wrote:
> >
> > But let me ask another question right now. what do you think about another
> > minor change below?
>
> Probably ok. Although I'm not convinced it makes things any more readable.

OK, lets forget it for now.

> > Again, mostly to make this logic more understandable. Although I am not
> > sure I really understand it...
>
> So see commit fe67f4dd8daa ("pipe: do FASYNC notifications for every
> pipe IO, not just state changes") on why that crazy poll_usage thing
> exists.

Ah. Yes, yes, thanks, I have already read this commit/changelog, because
I was confused by the unconditional kill_fasync()'s in pipe_read/write.
So I guess I mostly understand the "edge-triggered" issues.

As for epoll, I even wrote the stupid test-case:

	int main(void)
	{
		int pfd[2], efd;
		struct epoll_event evt = { .events = EPOLLIN | EPOLLET };

		pipe(pfd);
		efd = epoll_create1(0);
		epoll_ctl(efd, EPOLL_CTL_ADD, pfd[0], &evt);

		for (int i = 0; i < 2; ++i) {
			write(pfd[1], "", 1);
			assert(epoll_wait(efd, &evt, 1, 0) == 1);
		}

		return 0;
	}

without the pipe->poll_usage check in pipe_write() assert() fails on the
2nd iteration. BTW, I think pipe_write() needs READ_ONCE(pipe->poll_usage),
KCSAN can complain.

> The
>
>   #ifdef CONFIG_EPOLL
>
> addition is straightforward enough and matches the existing comment.
>
> But you adding the FMODE_READ test should probably get a new comment
> about how we only do this for epoll readability, not for writability..

Agreed. perhaps I'll try to make V2 later...

The unconditional WRITE_ONCE(pipe->poll_usage) in pipe_poll() may hide
some subtle race between pipe_write() and the "normal" select/poll, that
is why I'd like to make ->poll_usage depend on filp->f_ep != NULL.

Thanks!

Oleg.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ