Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2610514ybb; Mon, 30 Mar 2020 09:25:57 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvdLM49G3mKjsI57FGLqdB+AYwJbI2IrmpmBSoJfpx7MPg6CA5I6Z8g75VgSSRRDhrimjwX X-Received: by 2002:aca:ecd0:: with SMTP id k199mr115511oih.60.1585585557410; Mon, 30 Mar 2020 09:25:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585585557; cv=none; d=google.com; s=arc-20160816; b=RbZEh0aoFEPnZf88Lilw1qzsaiqCYob/8RL6tTRebUWa/+KGl40HIrRhnSPpbxjPCj V4Clw1pSFyZoVBlfBA+h6t1Y0J+3sHxKWz9xKcxGHv4PBoSzNa+XAxhgm9D290ousKw4 B6j2W/IjeljbMxp2x1Yi43PfyrOK8Izq4lo2EIWBBCACkv7DpTKv1Dxn+vagN1emjPfi u2vD7tHm0rqy+QW9HLC5x7WslqScGoTuLzcTjNIAsi2mOFkGxtsZSyafRvXtuEtBNPF+ WSawdbdeZyyQQwfkKAzKrOuxZPbouwAulXZ619WyNkXzK/JMQdVkamjhz5VMMoXNBdJF sIQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=k2+TymeanAx8Mj5E2Wcg8INuebKfMgm+jUMgJ65q428=; b=UiVhOrVsrunymcFQE/1sJ/z7F/EkbiOCHtyBRDgq4DhDvQqhd07LNrj3sha6IWG9x2 75MeUM9LbFEy6eTHLffKPh1klzJNitoHnGGyKNkRvrj7T1ECXRiV6KqlGz9tKPdezsQq TLOhle6HBZW3wbxlfGRqhV+b/5rzDCrGPtnhaSaVb7j5MqbO62qZViIaAm0ElLDC2hFk Q5HzXM+xjGloBNbxJdGRjj6KbOgq+PbCr6EHQHUls4h/ag8+scIQV+u+nhCKIx6kt5HU hBk3qbamhRqbud7uZSCOQtXXnfPzm4gGytKmaRJuF0bKJTtNRBHlRfM4aTyyOX5SH+Fv bciA== 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 w29si7084736oth.24.2020.03.30.09.25.42; Mon, 30 Mar 2020 09:25: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 S1730190AbgC3QYB (ORCPT + 99 others); Mon, 30 Mar 2020 12:24:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:56952 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727826AbgC3QYB (ORCPT ); Mon, 30 Mar 2020 12:24:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 46CBEAD63; Mon, 30 Mar 2020 16:23:59 +0000 (UTC) Subject: Re: [PATCH 1/3] kernel/sysctl: support setting sysctl parameters from kernel command line To: Luis Chamberlain , Kees Cook , Iurii Zaikin Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-mm@kvack.org, Ivan Teterevkov , Michal Hocko , David Rientjes , Matthew Wilcox , "Eric W . Biederman" , "Guilherme G . Piccoli" , Alexey Dobriyan , Thomas Gleixner , Greg Kroah-Hartman , Christian Brauner References: <20200330115535.3215-1-vbabka@suse.cz> <20200330115535.3215-2-vbabka@suse.cz> From: Vlastimil Babka Message-ID: Date: Mon, 30 Mar 2020 18:23:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200330115535.3215-2-vbabka@suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/30/20 1:55 PM, Vlastimil Babka wrote: > A recently proposed patch to add vm_swappiness command line parameter in > addition to existing sysctl [1] made me wonder why we don't have a general > support for passing sysctl parameters via command line. Googling found only > somebody else wondering the same [2], but I haven't found any prior discussion > with reasons why not to do this. > > Settings the vm_swappiness issue aside (the underlying issue might be solved in > a different way), quick search of kernel-parameters.txt shows there are already > some that exist as both sysctl and kernel parameter - hung_task_panic, > nmi_watchdog, numa_zonelist_order, traceoff_on_warning. A general mechanism > would remove the need to add more of those one-offs and might be handy in > situations where configuration by e.g. /etc/sysctl.d/ is impractical. > > Hence, this patch adds a new parse_args() pass that looks for parameters > prefixed by 'sysctl.' and tries to interpret them as writes to the > corresponding sys/ files using an temporary in-kernel procfs mount. This > mechanism was suggested by Eric W. Biederman [3], as it handles all dynamically > registered sysctl tables. Errors due to e.g. invalid parameter name or value > are reported in the kernel log. > > The processing is hooked right before the init process is loaded, as some > handlers might be more complicated than simple setters and might need some > subsystems to be initialized. At the moment the init process can be started and > eventually execute a process writing to /proc/sys/ then it should be also fine > to do that from the kernel. > > Sysctls registered later on module load time are not set by this mechanism - > it's expected that in such scenarios, setting sysctl values from userspace is > practical enough. > > [1] https://lore.kernel.org/r/BL0PR02MB560167492CA4094C91589930E9FC0@BL0PR02MB5601.namprd02.prod.outlook.com/ > [2] https://unix.stackexchange.com/questions/558802/how-to-set-sysctl-using-kernel-command-line-parameter > [3] https://lore.kernel.org/r/87bloj2skm.fsf@x220.int.ebiederm.org/ > > Signed-off-by: Vlastimil Babka Boo, all the error prints should terminate with \n Will wait for feedback before resend.