Skip to content

Commit

Permalink
[PATCH] Fix security check for joint context= and fscontext= mount op…
Browse files Browse the repository at this point in the history
…tions

After some discussion on the actual meaning of the filesystem class
security check in try context mount it was determined that the checks for
the context= mount options were not correct if fscontext mount option had
already been used.

When labeling the superblock we should be checking relabel_from and
relabel_to.  But if the superblock has already been labeled (with
fscontext) then context= is actually labeling the inodes, and so we should
be checking relabel_from and associate.  This patch fixes which checks are
called depending on the mount options.

Signed-off-by: Eric Paris <[email protected]>
Acked-by: Stephen Smalley <[email protected]>
Acked-by: James Morris <[email protected]>
Cc: Chris Wright <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
eparis authored and Linus Torvalds committed Jul 15, 2006
1 parent 517e7aa commit b04ea3c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,16 @@ static int try_context_mount(struct super_block *sb, void *data)
goto out_free;
}

rc = may_context_mount_sb_relabel(sid, sbsec, tsec);
if (rc)
goto out_free;

if (!fscontext)
if (!fscontext) {
rc = may_context_mount_sb_relabel(sid, sbsec, tsec);
if (rc)
goto out_free;
sbsec->sid = sid;
} else {
rc = may_context_mount_inode_relabel(sid, sbsec, tsec);
if (rc)
goto out_free;
}
sbsec->mntpoint_sid = sid;

sbsec->behavior = SECURITY_FS_USE_MNTPOINT;
Expand Down

0 comments on commit b04ea3c

Please sign in to comment.