diff mbox

Smack: Traverse the smack_known_list using list_for_each_entry_rcu macro

Message ID 1479878131-18814-1-git-send-email-vishal.goel@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vishal Goel Nov. 23, 2016, 5:15 a.m. UTC
In smack_from_secattr function,"smack_known_list" is being traversed
using list_for_each_entry macro, although it is a rcu protected
structure. So it should be traversed using "list_for_each_entry_rcu"
macro to fetch the rcu protected entry.

Signed-off-by: Vishal Goel <vishal.goel@samsung.com>
Signed-off-by: Himanshu Shukla <himanshu.sh@samsung.com>
---
 security/smack/smack_lsm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Casey Schaufler Nov. 28, 2016, 10:34 p.m. UTC | #1
On 11/22/2016 9:15 PM, Vishal Goel wrote:
> In smack_from_secattr function,"smack_known_list" is being traversed
> using list_for_each_entry macro, although it is a rcu protected
> structure. So it should be traversed using "list_for_each_entry_rcu"
> macro to fetch the rcu protected entry.
>
> Signed-off-by: Vishal Goel <vishal.goel@samsung.com>
> Signed-off-by: Himanshu Shukla <himanshu.sh@samsung.com>

Acked-by: Casey Schaufler <casey@schaufler-ca.com>

I have queued this for 4.11 as it's too late for 4.10.

> ---
>  security/smack/smack_lsm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index 1cb0602..3e94ca1 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -3849,7 +3849,7 @@ static struct smack_known *smack_from_secattr(struct netlbl_lsm_secattr *sap,
>  		 * ambient value.
>  		 */
>  		rcu_read_lock();
> -		list_for_each_entry(skp, &smack_known_list, list) {
> +		list_for_each_entry_rcu(skp, &smack_known_list, list) {
>  			if (sap->attr.mls.lvl != skp->smk_netlabel.attr.mls.lvl)
>  				continue;
>  			/*

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 1cb0602..3e94ca1 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -3849,7 +3849,7 @@  static struct smack_known *smack_from_secattr(struct netlbl_lsm_secattr *sap,
 		 * ambient value.
 		 */
 		rcu_read_lock();
-		list_for_each_entry(skp, &smack_known_list, list) {
+		list_for_each_entry_rcu(skp, &smack_known_list, list) {
 			if (sap->attr.mls.lvl != skp->smk_netlabel.attr.mls.lvl)
 				continue;
 			/*