From: Tyler Hicks <tyhicks@canonical.com>
To: Priya Bansal <p.bansal@samsung.com>
Cc: ecryptfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] NULL pointer dereference in ecryptfs (ecryptfs_setxattr)
Date: Tue, 7 Oct 2014 18:46:31 -0500 [thread overview]
Message-ID: <20141007234630.GA7935@boyd> (raw)
In-Reply-To: <1630743052.107781411541880641.JavaMail.weblogic@epmlwas02d>
[-- Attachment #1: Type: text/plain, Size: 3476 bytes --]
Hi Priya - Thanks for the report and patch. I have some inline comments.
On 2014-09-24 06:58:01, Priya Bansal wrote:
> This patch fixes the issue which was found in
> ecryptfs_setxattr(). Previously, while trying to create a file when ecryptfs
> is mounted over ext4 filesystem with encrypted view enabled, the kernel
> crashes. the reason being the function fsstack_copy_attr_all was trying to
> access dentry->d_inode which was null hence the kernel crashes with NULL
> pointer dereference. Now a check has been applied which prevents such
> condition.
>
> From 74856445756aba18f98aa5b98ad46e7d98f54737 Mon Sep 17 00:00:00 2001
> From: Priya Bansal <p.bansal@samsung.com>
> Date: Fri, 29 Aug 2014 10:27:27 +0530
> Subject: [PATCH] Fix in ecryptfs_setxattr for NULL check before calling
> fsstack_copy_attr_all. This patch fixes the issue which was found in
> ecryptfs_setxattr(). Previously, while trying to create a file when ecryptfs
> is mounted over ext4 filesystem with encrypted view enabled, the kernel
> crashes. the reason being the function fsstack_copy_attr_all was trying to
> access dentry->d_inode which was null hence the kernel crashes with NULL
> pointer dereference. Now a check has been applied which prevents such
> condition.
> Signed-off-by: Priya Bansal <p.bansal@samsung.com>
This commit message is poorly formatted. Have a look at the
"15) The canonical patch format" section of the
Documentation/SubmittingPatches file. It gives a nice description of how
the commit message should be formatted.
> ---
> linux-3.16.1/fs/ecryptfs/inode.c | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
> diff --git a/linux-3.16.1/fs/ecryptfs/inode.c b/linux-3.16.1/fs/ecryptfs/inode.c
> index d4a9431..7da03e5 100644
> --- a/linux-3.16.1/fs/ecryptfs/inode.c
> +++ b/linux-3.16.1/fs/ecryptfs/inode.c
> @@ -1031,6 +1031,8 @@ ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value,
> {
> int rc = 0;
> struct dentry *lower_dentry;
> + struct ecryptfs_mount_crypt_stat *mount_crypt_stat =
> + &ecryptfs_superblock_to_private(dentry->d_sb)->mount_crypt_stat;
>
> lower_dentry = ecryptfs_dentry_to_lower(dentry);
> if (!lower_dentry->d_inode->i_op->setxattr) {
> @@ -1039,8 +1041,20 @@ ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value,
> }
>
> rc = vfs_setxattr(lower_dentry, name, value, size, flags);
> - if (!rc)
> - fsstack_copy_attr_all(dentry->d_inode, lower_dentry->d_inode);
> + if (!rc) {
> + if (dentry->d_inode == NULL) {
> + if (mount_crypt_stat->flags
> + & ECRYPTFS_ENCRYPTED_VIEW_ENABLED)
> + rc = -EPERM;
> + else if (mount_crypt_stat->flags
> + & ECRYPTFS_XATTR_METADATA_ENABLED)
> + goto out;
> + } else {
> + fsstack_copy_attr_all(dentry->d_inode,
> + lower_dentry->d_inode);
> + }
> + }
> +
> out:
> return rc;
> }
> --
I don't think this is the proper fix. It fixes the NULL pointer
dereference but ecryptfs_setxattr() shouldn't be reachable in encrypted
view mounts. There's a feeble attempt to prevent the modification of
files in ecryptfs_open() when encrypted view is in use but I think we
should force the MS_RDONLY flag on the superblock when the
ecryptfs_encrypted_view mount option is specified.
I'll follow this email up with a patch. I'd appreciate any review and/or
testing you can provide. Thanks!
Tyler
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2014-10-07 23:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-24 6:58 [PATCH] NULL pointer dereference in ecryptfs (ecryptfs_setxattr) Priya Bansal
2014-09-24 6:58 ` Priya Bansal
2014-10-07 23:46 ` Tyler Hicks [this message]
2014-10-07 23:48 ` [PATCH] eCryptfs: Force RO mount when encrypted view is enabled Tyler Hicks
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=20141007234630.GA7935@boyd \
--to=tyhicks@canonical.com \
--cc=ecryptfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=p.bansal@samsung.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.