Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3896926pxj; Mon, 24 May 2021 18:11:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8CnyKlE8q1bLl00nCDtfPLmWMLvOk333uLw0Vsw0A+U18tKkh72CqXJy4JJSZ4O93QG1m X-Received: by 2002:a17:907:2bf4:: with SMTP id gv52mr25753733ejc.271.1621905065197; Mon, 24 May 2021 18:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621905065; cv=none; d=google.com; s=arc-20160816; b=F/rUxRGtIBodz/SGBdhuOhW6e36XiOg9Ar1pfr+tJY1mrILD3Xv1fVPJaAXz/4edDB JjJzu2aUpU4u7FI5Yb06BakSHxFDjybt7IFA3G3JLvAlukzOhhibpMIeiLqwJM6Y2TXg D/vHJOkYTX09vm9MWn94kJb0ikDPHXGGt2iz37OmAWG+Mkn0ymEvhyTm8NCBLYOol9Z6 Obc2cL9CIhru+afCHhgEoZMFaJwBRQXmpcIQoJYUBeywNPN1wiTDdrPsG9Dcqy7gNfEy 7qrNkfzyf87ZvI3CWZ/tLv6x3gV2brunFZRy68IzMTewPv2YPCIEIMOrb2nAfx+GHyrj aO5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=8f5ujIR9Or4+qH0a2z4e8y5V7RDsWD31fqmshcSfXKk=; b=vo+O5WxLofM+RYx2lDyXZUduZ9sztFwyVK9hrRouzgqT3MA60OKr0MRvoDHtusZIoc +g/Aj0R/YLPLazOrMO+QvMgo33bBHxApY15JAj5jW9vYE8bOuu6SNizWhSKSgZaNLwH4 VQzg4VY2WheRT4uWGnifmIirCilyc3THiiyrhV5kQg0C79Bkwd3XoU7IO9ylxc4xnv4n 7qkDRwMBiKKaewB3Sk+mMFvbvq+4wE+a/2lse4B8sS0ImV+iumd5SAiFNwloSbuaMnXO 8cwhE12Qa7cq+Ku3zwNjsQ63CAGFd1/PkMUgfn03G733PWPjzcYeK4sdVrVv0dy9urJl 0qaA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f5si13715154eje.733.2021.05.24.18.10.42; Mon, 24 May 2021 18:11:05 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229976AbhEYBJl (ORCPT + 99 others); Mon, 24 May 2021 21:09:41 -0400 Received: from mslow1.mail.gandi.net ([217.70.178.240]:60437 "EHLO mslow1.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbhEYBJj (ORCPT ); Mon, 24 May 2021 21:09:39 -0400 Received: from relay6-d.mail.gandi.net (unknown [217.70.183.198]) by mslow1.mail.gandi.net (Postfix) with ESMTP id E20D2D8704; Tue, 25 May 2021 01:02:40 +0000 (UTC) Received: (Authenticated sender: josh@joshtriplett.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id B7D4BC0004; Tue, 25 May 2021 01:02:06 +0000 (UTC) Date: Mon, 24 May 2021 18:02:04 -0700 From: Josh Triplett To: menglong8.dong@gmail.com Cc: mcgrof@kernel.org, viro@zeniv.linux.org.uk, keescook@chromium.org, samitolvanen@google.com, johan@kernel.org, ojeda@kernel.org, jeyu@kernel.org, joe@perches.com, dong.menglong@zte.com.cn, masahiroy@kernel.org, jack@suse.cz, axboe@kernel.dk, hare@suse.de, gregkh@linuxfoundation.org, tj@kernel.org, song@kernel.org, neilb@suse.de, akpm@linux-foundation.org, brho@google.com, f.fainelli@gmail.com, wangkefeng.wang@huawei.com, arnd@arndb.de, linux@rasmusvillemoes.dk, mhiramat@kernel.org, rostedt@goodmis.org, vbabka@suse.cz, glider@google.com, pmladek@suse.com, ebiederm@xmission.com, jojing64@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] init/main.c: introduce function ramdisk_exec_exist() Message-ID: References: <20210522113155.244796-1-dong.menglong@zte.com.cn> <20210522113155.244796-2-dong.menglong@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210522113155.244796-2-dong.menglong@zte.com.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 22, 2021 at 07:31:53PM +0800, menglong8.dong@gmail.com wrote: > Introduce the function ramdisk_exec_exist, which is used to check > the exist of 'ramdisk_execute_command'. > > It can do absolute path and relative path check. For relative path, > it will ignore '/' and '.' in the start of > 'ramdisk_execute_command'. > --- a/init/main.c > +++ b/init/main.c > @@ -1522,6 +1522,21 @@ void __init console_on_rootfs(void) > fput(file); > } > > +bool __init ramdisk_exec_exist(bool absolute) > +{ > + char *tmp_command = ramdisk_execute_command; > + > + if (!tmp_command) > + return false; > + > + if (!absolute) { > + while (*tmp_command == '/' || *tmp_command == '.') > + tmp_command++; As far as I can tell, this will break if the user wants to use ".mybinary" or ".mydir/mybinary" as the name of their init program. For that matter, it would break "...prog" or "...somedir/prog", which would be strange but not something the kernel should prevent. I don't think this code should be attempting to recreate relative-to-absolute filename resolution.