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: <CABPqkBTWqPNhMBEsLmto+3=2FYjyy_b2hzq2KLbKWDFSKNktsg@mail.gmail.com>
Date:	Wed, 23 Nov 2011 10:30:20 +0100
From:	Stephane Eranian <eranian@...gle.com>
To:	Peter Zijlstra <peterz@...radead.org>
Cc:	linux-kernel@...r.kernel.org, mingo@...e.hu
Subject: Re: [PATCH] perf_event: fix loss of notification with multi-event sampling

On Tue, Nov 22, 2011 at 2:29 PM, Peter Zijlstra <peterz@...radead.org> wrote:
> On Tue, 2011-11-22 at 14:15 +0100, Stephane Eranian wrote:
>
>> > Ah, could it be a race of poll()/wakeup() vs perf_event_set_output() ?
>> >
>> Are you saying that by dropping event->waitq in favor of event->rb->waitq
>> we make this problem disappear due to rcu protections?
>
> Well, except..
>
>> Poll_wait() is a blocking call. It may wait on a stale waitq.  But that problem
>> was probably already there. I am not clear as to what to do about that.
>> in perf_set_output() you would need to wakeup from poll_wait() and then
>> go back in with the new waitq.
>
> Right, the whole blocking thing is a problem, and the whole poll()
> interface always makes my head hurt.
>
> If there was a go-sleep and wake-up side to poll we could do
> ring_buffer_get()/put() and fix this problem, but I'm not finding a way
> to make that happen quite yet.
>
>> Similarly, I am not clear as to what happens when you close an event for
>> which you have  a waiter in poll_wait(). I assume you wakeup from it.
>> But I don't see where that's implemented.
>
> Good point, yes we should do that.
>
So I did run some checks on the behavior of poll() in case a polled fd is
closed. It appears that you don't get out of it in all cases. It depends on
the nature of the file. I believe you get out of poll() ONLY in case of a
producer-consumer file descriptor pair, e.g., a pipe, named pipe, socket.
In other words you need to have a producer file descriptor. In case the
producer is closed, the reader waiting in poll() returns with a POLLHUP
flag. I did verify that for named pipes: close the writer, and the reader
comes out of poll.

In the case of perf_event, we are not in a producer-consumer model, so
it seems like the behavior we have now is correct. The caller of poll()
gets stuck if the file descriptor is closed.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ