lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180717105845.GC27482@redhat.com>
Date:   Tue, 17 Jul 2018 12:58:45 +0200
From:   Oleg Nesterov <oleg@...hat.com>
To:     "Eric W. Biederman" <ebiederm@...ssion.com>
Cc:     Linus Torvalds <torvalds@...ux-foundation.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        linux-kernel@...r.kernel.org, Wen Yang <wen.yang99@....com.cn>,
        majiang <ma.jiang@....com.cn>
Subject: Re: [RFC][PATCH 09/11] tty_io: Use do_send_sig_info in __do_SACK  to
 forcibly kill tasks

On 07/16, Eric W. Biederman wrote:
>
> Oleg Nesterov <oleg@...hat.com> writes:
>
> > On 07/10, Eric W. Biederman wrote:
> >>
> >> Therefore use do_send_sig_info in all cases in __do_SAK to kill
> >> tasks as allows for exactly what the code wants to do.
> >
> > OK, but probably the changelog should also mention that now even the global
> > init will be killed if it has this tty opened.
>
> force_sig was ensuring the global init would die.  So that isn't a
> change.  Mentioning it isn't a bad idea.

I meant another "p->signal->tty == tty" case which uses send_sig(SIGKILL).

As for force_sig(), yes it kills init, but "by accident". See your commit
20ac94378 "do_SAK: Don't recursively take the tasklist_lock", it replaced
send_sig() because it took tasklist_lock.

Nevermind, let me repeat I am not arguing with this change.

But it looks off-topic in this series, why do we need it? Yes, these
send_sig/force_sig are ugly, we need do_send_sig_info(PIDTYPE_TGID). But
__do_SAK() needs more cleanups, do_each_thread() is ugly too by the same
reason, we should not send SIGKILL per-thread. And iirc it is racy either
way, a process can open tty right after it was checkeda process can open
tty right after it was checked.

I think the main loop should be rewritten as

	for_each_process(p) {
		if (p->signal->tty == tty) {
			tty_notice(tty, "SAK: killed process %d (%s): by controlling tty\n",
				   task_pid_nr(p), p->comm);
			goto kill;
		}

		files = NULL;
		for_each_thread(p, t) {
				if (t->files == files) /* racy but we do not care */
					continue;

				task_lock(t);
				files = t->files;
				i = iterate_fd(files, 0, this_tty, tty);
				task_unlock(t);

				if (i != 0) {
					tty_notice(tty, "SAK: killed process %d (%s): by fd#%d\n",
						   task_pid_nr(p), p->comm, i - 1);
					goto kill;
				}
		}

		continue;
 kill:
		do_send_sig_info(SIGKILL, SEND_SIG_NOINFO, p, true);
	}

If we want to kill init's as well, we can use SEND_SIG_FORCE and this can come
as a separate change, although I am personally fine either way.

Oleg.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ