Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3017540ybt; Mon, 29 Jun 2020 13:02:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcup5wGj2F1rqMDrAUQ/5nuHeZ5HEHEzASYh9tby4NKOgmWz41MfAFqpMJiY5ieW9gRUaS X-Received: by 2002:a17:906:4350:: with SMTP id z16mr15147743ejm.139.1593460927902; Mon, 29 Jun 2020 13:02:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593460927; cv=none; d=google.com; s=arc-20160816; b=i1bjzrjIcq4naNimwW4mcgAdF1pB/Qaz6gDIS3/sLOuGKWn2Yfsrueo/PyF6Z9GQs2 Ypyl1Le8CRaald1IMyd2fo8o+qTHE5Ls10xkWGjKeuLyyLBe3So4RI7gGhkBfDBhKNJt SJtE+K8rgkGEI5SbJ+pVTz8yigX54oCtGI5Q9b3rzMo6X0MBCXxnLfY1n7ACb2C4/pZv 18DcINuouHiPy5XyfwAr9aPnq/f2nmRQE9ql51fEXT9Lzj6Qd5o5JSDR0har0HULXF0E hZWj1tV39HT/3zV8ZRU2zqxc2IEgPHNXdT0l0atxtdTEh6hhotOxefpOdN9Kr9E887Kj t6Iw== 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; bh=6SkZA3Jv/BhlL9D+wh7HwyI8bjUViXrPD8FHO2vO+TE=; b=jWjjczgRTkaJaeQ3w0qnbrdbcV0Mqae5gJwX5dvCgUcVkQ1TXbjBQsvR1C4OEJJ0yq a6pYV7pibsHCmbiTK6dfhLJatV2UfeTTxnKQRhZvPZoJlrIZwmV9o0GF/LYYYFj+SxPg c3Ouu/PeiQgE1eGz3EHvnHG0KiMhJbeCT3gwbJIjZjlePtSANkLBkv/CjNVODbeSgmWj UH2h2QPn7m7Tj06EvvorYNRsof7wVGLDaP1TKlDmvyuG67NgFV89PQDutt5MEfniXa3I FRB1taO+l5L9fsF1HCANifm9ZX0iAsCnpIOG00tlERjSf38c3QYh+QGgn7JwvUJK7UdU pWXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs1si301346edb.76.2020.06.29.13.01.44; Mon, 29 Jun 2020 13:02:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388658AbgF2UBi (ORCPT + 99 others); Mon, 29 Jun 2020 16:01:38 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:37270 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388122AbgF2UBg (ORCPT ); Mon, 29 Jun 2020 16:01:36 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out03.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jpzyB-0005Vb-G4; Mon, 29 Jun 2020 14:01:35 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1jpzyA-0007zH-8m; Mon, 29 Jun 2020 14:01:35 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Cc: David Miller , Greg Kroah-Hartman , Tetsuo Handa , Alexei Starovoitov , Kees Cook , Andrew Morton , Alexei Starovoitov , Al Viro , bpf , linux-fsdevel , Daniel Borkmann , Jakub Kicinski , Masahiro Yamada , Gary Lin , Bruno Meneguele , LSM List , Casey Schaufler , Luis Chamberlain , Linus Torvalds References: <20200625095725.GA3303921@kroah.com> <778297d2-512a-8361-cf05-42d9379e6977@i-love.sakura.ne.jp> <20200625120725.GA3493334@kroah.com> <20200625.123437.2219826613137938086.davem@davemloft.net> <87pn9mgfc2.fsf_-_@x220.int.ebiederm.org> <87y2oac50p.fsf@x220.int.ebiederm.org> <87bll17ili.fsf_-_@x220.int.ebiederm.org> Date: Mon, 29 Jun 2020 14:57:03 -0500 In-Reply-To: <87bll17ili.fsf_-_@x220.int.ebiederm.org> (Eric W. Biederman's message of "Mon, 29 Jun 2020 14:55:05 -0500") Message-ID: <87zh8l63xs.fsf_-_@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1jpzyA-0007zH-8m;;;mid=<87zh8l63xs.fsf_-_@x220.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18tkilkwueNF9nWNOIZyHygLGlNpkZV+hs= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa07.xmission.com X-Spam-Level: X-Spam-Status: No, score=0.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TM2_M_HEADER_IN_MSG,T_TooManySym_01,XMSubLong autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 0; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: ; sa07 0; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ; X-Spam-Relay-Country: X-Spam-Timing: total 788 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 10 (1.3%), b_tie_ro: 9 (1.2%), parse: 0.95 (0.1%), extract_message_metadata: 18 (2.3%), get_uri_detail_list: 1.56 (0.2%), tests_pri_-1000: 91 (11.6%), tests_pri_-950: 2.1 (0.3%), tests_pri_-900: 1.79 (0.2%), tests_pri_-90: 290 (36.8%), check_bayes: 286 (36.4%), b_tokenize: 36 (4.5%), b_tok_get_all: 22 (2.8%), b_comp_prob: 2.7 (0.3%), b_tok_touch_all: 221 (28.0%), b_finish: 1.00 (0.1%), tests_pri_0: 337 (42.8%), check_dkim_signature: 0.75 (0.1%), check_dkim_adsp: 2.5 (0.3%), poll_dns_idle: 0.27 (0.0%), tests_pri_10: 3.7 (0.5%), tests_pri_500: 13 (1.6%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH v2 02/15] umh: Move setting PF_UMH into umh_pipe_setup 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 in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I am separating the code specific to user mode drivers from the code for ordinary user space helpers. Move setting of PF_UMH from call_usermodehelper_exec_async which is core user mode helper code into umh_pipe_setup which is user mode driver code. The code is equally as easy to write in one location as the other and the movement minimizes the impact of the user mode driver code on the core of the user mode helper code. Setting PF_UMH unconditionally is harmless as an action will only happen if it is paired with an entry on umh_list. Link: https://lkml.kernel.org/r/87bll6gf8t.fsf_-_@x220.int.ebiederm.org Reviewed-by: Greg Kroah-Hartman Signed-off-by: "Eric W. Biederman" --- kernel/umh.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/umh.c b/kernel/umh.c index c2a582b3a2bf..e6b9d6636850 100644 --- a/kernel/umh.c +++ b/kernel/umh.c @@ -102,12 +102,10 @@ static int call_usermodehelper_exec_async(void *data) commit_creds(new); - if (sub_info->file) { + if (sub_info->file) retval = do_execve_file(sub_info->file, sub_info->argv, sub_info->envp); - if (!retval) - current->flags |= PF_UMH; - } else + else retval = do_execve(getname_kernel(sub_info->path), (const char __user *const __user *)sub_info->argv, (const char __user *const __user *)sub_info->envp); @@ -468,6 +466,7 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new) umh_info->pipe_to_umh = to_umh[1]; umh_info->pipe_from_umh = from_umh[0]; umh_info->pid = task_pid_nr(current); + current->flags |= PF_UMH; return 0; } -- 2.25.0