LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Roman Gushchin <guro@fb.com>
Cc: Qian Cai <cai@lca.pw>, "tj@kernel.org" <tj@kernel.org>,
	"lizefan@huawei.com" <lizefan@huawei.com>,
	"hannes@cmpxchg.org" <hannes@cmpxchg.org>,
	"cgroups@vger.kernel.org" <cgroups@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: ptrace warning due to "cgroup: get rid of cgroup_freezer_frozen_exit()"
Date: Wed, 8 May 2019 17:25:36 +0200	[thread overview]
Message-ID: <20190508152536.GA17058@redhat.com> (raw)
In-Reply-To: <20190507213752.GA24308@tower.DHCP.thefacebook.com>

On 05/07, Roman Gushchin wrote:
>
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -2484,9 +2484,6 @@ bool get_signal(struct ksignal *ksig)
>                 sigdelset(&current->pending.signal, SIGKILL);
>                 recalc_sigpending();
>                 current->jobctl &= ~JOBCTL_TRAP_FREEZE;

just noticed... perhaps it makes more sense to clear JOBCTL_TRAP_FREEZE
before recalc_sigpending(). Or simply not clear it at all, see below.

> -               spin_unlock_irq(&sighand->siglock);
> -               if (unlikely(cgroup_task_frozen(current)))
> -                       cgroup_leave_frozen(true);
>                 goto fatal;
>         }
>  
> @@ -2608,8 +2605,10 @@ bool get_signal(struct ksignal *ksig)
>                         continue;
>                 }
>  
> -               spin_unlock_irq(&sighand->siglock);
>         fatal:
> +               spin_unlock_irq(&sighand->siglock);
> +               if (unlikely(cgroup_task_frozen(current)))
> +                       cgroup_leave_frozen(true);

Yes, ptrace_signal() can return a fatal signal... and in this case we do not
clear JOBCTL_TRAP_FREEZE. This doesn't look consistent with the code above.



I can only repeat that somehow we need to cleanup/improve the whole logic.

Say, a traced task reports syscall-enter. ptrace_stop() does enter_frozen().
The cgroup can become CGRP_FROZEN after that. Now the debugger does PTRACE_CONT,
the frozen task actually starts the syscall. Obviously not good.

Heh, and if this syscall is sys_exit or sys_exit_group we can hit the same
warning.

Oleg.


  parent reply	other threads:[~2019-05-08 15:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-07 20:04 Qian Cai
2019-05-07 21:37 ` Roman Gushchin
2019-05-08 13:10   ` Qian Cai
2019-05-08 15:25   ` Oleg Nesterov [this message]
2019-05-08 18:03     ` Roman Gushchin

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=20190508152536.GA17058@redhat.com \
    --to=oleg@redhat.com \
    --cc=cai@lca.pw \
    --cc=cgroups@vger.kernel.org \
    --cc=guro@fb.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=tj@kernel.org \
    --subject='Re: ptrace warning due to "cgroup: get rid of cgroup_freezer_frozen_exit()"' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).