mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] smack: miscellaneous small fixes in function comments
@ 2014-11-26 14:31 Lukasz Pawelczyk
  2014-11-26 14:31 ` [PATCH 2/2] smack: fix logic in smack_inode_init_security function Lukasz Pawelczyk
  2014-12-01 21:33 ` [PATCH 1/2] smack: miscellaneous small fixes in function comments Casey Schaufler
  0 siblings, 2 replies; 4+ messages in thread
From: Lukasz Pawelczyk @ 2014-11-26 14:31 UTC (permalink / raw)
  To: Casey Schaufler, James Morris, Serge E. Hallyn,
	linux-security-module, linux-kernel
  Cc: Lukasz Pawelczyk, Lukasz Pawelczyk

Signed-off-by: Lukasz Pawelczyk <l.pawelczyk@samsung.com>
---
 security/smack/smack_lsm.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 2717cdd..d1b14d5 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -202,6 +202,7 @@ static int smk_bu_credfile(const struct cred *cred, struct file *file,
 
 /**
  * smk_fetch - Fetch the smack label from a file.
+ * @name: type of the label (attribute)
  * @ip: a pointer to the inode
  * @dp: a pointer to the dentry
  *
@@ -254,7 +255,9 @@ struct inode_smack *new_inode_smack(struct smack_known *skp)
 
 /**
  * new_task_smack - allocate a task security blob
- * @smack: a pointer to the Smack label to use in the blob
+ * @task: a pointer to the Smack label for the running task
+ * @forked: a pointer to the Smack label for the forked task
+ * @gfp: type of the memory for the allocation
  *
  * Returns the new blob or NULL if there's no memory available
  */
@@ -277,8 +280,9 @@ static struct task_smack *new_task_smack(struct smack_known *task,
 
 /**
  * smk_copy_rules - copy a rule set
- * @nhead - new rules header pointer
- * @ohead - old rules header pointer
+ * @nhead: new rules header pointer
+ * @ohead: old rules header pointer
+ * @gfp: type of the memory for the allocation
  *
  * Returns 0 on success, -ENOMEM on error
  */
@@ -3835,11 +3839,11 @@ static void smack_key_free(struct key *key)
 	key->security = NULL;
 }
 
-/*
+/**
  * smack_key_permission - Smack access on a key
  * @key_ref: gets to the object
  * @cred: the credentials to use
- * @perm: unused
+ * @perm: requested key permissions
  *
  * Return 0 if the task has read and write to the object,
  * an error code otherwise
-- 
1.9.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] smack: fix logic in smack_inode_init_security function
  2014-11-26 14:31 [PATCH 1/2] smack: miscellaneous small fixes in function comments Lukasz Pawelczyk
@ 2014-11-26 14:31 ` Lukasz Pawelczyk
  2014-12-01 21:34   ` Casey Schaufler
  2014-12-01 21:33 ` [PATCH 1/2] smack: miscellaneous small fixes in function comments Casey Schaufler
  1 sibling, 1 reply; 4+ messages in thread
From: Lukasz Pawelczyk @ 2014-11-26 14:31 UTC (permalink / raw)
  To: Casey Schaufler, James Morris, Serge E. Hallyn,
	linux-security-module, linux-kernel
  Cc: Lukasz Pawelczyk, Lukasz Pawelczyk

In principle if this function was called with "value" == NULL and "len"
not NULL it could return different results for the "len" compared to a
case where "name" was not NULL. This is a hypothetical case that does
not exist in the kernel, but it's a logic bug nonetheless.

Signed-off-by: Lukasz Pawelczyk <l.pawelczyk@samsung.com>
---
 security/smack/smack_lsm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index d1b14d5..e8bed86 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -800,7 +800,7 @@ static int smack_inode_init_security(struct inode *inode, struct inode *dir,
 	if (name)
 		*name = XATTR_SMACK_SUFFIX;
 
-	if (value) {
+	if (value && len) {
 		rcu_read_lock();
 		may = smk_access_entry(skp->smk_known, dsp->smk_known,
 				       &skp->smk_rules);
@@ -821,10 +821,9 @@ static int smack_inode_init_security(struct inode *inode, struct inode *dir,
 		*value = kstrdup(isp->smk_known, GFP_NOFS);
 		if (*value == NULL)
 			return -ENOMEM;
-	}
 
-	if (len)
 		*len = strlen(isp->smk_known);
+	}
 
 	return 0;
 }
-- 
1.9.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] smack: miscellaneous small fixes in function comments
  2014-11-26 14:31 [PATCH 1/2] smack: miscellaneous small fixes in function comments Lukasz Pawelczyk
  2014-11-26 14:31 ` [PATCH 2/2] smack: fix logic in smack_inode_init_security function Lukasz Pawelczyk
@ 2014-12-01 21:33 ` Casey Schaufler
  1 sibling, 0 replies; 4+ messages in thread
From: Casey Schaufler @ 2014-12-01 21:33 UTC (permalink / raw)
  To: Lukasz Pawelczyk, James Morris, Serge E. Hallyn,
	linux-security-module, linux-kernel
  Cc: Lukasz Pawelczyk

On 11/26/2014 6:31 AM, Lukasz Pawelczyk wrote:
> Signed-off-by: Lukasz Pawelczyk <l.pawelczyk@samsung.com>

Applied to git://git.gitorious.org/smack-next/kernel.git#smack-for-3.20

> ---
>  security/smack/smack_lsm.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index 2717cdd..d1b14d5 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -202,6 +202,7 @@ static int smk_bu_credfile(const struct cred *cred, struct file *file,
>  
>  /**
>   * smk_fetch - Fetch the smack label from a file.
> + * @name: type of the label (attribute)
>   * @ip: a pointer to the inode
>   * @dp: a pointer to the dentry
>   *
> @@ -254,7 +255,9 @@ struct inode_smack *new_inode_smack(struct smack_known *skp)
>  
>  /**
>   * new_task_smack - allocate a task security blob
> - * @smack: a pointer to the Smack label to use in the blob
> + * @task: a pointer to the Smack label for the running task
> + * @forked: a pointer to the Smack label for the forked task
> + * @gfp: type of the memory for the allocation
>   *
>   * Returns the new blob or NULL if there's no memory available
>   */
> @@ -277,8 +280,9 @@ static struct task_smack *new_task_smack(struct smack_known *task,
>  
>  /**
>   * smk_copy_rules - copy a rule set
> - * @nhead - new rules header pointer
> - * @ohead - old rules header pointer
> + * @nhead: new rules header pointer
> + * @ohead: old rules header pointer
> + * @gfp: type of the memory for the allocation
>   *
>   * Returns 0 on success, -ENOMEM on error
>   */
> @@ -3835,11 +3839,11 @@ static void smack_key_free(struct key *key)
>  	key->security = NULL;
>  }
>  
> -/*
> +/**
>   * smack_key_permission - Smack access on a key
>   * @key_ref: gets to the object
>   * @cred: the credentials to use
> - * @perm: unused
> + * @perm: requested key permissions
>   *
>   * Return 0 if the task has read and write to the object,
>   * an error code otherwise


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] smack: fix logic in smack_inode_init_security function
  2014-11-26 14:31 ` [PATCH 2/2] smack: fix logic in smack_inode_init_security function Lukasz Pawelczyk
@ 2014-12-01 21:34   ` Casey Schaufler
  0 siblings, 0 replies; 4+ messages in thread
From: Casey Schaufler @ 2014-12-01 21:34 UTC (permalink / raw)
  To: Lukasz Pawelczyk, James Morris, Serge E. Hallyn,
	linux-security-module, linux-kernel
  Cc: Lukasz Pawelczyk

On 11/26/2014 6:31 AM, Lukasz Pawelczyk wrote:
> In principle if this function was called with "value" == NULL and "len"
> not NULL it could return different results for the "len" compared to a
> case where "name" was not NULL. This is a hypothetical case that does
> not exist in the kernel, but it's a logic bug nonetheless.
>
> Signed-off-by: Lukasz Pawelczyk <l.pawelczyk@samsung.com>

Applied to git://git.gitorious.org/smack-next/kernel.git#smack-for-3.20

> ---
>  security/smack/smack_lsm.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index d1b14d5..e8bed86 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -800,7 +800,7 @@ static int smack_inode_init_security(struct inode *inode, struct inode *dir,
>  	if (name)
>  		*name = XATTR_SMACK_SUFFIX;
>  
> -	if (value) {
> +	if (value && len) {
>  		rcu_read_lock();
>  		may = smk_access_entry(skp->smk_known, dsp->smk_known,
>  				       &skp->smk_rules);
> @@ -821,10 +821,9 @@ static int smack_inode_init_security(struct inode *inode, struct inode *dir,
>  		*value = kstrdup(isp->smk_known, GFP_NOFS);
>  		if (*value == NULL)
>  			return -ENOMEM;
> -	}
>  
> -	if (len)
>  		*len = strlen(isp->smk_known);
> +	}
>  
>  	return 0;
>  }


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-12-01 21:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-26 14:31 [PATCH 1/2] smack: miscellaneous small fixes in function comments Lukasz Pawelczyk
2014-11-26 14:31 ` [PATCH 2/2] smack: fix logic in smack_inode_init_security function Lukasz Pawelczyk
2014-12-01 21:34   ` Casey Schaufler
2014-12-01 21:33 ` [PATCH 1/2] smack: miscellaneous small fixes in function comments Casey Schaufler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome