Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 667226

Summary: linux_ro_checker produces false positives in the presence of read-only bind mounts
Product: Portage Development Reporter: Mira Ressel <aranea>
Component: CoreAssignee: Portage team <dev-portage>
Status: CONFIRMED ---    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 23851    

Description Mira Ressel 2018-09-28 13:27:13 UTC
Portage's logic to detect read-only filesystems (lib/portage/util/writeable_check.py) is broken because it incorrectly assumes that the st_dev value returned by stat() matches only one of the filesystems listed in /proc/self/mountinfo.

This assumption is incorrect because bind mounts share the st_dev value of their parent, but have an independent read-only/read-write status. (There may be other scenarios where the assumption fails, for example with btrfs snapshots.)

This isn't a huge issue because this whole check will only be triggered when Portage has already detected that a directory isn't writable -- so in general, when this bug is triggered, there's indeed a reason to abort the merge, Portage just does so with a nonsensical error message.

For example, I ran into this when I tried to emerge openssh -- /var/empty wasn't writable due to a problem on my system, but instead of exiting with the error message "Hey, I can't write /var/empty", Portage instead complained that /home/www/packages (a read-only bind mount from /var/portage/distfiles) was mounted read-only.