* [PATCH] fix 2.4.x incorrect argv[0] for init
@ 2003-09-09 22:32 Erik Andersen
0 siblings, 0 replies; 3+ messages in thread
From: Erik Andersen @ 2003-09-09 22:32 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: linux-kernel
In both 2.4.x and in 2.6.x, when someone specifies "init=" to
select an alternative binary to run instead of /sbin/init,
argv[0] is not set correctly. This is a problem for programs
such as busybox that multiplex applications based on the value of
argv[0]. For example, even if you specify init=/bin/sh" on the
kernel command line, busybox will still receive "/sbin/init" as
argv[0], and will therefore run init rather than /bin/sh...
This patch fixes it. Please apply,
-Erik
--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
--- orig/init/main.c 2003-08-30 10:50:15.000000000 -0600
+++ linux-2.4.22/init/main.c 2003-08-30 10:50:15.000000000 -0600
@@ -545,6 +545,12 @@
#endif
}
+static void run_init_process(char *init_filename)
+{
+ argv_init[0] = init_filename;
+ execve(init_filename, argv_init, envp_init);
+}
+
extern void prepare_namespace(void);
static int init(void * unused)
@@ -587,10 +593,12 @@
*/
if (execute_command)
- execve(execute_command,argv_init,envp_init);
- execve("/sbin/init",argv_init,envp_init);
- execve("/etc/init",argv_init,envp_init);
- execve("/bin/init",argv_init,envp_init);
- execve("/bin/sh",argv_init,envp_init);
+ run_init_process(execute_command);
+
+ run_init_process("/sbin/init");
+ run_init_process("/etc/init");
+ run_init_process("/bin/init");
+ run_init_process("/bin/sh");
+
panic("No init found. Try passing init= option to kernel.");
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Linux 2.4.23-pre6
@ 2003-10-01 17:44 Marcelo Tosatti
2003-10-01 18:56 ` [PATCH] fix 2.4.x incorrect argv[0] for init Erik Andersen
0 siblings, 1 reply; 3+ messages in thread
From: Marcelo Tosatti @ 2003-10-01 17:44 UTC (permalink / raw)
To: linux-kernel
Hi,
Here goes -pre6.
It contains several ACPI fixes (the USB "not working anymore" problems in
-pre5 should be gone), support for the SCTP protocol, x86-64/PPC/SH
merges, network drivers update (EMAC, e1000, sk98lin), megaraid update,
amongst others.
Enjoy :)
Summary of changes from v2.4.23-pre5 to v2.4.23-pre6
============================================
<dfages:arkoon.net>:
o [NET]: Fix HW_FLOWCONTROL on SMP
<galak:blarg.somerset.sps.mot.com>:
o Added "user64" versions of the user access functions that allow modification of 64-bit data.
o PPC32: Added "user64" versions of the user acess functions that allow modification of 64-bit data.
o PPC32: Added big-endian cfg_addr access
o PPC32: Simplified handling of big/little endian pci indirect access
<marcelo:dmt.cyclades>:
o Dave Jones: Fix cache size of Centrino CPU
o Changed EXTRAVERSION to -pre6
<moilanen:austin.ibm.com>:
o Workaround PPC64 PCI scan issue
<mpm:selenic.com>:
o netif_carrier_* support for tlan
Alexander Viro:
o Convert /proc/<pid>/maps to seqfile
Andi Kleen:
o x86-64 merge
o AGP Updates for K8
o /proc/kcore fixes for x86-64
o Add 3GB personality for x86-64
o Use MTRR in vesafb by default on x86-64
o Support 32bit uids on x86-64
o Remove IORR manipulation in agpgart nvidia drivers
Atul Mukker:
o Update megaraid driver to 1.18k
Chas Williams:
o [ATM]: [clip] Fix race between modifying entry->vccs and clip_start_xmit()
o [ATM]: Split atm_ioctl into vcc_ioctl and atm_dev_ioctl
o [ATM]: Cleanup atm_dev_ioctl a bit (from mitch@sfgoth.com)
o [ATM]: Implement pppoatm_ioctl_hook for pppoatm
o [ATM]: Implement br2684_ioctl_hook for br2684
o [ATM]: [he] Possibly using corrupted structure (from felipewd@terra.com.br)
o [ATM]: Update link in documentation
Damien Morange:
o [SCTP] LKSCTP 0.6.9 backport on kernel 2.4 patch #1
o [SCTP] LKSCTP 0.6.9 backport on kernel 2.4 patch #2
o [SCTP] LKSCTP 0.6.9 backport on kernel 2.4 patch #3
David S. Miller:
o [NET]: Increase ethernet tx_queue_len to 1000
o [IPV4]: Fix route leak in igmp.c
o [SCTP]: Do not redefine SMTP stat inc macros
o [SCTP]: Include linux/crypto.h as needed
o [NET]: Unlink qdiscs in qdisc_destroy even when CONFIG_NET_SCHED is not enabled
o [IPV4]: In arp_rcv() do not inspect ARP header until packet length and linearity is verified
Harald Welte:
o [NETFILTER]: Fix ipt_REJECT when used in OUTPUT
o [NETFILTER]: In ipt_REJECT handle various hooks correctly in route_reverse()
Ivan Kokshaysky:
o Alpha update
Jamal Hadi Salim:
o [NET]: Make pfifo_fast actually report statistics
Jeff Garzik:
o [wireless airo] Fix build
Jens Axboe:
o cdrom memory leak
John Stultz:
o Fix boot code overflow with more CPUs than CONFIG_NR_CPUS
Krishna Kumar:
o [IPV6]: Export ipv6_devconf via netlink
Larry McVoy:
o Add pre-apply.paranoid trigger from the Linux 2.5 tree
Len Brown:
o [ACPI] For ThinkPad -- carry on in face of ECDT probe failure (Andi Kleen)
o [ACPI] ACPI Component Architecture 20030918 (Bob Moore)
o [ACPI] CONFIG_ACPI is no longer necessary to enable HT if (CONFIG_ACPI || CONFIG_SMP) CONFIG_ACPI_BOOT=y
o [ACPI] acpi_pci_link_allocate() should stick with irq.active if set. (Andrew de Quincey) Fixes OSDL #1186 "broken USB" and others
o [ACPI] acpi4asus-0.24a-0.25-2.4 (Karol Kozimor)
o [ACPI] acpi4asus-0.25-0.26 (Karol Kozimor)
o [ACPI] build fix: remove 2nd __exit from asus_acpi.c
o [ACPI] deal with lack of acpi prt entries gracefully (Jesse Barnes)
Marcelo Tosatti:
o Removed unused label in page_alloc.c
Matt Porter:
o PPC32: Fix 44x _PMD_PRESENT bug
o PPC32: Use CONFIG_PTE_64BIT instead of CONFIG_44x where appropriate
o 2.4 IBM EMAC updates
Matthew Wilcox:
o [NETFILTER]: Use net/checksum.h instead of asm/checksum.h
Mike Miller:
o cciss support more than 8 controllers
Mirko Lindner:
o sk98lin-2.4: Remove useless configure options
o sk98lin-2.4: Readme version update
Paul Mundt:
o sh: shmse updates
o sh: div64 backport and random cleanups
o sh: Add bzImage support
o sh: sh-sci updates
o [sh64] Add a new configure option + support code to provide a /proc/asids file
o sh64: Fixup unaligned accesses
o sh: Interim cache coherency fix for 2-way caches
o sh64: Fix CONFIG_SH64_USER_MISALIGNED_FIXUP compile error
Scott Feldman:
o [e1000] cleanup error return codes
o [e1000] Add PHY master/slave #define override
o [e1000] add ethtool flow control support
o [e1000] move static to table from .h to .c
o [e1000] Turn off ASF support on Fiber nics
o [e1000] make function out of setting media type
o [e1000] sync w/ 2.6 e1000 driver
o [e1000] read correct bit from EEPROM for getting WoL settings
o [e1000] new 82541/5/6/7 hardware support
o [e1000] misc whitespace cleanup, changelog
o [e1000] 82544 PCI-X hang fix + TSO updates
Sean McGoogan:
o bug fix: preserve EXPEVT across nested interrupts
o bug fix: ensure FPSCR.PR == FPSCR.SZ == 1 never occurs
o provide support for SH4-202 chip
o Addition of support for the SuperH SH4-202 MicroDev CPU Board
Tom Rini:
o PPC32: Add CONFIG_ADVNACED_OPTIONS to make the kernel more flexible
o PPC32: Make ISA support a question on CONFIG_ALL_PPC
o PPC32: Add the D-Box2 MPC8xx board
o PPC32: Misc changes for the D-Box2
o PPC32: Fix a multiple definition problem in the bootwrapper
o PPC32: UART support and configuration updates from Gary Thomas
o PPC32: Add a potential bugfix to the MPC8xx uart driver, by way of Dan Malek
o PPC32: Update MPC8xx code so that it uses consistent_alloc
o PPC32: Fix KGDB on MPC8xx targets with one serial port
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] fix 2.4.x incorrect argv[0] for init
2003-10-01 17:44 Linux 2.4.23-pre6 Marcelo Tosatti
@ 2003-10-01 18:56 ` Erik Andersen
2003-10-01 19:34 ` jhf
0 siblings, 1 reply; 3+ messages in thread
From: Erik Andersen @ 2003-10-01 18:56 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: linux-kernel
In 2.4.x when someone specifies "init=/bin/foo" to select an
alternative binary to run instead of /sbin/init, argv[0] is not
to the correct value. This is a problem for programs such as
busybox that multiplex applications based on the value of
argv[0]. For example, even if you specify init=/bin/sh" on the
kernel command line, busybox will still receive "/sbin/init" as
argv[0], and will therefore run init rather than /bin/sh...
This problem was recently fixed in 2.6.x. This patch applies
the same fix to 2.4.x.
-Erik
--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
--- orig/init/main.c 2003-08-30 10:50:15.000000000 -0600
+++ linux-2.4.22/init/main.c 2003-08-30 10:50:15.000000000 -0600
@@ -545,6 +545,12 @@
#endif
}
+static void run_init_process(char *init_filename)
+{
+ argv_init[0] = init_filename;
+ execve(init_filename, argv_init, envp_init);
+}
+
extern void prepare_namespace(void);
static int init(void * unused)
@@ -587,10 +593,12 @@
*/
if (execute_command)
- execve(execute_command,argv_init,envp_init);
- execve("/sbin/init",argv_init,envp_init);
- execve("/etc/init",argv_init,envp_init);
- execve("/bin/init",argv_init,envp_init);
- execve("/bin/sh",argv_init,envp_init);
+ run_init_process(execute_command);
+
+ run_init_process("/sbin/init");
+ run_init_process("/etc/init");
+ run_init_process("/bin/init");
+ run_init_process("/bin/sh");
+
panic("No init found. Try passing init= option to kernel.");
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] fix 2.4.x incorrect argv[0] for init
2003-10-01 18:56 ` [PATCH] fix 2.4.x incorrect argv[0] for init Erik Andersen
@ 2003-10-01 19:34 ` jhf
0 siblings, 0 replies; 3+ messages in thread
From: jhf @ 2003-10-01 19:34 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: Erik Andersen, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1249 bytes --]
On Wed, Oct 01, 2003 at 12:56:13PM -0600, Erik Andersen wrote:
> In 2.4.x when someone specifies "init=/bin/foo" to select an
> alternative binary to run instead of /sbin/init, argv[0] is not
> to the correct value. This is a problem for programs such as
> busybox that multiplex applications based on the value of
> argv[0]. For example, even if you specify init=/bin/sh" on the
> kernel command line, busybox will still receive "/sbin/init" as
> argv[0], and will therefore run init rather than /bin/sh...
>
> This problem was recently fixed in 2.6.x. This patch applies
> the same fix to 2.4.x.
I didn't know that got merged. Great!
Debian users running 2.6: go install busybox-static, then make a
link from /sbin/sh to /bin/busybox. If something bad happens to your
file system or libc or something like that, you can still boot with
init=/sbin/sh and get a shell prompt and all the important utilities
as long as /bin/busybox is okay. It's a nice failsafe, especially
when testing kernels or running an unstable distribution.
If this patch gets merged in 2.4, 2.4 users will be able to do this
too.
--
Joseph Fannin
jhf@rivenstone.net
"That's all I have to say about that." -- Forrest Gump.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-10-01 19:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-09 22:32 [PATCH] fix 2.4.x incorrect argv[0] for init Erik Andersen
-- strict thread matches above, loose matches on Subject: below --
2003-10-01 17:44 Linux 2.4.23-pre6 Marcelo Tosatti
2003-10-01 18:56 ` [PATCH] fix 2.4.x incorrect argv[0] for init Erik Andersen
2003-10-01 19:34 ` jhf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox