From: Mimi Zohar <zohar@linux.vnet.ibm.com>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: linux-ima-devel@lists.sourceforge.net,
linux-ima-user@lists.sourceforge.net,
linux-security-module@vger.kernel.org,
Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
James Morris <james.l.morris@oracle.com>,
"Serge E. Hallyn" <serge@hallyn.com>,
LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 3/3] ima_fs: Move three error code assignments in ima_write_policy()
Date: Fri, 27 Jan 2017 12:39:24 +0000 [thread overview]
Message-ID: <1485520764.2596.89.camel@linux.vnet.ibm.com> (raw)
In-Reply-To: <b6339fa4-69b3-afc4-18a8-254369fec074@users.sourceforge.net>
On Wed, 2017-01-25 at 10:34 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 24 Jan 2017 22:47:07 +0100
>
> A local variable was set to an error code in three 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.
This coding style was pretty common. I assume the compiler is smart
enough to do the right thing. Is this a FYI, letting us know for the
future the preferred coding style, or are we really upstreaming these
sorts of coding style changes?
Mimi
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> security/integrity/ima/ima_fs.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
> index 98304411915d..a50c26f9772c 100644
> --- a/security/integrity/ima/ima_fs.c
> +++ b/security/integrity/ima/ima_fs.c
> @@ -317,21 +317,24 @@ static ssize_t ima_write_policy(struct file *file, const char __user *buf,
>
> /* No partial writes. */
> result = -EINVAL;
> - if (*ppos != 0)
> + if (*ppos != 0) {
> + result = -EINVAL;
> goto reset_validity;
> + }
>
> - result = -ENOMEM;
> if (datalen >= PAGE_SIZE)
> datalen = PAGE_SIZE - 1;
> data = kmalloc(datalen + 1, GFP_KERNEL);
> - if (!data)
> + if (!data) {
> + result = -ENOMEM;
> goto reset_validity;
> + }
>
> *(data + datalen) = '\0';
> -
> - result = -EFAULT;
> - if (copy_from_user(data, buf, datalen))
> + if (copy_from_user(data, buf, datalen)) {
> + result = -EFAULT;
> goto out_free;
> + }
>
> result = mutex_lock_interruptible(&ima_write_mutex);
> if (result < 0)
WARNING: multiple messages have this Message-ID (diff)
From: Mimi Zohar <zohar@linux.vnet.ibm.com>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: linux-ima-devel@lists.sourceforge.net,
linux-ima-user@lists.sourceforge.net,
linux-security-module@vger.kernel.org,
Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
James Morris <james.l.morris@oracle.com>,
"Serge E. Hallyn" <serge@hallyn.com>,
LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 3/3] ima_fs: Move three error code assignments in ima_write_policy()
Date: Fri, 27 Jan 2017 07:39:24 -0500 [thread overview]
Message-ID: <1485520764.2596.89.camel@linux.vnet.ibm.com> (raw)
In-Reply-To: <b6339fa4-69b3-afc4-18a8-254369fec074@users.sourceforge.net>
On Wed, 2017-01-25 at 10:34 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 24 Jan 2017 22:47:07 +0100
>
> A local variable was set to an error code in three 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.
This coding style was pretty common. I assume the compiler is smart
enough to do the right thing. Is this a FYI, letting us know for the
future the preferred coding style, or are we really upstreaming these
sorts of coding style changes?
Mimi
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> security/integrity/ima/ima_fs.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
> index 98304411915d..a50c26f9772c 100644
> --- a/security/integrity/ima/ima_fs.c
> +++ b/security/integrity/ima/ima_fs.c
> @@ -317,21 +317,24 @@ static ssize_t ima_write_policy(struct file *file, const char __user *buf,
>
> /* No partial writes. */
> result = -EINVAL;
> - if (*ppos != 0)
> + if (*ppos != 0) {
> + result = -EINVAL;
> goto reset_validity;
> + }
>
> - result = -ENOMEM;
> if (datalen >= PAGE_SIZE)
> datalen = PAGE_SIZE - 1;
> data = kmalloc(datalen + 1, GFP_KERNEL);
> - if (!data)
> + if (!data) {
> + result = -ENOMEM;
> goto reset_validity;
> + }
>
> *(data + datalen) = '\0';
> -
> - result = -EFAULT;
> - if (copy_from_user(data, buf, datalen))
> + if (copy_from_user(data, buf, datalen)) {
> + result = -EFAULT;
> goto out_free;
> + }
>
> result = mutex_lock_interruptible(&ima_write_mutex);
> if (result < 0)
next prev parent reply other threads:[~2017-01-27 12:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-25 9:30 [PATCH 0/3] ima_fs: Fine-tuning for ima_write_policy() SF Markus Elfring
2017-01-25 9:30 ` SF Markus Elfring
2017-01-25 9:31 ` [PATCH 1/3] ima_fs: One check less in ima_write_policy() after error detection SF Markus Elfring
2017-01-25 9:31 ` SF Markus Elfring
2017-01-27 12:38 ` Mimi Zohar
2017-01-27 12:38 ` Mimi Zohar
2017-01-25 9:33 ` [PATCH 2/3] ima_fs: Reorder input parameter validation in ima_write_policy() SF Markus Elfring
2017-01-25 9:33 ` SF Markus Elfring
2017-01-25 9:34 ` [PATCH 3/3] ima_fs: Move three error code assignments " SF Markus Elfring
2017-01-25 9:34 ` SF Markus Elfring
2017-01-27 12:39 ` Mimi Zohar [this message]
2017-01-27 12:39 ` Mimi Zohar
2017-01-29 23:43 ` James Morris
2017-01-29 23:43 ` James Morris
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=1485520764.2596.89.camel@linux.vnet.ibm.com \
--to=zohar@linux.vnet.ibm.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=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-ima-user@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=serge@hallyn.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.