diff mbox

[1/1] eCryptfs: Remove mmap from directory operations

Message ID 1329326669-20243-2-git-send-email-colin.king@canonical.com
State New
Headers show

Commit Message

Colin Ian King Feb. 15, 2012, 5:24 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Adrian reported that mkfontscale didn't work inside of eCryptfs mounts.
Strace revealed the following:

open("./", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
fcntl64(3, F_GETFD) = 0x1 (flags FD_CLOEXEC)
open("./fonts.scale", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
getdents(3, /* 80 entries */, 32768) = 2304
open("./.", O_RDONLY) = 5
fcntl64(5, F_SETFD, FD_CLOEXEC) = 0
fstat64(5, {st_mode=S_IFDIR|0755, st_size=16384, ...}) = 0
mmap2(NULL, 16384, PROT_READ, MAP_PRIVATE, 5, 0) = 0xb7fcf000
close(5) = 0
--- SIGBUS (Bus error) @ 0 (0) ---
+++ killed by SIGBUS +++

The mmap2() on a directory was successful, resulting in a SIGBUS
signal later.  This patch removes mmap() from the list of possible
ecryptfs_dir_fops so that mmap() isn't possible on eCryptfs directory
files.

https://bugs.launchpad.net/ecryptfs/+bug/400443

Reported-by: Adrian C. <anrxc@sysphere.org>
Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/ecryptfs/file.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

Comments

Herton Ronaldo Krzesinski Feb. 15, 2012, 6:01 p.m. UTC | #1
On Wed, Feb 15, 2012 at 05:24:29PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Adrian reported that mkfontscale didn't work inside of eCryptfs mounts.
> Strace revealed the following:
> 
> open("./", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
> fcntl64(3, F_GETFD) = 0x1 (flags FD_CLOEXEC)
> open("./fonts.scale", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
> getdents(3, /* 80 entries */, 32768) = 2304
> open("./.", O_RDONLY) = 5
> fcntl64(5, F_SETFD, FD_CLOEXEC) = 0
> fstat64(5, {st_mode=S_IFDIR|0755, st_size=16384, ...}) = 0
> mmap2(NULL, 16384, PROT_READ, MAP_PRIVATE, 5, 0) = 0xb7fcf000
> close(5) = 0
> --- SIGBUS (Bus error) @ 0 (0) ---
> +++ killed by SIGBUS +++
> 
> The mmap2() on a directory was successful, resulting in a SIGBUS
> signal later.  This patch removes mmap() from the list of possible
> ecryptfs_dir_fops so that mmap() isn't possible on eCryptfs directory
> files.
> 
> https://bugs.launchpad.net/ecryptfs/+bug/400443
> 
> Reported-by: Adrian C. <anrxc@sysphere.org>
> Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>

Ack, just missing the backported from
38e3eaeedcac75360af8a92e7b66956ec4f334e5 line here.

> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  fs/ecryptfs/file.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
> index 4e25328..d8adc51 100644
> --- a/fs/ecryptfs/file.c
> +++ b/fs/ecryptfs/file.c
> @@ -327,7 +327,6 @@ const struct file_operations ecryptfs_dir_fops = {
>  #ifdef CONFIG_COMPAT
>  	.compat_ioctl = ecryptfs_compat_ioctl,
>  #endif
> -	.mmap = generic_file_mmap,
>  	.open = ecryptfs_open,
>  	.flush = ecryptfs_flush,
>  	.release = ecryptfs_release,
> -- 
> 1.7.0.4
>
Tim Gardner Feb. 15, 2012, 6:03 p.m. UTC | #2
On 02/15/2012 10:24 AM, Colin King wrote:
> From: Colin Ian King<colin.king@canonical.com>
>
> Adrian reported that mkfontscale didn't work inside of eCryptfs mounts.
> Strace revealed the following:
>
> open("./", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
> fcntl64(3, F_GETFD) = 0x1 (flags FD_CLOEXEC)
> open("./fonts.scale", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
> getdents(3, /* 80 entries */, 32768) = 2304
> open("./.", O_RDONLY) = 5
> fcntl64(5, F_SETFD, FD_CLOEXEC) = 0
> fstat64(5, {st_mode=S_IFDIR|0755, st_size=16384, ...}) = 0
> mmap2(NULL, 16384, PROT_READ, MAP_PRIVATE, 5, 0) = 0xb7fcf000
> close(5) = 0
> --- SIGBUS (Bus error) @ 0 (0) ---
> +++ killed by SIGBUS +++
>
> The mmap2() on a directory was successful, resulting in a SIGBUS
> signal later.  This patch removes mmap() from the list of possible
> ecryptfs_dir_fops so that mmap() isn't possible on eCryptfs directory
> files.
>
> https://bugs.launchpad.net/ecryptfs/+bug/400443
>
> Reported-by: Adrian C.<anrxc@sysphere.org>
> Signed-off-by: Tyler Hicks<tyhicks@linux.vnet.ibm.com>
> Signed-off-by: Colin Ian King<colin.king@canonical.com>
> ---
>   fs/ecryptfs/file.c |    1 -
>   1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
> index 4e25328..d8adc51 100644
> --- a/fs/ecryptfs/file.c
> +++ b/fs/ecryptfs/file.c
> @@ -327,7 +327,6 @@ const struct file_operations ecryptfs_dir_fops = {
>   #ifdef CONFIG_COMPAT
>   	.compat_ioctl = ecryptfs_compat_ioctl,
>   #endif
> -	.mmap = generic_file_mmap,
>   	.open = ecryptfs_open,
>   	.flush = ecryptfs_flush,
>   	.release = ecryptfs_release,

I'll add 'backported from 38e3eaeedcac75360af8a92e7b66956ec4f334e5' and 
send it to stable.

rtg
Colin Ian King Feb. 15, 2012, 6:09 p.m. UTC | #3
On 15/02/12 18:03, Tim Gardner wrote:
> On 02/15/2012 10:24 AM, Colin King wrote:
>> From: Colin Ian King<colin.king@canonical.com>
>>
>> Adrian reported that mkfontscale didn't work inside of eCryptfs mounts.
>> Strace revealed the following:
>>
>> open("./", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
>> fcntl64(3, F_GETFD) = 0x1 (flags FD_CLOEXEC)
>> open("./fonts.scale", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
>> getdents(3, /* 80 entries */, 32768) = 2304
>> open("./.", O_RDONLY) = 5
>> fcntl64(5, F_SETFD, FD_CLOEXEC) = 0
>> fstat64(5, {st_mode=S_IFDIR|0755, st_size=16384, ...}) = 0
>> mmap2(NULL, 16384, PROT_READ, MAP_PRIVATE, 5, 0) = 0xb7fcf000
>> close(5) = 0
>> --- SIGBUS (Bus error) @ 0 (0) ---
>> +++ killed by SIGBUS +++
>>
>> The mmap2() on a directory was successful, resulting in a SIGBUS
>> signal later. This patch removes mmap() from the list of possible
>> ecryptfs_dir_fops so that mmap() isn't possible on eCryptfs directory
>> files.
>>
>> https://bugs.launchpad.net/ecryptfs/+bug/400443
>>
>> Reported-by: Adrian C.<anrxc@sysphere.org>
>> Signed-off-by: Tyler Hicks<tyhicks@linux.vnet.ibm.com>
>> Signed-off-by: Colin Ian King<colin.king@canonical.com>
>> ---
>> fs/ecryptfs/file.c | 1 -
>> 1 files changed, 0 insertions(+), 1 deletions(-)
>>
>> diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
>> index 4e25328..d8adc51 100644
>> --- a/fs/ecryptfs/file.c
>> +++ b/fs/ecryptfs/file.c
>> @@ -327,7 +327,6 @@ const struct file_operations ecryptfs_dir_fops = {
>> #ifdef CONFIG_COMPAT
>> .compat_ioctl = ecryptfs_compat_ioctl,
>> #endif
>> - .mmap = generic_file_mmap,
>> .open = ecryptfs_open,
>> .flush = ecryptfs_flush,
>> .release = ecryptfs_release,
>
> I'll add 'backported from 38e3eaeedcac75360af8a92e7b66956ec4f334e5' and
> send it to stable.

Thanks, I overlooked that, doh.
>
> rtg
diff mbox

Patch

diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index 4e25328..d8adc51 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -327,7 +327,6 @@  const struct file_operations ecryptfs_dir_fops = {
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = ecryptfs_compat_ioctl,
 #endif
-	.mmap = generic_file_mmap,
 	.open = ecryptfs_open,
 	.flush = ecryptfs_flush,
 	.release = ecryptfs_release,