lkml.org 
[lkml]   [2019]   [Jun]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 2/2] aio: fix the usage of restore_saved_sigmask_unless()
do_io_getevents() is the only user of set/restore_user_sigmask which
can return success or error and deliver a signal which was temporary
unblocked by set_user_sigmask().

Change it to keep the modified sigmask (pass true to restore_unless)
only if the syscall returns ERESTARTNOHAND/EINTR. This matches all
other syscalls which modify current->blocked before wait-for-event.

Note that it doesn't even need the signal_pending() check, read_event()
wait_event_interruptible_hrtimeout() returns ERESTARTSYS if interrupted.
But it seems that read_events() needs some unrelated cleanups which
should be done first.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
fs/aio.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/aio.c b/fs/aio.c
index 944eef7..5bdbef0 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -2034,7 +2034,6 @@ static long do_io_getevents(aio_context_t ctx_id,
{
ktime_t until = ts ? timespec64_to_ktime(*ts) : KTIME_MAX;
struct kioctx *ioctx = lookup_ioctx(ctx_id);
- bool interrupted;
long ret = -EINVAL;

if (likely(ioctx)) {
@@ -2043,10 +2042,9 @@ static long do_io_getevents(aio_context_t ctx_id,
percpu_ref_put(&ioctx->users);
}

- interrupted = signal_pending(current);
- restore_saved_sigmask_unless(interrupted);
- if (interrupted && !ret)
+ if (!ret && signal_pending(current))
ret = -ERESTARTNOHAND;
+ restore_saved_sigmask_unless(ret == -ERESTARTNOHAND);

return ret;
}
--
2.5.0

\
 
 \ /
  Last update: 2019-06-07 12:32    [W:0.118 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site