Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4162711pxj; Tue, 25 May 2021 01:38:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnb+JBwQ0qx5rDQ4qAQ5/akvSt0xeY77gWoMOjTaklMohytbPTxoL4v5mTrKbUP4tMS0D4 X-Received: by 2002:a05:6402:30ac:: with SMTP id df12mr30427374edb.117.1621931919323; Tue, 25 May 2021 01:38:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621931919; cv=none; d=google.com; s=arc-20160816; b=oItBi7ooUbbFUCvqfYOm2Vlt9YqFh0sLbj2dhVs9+5qdwQBI7xph/FlQ92glgCG16Z 6zVf7mTo5BnSVRjw5d1KEEpInUaXiaKr18Ao1W3O6bnE9Jg2ODsbSnRV5nl0lLM5H1js XZDtQ80DASiYFOHFYqpU8ZMGi1LlJPr/areoAuiPCTZKeP8vrTiBAHWJ7oJhkbxQCtP9 UaGLYdt3VQvuYAxM/fV/nuEp17NIuH94zugd465ou6nRiU2mhjf72nsdA67xzo+gbx+S SgsKQNm/bJh/AAdw/52GZBGWwML5yTBZ8N230SvSSzcBjBZJmxsV/h+Ik0br3gYEGnoo QniQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ZbxWFPATpyH8KlB2XfCYNbm150My8VFNA+BbTsSBPxg=; b=tUqfMTjom7naDWpbiF1fO0QBZ+p6W/uJvw9DzRNsn2V924uHenJuhK51mPInk0bdn5 VGF3BNlxjn1D/NV/7oNdQG2jQMN/5ZvAXcLb7SpL9Ncu1XVg2wSR6IAJ6ZMiCxufEDq0 iY9tSloLh/TV6a1ZutgNHxQfbIeVdVejlI4sh3E3faYTHBywFVOhPdqmeT+cMLRMJABN AdfApV9TPDR6sZhLfPCuUWDnv2943F7VCd2buEFZ2Xd2tystrrRjID/07GI9MgCcx6MX l7ttqDx79MC7CY1ZGVpM7OcPbHHJqKJSrmO21QfVkOVSjmrlWWzfK3z2g+fvUuHnvQI9 MyfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RgpWwD4W; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn42si2244096ejc.47.2021.05.25.01.38.16; Tue, 25 May 2021 01:38:39 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RgpWwD4W; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232095AbhEYIJh (ORCPT + 99 others); Tue, 25 May 2021 04:09:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231970AbhEYIIw (ORCPT ); Tue, 25 May 2021 04:08:52 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 195E4C061574; Tue, 25 May 2021 01:04:50 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id w7so23576635lji.6; Tue, 25 May 2021 01:04:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZbxWFPATpyH8KlB2XfCYNbm150My8VFNA+BbTsSBPxg=; b=RgpWwD4WRc3ueLXmlv9OOs3YLGs03roiOPTTskReUUYgTiCBZDAhQHSPfklCjllp6z +Eu4a12VeWdJtyIBbBVlwee5Mqn6/Jkve32DTYea5TaBDUHh0flAqAXjmggdJPlbQrCt HKRFLJhHZYrxf7yL3IBHA7PR7eK2bQgCrCbE/v2LXJ6ihC5bZvvnBL3cGbMTotJf7DDI sByiKHAUdueaGOc20tQKlGTieOrPjTQMMTbEyT6sepCsNhPtjXRKVw7udJ7WKUo1Nd23 Uekf50wSXiAHv19scLEp0rwM8yl4kHo9p4xddziC+f5sHPGtmP1ZUnANn7kNXkXzzV8v H4lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZbxWFPATpyH8KlB2XfCYNbm150My8VFNA+BbTsSBPxg=; b=UxuPv9QGA0iryXXp7yNnkUTMae27Pm/Knm1bbgq0NDeabx4HOqJ1ipL6ZG4QbL5c3m QAYZQriquw9q93wCB6tm2GNcOomIBYLERA71bqbJDpfBjrMu+P6ttlbchguZVxbO4bIg dQZbDcJdTnrXUCyZGPGPPHDKCpa0sC/B0bX9R1LY3pHkNPDDHzN0Mvi5hiCkhr7FNRk9 9kOxGSeR2e0f/j+RIi959GpK9inBHPBFtpGZgHG3j4pKb8a6VCkmKK+F6zUJOyF5mXv+ aCDKAlolJZgfzXzf+Z/W4h2GnCAv//tRAYz5qkV/ZpXUE8uQbaX6e/fG/Fnid+Z8gAO6 /beA== X-Gm-Message-State: AOAM532YyK7e/iowHMRkplCjxcomikbmNfr4sI2d45mneYzqgH2uTVjj Ook0XRQA9qwK1jtEXlrwvu8ljIKlgqzv23m0vLE= X-Received: by 2002:a2e:a374:: with SMTP id i20mr13769655ljn.149.1621929888405; Tue, 25 May 2021 01:04:48 -0700 (PDT) MIME-Version: 1.0 References: <20210522113155.244796-1-dong.menglong@zte.com.cn> <20210522113155.244796-2-dong.menglong@zte.com.cn> In-Reply-To: From: Menglong Dong Date: Tue, 25 May 2021 16:04:36 +0800 Message-ID: Subject: Re: [PATCH 1/3] init/main.c: introduce function ramdisk_exec_exist() To: Josh Triplett Cc: Luis Chamberlain , Alexander Viro , Kees Cook , Sami Tolvanen , johan@kernel.org, ojeda@kernel.org, jeyu@kernel.org, joe@perches.com, Menglong Dong , masahiroy@kernel.org, Jan Kara , Jens Axboe , hare@suse.de, gregkh@linuxfoundation.org, tj@kernel.org, song@kernel.org, NeilBrown , Andrew Morton , Barret Rhoden , f.fainelli@gmail.com, wangkefeng.wang@huawei.com, arnd@arndb.de, Rasmus Villemoes , mhiramat@kernel.org, Steven Rostedt , vbabka@suse.cz, Alexander Potapenko , pmladek@suse.com, ebiederm@xmission.com, jojing64@gmail.com, linux-fsdevel@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 25, 2021 at 11:43 AM Menglong Dong wrote: > > On Tue, May 25, 2021 at 9:02 AM Josh Triplett wrote: > > > ...... > > > > 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. > > > > Wow, seems I didn't give enough thought to it. > > > I don't think this code should be attempting to recreate > > relative-to-absolute filename resolution. > > Trust me, I don't want to do it either. However, I need to check if > ramdisk_execute_command exist before chroot while the cpio is unpacked > to '/root'. > > Maybe I can check it after chroot, but I need to chroot back if it not > exist. Can I chroot back in a nice way? > > I tried to move the mount on '/root' to '/' before I do this check in > absolute path, but seems '/' is special, the lookup of '/init' never > follow the mount on '/' and it can't be found. However, if I lookup > '/../init', it can be found! > I have figured it out. While path lookup, '/' won't follow the mount. However, with the set of LOOKUP_DOWN, it will be followed. So I will move the mount on '/root' to '/' and check the exist of ramdisk_execute_command with LOOKUP_DOWN setted. Seems there is still a long way to go on kernel...... Thanks! Menglong Dong