ecryptfs-devel team mailing list archive
-
ecryptfs-devel team
-
Mailing list archive
-
Message #00162
Re: [RFC][PATCH 4/7] smack: fix label check in smack_kernel_act_as()
-
To:
Roberto Sassu <roberto.sassu@xxxxxxxxx>
-
From:
Casey Schaufler <casey@xxxxxxxxxxxxxxxx>
-
Date:
Wed, 27 Apr 2011 16:22:34 -0700
-
Cc:
kirkland@xxxxxxxxxxxxx, safford@xxxxxxxxxxxxxx, sds@xxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, eparis@xxxxxxxxxx, jmorris@xxxxxxxxx, dhowells@xxxxxxxxxx, linux-security-module@xxxxxxxxxxxxxxx, viro@xxxxxxxxxxxxxxxxxx, selinux@xxxxxxxxxxxxx, ecryptfs-devel@xxxxxxxxxxxxxxxxxxx, linux-fsdevel@xxxxxxxxxxxxxxx, zohar@xxxxxxxxxxxxxxxxxx
-
In-reply-to:
<1303907657-18366-5-git-send-email-roberto.sassu@polito.it>
-
User-agent:
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
On 4/27/2011 5:34 AM, Roberto Sassu wrote:
> The function smack_kernel_act_as() must return -EINVAL if the label
> returned by smack_from_secid() is equal to 'smack_known_invalid.smk_known',
> which means that no entries in the 'smack_known_list' list matching the
> security identifier given are found.
I'll admit that the code here is wrong, but I disagree with the fix.
smack_from_secid() will never return NULL, so the check for NULL is
pointless. Checking for known_invalid is not right either, as the
Smack philosophy is to return a label in all cases, as is evident
by the behavior of smack_from_secid(). Thus, the correct change
would be to remove the error check completely and set the new task
value to the value obtained from smack_from_secid in all cases.
Besides, where did the caller of this function get a secid that isn't
going to map to a Smack label?
> Signed-off-by: Roberto Sassu <roberto.sassu@xxxxxxxxx>
> ---
> security/smack/smack_lsm.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index e3c9e54..0e7ed31 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -1415,7 +1415,7 @@ static int smack_kernel_act_as(struct cred *new, u32 secid)
> struct task_smack *new_tsp = new->security;
> char *smack = smack_from_secid(secid);
>
> - if (smack == NULL)
> + if (smack == smack_known_invalid.smk_known)
> return -EINVAL;
>
> new_tsp->smk_task = smack;