Commit f8e5f9f2 authored by Bryan Freed's avatar Bryan Freed
Browse files

rootdev: Prevent infinite recursion when parsing /sys/block.

The mmcblk driver of the 3.0.8 kernel adds mmcblk0boot0 and mmcblk0boot1
directories under /sys/block or /sys/block/mmcblk0.  I have seen it both ways.
The device symlink in those directories points to "../../mmcblk0" which
points to the grandparent directory.

When rootdev scans /sys/block looking for a device that matches "/", it
can fall into this loop and recurse until failure.

While a proper fix would detect loops to prevent recursion, that adds
considerable complexity to the directory scan.
This relatively simple solution limits recursion depth to 5 to prevent
infinitely looping.  It will fail to find device matches beyond 5 levels
of directories, but we are nowhere near that in today's systems.  We find
matches at level 3 as best I can tell.

BUG=chromium-os:22855
TEST=Run rootdev and check for failures.

Change-Id: I9ef3aa0a6d6f8143dd0b9e012ba4bb4adfa0c73b
Reviewed-on: https://gerrit.chromium.org/gerrit/11575


Reviewed-by: default avatarWill Drewry <wad@chromium.org>
Commit-Ready: Bryan Freed <bfreed@chromium.org>
Tested-by: default avatarBryan Freed <bfreed@chromium.org>
parent 80fbc6c5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment