Received: by 10.192.165.148 with SMTP id m20csp662067imm; Wed, 9 May 2018 21:04:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqm/yI09wOQttraJ4PmNYzaEXwkvCF3s8kmomwuKzgYfT8ZYC9V0QXE1DA0gUwZYOzCpMb0 X-Received: by 2002:a63:715a:: with SMTP id b26-v6mr3643443pgn.440.1525925097606; Wed, 09 May 2018 21:04:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525925097; cv=none; d=google.com; s=arc-20160816; b=bGdOfTHxN8r6cbGH+Yl2xl3K5C4F+b9zNupS0mibEyGrPpt/m61//frz7HCbGL9mdC jm3nqioEJW/La8hkLSts5Rq2dkdwnqN+CHoGp+2yEDs9trnhd3sHmJHufo9CBg/QNcGH 8nPtT2BSW+0eKTL0UlwJlv0MLIPRW+98iziTaTA94jLGEov8PLqKo7hEjOXcsiyOgM7V Fa20kgOFa4Jdpk+u5NH1ENiV1qqIlD6A9VeMdFjL1DVWmZSick/Sq3OYaF+9xzQw3Jx/ /ewL24d3KzzuLfAlEOHkgAKOc84Bri2hzxGP7ktbl4u5dxSXjEoLniLwmTfJ1uWT4Ro7 lG4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from :arc-authentication-results; bh=AmAvg8aorsg7JG5wdY8+b/YmBxZGC9PZ5nS4mLKr7Zo=; b=id0esuB/hlIRBLX2zgHZUtuXjdtat+oLorhkL84jAqBp2Bp9RmP5VNtmn9mzNU3ayJ m35aR4GiuPEjAOt3rQ0+pkAEI1DUMHMhWKhT7C7kh2wVsRnOScxMF1+lc8Ij4uUGlO3S 28TWpX2FleN4kHCY6o75Tg4p7zy64PkLTA4wzwXlOmwRhEjuv58flxMltTuNjM78nu1T teq93V1e9O1ttD02HNjxojbbbQB8FGM7BX4xqZUN/lu6jJUsGZdwOqM2xK/HZTRypCB0 G1//s03w7wO2Nn69CYdC03UdWSVqn2yT+BX/OSN+eWk8WfHwxwKPQEO+QbEb/7KVAQCP KcZQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e66-v6si27577939plb.499.2018.05.09.21.04.42; Wed, 09 May 2018 21:04:57 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753639AbeEJEDd (ORCPT + 99 others); Thu, 10 May 2018 00:03:33 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:42302 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753544AbeEJEDc (ORCPT ); Thu, 10 May 2018 00:03:32 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fGcni-0003lg-E6; Wed, 09 May 2018 22:03:30 -0600 Received: from [97.90.247.198] (helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fGcnh-00051m-OJ; Wed, 09 May 2018 22:03:30 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Oleg Nesterov Cc: Johannes Weiner , Michal Hocko , Kirill Tkhai , akpm@linux-foundation.org, peterz@infradead.org, viro@zeniv.linux.org.uk, mingo@kernel.org, paulmck@linux.vnet.ibm.com, keescook@chromium.org, riel@redhat.com, tglx@linutronix.de, kirill.shutemov@linux.intel.com, marcos.souza.org@gmail.com, hoeun.ryu@gmail.com, pasha.tatashin@oracle.com, gs051095@gmail.com, dhowells@redhat.com, rppt@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, Balbir Singh , Tejun Heo References: <20180503133338.GA23401@redhat.com> <87y3h0x0qg.fsf@xmission.com> <20180504142056.GA26151@redhat.com> <87r2mrh4is.fsf@xmission.com> <20180504145435.GA26573@redhat.com> <87y3gzfmjt.fsf@xmission.com> <20180504162209.GB26573@redhat.com> <871serfk77.fsf@xmission.com> <20180507143358.GA3071@redhat.com> <87vabyvnw0.fsf@xmission.com> <20180509144016.GA25742@redhat.com> <87vabwp5p6.fsf@xmission.com> Date: Wed, 09 May 2018 23:03:23 -0500 In-Reply-To: <87vabwp5p6.fsf@xmission.com> (Eric W. Biederman's message of "Wed, 09 May 2018 22:09:25 -0500") Message-ID: <871sekp378.fsf_-_@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1fGcnh-00051m-OJ;;;mid=<871sekp378.fsf_-_@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=97.90.247.198;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/mb1mmPHGnnYQkWVVCE01dE+vxBTjSsX0= X-SA-Exim-Connect-IP: 97.90.247.198 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa06.xmission.com X-Spam-Level: * X-Spam-Status: No, score=1.3 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,TR_Symld_Words autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 1.5 TR_Symld_Words too many words that have symbols inside * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;Oleg Nesterov X-Spam-Relay-Country: X-Spam-Timing: total 257 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 2.9 (1.1%), b_tie_ro: 2.1 (0.8%), parse: 0.94 (0.4%), extract_message_metadata: 12 (4.5%), get_uri_detail_list: 1.55 (0.6%), tests_pri_-1000: 6 (2.3%), tests_pri_-950: 1.16 (0.5%), tests_pri_-900: 0.99 (0.4%), tests_pri_-400: 23 (8.9%), check_bayes: 22 (8.5%), b_tokenize: 7 (2.9%), b_tok_get_all: 7 (2.8%), b_comp_prob: 2.1 (0.8%), b_tok_touch_all: 3.5 (1.4%), b_finish: 0.64 (0.2%), tests_pri_0: 204 (79.2%), check_dkim_signature: 0.62 (0.2%), check_dkim_adsp: 2.8 (1.1%), tests_pri_500: 4.4 (1.7%), rewrite_mail: 0.00 (0.0%) Subject: [RFC][PATCH] cgroup: Don't mess with tasks in exec X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Semantically exec is supposed to be atomic with no user space visible intermediate points. Migrating tasks during exec may change that and lead to all manner of difficult to analyze and maintin corner cases. So avoid the problems by simply blocking cgroup migration over the entirety of exec. Reported-by: Oleg Nesterov Signed-off-by: "Eric W. Biederman" --- Unless this leads to some kind of deadlock fs/exec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 32461a1543fc..54bb01cfc635 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1101,7 +1099,6 @@ static int de_thread(struct task_struct *tsk) struct task_struct *leader = tsk->group_leader; for (;;) { - cgroup_threadgroup_change_begin(tsk); write_lock_irq(&tasklist_lock); /* * Do this under tasklist_lock to ensure that @@ -1112,7 +1109,6 @@ static int de_thread(struct task_struct *tsk) break; __set_current_state(TASK_KILLABLE); write_unlock_irq(&tasklist_lock); - cgroup_threadgroup_change_end(tsk); schedule(); if (unlikely(__fatal_signal_pending(tsk))) goto killed; @@ -1750,6 +1746,7 @@ static int do_execveat_common(int fd, struct filename *filename, if (retval) goto out_free; + cgroup_threadgroup_change_begin(current); check_unsafe_exec(bprm); current->in_execve = 1; @@ -1822,6 +1819,7 @@ static int do_execveat_common(int fd, struct filename *filename, /* execve succeeded */ current->fs->in_exec = 0; current->in_execve = 0; + cgroup_threadgroup_change_end(current); membarrier_execve(current); acct_update_integrals(current); task_numa_free(current); @@ -1841,6 +1839,7 @@ static int do_execveat_common(int fd, struct filename *filename, out_unmark: current->fs->in_exec = 0; current->in_execve = 0; + cgroup_threadgroup_change_end(current); out_free: free_bprm(bprm); -- 2.14.1