From: zohar@linux.vnet.ibm.com (Mimi Zohar)
To: linux-security-module@vger.kernel.org
Subject: [PATCH] EVM: prevent array underflow in evm_write_xattrs()
Date: Thu, 31 May 2018 11:00:39 -0400 [thread overview]
Message-ID: <1527778839.3427.14.camel@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180529131128.3rkzzv66uy6h5ts7@kili.mountain>
On Tue, 2018-05-29 at 16:11 +0300, Dan Carpenter wrote:
> If the user sets xattr->name[0] to NUL then we would read one character
> before the start of the array. This bug seems harmless as far as I can
> see but perhaps it would trigger a warning in KASAN.
>
> Fixes: fa516b66a1bf ("EVM: Allow runtime modification of the set of verified xattrs")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Thanks, this patch is now queued in the next-integrity branch.
Mimi
> ---
> The user can pass a zeroed buffer to memdup_user_nul() so we can't rely
> on "count" to test this.
>
> diff --git a/security/integrity/evm/evm_secfs.c b/security/integrity/evm/evm_secfs.c
> index a7a0a1acae99..94c739180a0b 100644
> --- a/security/integrity/evm/evm_secfs.c
> +++ b/security/integrity/evm/evm_secfs.c
> @@ -207,7 +207,7 @@ static ssize_t evm_write_xattrs(struct file *file, const char __user *buf,
>
> /* Remove any trailing newline */
> len = strlen(xattr->name);
> - if (xattr->name[len-1] == '\n')
> + if (len && xattr->name[len-1] == '\n')
> xattr->name[len-1] = '\0';
>
> if (strcmp(xattr->name, ".") == 0) {
>
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2018-05-31 15:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-27 22:55 [PATCH] EVM: Fix null dereference on xattr when xattr fails to allocate Colin King
2018-05-29 9:05 ` Dan Carpenter
2018-05-29 12:31 ` Mimi Zohar
2018-05-29 13:11 ` [PATCH] EVM: prevent array underflow in evm_write_xattrs() Dan Carpenter
2018-05-31 15:00 ` Mimi Zohar [this message]
2018-05-29 12:30 ` [PATCH] EVM: Fix null dereference on xattr when xattr fails to allocate Mimi Zohar
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=1527778839.3427.14.camel@linux.vnet.ibm.com \
--to=zohar@linux.vnet.ibm.com \
--cc=linux-security-module@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).