Bug 72920 - [linux] path "prefixing" is not done on unix domain socket addresses
Summary: [linux] path "prefixing" is not done on unix domain socket addresses
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 14.0-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Dmitry Chagin
URL:
Keywords:
Depends on:
Blocks: 247219
  Show dependency treegraph
 
Reported: 2004-10-20 13:00 UTC by Andriy Gapon
Modified: 2024-01-02 20:06 UTC (History)
3 users (show)

See Also:
linimon: mfc-stable13?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andriy Gapon 2004-10-20 13:00:50 UTC
It seems that pathname "prefixing" is not performed for unix domain
socket calls in linux emulation e.g. "/compat/linux" prefix is never
tried to be prepended for bind() and connect() calls. 
When mixed with filesystem calls this leads to linux applications
failing in scenarios like this:


mkdir("/tmp/foo");
//this will create /compat/linux/tmp/foo/ directory

s = socket(AF_LOCAL, SOCK_DGRAM, PF_LOCAL);
strcpy(addr.sun_path, "/tmp/foo/bar");
addr.sun_family = AF_LOCAL;
bind(s, (struct sockaddr *) &addr, SUN_LEN(&addr));
//this will try to bind socket in /tmp/foo/ directory
//which does not exist

I have experinced this problem on FreeBSD 5.2.1 with two real-life
applications:
	oracle 9.2.0.4.0
	IBM WebSphere MQ 5.3

Fix: 

fix should not be very hard to implement, but I'd prefer that someone more
familiar with the code would do it (someone who wrote the similar code for 
filesystem calls).
How-To-Repeat: Existence of this problem can be easily verified using a small program 
with the above code (make sure /tmp/foo directory is not existant).
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2004-11-29 09:31:36 UTC
Responsible Changed
From-To: freebsd-bugs->emulation

Reassign to appropriate mailing list.
Comment 2 Alexander Leidinger freebsd_committer freebsd_triage 2005-12-29 16:09:27 UTC
State Changed
From-To: open->feedback

Does this problem still persists on a recent FreeBSD? 
If yes, I suggest to try to come up with a patch, since most 
of the problems are fixed by people which need a particular 
feature (we don't have a maintainer for the linuxolator).
Comment 3 Alexander Leidinger freebsd_committer freebsd_triage 2006-01-14 14:23:47 UTC
State Changed
From-To: feedback->open

Feedback reveived, the bug still exist in -current. 
 
http://www.freebsd.org/cgi/query-pr.cgi?pr=72920 
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2006-01-14 18:19:19 UTC
State Changed
From-To: open->analyzed

ISTM 'analyzed' is a better state for this.
Comment 5 Andriy Gapon freebsd_committer freebsd_triage 2010-12-05 15:26:02 UTC
State Changed
From-To: analyzed->closed
Comment 6 Andriy Gapon freebsd_committer freebsd_triage 2010-12-05 15:27:04 UTC
State Changed
From-To: closed->analyzed

Revert accidental status change.
Comment 7 Dmitry Chagin freebsd_committer freebsd_triage 2016-01-17 15:38:49 UTC
take
Comment 8 Eitan Adler freebsd_committer freebsd_triage 2018-05-28 19:46:43 UTC
batch change:

For bugs that match the following
-  Status Is In progress 
AND
- Untouched since 2018-01-01.
AND
- Affects Base System OR Documentation

DO:

Reset to open status.


Note:
I did a quick pass but if you are getting this email it might be worthwhile to double check to see if this bug ought to be closed.
Comment 9 commit-hook freebsd_committer freebsd_triage 2023-05-29 08:20:24 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=fd745e1db6b561900b8e5e9caa4ed05cf15398b3

commit fd745e1db6b561900b8e5e9caa4ed05cf15398b3
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-05-29 08:16:46 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-05-29 08:16:46 +0000

    linux(4): Use pwd_altroot() to tell namei() about ABI root path

    PR:                     72920
    Differential Revision:  https://reviews.freebsd.org/D40090
    MFC after:              2 month

 sys/amd64/linux/linux_sysvec.c      |   6 +-
 sys/amd64/linux32/linux32_machdep.c |  12 +-
 sys/amd64/linux32/linux32_sysvec.c  |   6 +-
 sys/arm64/linux/linux_sysvec.c      |   4 +-
 sys/compat/linux/linux_emul.c       |  47 +----
 sys/compat/linux/linux_emul.h       |   3 +-
 sys/compat/linux/linux_file.c       | 407 ++++++------------------------------
 sys/compat/linux/linux_mib.c        |   4 -
 sys/compat/linux/linux_misc.c       | 120 ++---------
 sys/compat/linux/linux_stats.c      | 111 ++--------
 sys/compat/linux/linux_uid16.c      |  43 +---
 sys/compat/linux/linux_util.c       |  41 ++--
 sys/compat/linux/linux_util.h       |  25 +--
 sys/i386/linux/linux_machdep.c      |  15 +-
 sys/i386/linux/linux_sysvec.c       |   7 +-
 15 files changed, 158 insertions(+), 693 deletions(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2023-05-29 08:20:27 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=3d2fec7db856c67e1a94a87a846d8ffe6f48b61f

commit 3d2fec7db856c67e1a94a87a846d8ffe6f48b61f
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-05-29 08:15:28 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-05-29 08:15:28 +0000

    namei: Add the abilty for the ABI to specify an alternate root path

    For now a non-native ABI (i.e., Linux) uses the kern_alternate_path()
    facility to dynamically reroot lookups. First, an attempt is made to
    lookup the file in /compat/linux/original-path. If that fails, the
    lookup is done in /original-path. Thats requires a bit of code in
    every ABI syscall implementation where path name translation is needed.
    Also our kern_alternate_path() does not properly lookups absolute symlinks
    in second attempt, i.e., does not append /compat/linux part to the resolved
    link.
    The change is intended to avoid this by specifiyng the ABI root directory
    for namei(), using one call to pwd_altroot() during exec-time into the ABI.
    In that case namei() will dynamically reroot lookups as mentioned above.

    PR:                     72920
    Reviewed by:            kib
    Differential revision:  https://reviews.freebsd.org/D38933
    MFC after:              2 month

 sys/kern/kern_descrip.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++--
 sys/kern/vfs_cache.c    |  4 ++--
 sys/kern/vfs_lookup.c   | 30 +++++++++++++++++++++---
 sys/sys/filedesc.h      |  4 ++++
 sys/sys/namei.h         | 11 +++++++--
 5 files changed, 101 insertions(+), 9 deletions(-)
Comment 11 Mark Linimon freebsd_committer freebsd_triage 2023-12-25 15:22:03 UTC
^Triage: committed directly to -14, so the mfc-stable14 flag is OBE.  The mfc-stable[11|12] flags' values are now OBE.
Comment 12 Mark Linimon freebsd_committer freebsd_triage 2024-01-02 20:06:26 UTC
^Triage: FreeBSD 12 is now out of support.