Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 160162 - bug in generate-modprobe.conf causes bash to fork-bomb
Summary: bug in generate-modprobe.conf causes bash to fork-bomb
Status: RESOLVED DUPLICATE of bug 149426
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-05 00:13 UTC by foo banana
Modified: 2007-01-05 00:34 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description foo banana 2007-01-05 00:13:57 UTC
When I attempt to do a modules-update (or emerge a kernel module), my system stops. I tracked down the bug, and this is what it is. It may be specific to my system.

In trying to resolve device char-major-195 (the nvidia driver), function resolve_alias in generate-modprobe.conf goes into infinite recursion, which causes bash to fork indefinitely, choking the system until a reboot is done. The line in question is the first and last lines (68 and 74):

resolve_alias()
{
    RA_RESOLVE=`grep "^alias[  ][  ]*$2[  ]" -- $1 | awk '{ print $3 }'`
    ...
    # Recurse.
    (resolve_alias $1 "$RA_RESOLVE")
}

$1 is a temporary file /tmp/modprobe.XXXXXX . $2 is the symbol to resolve. Here are the relevant lines of /tmp/modprobe.XXXXXX:

# Old nvidia support ...
alias char-major-195 NVdriver
alias char-major-195 nvidia
#   To enable Side Band Adressing:  NVreg_EnableAGPSBA=1
#options nvidia NVreg_EnableAGPSBA=1 NVreg_EnableAGPFW=1
#options nvidia NVreg_SoftEDIDs=0 NVreg_Mobile=3

The first two lines were imported from /etc/modules.d/aliases in package sys-apps/baselayout-1.12.6. The last 4 lines were imported from /etc/modules.d/nvidia in package x11-drivers/nvidia-drivers-1.0.8776. Here is a run-down of what happens:

In the course of normal events, resolve_aliases is called to resolve char-major-195 like so:

resolve_alias /tmp/modprobe.XXXXXX char-major-195

grep finds the two lines:

alias char-major-195 NVdriver
alias char-major-195 nvidia

and awk strips that to:

NVdriver
nvidia

Since that is not empty, resolve_alias is called recursively, but with a malformed second argument (unexpected embedded newline):

resolve_alias /tmp/modprobe.XXXXXX 'NVdriver
nvidia'

this wrecks havoc since that argument is used in a regular expression. the grep command is now

grep '^alias[       ][      ]*NVdriver
nvidia[         ]' -- /tmp/modprobe.XXXXXX

in my grep, the newline in argument 1 is treated like an or, so grep finds a match to either of the two incorrect regular expressions (this may be a bug in grep). It now matches these three lines, all of which are comments:

# Old nvidia support ...
#options nvidia NVreg_EnableAGPSBA=1 NVreg_EnableAGPFW=1
#options nvidia NVreg_SoftEDIDs=0 NVreg_Mobile=3

awk reduces this to:

nvidia
NVreg_EnableAGPSBA=1
NVreg_SoftEDIDs=0

since this is still not empty, resolve_aliases is recursively called again, this time with a completely bogus second argument:

resolve_alias /tmp/modprobe.XXXXXX 'nvidia
NVreg_EnableAGPSBA=1
NVreg_SoftEDIDs=0'

grep finds:

#   To enable Side Band Adressing:  NVreg_EnableAGPSBA=1
#options nvidia NVreg_EnableAGPSBA=1 NVreg_EnableAGPFW=1
#options nvidia NVreg_SoftEDIDs=0 NVreg_Mobile=3

resolve_aliases is called again:

resolve_alias /tmp/modprobe.XXXXXX 'enable
NVreg_EnableAGPSBA=1
NVreg_SoftEDIDs=0'

grep finds the same three lines as before:

#   To enable Side Band Adressing:  NVreg_EnableAGPSBA=1
#options nvidia NVreg_EnableAGPSBA=1 NVreg_EnableAGPFW=1
#options nvidia NVreg_SoftEDIDs=0 NVreg_Mobile=3

and resolve_alias is called with the same arguments as before, starting the endless forking bash recursion that killed my computer several times:

resolve_alias /tmp/modprobe.XXXXXX 'nvidia
NVreg_EnableAGPSBA=1
NVreg_SoftEDIDs=0'

I am not sure what the proper solution is. Perhaps it is wrong that /etc/modules.d/aliases and /etc/modules.d/nvidia contain competing aliases of char-major-195. Perhaps it is wrong that the output of grep is not limited to one line via head or tail. It is probably wrong that grep treats a newline like an OR operation. I don't know. As a workaround to enable emerging, I commented out the competing line in /etc/modules.d/aliases.
Comment 1 SpanKY gentoo-dev 2007-01-05 00:34:26 UTC

*** This bug has been marked as a duplicate of 149426 ***