From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 581DAC47088 for ; Tue, 25 May 2021 08:08:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C5406135F for ; Tue, 25 May 2021 08:08:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232114AbhEYIJj (ORCPT ); Tue, 25 May 2021 04:09:39 -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-Google-Smtp-Source: ABdhPJyDMICdFeOt+b39OBnMer8Q9QXklHhJJ/77fP6ltOKwSZwSeZSsI07PzZ73h75AN/ANslMGSjSsrvswM/YfWs4= 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