Received: by 10.223.185.82 with SMTP id b18csp7880wrg; Thu, 8 Mar 2018 17:59:41 -0800 (PST) X-Google-Smtp-Source: AG47ELuzftFXBB2PJmPAVH9EBvhLtqNAGHl3cNYRrkJIa5Hakq7FZeVfQHKCGjdzIyfqi7TKvQcT X-Received: by 2002:a17:902:6bc9:: with SMTP id m9-v6mr20680586plt.421.1520560780928; Thu, 08 Mar 2018 17:59:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520560780; cv=none; d=google.com; s=arc-20160816; b=Fn4uvhReIO4HkWX7+xuBRot0VWAHelELyVbQ9JVy8ZCbDJ4qns3zu9KvKgfsfFeq5y qWl+REPN7e9evRvkxushWm6KEOg4uHwZC35S/nMJb86r19RqKDDywbxq0U6wzYqHQXRg vvqU4SFXkQ9R9IngwA+QVIyWU4cxj/OiC12whhNA5U1ULZcMP4vHUP+k21diGPbhQ624 jEMKgbIFyhQ/P6P7g//75h1UOblWua0upm8/BgXzCXHtEiVLaAW5G6akx05ugQcAHMoZ Mht7Cwyf/SQkzIGQxC/nHfHMY+f+QubgzAFjRPDlpESl/UfdQo3mBq5uJv1vxkK+Rdw3 45wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=V9zGm8+3KZRbEc1XTHCEk3EjXSUD9jjMc3YrXZ3mzoo=; b=AjyPVTBaYYtM8VQLgxZygmnIVMnSQFcmlO8bE/1n+VPZc6hUbJ/PduU/rbBif+sxVU XV8IYFWNijWSmZBefqQfiOdAyDNWXU8cLMuMzTrWWLhK7u4VCknIN3+M55sktD5zTHw7 VRzVeQUkyPyELJ9JTpTP3JI/xml5UCCY1eH0dKFkFgXIQFuSLIZZdqzzl4mQAVUGvvCx DKvhBrczp2RVDodr+lQ7oPsbJPz3SPeEaYSp2nLBjGenRSEvjpSReR9j9hfHMs+FgzIX wqezbknnr1AoCPbXRhMhxt7PhK5vt4UWtNUBxD5lm87GusvFV62TIR6b/CeqEgycNNWd 0HvA== 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 m16-v6si15831115pls.471.2018.03.08.17.59.25; Thu, 08 Mar 2018 17:59:40 -0800 (PST) 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 S932123AbeCIB6e (ORCPT + 99 others); Thu, 8 Mar 2018 20:58:34 -0500 Received: from mx2.suse.de ([195.135.220.15]:45053 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751113AbeCIB6d (ORCPT ); Thu, 8 Mar 2018 20:58:33 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2DFA0AF80; Fri, 9 Mar 2018 01:58:31 +0000 (UTC) Date: Fri, 9 Mar 2018 01:58:30 +0000 From: "Luis R. Rodriguez" To: Alexei Starovoitov Cc: "Luis R. Rodriguez" , Alexei Starovoitov , davem@davemloft.net, daniel@iogearbox.net, torvalds@linux-foundation.org, gregkh@linuxfoundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, linux-api@vger.kernel.org, Jessica Yu , Kees Cook , "Rafael J. Wysocki" , Mimi Zohar , Jiri Kosina Subject: Re: [PATCH net-next] modules: allow modprobe load regular elf binaries Message-ID: <20180309015830.GO4449@wotan.suse.de> References: <20180306013457.1955486-1-ast@kernel.org> <20180308012353.GO14069@wotan.suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 08, 2018 at 03:07:01PM -0800, Alexei Starovoitov wrote: > On 3/7/18 5:23 PM, Luis R. Rodriguez wrote: > > > > request_module() has its own world though too. How often in your proof of > > concept is request_module() called? How many times do you envision it being > > called? > > once. What about other users later in the kernel? > > > +static int run_umh(struct file *file) > > > +{ > > > + struct subprocess_info *sub_info = call_usermodehelper_setup_file(file); > > > + > > > + if (!sub_info) > > > + return -ENOMEM; > > > + return call_usermodehelper_exec(sub_info, UMH_WAIT_EXEC); > > > +} > > > > run_umh() calls the program and waits. Note that while we are running a UMH we > > can't suspend. What if they take forever, who is hosing them down with an > > equivalent: > > > > schedule(); > > try_to_freeze(); > > > > Say they are buggy and never return, will they stall suspend, have you tried? > > > > call_usermodehelper_exec() uses helper_lock() which in turn is used for > > umh's accounting for number of running umh's. One of the sad obscure uses > > for this is to deal with suspend/resume. Refer to __usermodehelper* calls > > on kernel/power/process.c > > > > Note how you use UMH_WAIT_EXEC too, so this is all synchronous. > > looks like you misread this code > > #define UMH_NO_WAIT 0 /* don't wait at all */ > #define UMH_WAIT_EXEC 1 /* wait for the exec, but not the process */ > #define UMH_WAIT_PROC 2 /* wait for the process to complete */ > #define UMH_KILLABLE 4 /* wait for EXEC/PROC killable */ I certainly did get the incorrect impression this was a sync op, sorry about that. In that case its odd to see a request_module() call, when what is really meant is more of a request_module_nowait(), its also UMH_NO_WAIT on the modprobe call itself as well. In fact I think I'd much prefer at the very least to see a different wrapper for this, even if its using the same bolts and nuts underneath for userspace processes compiled on the kernel. The sanity checks in place for request_module() may change later and this use case seems rather simple and limited. Keeping tabs on this type of users seems desirable. At the *very least* diff --git a/include/linux/kmod.h b/include/linux/kmod.h index 40c89ad4bea6..7530e00da03b 100644 --- a/include/linux/kmod.h +++ b/include/linux/kmod.h @@ -37,11 +37,13 @@ extern __printf(2, 3) int __request_module(bool wait, const char *name, ...); #define request_module(mod...) __request_module(true, mod) #define request_module_nowait(mod...) __request_module(false, mod) +#define request_umh_proc(mod...) __request_module(false, mod) #define try_then_request_module(x, mod...) \ ((x) ?: (__request_module(true, mod), (x))) #else static inline int request_module(const char *name, ...) { return -ENOSYS; } static inline int request_module_nowait(const char *name, ...) { return -ENOSYS; } +static inline int request_umh_proc(const char *name, ...) { return -ENOSYS; } #define try_then_request_module(x, mod...) (x) #endif Modulo, kernel/umh.c is already its own thing, so pick a name that helps identify these things clearly. > and the rest of your concerns with suspend/resume are not applicable any > more. Agreed, except it does still mean these userspace processes are limited to execution only the kernel is up, and not going to suspend, but I think that's a proper sanity check by the umh API. > bpftiler.ko is started once and runs non-stop from there on. > Unless it crashes, but it's a different discussion. Sure. Luis