Smack: Lock mode for the floor and hat labels
authorjooseong.lee <jooseong.lee@samsung.com>
Tue, 24 Mar 2015 02:29:07 +0000 (11:29 +0900)
committerjuseong lee <jooseong.lee@samsung.com>
Wed, 25 Mar 2015 00:58:41 +0000 (09:58 +0900)
The lock access mode allows setting a read lock on a file
for with the process has only read access. The floor label is
defined to make it easy to have the basic system installed such
that everyone can read it. Once there's a desire to read lock
(rationally or otherwise) a floor file a rule needs to get set.
This happens all the time, so make the floor label a little bit
more special and allow everyone lock access, too. By implication,
give processes with the hat label (hat can read everything)
lock access as well. This reduces clutter in the Smack rule set.

Change-Id: I4c3c172f803f1d98002b20ea01a2b5d617e2541c
Signed-off-by: jooseong.lee <jooseong.lee@samsung.com>
security/smack/smack_access.c

index c062e9467b62f91cb2b975f271de60755d66248c..821f283b2417326ea788372f384102a8b35861ca 100644 (file)
@@ -157,10 +157,11 @@ int smk_access(struct smack_known *subject_known, char *object_label,
        if (subject_known->smk_known == object_label)
                goto out_audit;
        /*
-        * A hat subject can read any object.
-        * A floor object can be read by any subject.
+        * A hat subject can read or lock any object.
+        * A floor object can be read or locked by any subject.
         */
-       if ((request & MAY_ANYREAD) == request) {
+       if ((request & MAY_ANYREAD) == request ||
+           (request & MAY_LOCK) == request) {
                if (object_label == smack_known_floor.smk_known)
                        goto out_audit;
                if (subject_known == &smack_known_hat)