Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6510928yba; Wed, 1 May 2019 13:55:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhxFRPSFvWBIhcLo2Kze49nbCb5eEdpirHJKtpwpIlJP6hSkr5562tFLSjg1a5FXnMwsWJ X-Received: by 2002:a63:570d:: with SMTP id l13mr87555pgb.55.1556744116273; Wed, 01 May 2019 13:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556744116; cv=none; d=google.com; s=arc-20160816; b=JJKu6c1EFZHSW/8yjPmM+ArjuuCnnWDlgsVXgGa2KbrM4WANFEAurCTnTZ860BkfLU aFRnC3d9Sygl2bv8EaOzVoNRtEqjlmTTdii/SLnSMre7+BcyL9cR30E0ngJ9rGI5guzk gmQDCLpHorQ2alJCo7L1T4RtdmVDfgah5c5aq6TaFOQ/ibwEaZkGbOo0Qjnw+lyf+ZBe EhNzcaaoMG7O7Ie7O3gdYxIKEqewMoVnx+rteTSEHTSys/+Kt5aUwaOpT8RFnNVd5RWb EMaXRCysARKR14BepU/8N5huiuOXrLK0kQaW+SSgcj2Je2p7/Fr5Cu4gnlQI15z2b4g7 EExA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=NIcJKYBcMp0LBZVdGWmzzu8eQ6eVC6AwEkLQJhbgPJA=; b=VmKG7PxYvUsTeAvl2vxFvIujXZuTYLOug+T9JCMmMYtTdA/jnMH7E/aKDasFMl0oPq 7Qkc1KbBDIUn5yL1gaPTDIKd/zuEsj1Yg5S47k3TbJ05Td+3InZWgEZTUiq0n+uajg5s GTzeerV5VbBmvBECUosxT3beQFAjpqRmHwXQTWjgJ91pcCqqk8NGxrZIVwcFOXux6wuJ Hb6H7dqU/hcT9QGQIcz9fBUS8ZX4XMiTare8diypMxdUJi1zcpLjD8mjJQGJyB0/vqSo PxRfJN6GGBxPQVImG4JR9QnITJX1V0s4u3kKJkiME7DaI1BmD7KhYE6X/g7cOaWcwybW YQFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="uQOR/ugM"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z29si9971612pgl.584.2019.05.01.13.54.59; Wed, 01 May 2019 13:55:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="uQOR/ugM"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726152AbfEAUyJ (ORCPT + 99 others); Wed, 1 May 2019 16:54:09 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:50624 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726088AbfEAUyJ (ORCPT ); Wed, 1 May 2019 16:54:09 -0400 Received: by mail-it1-f194.google.com with SMTP id q14so722287itk.0; Wed, 01 May 2019 13:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NIcJKYBcMp0LBZVdGWmzzu8eQ6eVC6AwEkLQJhbgPJA=; b=uQOR/ugMpYcHFXtprrn5lLtqOgrkNpwpZgQl13kys6czcZPk8ShghAJNb/tq+GerLz aFa8rVINWNqfqcBUW+oLMEN4v1TVZTrmsMXUYF5S3RnjZN6t2KR54P/GSIpn522xOD76 aIfVMfBp5Ls4Gw4RjG5Lw2a2o5KEdKzKrFh8nS82TqMRrc3wEz8mYIjqjkKSQRHsF3/d KC0R0vKhgYa5Bk7Ex+gpoSw7zkXqK5pEty7RvS6D/RdmloGmb8oZjgsJppdUITXCrqWI WwQVEsDyF9rjMWcywF+ccA+KC6tWrDE7d2KFaCHwZ0Y1qx64ZNYwCuobSFyofd5la7tB elGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NIcJKYBcMp0LBZVdGWmzzu8eQ6eVC6AwEkLQJhbgPJA=; b=ck2eLxj+/S2KCGdY617akxtCQfiJTMG2G2VR8MOy2nbcy5de0GZyG8RKk7Ut1C2LAW hfjuHHZkQt8ee1n4W2LY98WDElu/zeWUw3fdhaET8ctSBD1M9yg0Xu5dkn+51m0rW9oP ye6HzvHho5NX1e9ZO4CmL3SGlHHda3eYnCUINivF8XBvRK70CgsUdOlPVsZFx9L8M0bl pfYZ0a6OtAvPmKDKSoxYO2IRaxlBHud739GZt9aOHpfeUz0gi/oca9PXj3uBz9kme+ca pVr99cOrFZUYYoIRcCvD9LtrpIUsVvqui9kIeHIlF0c6gqf2cjoAgTk1+sjowjCIe3ZM rkYQ== X-Gm-Message-State: APjAAAV7yck8YLAdI2Yvhc1mk+H1f99eHo/lf3jGUHb4IUEwwULKJjZ9 C9HNyJPJTPuLkuOY/NThkE+NlPFS7cvqRs7a4SaM6BU/ X-Received: by 2002:a24:7347:: with SMTP id y68mr9823741itb.58.1556744048323; Wed, 01 May 2019 13:54:08 -0700 (PDT) MIME-Version: 1.0 References: <20190424193903.swlfmfuo6cqnpkwa@dcvr> <20190427093319.sgicqik2oqkez3wk@dcvr> <20190428004858.el3yk6hljloeoxza@dcvr> <20190429204754.hkz7z736tdk4ucum@linux-r8p5> <20190429210427.dmfemfft2t2gdwko@dcvr> <20190501021405.hfvd7ps623liu25i@dcvr> <20190501073906.ekqr7xbw3qkfgv56@dcvr> <20190501204826.umekxc7oynslakes@dcvr> In-Reply-To: <20190501204826.umekxc7oynslakes@dcvr> From: Deepa Dinamani Date: Wed, 1 May 2019 13:53:57 -0700 Message-ID: Subject: Re: Strange issues with epoll since 5.0 To: Eric Wong Cc: Davidlohr Bueso , Arnd Bergmann , Al Viro , Jason Baron , Linux Kernel Mailing List , Omar Kilani , Linux FS-devel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 1, 2019 at 1:48 PM Eric Wong wrote: > > Deepa Dinamani wrote: > > So here is my analysis: > > > > > So the 854a6ed56839a40f6 seems to be better than the original code in > > that it detects the signal. > > OTOH, does matter to anybody that a signal is detected slightly > sooner than it would've been, otherwise? The original code drops the signal altogether. This is because it overwrites the current's sigmask with the provided one(set_current_blocked()). If a signal bit was set, it is lost forever. It does not detect it sooner. The check for pending signal is sooner and not just before the syscall returns. This is what the patch in discussion does: check for signals just before returning. > > > But, the problem is that it doesn't > > communicate it to the userspace. > > Yup, that's a big problem :) > > > So a patch like below solves the problem. This is incomplete. I'll > > verify and send you a proper fix you can test soon. This is just for > > the sake of discussion: > > > > diff --git a/fs/eventpoll.c b/fs/eventpoll.c > > index 4a0e98d87fcc..63a387329c3d 100644 > > --- a/fs/eventpoll.c > > +++ b/fs/eventpoll.c > > @@ -2317,7 +2317,7 @@ SYSCALL_DEFINE6(epoll_pwait, int, epfd, struct > > epoll_event __user *, events, > > int, maxevents, int, timeout, const sigset_t __user *, sigmask, > > size_t, sigsetsize) > > { > > - int error; > > + int error, signal_detected; > > sigset_t ksigmask, sigsaved; > > > > /* > > @@ -2330,7 +2330,10 @@ SYSCALL_DEFINE6(epoll_pwait, int, epfd, struct > > epoll_event __user *, events, > > > > error = do_epoll_wait(epfd, events, maxevents, timeout); > > > > - restore_user_sigmask(sigmask, &sigsaved); > > + signal_detected = restore_user_sigmask(sigmask, &sigsaved); > > + > > + if (signal_detected && !error) > > + return -EITNR; > > > > return error; > > Looks like a reasonable API. > > > @@ -2862,7 +2862,7 @@ void restore_user_sigmask(const void __user > > *usigmask, sigset_t *sigsaved) > > if (signal_pending(current)) { > > current->saved_sigmask = *sigsaved; > > set_restore_sigmask(); > > - return; > > + return 0; > > Shouldn't that "return 1" if a signal is pending? Yep, I meant this to be 1. -Deepa