-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathnasty-bash-hack.txt
79 lines (59 loc) · 2.4 KB
/
nasty-bash-hack.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
2010-11-17
Summary: /bin/bash on some distros like Ubuntu crashes when invoked with
ld-linux.so.2. This doesn't seem related to CDE at all, but the
implication is that when running on those machines, you must tell CDE to
explicitly ignore /bin/bash or else you will encounter random crashes.
Here is the original code that I just cut out of CDE_begin_execve():
/* This seems like a really ugly hack, but I can't think of a way
around it ... on some linux distros, /bin/bash sporadically crashes
once in a blue moon if you attempt to run it through
/lib/ld-linux.so.2 (but it works fine if you run it directly from
the shell). here is an example from Xubuntu 9.10 (32-bit)
$ while true; do /lib/ld-linux.so.2 /bin/bash -c "echo hello"; sleep 0.1; done > /dev/null
Segmentation fault
Segmentation fault
Segmentation fault
Segmentation fault
/bin/bash: xmalloc: ../bash/variables.c:2150: cannot allocate 1187 bytes (0 bytes allocated)
Segmentation fault
Segmentation fault
Segmentation fault
Segmentation fault
Segmentation fault
Segmentation fault
Segmentation fault
Segmentation fault
/bin/bash: xmalloc: ../bash/make_cmd.c:76: cannot allocate 240 bytes (0 bytes allocated)
Segmentation fault
[...]
the command is simple enough: /lib/ld-linux.so.2 /bin/bash -c "echo hello"
but when run enough times, it sporadically crashes
Google for "xmalloc /bin/bash cannot allocate" for some random
forum posts about these mysterious crashes
e.g., http://lists.debian.org/debian-glibc/2004/09/msg00149.html
note that if you just directly run:
/bin/bash -c "echo hello"
repeatedly, there are NO segfaults.
thus, don't try invoking the dynamic linker on /bin/bash (this doesn't
seem to be CDE's fault, because it crashes even when not running in CDE)
Update on 2010-11-05:
A more direct way this problem manifests is if you run 'make' with this as the Makefile:
'''
all:
/lib64/ld-linux-x86-64.so.2 /bin/bash -c "echo hello"
'''
HA, it seems like someone reported this as a bug in Ubuntu:
http://www.mail-archive.com/ubuntu-bugs@lists.ubuntu.com/msg925663.html
https://bugs.launchpad.net/ubuntu/+source/make/+bug/249872
Related bug report that hones in on /bin/bash itself:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/452175
test case:
#!/bin/sh
while true
do
/lib/ld-linux.so.2 /bin/bash /usr/bin/which apt-get
done
*/
if (strcmp(tcp->opened_filename, "/bin/bash") == 0) {
return;
}