Commit b04ea3ce authored by Eric Paris's avatar Eric Paris Committed by Linus Torvalds

[PATCH] Fix security check for joint context= and fscontext= mount options

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: default avatarEric Paris <eparis@redhat.com>
Acked-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
Acked-by: default avatarJames Morris <jmorris@namei.org>
Cc: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 517e7aa5
...@@ -523,12 +523,16 @@ static int try_context_mount(struct super_block *sb, void *data) ...@@ -523,12 +523,16 @@ static int try_context_mount(struct super_block *sb, void *data)
goto out_free; goto out_free;
} }
if (!fscontext) {
rc = may_context_mount_sb_relabel(sid, sbsec, tsec); rc = may_context_mount_sb_relabel(sid, sbsec, tsec);
if (rc) if (rc)
goto out_free; goto out_free;
if (!fscontext)
sbsec->sid = sid; sbsec->sid = sid;
} else {
rc = may_context_mount_inode_relabel(sid, sbsec, tsec);
if (rc)
goto out_free;
}
sbsec->mntpoint_sid = sid; sbsec->mntpoint_sid = sid;
sbsec->behavior = SECURITY_FS_USE_MNTPOINT; sbsec->behavior = SECURITY_FS_USE_MNTPOINT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment