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]
Message-Id: <200902222213.DAE48955.FFSLFtJOVQOHMO@I-love.SAKURA.ne.jp>
Date:	Sun, 22 Feb 2009 22:13:49 +0900
From:	Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
To:	paulmck@...ux.vnet.ibm.com
Cc:	linux-security-module@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH][SMACK] convert smack rule list to linux list

Paul, would you review this locking?

> static DEFINE_MUTEX(smack_known_lock);
> 
> /**
>  * smk_import_entry - import a label, return the list entry
>  * @string: a text string that might be a Smack label
>  * @len: the maximum size, or zero if it is NULL terminated.
>  *
>  * Returns a pointer to the entry in the label list that
>  * matches the passed string, adding it if necessary.
>  */
> struct smack_known *smk_import_entry(const char *string, int len)
> {
> 	struct smack_known *skp;
> 	char smack[SMK_LABELLEN];
> 	int found;
> 	int i;
> 
> 	if (len <= 0 || len > SMK_MAXLEN)
> 		len = SMK_MAXLEN;
> 
> 	for (i = 0, found = 0; i < SMK_LABELLEN; i++) {
> 		if (found)
> 			smack[i] = '\0';
> 		else if (i >= len || string[i] > '~' || string[i] <= ' ' ||
> 			 string[i] == '/') {
> 			smack[i] = '\0';
> 			found = 1;
> 		} else
> 			smack[i] = string[i];
> 	}
> 
> 	if (smack[0] == '\0')
> 		return NULL;
> 
> 	mutex_lock(&smack_known_lock);
> 
> 	for (skp = smack_known; skp != NULL; skp = skp->smk_next)
> 		if (strncmp(skp->smk_known, smack, SMK_MAXLEN) == 0)
> 			break;
> 
> 	if (skp == NULL) {
> 		skp = kzalloc(sizeof(struct smack_known), GFP_KERNEL);
> 		if (skp != NULL) {
> 			skp->smk_next = smack_known;
> 			strncpy(skp->smk_known, smack, SMK_MAXLEN);
> 			skp->smk_secid = smack_next_secid++;
> 			skp->smk_cipso = NULL;
> 			spin_lock_init(&skp->smk_cipsolock);
> 			/*
> 			 * Make sure that the entry is actually
> 			 * filled before putting it on the list.
> 			 */
> 			smp_mb();
> 			smack_known = skp;
> 		}
> 	}
> 
> 	mutex_unlock(&smack_known_lock);
> 
> 	return skp;
> }
> 
> /**
>  * smack_from_secid - find the Smack label associated with a secid
>  * @secid: an integer that might be associated with a Smack label
>  *
>  * Returns a pointer to the appropraite Smack label if there is one,
>  * otherwise a pointer to the invalid Smack label.
>  */
> char *smack_from_secid(const u32 secid)
> {
> 	struct smack_known *skp;
> 
> 	for (skp = smack_known; skp != NULL; skp = skp->smk_next)
> 		if (skp->smk_secid == secid)
> 			return skp->smk_known;
> 
> 	/*
> 	 * If we got this far someone asked for the translation
> 	 * of a secid that is not on the list.
> 	 */
> 	return smack_known_invalid.smk_known;
> }

I think this is a case called "dependency ordering".
This function needs rcu_dereference(), doesn't it?

Regards.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ