From nobody Sun Apr 5 13:23:28 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27DB6327798 for ; Thu, 19 Feb 2026 21:04:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771535084; cv=none; b=mnkr8oPut95i7Z2nQc6v8SPAE6GWuhkmiq31G1XwChkaUr2dln4ZiuUsAtiK7I7lBFWfrUEx3ezsxO37NbQYknHxxT1vHux2SSw6D3u8bSjFyY/zs/qRBJTcDOJltNzEI9PPOyuEkcOS+Tz46S+IT2WVY5D4UOEJAApwZ3wjSwU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771535084; c=relaxed/simple; bh=FRv7eowAcNyO65MPdC6mYQ+EkktIEpwQbRI5qwDk7Qk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D4/cdfpTDVvWxkTfVx5KyXaYMzAeNRLbv9996NbbrWhMZq2UDCgwjG1sRlhQYZ0Y7OYbvyjS/RlGnORzzloES+p8Q0quUOWhGgqGtoTdbvBvX6CXM+R7BMYj/EqHe23ueu8fkhpW6AZiTl76AKlYdPUZSvAOBrmlc6WIQTkycjc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=d7sr/7xO; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d7sr/7xO" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4837f27cf2dso11922945e9.2 for ; Thu, 19 Feb 2026 13:04:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771535081; x=1772139881; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f0GUcmDt7bO2Sn9J+9uf0HNcJyXZ2g0c2Cg3p3pl5n4=; b=d7sr/7xOKDrfhuaSB0ZaM8z+I9/E3H2P1grkmIKoq0mrR2YMOLI7Ei5lN3G+1tuL1M bAh1L+IT/x/2I2nzZvOksXY/2pW3tkPfoGlHSM47Mfk6bEEliZO3+cixLQyWldh8KJWA 7D6mPT/cJoeEcqs2TFWDXW1cuBZOu0Lq7s4CD6i4ewyM1iOnXl/kdRZqGfcqiNZkPjZu bH6lcohp9EM2RMUZViYeI6u5y62YyI4ET6XnnedizeSr6N58QC+Z9JjAWyHBNq6vYbSH YGs0TFuSpiT0SF6tgNVHZQJSWiHrPR1NsyqkYLPEjJ4vnJvjHwn3zTmQU6KUpwrl8KcV WJhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771535081; x=1772139881; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=f0GUcmDt7bO2Sn9J+9uf0HNcJyXZ2g0c2Cg3p3pl5n4=; b=Ct+Zh/rpuvmxq0obT6vg4NgCjYs805kHWPqvRafea74l5ELYtm/AHyymEX0+/Mb/aT Wp2TBJ6m4kRmeoVlB0CQAfvN3RmUNAVkSr3gDg7qfkIYOQrJsss+lHVriBRcz+XSYWYD VkggQLwbfclSNT5ZJcjgvAuMK6Rezt1yPQ9YMeMckx7XLeb+fpCbviT6xeuPJfGKsrdy ouB8zlAqURLajMCgqdlMlfFjGw3M9iYdf5YWetqsdPIOO+ORTE4ajQ8sxVCiTkdIsfEf FCB5yle6q6fJ/gFH2dLBOTX3XlaeTr6nKD2YqMY9JGZfkygm6Y25OySZq8/IFXKEic6O D58A== X-Forwarded-Encrypted: i=1; AJvYcCVdfZccxKB6wcvMhlPsfXTo8dTHhxckA5k0EffegEubpa/vmgiWtwdnRGJJE6tNdYRtReawKSLOO+9Pse8=@vger.kernel.org X-Gm-Message-State: AOJu0Yxj786+CFpwwkindYuNK4tsrLhL5CFOlrlvKdMTT5jaibWnE3+8 l4Br9MFsB+qwWYbwL+bX45TcPex9oIFYUSPGb0w49aAOrhaQY5vbRewO X-Gm-Gg: AZuq6aJUoasntkVPeIIzj6vMmuHqzoyA/gz2uS+Q6ptsArBCBqxGGTcpsEgov4fz/x0 PXO9xqQgMmPuYlZuyr3A8Yf6c41at5mIt5TCjvdBw0YOjKzSp1YAplmgabALPFRFNWOTaQnbLzC uC25svFBz7DgxebKSypAeB6T0jVcl+xHlBgTOF09hhWEPiImRW4Kdljl3RToPmwCp9swMFrTPEW /hlCrYaj2tOArla+iOBVoJcWTvboDc+ShMYw4iLzAbHBUxBO3XOYb4wAsgmbW0IjjY3/GG2oWIe kWAQxjVAv/X1BW60lzWhYDbFoYFvhLqNMLfnvF3cxy6ALpY2MppxFmXIgXsI+o3g4dv6VrCR1HE /qVi6tQ9C30g11iH4/Q04jb1rQNWcGxJIFZ/IWB4t9yIolLgPF+b2nTcldwQeRtdqBtB7IXzBKg Z1w1UOCsUQ2v2LZKq5XieLNt+y4zpTOw== X-Received: by 2002:a05:6000:420a:b0:437:6758:ce75 with SMTP id ffacd0b85a97d-43796ac216amr43835401f8f.23.1771535081365; Thu, 19 Feb 2026 13:04:41 -0800 (PST) Received: from localhost ([212.73.77.104]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-43796a5b4cdsm55044994f8f.8.2026.02.19.13.04.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Feb 2026 13:04:41 -0800 (PST) From: Askar Safin To: linux-fsdevel@vger.kernel.org, Christian Brauner , Alexander Viro , Jan Kara Cc: Randy Dunlap , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, initramfs@vger.kernel.org, Rob Landley , David Disseldorp , Nathan Chancellor , Nicolas Schier , patches@lists.linux.dev Subject: [PATCH 2/2] init: ensure that /dev/null is (nearly) always available in initramfs Date: Thu, 19 Feb 2026 21:03:12 +0000 Message-ID: <20260219210312.3468980-3-safinaskar@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260219210312.3468980-1-safinaskar@gmail.com> References: <20260219210312.3468980-1-safinaskar@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Binaries linked with bionic libc require /dev/null to be present, otherwise they will crash before entering "main", as explained in https://landley.net/toybox/faq.html#cross3 . So we should put /dev/null to initramfs, but this is impossible if we create initramfs using "cpio" and we are running as normal user. This problem can be solved by using gen_init_cpio. But let's make sure instead that /dev/null is always available as a quality-of-implementation feature. This will reduce number of failure modes and will make it easier for developers to get early boot right. (Early boot issues are very hard to debug.) Signed-off-by: Askar Safin --- init/do_mounts.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init/do_mounts.c b/init/do_mounts.c index f911280a348e..3e71049b3dcf 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c @@ -525,5 +525,8 @@ void __init create_basic_rootfs(void) WARN_ON_ONCE(init_mkdir("/dev", 0755) !=3D 0); WARN_ON_ONCE(init_mknod("/dev/console", S_IFCHR | 0600, new_encode_dev(MKDEV(5, 1))) !=3D 0); + WARN_ON_ONCE(init_mknod("/dev/null", S_IFCHR, + new_encode_dev(MKDEV(1, 3))) !=3D 0); + WARN_ON_ONCE(init_chmod("/dev/null", 0666) !=3D 0); WARN_ON_ONCE(init_mkdir("/root", 0700) !=3D 0); } --=20 2.47.3