Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-29 Thread Deepa Dinamani
On Wed, May 29, 2019 at 9:57 AM Oleg Nesterov wrote: > > On 05/28, Deepa Dinamani wrote: > > > > I agree that signal handller being called and return value not being > > altered is an issue with other syscalls also. I was just wondering if > > some userspace code assumption would be assuming this.

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-29 Thread Oleg Nesterov
On 05/28, Deepa Dinamani wrote: > > I agree that signal handller being called and return value not being > altered is an issue with other syscalls also. I was just wondering if > some userspace code assumption would be assuming this. This is not a > kernel bug. > > But, I do not think we have an un

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-28 Thread Deepa Dinamani
On Mon, May 27, 2019 at 8:04 AM Oleg Nesterov wrote: > > Deepa, > > it seems that we both are saying the same things again and again, and we > simply can't understand each other. Oleg, I'm sorry for the confusion. Maybe I should point out what I agree with also. I agree that signal handller bei

RE: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-28 Thread David Laight
From: Deepa Dinamani > Sent: 28 May 2019 12:38 > > On May 28, 2019, at 2:12 AM, David Laight wrote: > > > > From: Deepa Dinamani > >> Sent: 24 May 2019 18:02 > > ... > >> Look at the code before 854a6ed56839a: > >> > >> /* > >> * If we changed the signal mask, we need to restore the original

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-28 Thread Deepa Dinamani
> On May 28, 2019, at 2:12 AM, David Laight wrote: > > From: Deepa Dinamani >> Sent: 24 May 2019 18:02 > ... >> Look at the code before 854a6ed56839a: >> >> /* >> * If we changed the signal mask, we need to restore the original one. >> * In case we've got a signal while waiting, w

RE: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-28 Thread David Laight
From: Deepa Dinamani > Sent: 24 May 2019 18:02 ... > Look at the code before 854a6ed56839a: > > /* > * If we changed the signal mask, we need to restore the original one. > * In case we've got a signal while waiting, we do not restore the > * signal mask yet, and we allow

RE: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-28 Thread David Laight
From: Deepa Dinamani > Sent: 24 May 2019 18:02 ... > Maybe a crude userspace application could do something like this: > > sig_handler() > { > set global abort = 1 > } > > poll_the_fds() > { > ret = epoll_pwait() > if (ret) > return ret > if (abort) >

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-27 Thread Oleg Nesterov
Deepa, it seems that we both are saying the same things again and again, and we simply can't understand each other. I'll try to write another email to restart this discussion. Tomorrow, somehow I can't wake up today. And let me repeat, of course I can be wrong. IOW, it is not that I am trying to

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-24 Thread Deepa Dinamani
On Fri, May 24, 2019 at 9:33 AM Oleg Nesterov wrote: > > On 05/24, Deepa Dinamani wrote: > > > > On Fri, May 24, 2019 at 7:11 AM Oleg Nesterov wrote: > > > > > > On 05/23, Deepa Dinamani wrote: > > > > > > > > Ok, since there has been quite a bit of argument here, I will > > > > backtrack a littl

RE: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-24 Thread David Laight
From: Oleg Nesterov > Sent: 24 May 2019 16:44 > > To my mind changing the signal mask should be enough to get a masked > > signal handler called - even if the mask is reset before the syscall exits. > > well, the kernel doesn't do this, and on purpose. > > > There shouldn't be any need for an int

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-24 Thread Oleg Nesterov
On 05/24, Deepa Dinamani wrote: > > On Fri, May 24, 2019 at 7:11 AM Oleg Nesterov wrote: > > > > On 05/23, Deepa Dinamani wrote: > > > > > > Ok, since there has been quite a bit of argument here, I will > > > backtrack a little bit and maybe it will help us understand what's > > > happening here.

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-24 Thread Oleg Nesterov
On 05/24, David Laight wrote: > > From: David Laight > > Sent: 24 May 2019 16:00 > ... > > I've had horrid thoughts about SIG_SUSPEND :-) > > Not to mention exiting signal handlers with longjmp(). that is why we have siglongjmp(). Oleg.

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-24 Thread Oleg Nesterov
On 05/24, David Laight wrote: > > From: Oleg Nesterov > > Sent: 24 May 2019 14:29 > > It seems that we all are just trying to confuse each other. I got lost. > > I'm always lost :-) same here ;) > To my mind changing the signal mask should be enough to get a masked > signal handler called - even

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-24 Thread Deepa Dinamani
On Fri, May 24, 2019 at 7:11 AM Oleg Nesterov wrote: > > On 05/23, Deepa Dinamani wrote: > > > > Ok, since there has been quite a bit of argument here, I will > > backtrack a little bit and maybe it will help us understand what's > > happening here. > > There are many scenarios being discussed on

RE: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-24 Thread David Laight
From: David Laight > Sent: 24 May 2019 16:00 ... > I've had horrid thoughts about SIG_SUSPEND :-) Not to mention exiting signal handlers with longjmp(). David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

RE: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-24 Thread David Laight
From: Oleg Nesterov > Sent: 24 May 2019 14:29 > It seems that we all are just trying to confuse each other. I got lost. I'm always lost :-) > On 05/23, David Laight wrote: > > > > From: Oleg Nesterov > > > Sent: 23 May 2019 17:36 > > > On 05/23, David Laight wrote: > > > > > > > > From: Oleg Nest

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-24 Thread Oleg Nesterov
On 05/24, Deepa Dinamani wrote: > > I think you are misunderstanding what I said. probably. Everything was very confusing to me from the very beginning. And yes, I can hardly understand your emails, sorry. This one too :/ > You are taking things > out of context. I was saying here what I did was

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-24 Thread Deepa Dinamani
I think you are misunderstanding what I said. You are taking things out of context. I was saying here what I did was inspired by why the syscall was designed to begin with. The syscall below refers to epoll_wait and not epoll_pwait. -Deepa On Fri, May 24, 2019 at 7:19 AM Oleg Nesterov wrote: > >

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-24 Thread Oleg Nesterov
On 05/23, Deepa Dinamani wrote: > > 1. block the signals you don't care about. > 2. syscall() > 3. unblock the signals blocked in 1. and even this part of your email is very confusing. because in this case we can never miss a signal. I'd say 1. block the signals you don't care about

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-24 Thread Oleg Nesterov
On 05/23, Deepa Dinamani wrote: > > Ok, since there has been quite a bit of argument here, I will > backtrack a little bit and maybe it will help us understand what's > happening here. > There are many scenarios being discussed on this thread: > a. State of code before 854a6ed56839a I think everyt

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-24 Thread Oleg Nesterov
It seems that we all are just trying to confuse each other. I got lost. On 05/23, David Laight wrote: > > From: Oleg Nesterov > > Sent: 23 May 2019 17:36 > > On 05/23, David Laight wrote: > > > > > > From: Oleg Nesterov > > > > On 05/23, David Laight wrote: > ... > > > > Not sure I understand... O

RE: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-24 Thread David Laight
From: Deepa Dinamani > Sent: 23 May 2019 19:07 > Ok, since there has been quite a bit of argument here, I will > backtrack a little bit and maybe it will help us understand what's > happening here. > There are many scenarios being discussed on this thread: > a. State of code before 854a6ed56839a >

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-23 Thread Deepa Dinamani
> Just adding a little more clarification, there is an additional change > between [a] and [b]. > As per [a] we would just restore the signal instead of changing the > saved_sigmask and the signal could get delivered right then. [b] > changes this to happen at syscall exit: Rewording above, as the

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-23 Thread Deepa Dinamani
On Thu, May 23, 2019 at 11:06 AM Deepa Dinamani wrote: > > Ok, since there has been quite a bit of argument here, I will > backtrack a little bit and maybe it will help us understand what's > happening here. > There are many scenarios being discussed on this thread: > a. State of code before 854a6

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-23 Thread Deepa Dinamani
Ok, since there has been quite a bit of argument here, I will backtrack a little bit and maybe it will help us understand what's happening here. There are many scenarios being discussed on this thread: a. State of code before 854a6ed56839a b. State after 854a6ed56839a c. Proposed fix as per the pat

RE: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-23 Thread David Laight
From: Oleg Nesterov > Sent: 23 May 2019 17:36 > On 05/23, David Laight wrote: > > > > From: Oleg Nesterov > > > On 05/23, David Laight wrote: ... > > > Not sure I understand... OK, suppose that you do > > > > > > block-all-signals; > > > ret = pselect(..., sigmask(SIG_URG)); > > > > > > if it r

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-23 Thread Oleg Nesterov
On 05/23, David Laight wrote: > > From: Oleg Nesterov > > On 05/23, David Laight wrote: > > > > > > I'm confused... > > > > Me too. To clarify, the current code is obviously buggy, pselect/whatever > > shouldn't return 0 (or anything else) if it was interrupted and we are going > > to deliver the s

RE: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-23 Thread David Laight
From: Oleg Nesterov > On 05/23, David Laight wrote: > > > > I'm confused... > > Me too. To clarify, the current code is obviously buggy, pselect/whatever > shouldn't return 0 (or anything else) if it was interrupted and we are going > to deliver the signal. If it was interrupted the return value

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-23 Thread Oleg Nesterov
On 05/23, David Laight wrote: > > I'm confused... Me too. To clarify, the current code is obviously buggy, pselect/whatever shouldn't return 0 (or anything else) if it was interrupted and we are going to deliver the signal. But it seems that Deepa has other concerns which I do not understand at a

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-23 Thread Oleg Nesterov
On 05/22, Deepa Dinamani wrote: > > > > > --- a/include/linux/sched/signal.h > > > > +++ b/include/linux/sched/signal.h > > > > @@ -416,7 +416,6 @@ void task_join_group_stop(struct task_struct *task); > > > > static inline void set_restore_sigmask(void) > > > > { > > > >set_thread_flag(TIF_REST

RE: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-23 Thread David Laight
From: Deepa Dinamani > Sent: 22 May 2019 17:34 > On Wed, May 22, 2019 at 9:14 AM Oleg Nesterov wrote: > > > > On 05/22, Deepa Dinamani wrote: > > > > > > -Deepa > > > > > > > On May 22, 2019, at 8:05 AM, Oleg Nesterov wrote: > > > > > > > >> On 05/21, Deepa Dinamani wrote: > > > >> > > > >> Note

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-22 Thread Deepa Dinamani
On Wed, May 22, 2019 at 3:18 PM Chris Down wrote: > > +Cc: linux-mm, since this broke mmots tree and has been applied there > > This patch is missing a definition for signal_detected in io_cqring_wait, > which > breaks the build. This patch does not break the build. The patch the breaks the buil

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-22 Thread Chris Down
+Cc: linux-mm, since this broke mmots tree and has been applied there This patch is missing a definition for signal_detected in io_cqring_wait, which breaks the build. diff --git fs/io_uring.c fs/io_uring.c index b785c8d7efc4..b34311675d2d 100644 --- fs/io_uring.c +++ fs/io_uring.c @@ -2182,7

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-22 Thread Deepa Dinamani
On Wed, May 22, 2019 at 9:14 AM Oleg Nesterov wrote: > > On 05/22, Deepa Dinamani wrote: > > > > -Deepa > > > > > On May 22, 2019, at 8:05 AM, Oleg Nesterov wrote: > > > > > >> On 05/21, Deepa Dinamani wrote: > > >> > > >> Note that this patch returns interrupted errors (EINTR, ERESTARTNOHAND, >

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-22 Thread Oleg Nesterov
On 05/22, Deepa Dinamani wrote: > > -Deepa > > > On May 22, 2019, at 8:05 AM, Oleg Nesterov wrote: > > > >> On 05/21, Deepa Dinamani wrote: > >> > >> Note that this patch returns interrupted errors (EINTR, ERESTARTNOHAND, > >> etc) only when there is no other error. If there is a signal and an err

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-22 Thread Deepa Dinamani
-Deepa > On May 22, 2019, at 8:05 AM, Oleg Nesterov wrote: > >> On 05/21, Deepa Dinamani wrote: >> >> Note that this patch returns interrupted errors (EINTR, ERESTARTNOHAND, >> etc) only when there is no other error. If there is a signal and an error >> like EINVAL, the syscalls return -EINVAL ra

Re: [PATCH v2] signal: Adjust error codes according to restore_user_sigmask()

2019-05-22 Thread Oleg Nesterov
On 05/21, Deepa Dinamani wrote: > > Note that this patch returns interrupted errors (EINTR, ERESTARTNOHAND, > etc) only when there is no other error. If there is a signal and an error > like EINVAL, the syscalls return -EINVAL rather than the interrupted > error codes. Ugh. I need to re-check, but