From: Jan Kara <jack@suse.cz>
To: Ted Tso <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org
Subject: Coverity complaints about new crypto code
Date: Tue, 5 May 2015 09:54:36 +0200 [thread overview]
Message-ID: <20150505075436.GA11943@quack.suse.cz> (raw)
Hi,
Coverity complains about the new ext4 crypto code. The complaint is that
ext4_fname_crypto_alloc_buffer() and ext4_fname_crypto_namelen_on_disk()
check for ctx being NULL but they dereference it before that check.
I've checked and didn't find callers that would actually pass NULL into
these functions so do we want to remove the unused check or move the
dereference? I think it would be worth cleaning up just that we don't fall
into the trap sometime later...
Honza
----- Forwarded message from scan-admin@coverity.com -----
** CID 1296585: Null pointer dereferences (REVERSE_INULL)
/fs/ext4/crypto_fname.c: 500 in ext4_fname_crypto_alloc_buffer()
________________________________________________________________________________________________________
*** CID 1296585: Null pointer dereferences (REVERSE_INULL)
/fs/ext4/crypto_fname.c: 500 in ext4_fname_crypto_alloc_buffer()
494 int ext4_fname_crypto_alloc_buffer(struct ext4_fname_crypto_ctx *ctx,
495 u32 ilen, struct ext4_str *crypto_str)
496 {
497 unsigned int olen;
498 int padding = 4 << (ctx->flags & EXT4_POLICY_FLAGS_PAD_MASK);
499
>>> CID 1296585: Null pointer dereferences (REVERSE_INULL)
>>> Null-checking "ctx" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
500 if (!ctx)
501 return -EIO;
502 if (padding < EXT4_CRYPTO_BLOCK_SIZE)
503 padding = EXT4_CRYPTO_BLOCK_SIZE;
504 olen = ext4_fname_crypto_round_up(ilen, padding);
505 crypto_str->len = olen;
** CID 1296586: Null pointer dereferences (REVERSE_INULL)
/fs/ext4/crypto_fname.c: 476 in ext4_fname_crypto_namelen_on_disk()
________________________________________________________________________________________________________
*** CID 1296586: Null pointer dereferences (REVERSE_INULL)
/fs/ext4/crypto_fname.c: 476 in ext4_fname_crypto_namelen_on_disk()
470 int ext4_fname_crypto_namelen_on_disk(struct ext4_fname_crypto_ctx *ctx,
471 u32 namelen)
472 {
473 u32 ciphertext_len;
474 int padding = 4 << (ctx->flags & EXT4_POLICY_FLAGS_PAD_MASK);
475
>>> CID 1296586: Null pointer dereferences (REVERSE_INULL)
>>> Null-checking "ctx" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
476 if (ctx == NULL)
477 return -EIO;
478 if (!(ctx->has_valid_key))
479 return -EACCES;
480 ciphertext_len = (namelen < EXT4_CRYPTO_BLOCK_SIZE) ?
481 EXT4_CRYPTO_BLOCK_SIZE : namelen;
________________________________________________________________________________________________________
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next reply other threads:[~2015-05-05 7:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-05 7:54 Jan Kara [this message]
2015-05-05 12:41 ` Coverity complaints about new crypto code Theodore Ts'o
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=20150505075436.GA11943@quack.suse.cz \
--to=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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).