All of lore.kernel.org
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-ima-devel@lists.sourceforge.net,
	linux-security-module@vger.kernel.org,
	James Morris <james.l.morris@oracle.com>,
	Mimi Zohar <zohar@linux.vnet.ibm.com>,
	"Serge E. Hallyn" <serge@hallyn.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] evm: Move two error code assignments in evm_set_key()
Date: Tue, 24 Jan 2017 19:44:45 +0100	[thread overview]
Message-ID: <a9edf310-0edb-0dc7-f623-164ee9c7f102@users.sourceforge.net> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Jan 2017 19:37:20 +0100

A local variable was set to an error code in two cases before a concrete
error situation was detected. Thus move the corresponding assignments into
if branches to indicate a software failure there.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 security/integrity/evm/evm_crypto.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
index d7f282d75cc1..71bc204e2ee8 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -53,12 +53,14 @@ int evm_set_key(void *key, size_t keylen)
 {
 	int rc;
 
-	rc = -EBUSY;
-	if (test_and_set_bit(EVM_SET_KEY_BUSY, &evm_set_key_flags))
+	if (test_and_set_bit(EVM_SET_KEY_BUSY, &evm_set_key_flags)) {
+		rc = -EBUSY;
 		goto busy;
-	rc = -EINVAL;
-	if (keylen > MAX_KEY_SIZE)
+	}
+	if (keylen > MAX_KEY_SIZE) {
+		rc = -EINVAL;
 		goto inval;
+	}
 	memcpy(evmkey, key, keylen);
 	evm_initialized |= EVM_INIT_HMAC;
 	pr_info("key initialized\n");
-- 
2.11.0

WARNING: multiple messages have this Message-ID (diff)
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-ima-devel@lists.sourceforge.net,
	linux-security-module@vger.kernel.org,
	James Morris <james.l.morris@oracle.com>,
	Mimi Zohar <zohar@linux.vnet.ibm.com>,
	"Serge E. Hallyn" <serge@hallyn.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] evm: Move two error code assignments in evm_set_key()
Date: Tue, 24 Jan 2017 18:44:45 +0000	[thread overview]
Message-ID: <a9edf310-0edb-0dc7-f623-164ee9c7f102@users.sourceforge.net> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Jan 2017 19:37:20 +0100

A local variable was set to an error code in two cases before a concrete
error situation was detected. Thus move the corresponding assignments into
if branches to indicate a software failure there.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 security/integrity/evm/evm_crypto.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
index d7f282d75cc1..71bc204e2ee8 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -53,12 +53,14 @@ int evm_set_key(void *key, size_t keylen)
 {
 	int rc;
 
-	rc = -EBUSY;
-	if (test_and_set_bit(EVM_SET_KEY_BUSY, &evm_set_key_flags))
+	if (test_and_set_bit(EVM_SET_KEY_BUSY, &evm_set_key_flags)) {
+		rc = -EBUSY;
 		goto busy;
-	rc = -EINVAL;
-	if (keylen > MAX_KEY_SIZE)
+	}
+	if (keylen > MAX_KEY_SIZE) {
+		rc = -EINVAL;
 		goto inval;
+	}
 	memcpy(evmkey, key, keylen);
 	evm_initialized |= EVM_INIT_HMAC;
 	pr_info("key initialized\n");
-- 
2.11.0


             reply	other threads:[~2017-01-24 18:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-24 18:44 SF Markus Elfring [this message]
2017-01-24 18:44 ` [PATCH] evm: Move two error code assignments in evm_set_key() SF Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a9edf310-0edb-0dc7-f623-164ee9c7f102@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=james.l.morris@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-ima-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=serge@hallyn.com \
    --cc=zohar@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.