All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tyler Hicks <tyhicks@canonical.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] eCryptfs: fix a couple type promotion bugs
Date: Thu, 05 Jul 2018 14:52:18 +0000	[thread overview]
Message-ID: <20180705145218.GA29046@sec> (raw)
In-Reply-To: <20180704093556.dlosbefurp2o42zs@kili.mountain>

[-- Attachment #1: Type: text/plain, Size: 1765 bytes --]

On 2018-07-04 12:35:56, Dan Carpenter wrote:
> ECRYPTFS_SIZE_AND_MARKER_BYTES is type size_t, so if "rc" is negative
> that gets type promoted to a high positive value and treated as success.
> 
> Fixes: 778aeb42a708 ("eCryptfs: Cleanup and optimize ecryptfs_lookup_interpose()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, Dan!

I made a small change to use "if/else if" rather than "if/if". I've
pushed the patch to the ecryptfs next branch.

Tyler

> 
> diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
> index 4dd842f72846..506f2a0bba41 100644
> --- a/fs/ecryptfs/crypto.c
> +++ b/fs/ecryptfs/crypto.c
> @@ -1018,8 +1018,10 @@ int ecryptfs_read_and_validate_header_region(struct inode *inode)
>  
>  	rc = ecryptfs_read_lower(file_size, 0, ECRYPTFS_SIZE_AND_MARKER_BYTES,
>  				 inode);
> +	if (rc < 0)
> +		return rc;
>  	if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES)
> -		return rc >= 0 ? -EINVAL : rc;
> +		return -EINVAL;
>  	rc = ecryptfs_validate_marker(marker);
>  	if (!rc)
>  		ecryptfs_i_size_init(file_size, inode);
> @@ -1381,8 +1383,10 @@ int ecryptfs_read_and_validate_xattr_region(struct dentry *dentry,
>  				     ecryptfs_inode_to_lower(inode),
>  				     ECRYPTFS_XATTR_NAME, file_size,
>  				     ECRYPTFS_SIZE_AND_MARKER_BYTES);
> +	if (rc < 0)
> +		return rc;
>  	if (rc < ECRYPTFS_SIZE_AND_MARKER_BYTES)
> -		return rc >= 0 ? -EINVAL : rc;
> +		return -EINVAL;
>  	rc = ecryptfs_validate_marker(marker);
>  	if (!rc)
>  		ecryptfs_i_size_init(file_size, inode);
> --
> To unsubscribe from this list: send the line "unsubscribe ecryptfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

      reply	other threads:[~2018-07-05 14:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-04  9:35 [PATCH] eCryptfs: fix a couple type promotion bugs Dan Carpenter
2018-07-05 14:52 ` Tyler Hicks [this message]

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=20180705145218.GA29046@sec \
    --to=tyhicks@canonical.com \
    --cc=kernel-janitors@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 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.