Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3892728ybz; Mon, 20 Apr 2020 11:21:22 -0700 (PDT) X-Google-Smtp-Source: APiQypLHN9BuMIwdb046dny4VxSgjw3hc92K0gpZkUvrIvw+cVCalrGKIL/6jf5AAUcXzPAYDWxj X-Received: by 2002:a17:906:4003:: with SMTP id v3mr17099419ejj.144.1587406882148; Mon, 20 Apr 2020 11:21:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587406882; cv=none; d=google.com; s=arc-20160816; b=PcaDvVXt/ESt2OqjKLIsEZWRI5VTjJpxgDRELNLnXKwCh/Jajgy0uuqthNPSR8NizU pA8iDlWp9FLnw46bXSK7XhLziJ1a5xmeyJb+9Z8aQqo72nflYbg92Ia1qGDosXV7tsuT 5+ulDNgSYhg+Bgkbx3Rfkhlb0E4ulpDs/CpIQKPfNx2oQxKxYEQGf+Idc2BbbNPBF2LE Ipw26n3yauIiJfw4Z31KWgQnMJpieYhzFBeDM4S9leKpo5h+ayevEiQHXHz1B2g2SHT+ um/jlBV7BgqxzjowfgDYGW+CnmppE/fRhFj/n068a2Wsp4xlnNdDQhXEuSR+TxzwMYhg cpQw== 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; bh=T7v8hOkx9WmIy3YT7d2v0dE+Bx4o1hmDGi8iBopJx8s=; b=u3p5kZOD3EFl5R/r8XBt+3g3fvEV4sMe3lhTiCDP25J9MyGzZejM8MJZ9uSyypMClD G4c4puhBdDrRZhjQJYPDSYCsZ02h1JQFtI6rbF0XrNYQAg52B6KN5OAiemjwByQW5/is 8Alg+TH9qeUQB00GK2je2Q8HzuLzzfI9iSAOWGdqxGLKofj8zqQiCpkNm3QRjkwdkSYv Cj1GqifPl/M/VTVZtQNs6gAcTjlD3XSaeASzK1tKv5mH3SnFwEj5T1Mrt5YL5JiCxEV8 LnsFUbVlsB04T+WmG7tg6fsE/BpUprbGPwngMQYGfPLMMJe7a4EyWCX7UaER3MCNHCvY zDJw== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j19si134898eds.208.2020.04.20.11.20.45; Mon, 20 Apr 2020 11:21:22 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726882AbgDTSTf (ORCPT + 99 others); Mon, 20 Apr 2020 14:19:35 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41302 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726123AbgDTSTf (ORCPT ); Mon, 20 Apr 2020 14:19:35 -0400 Received: by mail-pl1-f193.google.com with SMTP id d24so4248735pll.8; Mon, 20 Apr 2020 11:19:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=T7v8hOkx9WmIy3YT7d2v0dE+Bx4o1hmDGi8iBopJx8s=; b=BsySMqaAcPXGGn3krkyUXsewJQoYTRz0tKGMsHlPAXRyPv/5fPKZdgkH+UAFvykbhO NznnhAHnSm4GCUKUO3IFUdGpkLi2CJgwjcgOUVkINLB+MWy5xbdWRvAhI4Qxmf0NuPhM 4ie+r/3mGnUJ3rmM9PJbJIaBsYnm1fuZx9BMokJecGwCxBg2cx2DJX1rF8qjuYJ/PWcC anG6IUNazIOCuq/uqGvz8wFC2yd9sYkiJFFdYOCar6htV78ITfMgrFop03Wi+NkxfgCd t4aQ1XzTn1RrxgE1gOr4emu8DySnxBh0po9L6gmlc9KWu8Q1XgCr8hYKeezaIzsZ1A34 Q+4A== X-Gm-Message-State: AGi0PuZtpZY1CA0GG0e6YLTjwakBJGhfVzWlSf3cE3033BsJXlvRzX13 xb3gjY19tagqnpuIZ24CCfcMBLhG/W0= X-Received: by 2002:a17:90a:1955:: with SMTP id 21mr750807pjh.133.1587406772794; Mon, 20 Apr 2020 11:19:32 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id j14sm35043pjm.27.2020.04.20.11.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2020 11:19:31 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 12DF74028E; Mon, 20 Apr 2020 18:19:31 +0000 (UTC) Date: Mon, 20 Apr 2020 18:19:31 +0000 From: Luis Chamberlain To: Tiezhu Yang Cc: Shuah Khan , Andrew Morton , Jessica Yu , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Elfring , Xuefeng Li Subject: Re: [PATCH v3 3/4] kmod: Return directly if module name is empty in request_module() Message-ID: <20200420181931.GJ11244@42.do-not-panic.com> References: <1587386035-5188-1-git-send-email-yangtiezhu@loongson.cn> <1587386035-5188-4-git-send-email-yangtiezhu@loongson.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1587386035-5188-4-git-send-email-yangtiezhu@loongson.cn> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 20, 2020 at 08:33:54PM +0800, Tiezhu Yang wrote: > If module name is empty, it is better to return directly at the beginning > of request_module() without doing the needless call_modprobe() operation. > > Call trace: > > request_module() > | > | > __request_module() > | > | > call_modprobe() > | > | > call_usermodehelper_exec() -- retval = sub_info->retval; > | > | > call_usermodehelper_exec_work() > | > | > call_usermodehelper_exec_sync() -- sub_info->retval = ret; > | > | --> call_usermodehelper_exec_async() --> do_execve() > | > kernel_wait4(pid, (int __user *)&ret, 0, NULL); > > sub_info->retval is 256 after call kernel_wait4(), the function > call_usermodehelper_exec() returns sub_info->retval which is 256, > then call_modprobe() and __request_module() returns 256. > > Signed-off-by: Tiezhu Yang Thanks for looking into this. I still cannot find where userspace it returns 256. Can you? If I run modprobe without an argument I see 1 returned. At least kmod [0] has a series of cmd helper structs, the one for modprobe seems to be kmod_cmd_compat_modprobe, and I can see -1 returned which can be converted to 255. It can also return EXIT_FAILURE or EXIT_SUCCESS and /usr/include/stdlib.h defines these as 1 and 0 respectively. https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/ Luis