lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 15 Jul 2021 08:15:12 -0700
From:   Casey Schaufler <casey@...aufler-ca.com>
To:     Tianjia Zhang <tianjia.zhang@...ux.alibaba.com>,
        James Morris <jmorris@...ei.org>,
        "Serge E. Hallyn" <serge@...lyn.com>,
        linux-security-module@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Casey Schaufler <casey@...aufler-ca.com>
Subject: Re: [PATCH] Smack: Fix wrong semantics in smk_access_entry()

On 7/15/2021 2:17 AM, Tianjia Zhang wrote:
> In the smk_access_entry() function, if no matching rule is found
> in the rust_list, a negative error code will be used to perform bit
> operations with the MAY_ enumeration value. This is semantically
> wrong. This patch fixes this issue.

Indeed, the code as written is functioning correctly by
sheer luck. I will take this patch. Thank you.

>
> Signed-off-by: Tianjia Zhang <tianjia.zhang@...ux.alibaba.com>
> ---
>  security/smack/smack_access.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
> index 1f391f6a3d47..d2186e2757be 100644
> --- a/security/smack/smack_access.c
> +++ b/security/smack/smack_access.c
> @@ -81,23 +81,22 @@ int log_policy = SMACK_AUDIT_DENIED;
>  int smk_access_entry(char *subject_label, char *object_label,
>  			struct list_head *rule_list)
>  {
> -	int may = -ENOENT;
>  	struct smack_rule *srp;
>  
>  	list_for_each_entry_rcu(srp, rule_list, list) {
>  		if (srp->smk_object->smk_known == object_label &&
>  		    srp->smk_subject->smk_known == subject_label) {
> -			may = srp->smk_access;
> -			break;
> +			int may = srp->smk_access;
> +			/*
> +			 * MAY_WRITE implies MAY_LOCK.
> +			 */
> +			if ((may & MAY_WRITE) == MAY_WRITE)
> +				may |= MAY_LOCK;
> +			return may;
>  		}
>  	}
>  
> -	/*
> -	 * MAY_WRITE implies MAY_LOCK.
> -	 */
> -	if ((may & MAY_WRITE) == MAY_WRITE)
> -		may |= MAY_LOCK;
> -	return may;
> +	return -ENOENT;
>  }
>  
>  /**

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ