Bug 73777 - [linux] [patch] linux emulation: root dir special handling useless and harmful
Summary: [linux] [patch] linux emulation: root dir special handling useless and harmful
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 5.2.1-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-emulation (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-10 15:50 UTC by Andriy Gapon
Modified: 2016-12-05 13:49 UTC (History)
0 users

See Also:


Attachments
rootdir.patch (1.67 KB, patch)
2004-11-10 15:50 UTC, Andriy Gapon
no flags Details | Diff
rootdir-6.patch (1.19 KB, patch)
2008-02-23 07:46 UTC, Andriy Gapon
no flags Details | Diff
rootdir-7.patch (2.09 KB, patch)
2008-03-03 20:14 UTC, Andriy Gapon
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andriy Gapon 2004-11-10 15:50:29 UTC
A little background: in linux emulation any access to file system node is first
tried with "/compt/linux" prepended to its path, original path is tried only
if linuxified path is not vaiable. In that fashion linux applications can
access both files under linux emulation root (/compat/linux) and those files
under the real root that are not shadowed by the former files. This behavior
is reverted only for one filesystem node - "/compat/linux" itself. That is,
no application under linux emualtion is able to access linux compatibility
root, real root ("/") is given to it instead.
This seems to be illogical, linux application is probably more ineterested
in linux root directory rather than real root directory. Also, no linux 
application should ever want to "break out" from linux root by "cd ..".

So I think that the special handling for root directories should be removed
and real root directory should be shadowed by /compat/linux.

Existing linux emulation behavior also breaks "mkdir -p" from linux base r7, if
you want to creat a directory with more than one path unexstistant component:
in this case mkdir first performs chdir("/") and then iterativly mkdir()s and
chdir()s to subdirectories. So, the first action, chdir("/") would chdir to
real root and directory created either will be wrong one or will not be
created at all because of permissions.

Please also see my attemps to discuss this issue on mailing lists:
http://docs.freebsd.org/cgi/mid.cgi?4178DBA0.8050605
http://docs.freebsd.org/cgi/mid.cgi?4176A6C0.5070408

I have applied the patch attached on my system and have not seen any
problems with linux emulation, only improvements.
I run oracle 9, ibm websphere 5.1 with mq and wemps.

How-To-Repeat: 1. work as unpriviledged user with shell /compat/linux/bin/bash
2. make sure /var and /compat/linux/var are different directories
3. create /compat/linux/var/foo directory with rwx permission for the user
   mentioned in step 1.
4. make sure there is no /var/foo directory
5. execute "mkdir -p /var/foo/1/2/3" as user from step 1.
6. see the above command fail with permission denied error
7. apply the attached patch
8. recompile kernel and/or linux.ko, reboot
9. try the same again
10. see successful creation of expected directory
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2004-11-29 09:29:49 UTC
Responsible Changed
From-To: freebsd-bugs->emulation

Reassign to appropriate mailing list.
Comment 2 Volker 2008-02-22 21:16:02 UTC
Andriy,

I'm sorry to see your PR being in GNATS for years. I've checked your
issue and was not able to get your patch into sync with current RELENG_7
sources.

I'm wondering if you're still thinking, the issue is real and am willing
to send in new patches? If you think this issue has been solved in the
meantime, please report back so we can close this PR.

Thanks!
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2008-02-23 03:10:25 UTC
State Changed
From-To: open->feedback

Note that submitter has been asked for feedback.
Comment 4 Andriy Gapon 2008-02-23 07:46:53 UTC
Well, I think that the issue described in this PR still holds.
On the other hand, I now think that some people might still prefer
current behavior over what I suggest. There could be some POLA concerns too.
Another concern is that now the code is common to all emulation, so it's
not linux specific anymore.
In any case, I am attaching a patch that I currently use.

-- 
Andriy Gapon
Comment 5 Andriy Gapon 2008-03-03 20:14:40 UTC
An updated patch that makes the proposed behavior controlled by sysctl.
Present behavior is the default.


-- 
Andriy Gapon
Comment 6 Volker Werth freebsd_committer freebsd_triage 2008-05-18 10:22:03 UTC
State Changed
From-To: feedback->open


feedback and new patch provided
Comment 7 Andriy Gapon freebsd_committer freebsd_triage 2010-12-05 15:28:19 UTC
State Changed
From-To: open->closed

It seems that the suggested change is not really useful 
for general FreeBSD user base. 
And I have no use for it now as well.