#1710 closed defect (fixed)

symlink in IMFS fails to cross mount point

Reported by: strauman Owned by: Chris Johns
Priority: normal Milestone: 4.11
Component: fs Version: 4.9
Severity: major Keywords:
Cc: sebastian.huber@… Blocked By:
Blocking:

Description

My root FS is IMFS.

I create a directory

mkdir("/mnt",0777)

and a symlink

symlink("mnt","/lnk")

which works fine (e.g., chdir("/lnk") or opendir("/lnk")
do not produce errors).

If I mount a NFS volume on "/mnt" then e.g.,

chdir("/lnk")

fails. (chdir("/mnt") works fine)

I believe this is related to the code in IMFS_evaluate_sym_link()

...

result = IMFS_eval_path(

&jnode->info.sym_link.name[i],
strlen( &jnode->info.sym_link.name[i] ),
flags,
node

);


IMFS_Set_handlers( node );


/*

  • Verify we have the correct permissions for this node. */


if ( !IMFS_evaluate_permission( node, flags ) )

rtems_set_errno_and_return_minus_one( EACCES );

return result;

}

where after evaluating the target of the symlink
IMFS_Set_handlers(node) and IMFS_evaluate_permission(node,flags)
are executed on the 'node' ignoring the possibility that
the node returned by the IMFS_eval_path() routine could
actually reside on another file system after crossing
a moint point!

Observation:
A look at IMFS_eval_path() reveals that any non-error return
path from IMFS_eval_path() which does *not* cross mount points
already executes IMFS_Set_handlers and IMFS_evaluate_permission.
Hence I believe that simply removing these operations from
IMFS_evaluate_sym_link() would fix the problem.

I just tested removing these two calls and it did indeed
fix the problem but I'm not familiar enough with the
FS code to be sure that it wouldn't break other things
even though it is quite unlikely given that my observation
is easy to verify.

Change History (1)

comment:1 Changed on 03/13/12 at 11:05:37 by Sebastian Huber

Resolution: fixed
Status: newclosed, sebastian.huber@embedded-brains.de
Note: See TracTickets for help on using tickets.