From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Benjamin LaHaise <bcrl@kvack.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
David Laight <David.Laight@ACULAB.COM>,
Deepa Dinamani <deepa.kernel@gmail.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Eric Wong <e@80x24.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-aio@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] aio: fix the usage of restore_saved_sigmask_unless()
Date: Fri, 7 Jun 2019 12:32:23 +0200 [thread overview]
Message-ID: <20190607103223.GB22159@redhat.com> (raw)
In-Reply-To: <20190607103122.GA22167@redhat.com>
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
prev parent reply other threads:[~2019-06-07 10:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-07 10:31 [PATCH -mm 0/2] aio: simplify/fix the usage of restore_saved_sigmask_unless() Oleg Nesterov
2019-06-07 10:31 ` [PATCH 1/2] aio: simplify " Oleg Nesterov
2019-06-07 17:33 ` Linus Torvalds
2019-06-07 17:37 ` Linus Torvalds
2019-06-07 18:02 ` Eric W. Biederman
2019-06-07 18:09 ` Linus Torvalds
2019-06-07 10:32 ` Oleg Nesterov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190607103223.GB22159@redhat.com \
--to=oleg@redhat.com \
--cc=David.Laight@ACULAB.COM \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=bcrl@kvack.org \
--cc=deepa.kernel@gmail.com \
--cc=e@80x24.org \
--cc=ebiederm@xmission.com \
--cc=linux-aio@kvack.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.