Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3989967pxj; Mon, 24 May 2021 20:45:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvc0CdeByl4QA/iPNgODNoU60dyHZH/p5Gmawdv6GzAus2iEoMNDXn26ToyfTCmjzQ8gay X-Received: by 2002:a17:906:e0d5:: with SMTP id gl21mr26758695ejb.93.1621914359743; Mon, 24 May 2021 20:45:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621914359; cv=none; d=google.com; s=arc-20160816; b=k4Bs3hrJuWJocY3NV/DHBVeFrRUNj9u3U0tAtbKaIqElRKacg51ZOjr8hhl/X0Wkww tpoIT1gAxYRHQi2jq9GMBmg8VrMk/e5BrE0JAEkjoSTSkKYjX5PBpoInAetkIBPmNc7H zD+bmmUFyJTn8XbWJmDDcvrT7lamgLHbBPh4RKi5R/TqoWwZsf8/EWuW4bsHVqes4FNs u8DS00hWXlGidqMzcseZrw+/OStwOLyYS1PRibxaqv/F3j8403Md5w7Vfj+EKvZhXMD2 QdJUdQYfaxyhoyIrXaKkVI1IVnlrg9vvnz6VYMatdC8n1rkYMc1LYjuJbbHzZc7KEohv M5jQ== 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=iDF6mBMgNJLUIrRtn1QdpOxFrtc+wC5o+OnjVFJaNNk=; b=vtDOQGjO2zZC/rKJ/QN7nTm4KHSlVS5ou0E4y1/rFviSfXjhxQz3lQI0+QdchsWlKq GsD0vhdTWXqR0s8YHjOxpJIPq+OpI0rJQru29dXRbsnereN+8K7E8ATsJIPkVWl3Mfqn MnBpcEi5B8+4BujpgX62ZszqXZSJj1KWtO/be0FbdzAqGYgzuh2ROgOOzyz3ez9Owhme EDZMB86O3woHnn/FPHkwgOMCUvCWazcwC7+nN8sPlds6TPVb8Re6HctPFPvI1my0knXj HXkD10oQCWCvdbgdmEYme0mDj8m8vLqAJFUCATggl0R5WL9sANpAbDhf2d8RVN/VLd77 HTFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Bgyg3Suf; 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 d24si13125921edv.171.2021.05.24.20.45.36; Mon, 24 May 2021 20:45:59 -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=Bgyg3Suf; 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 S230361AbhEYDpR (ORCPT + 99 others); Mon, 24 May 2021 23:45:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230048AbhEYDpQ (ORCPT ); Mon, 24 May 2021 23:45:16 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F5BAC061574; Mon, 24 May 2021 20:43:46 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id p20so36315346ljj.8; Mon, 24 May 2021 20:43:46 -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=iDF6mBMgNJLUIrRtn1QdpOxFrtc+wC5o+OnjVFJaNNk=; b=Bgyg3SufXoRKshaUkZgPFsX+GP+0f8Lok/5IYi98BOdCvCIIu1A3RR1yWrGeBHsEdu MXxxFSsQ42UWUUsKEVd2JehHqdkHJIG1FT5hbQdF/ZzoVLz1JQPPo/3VE0qaCd7/VKrj 6Y4UGGJ+pRDPORu1qATrXn6+T+kYbzeoJi05R6mxV+lq2kF2SHEpqDWvA7YmLDSOqsNu SpwCvzVLjo8o0i0aGi2v1d4j245DX7aRevsWcvLkXBfaIfPskTnw4O7060TnLGm8HPar kLwjZ0h2+Mc0bXiYhSWn4DmyIFGF0mmAlNF6znSDqSJkA/7waZGmr6AcqavdYwIRtSM4 2f4w== 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=iDF6mBMgNJLUIrRtn1QdpOxFrtc+wC5o+OnjVFJaNNk=; b=IUBH+IdzM/7f0gX7K/NWAS1pxfgcvrxSBJtavten04o/BXOEB8Mb5PY+d5KCeG8Z1M 7tekd+wxN/vpJeajBcZjJdLoonxN5mMiyHaa0ceI6KD6Uts4cbOmBblErcJVzeYDyKtH vU80fQoR73JKF+iFL9LJ1rvshiXI+CpXzNEOjTfUNDlPKLNXbpp2y03zPTwDvYaspJbV 8YE7VbCYenZ3mVyKF/9B+uSt/qVawlLKUvSSr6MXaA4OU9d03tQZU0ijZOGjZ5sb8qaZ arcF8krQjyVrHacpcZG9uuh35/uHFw6uFXaIONFLBRIP1krXdJGc2ODBoIN2CpzmwL5r NscA== X-Gm-Message-State: AOAM533ZBE0QEndmpLiwkMG1c18K+X3PnKi6Ni9twFt29mTKhn8ZDZA1 eyqdfVvha5rLPMeFQtjW6ziv/wUac3ydSSPOjiQ= X-Received: by 2002:a2e:240e:: with SMTP id k14mr19355228ljk.423.1621914223981; Mon, 24 May 2021 20:43:43 -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 11:43:31 +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 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! Is there any one have a good idea? Or I have to dig into the code of 'kern_path()' and figure out the reason. Thanks! Menglong Dong