FS#15362 - [klibc] problem with kinit-fix-init-cmdline.patch

Attached to Project: Arch Linux
Opened by Gerardo Exequiel Pozzi (djgera) - Saturday, 04 July 2009, 04:45 GMT
Last edited by Aaron Griffin (phrakture) - Tuesday, 01 December 2009, 21:10 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Thomas Bächler (brain0)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description: I am not sure if this can be problematic or not, but the patch kinit-fix-init-cmdline.patch [#1] added to solve  FS#8832  makes the 'init' command line looks bad, this can be viewed with 'ps' command or directly with /proc/1/cmdline.

# cat /proc/1/cmdline <-- klibc-1.5.15-3
ini

# cat /proc/1/cmdline <-- rebuiling klibc-1.5.15-3 without the patch
init [3]

Additional info:
klibc-1.5.15-3

[#1] http://repos.archlinux.org/viewvc.cgi/klibc/repos/core-i686/kinit-fix-init-cmdline.patch?revision=43019&view=markup
This task depends upon

Closed by  Aaron Griffin (phrakture)
Tuesday, 01 December 2009, 21:10 GMT
Reason for closing:  Deferred
Additional comments about closing:   FS#17298 
Comment by Thomas Bächler (brain0) - Saturday, 04 July 2009, 09:59 GMT
Yes, I investigated that already. It seems that init overwrites its cmdline with a new string. However, now that we stopped passing unnecessary (and wrong) options, the memory for that is too short. Why it only fits three characters in there is a mystery to me though, the strings should be longer.
Comment by solsTiCe (zebul666) - Wednesday, 21 October 2009, 11:50 GMT
i still see this with kernel2.6.31.4-1, klibc 1.5.15-3, mkinitcpio 0.5.26-1
Comment by Thomas Bächler (brain0) - Wednesday, 21 October 2009, 12:53 GMT
Hm, I think I know how to "fix" it, but it's not really worth the effort, as rebuilding klibc against a new kernel is always a PITA (it seems to be okay this time, but we'll have to see). I thought I would have switched to uclibc by now and left klibc/kinit behind, but it seems that didn't happen, as creating the necessary tools is not as flawless as I would have wished.

What happens is the following: We pass no options at all to init by default. That means klibc calls /sbin/init with argc=1 and argv="init\0" (note that the array is allocated on the stack as continuous memory). If we were to pass "3" as an argument, this would be argv="init\03\0". Now, what I suspect to be an off-by-one error in sysvinit causes init to overwrite this by "ini\0\0". If we would change the command line to "/sbin/init\0" in kinit, then init would be able to write "init [5]\0\0\0" as it wants to.
Comment by Thomas Bächler (brain0) - Wednesday, 21 October 2009, 22:51 GMT
Okay, this should be fixed in testing, at least it works here.
Comment by Thomas Bächler (brain0) - Saturday, 07 November 2009, 01:40 GMT
I cannot rebuild a working version of klibc against 2.6.31 on i686, and upstream is dead. I will hopefully get to dumping klibc for good.

Loading...