Commit 270b050a authored by abveritas's avatar abveritas

linux-lts update + all used files moved to core-package git

parent 126d8ca9
From e268337dfe26dfc7efd422a804dbb27977a3cccc Mon Sep 17 00:00:00 2001
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Tue, 17 Jan 2012 15:21:19 -0800
Subject: proc: clean up and fix /proc/<pid>/mem handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From: Linus Torvalds <torvalds@linux-foundation.org>
commit e268337dfe26dfc7efd422a804dbb27977a3cccc upstream.
Jri Aedla reported that the /proc/<pid>/mem handling really isn't very
robust, and it also doesn't match the permission checking of any of the
other related files.
This changes it to do the permission checks at open time, and instead of
tracking the process, it tracks the VM at the time of the open. That
simplifies the code a lot, but does mean that if you hold the file
descriptor open over an execve(), you'll continue to read from the _old_
VM.
That is different from our previous behavior, but much simpler. If
somebody actually finds a load where this matters, we'll need to revert
this commit.
I suspect that nobody will ever notice - because the process mapping
addresses will also have changed as part of the execve. So you cannot
actually usefully access the fd across a VM change simply because all
the offsets for IO would have changed too.
Reported-by: Jri Aedla <asd@ut.ee>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
fs/proc/base.c | 145 +++++++++++++++------------------------------------------
1 file changed, 39 insertions(+), 106 deletions(-)
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -194,65 +194,7 @@ static int proc_root_link(struct inode *
return result;
}
-static struct mm_struct *__check_mem_permission(struct task_struct *task)
-{
- struct mm_struct *mm;
-
- mm = get_task_mm(task);
- if (!mm)
- return ERR_PTR(-EINVAL);
-
- /*
- * A task can always look at itself, in case it chooses
- * to use system calls instead of load instructions.
- */
- if (task == current)
- return mm;
-
- /*
- * If current is actively ptrace'ing, and would also be
- * permitted to freshly attach with ptrace now, permit it.
- */
- if (task_is_stopped_or_traced(task)) {
- int match;
- rcu_read_lock();
- match = (tracehook_tracer_task(task) == current);
- rcu_read_unlock();
- if (match && ptrace_may_access(task, PTRACE_MODE_ATTACH))
- return mm;
- }
-
- /*
- * No one else is allowed.
- */
- mmput(mm);
- return ERR_PTR(-EPERM);
-}
-
-/*
- * If current may access user memory in @task return a reference to the
- * corresponding mm, otherwise ERR_PTR.
- */
-static struct mm_struct *check_mem_permission(struct task_struct *task)
-{
- struct mm_struct *mm;
- int err;
-
- /*
- * Avoid racing if task exec's as we might get a new mm but validate
- * against old credentials.
- */
- err = mutex_lock_killable(&task->signal->cred_guard_mutex);
- if (err)
- return ERR_PTR(err);
-
- mm = __check_mem_permission(task);
- mutex_unlock(&task->signal->cred_guard_mutex);
-
- return mm;
-}
-
-struct mm_struct *mm_for_maps(struct task_struct *task)
+static struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
{
struct mm_struct *mm;
int err;
@@ -263,7 +205,7 @@ struct mm_struct *mm_for_maps(struct tas
mm = get_task_mm(task);
if (mm && mm != current->mm &&
- !ptrace_may_access(task, PTRACE_MODE_READ)) {
+ !ptrace_may_access(task, mode)) {
mmput(mm);
mm = ERR_PTR(-EACCES);
}
@@ -272,6 +214,11 @@ struct mm_struct *mm_for_maps(struct tas
return mm;
}
+struct mm_struct *mm_for_maps(struct task_struct *task)
+{
+ return mm_access(task, PTRACE_MODE_READ);
+}
+
static int proc_pid_cmdline(struct task_struct *task, char * buffer)
{
int res = 0;
@@ -816,38 +763,39 @@ static const struct file_operations proc
static int mem_open(struct inode* inode, struct file* file)
{
- file->private_data = (void*)((long)current->self_exec_id);
+ struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
+ struct mm_struct *mm;
+
+ if (!task)
+ return -ESRCH;
+
+ mm = mm_access(task, PTRACE_MODE_ATTACH);
+ put_task_struct(task);
+
+ if (IS_ERR(mm))
+ return PTR_ERR(mm);
+
/* OK to pass negative loff_t, we can catch out-of-range */
file->f_mode |= FMODE_UNSIGNED_OFFSET;
+ file->private_data = mm;
+
return 0;
}
static ssize_t mem_read(struct file * file, char __user * buf,
size_t count, loff_t *ppos)
{
- struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
+ int ret;
char *page;
unsigned long src = *ppos;
- int ret = -ESRCH;
- struct mm_struct *mm;
+ struct mm_struct *mm = file->private_data;
- if (!task)
- goto out_no_task;
+ if (!mm)
+ return 0;
- ret = -ENOMEM;
page = (char *)__get_free_page(GFP_TEMPORARY);
if (!page)
- goto out;
-
- mm = check_mem_permission(task);
- ret = PTR_ERR(mm);
- if (IS_ERR(mm))
- goto out_free;
-
- ret = -EIO;
-
- if (file->private_data != (void*)((long)current->self_exec_id))
- goto out_put;
+ return -ENOMEM;
ret = 0;
@@ -874,13 +822,7 @@ static ssize_t mem_read(struct file * fi
}
*ppos = src;
-out_put:
- mmput(mm);
-out_free:
free_page((unsigned long) page);
-out:
- put_task_struct(task);
-out_no_task:
return ret;
}
@@ -889,27 +831,15 @@ static ssize_t mem_write(struct file * f
{
int copied;
char *page;
- struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
unsigned long dst = *ppos;
- struct mm_struct *mm;
+ struct mm_struct *mm = file->private_data;
- copied = -ESRCH;
- if (!task)
- goto out_no_task;
+ if (!mm)
+ return 0;
- copied = -ENOMEM;
page = (char *)__get_free_page(GFP_TEMPORARY);
if (!page)
- goto out_task;
-
- mm = check_mem_permission(task);
- copied = PTR_ERR(mm);
- if (IS_ERR(mm))
- goto out_free;
-
- copied = -EIO;
- if (file->private_data != (void *)((long)current->self_exec_id))
- goto out_mm;
+ return -ENOMEM;
copied = 0;
while (count > 0) {
@@ -933,13 +863,7 @@ static ssize_t mem_write(struct file * f
}
*ppos = dst;
-out_mm:
- mmput(mm);
-out_free:
free_page((unsigned long) page);
-out_task:
- put_task_struct(task);
-out_no_task:
return copied;
}
@@ -959,11 +883,20 @@ loff_t mem_lseek(struct file *file, loff
return file->f_pos;
}
+static int mem_release(struct inode *inode, struct file *file)
+{
+ struct mm_struct *mm = file->private_data;
+
+ mmput(mm);
+ return 0;
+}
+
static const struct file_operations proc_mem_operations = {
.llseek = mem_lseek,
.read = mem_read,
.write = mem_write,
.open = mem_open,
+ .release = mem_release,
};
static ssize_t environ_read(struct file *file, char __user *buf,
......@@ -9,43 +9,91 @@ pkgname=('linux-lts' 'linux-lts-headers' 'linux-lts-docs') # Build stock -CHAKRA
# pkgname=linux-custom # Build kernel with a different name
_kernelname=${pkgname#linux-lts}
_basekernel=3.0
pkgver=${_basekernel}.24
pkgver=${_basekernel}.34
pkgrel=1
_aufs="3.0-20120109"
makedepends=('xmlto' 'docbook-xsl')
_patchname="patch-${pkgver}-1-CHAKRA-LTS"
arch=(i686 x86_64)
license=('GPL2')
url="http://www.kernel.org"
options=(!strip)
source=(ftp://ftp.kernel.org/pub/linux/kernel/v3.0/linux-$_basekernel.tar.bz2
http://chakra.sourceforge.net/sources/linux/${_patchname}.bz2
source=("ftp://ftp.kernel.org/pub/linux/kernel/v3.0/linux-$_basekernel.tar.bz2"
"http://www.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.xz"
# the main kernel config files
config.i686 config.x86_64
'config' 'config.x86_64'
#aufs patches
'aufs3.0-loopback.patch'
'aufs3.0-base.patch'
'aufs3.0-proc_map.patch'
'aufs3.0-standalone.patch'
'aufs3.0-kbuild.patch'
'aufs3.0.patch'
'config.aufs'
# standard config files for mkinitcpio ramdisk
linux-lts.preset)
'linux-lts.preset'
'change-default-console-loglevel.patch'
'i915-fix-ghost-tv-output.patch'
'ext4-options.patch')
md5sums=('398e95866794def22b12dfbc15ce89c0'
'1aa4155854e9352a4a73ed9cc3a48f08'
'4641adbc91eb89d98870d8984abd10c1'
'46aa71d1918a8a167aa6a6ab503375c4'
'56cdd0978dd4a539a25813fd4273c834')
'080b631fcdcb8fc1aea5ecf17c44d6a6'
'78383062c45a0aaf1e733ee16115bd75'
'eb3a80c9bd76e7c1f281bfbc0943dce3'
'821e1112493f187dc70df9412e61f324'
'b9248a75a3fe415a18d4730887daa339'
'798336f60f73b1fb63331225b9c9c971'
'd5ca601dc80b35fda18b078daf4aeb61'
'967195f0bf1d9a3b54ce8ae6173072d8'
'fcb34283bfb627a15b31f3b3e3228c05'
'52f4a2c7f6277774117c834d949d6b81'
'1277dd4aa587632fc27964edde49970f'
'9d3c56a4b999c8bfbd4018089a62f662'
'263725f20c0b9eb9c353040792d644e5'
'74d2b710d6c97aee441d7566f8f68815')
build() {
cd ${srcdir}/linux-$_basekernel
# fix setlocalversion
sed -i 's|echo "+"|# echo "+"|g' ./scripts/setlocalversion
# add upstream patch
patch -p1 -i "${srcdir}/patch-${pkgver}"
# Add -CHAKRA-LTS patches
patch -Np1 -i ${srcdir}/${_patchname}
# add latest fixes from stable queue, if needed
# http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
# Some chips detect a ghost TV output
patch -p1 -i "${srcdir}/i915-fix-ghost-tv-output.patch"
# set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
# remove this when a Kconfig knob is made available by upstream
# (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
patch -p1 -i "${srcdir}/change-default-console-loglevel.patch"
# fix ext4 module to mount ext3/2 correct
patch -p1 -i "${srcdir}/ext4-options.patch"
#aufs patches for Live:
patch -p1 -i "${srcdir}/aufs3.0.patch"
patch -p1 -i "${srcdir}/aufs3.0-base.patch"
patch -p1 -i "${srcdir}/aufs3.0-kbuild.patch"
patch -p1 -i "${srcdir}/aufs3.0-loopback.patch"
patch -p1 -i "${srcdir}/aufs3.0-proc_map.patch"
#patch -p1 -i "${srcdir}/aufs3.0-fix-export-__devcgroup_inode_permission.patch"
patch -p1 -i "${srcdir}/aufs3.0-standalone.patch"
# create .config
cat "${srcdir}/config.${CARCH}" > ./.config
if [ "${CARCH}" = "x86_64" ]; then
cat "${srcdir}/config.x86_64" > ./.config
else
cat "${srcdir}/config" > ./.config
fi
cat "${srcdir}/config.aufs" >> ./.config
if [ "${_kernelname}" != "" ]; then
sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
fi
# set extraversion to pkgrel
sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
# get kernel version
make prepare
......@@ -73,11 +121,10 @@ build() {
package_linux-lts() {
pkgdesc="The Linux LTS-Kernel and modules"
groups=('lts')
depends=('coreutils' 'linux-firmware' 'module-init-tools>=3.16' 'mkinitcpio>=0.7.5')
depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7.5')
optdepends=('crda: to set the correct wireless channels of your country')
replaces=('kernel24' 'kernel24-scsi' 'kernel26-lts' 'linux-scsi'
'alsa-driver' 'ieee80211' 'hostap-driver26'
'pwc' 'nforce' 'squashfs' 'unionfs' 'ivtv'
replaces=('kernel26-lts' 'linux-scsi'
'squashfs' 'unionfs' 'ivtv'
'zd1211' 'kvm-modules' 'iwlwifi' 'rt2x00-cvs'
'gspcav1' 'atl2' 'wlan-ng26' 'rt2500'
'aufs3' 'nouveau-drm')
......@@ -202,25 +249,18 @@ package_linux-lts-headers() {
cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
# add dvb headers for external modules
# in reference to:
# http://bugs.archlinux.org/task/9912
mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core"
cp drivers/media/dvb/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/"
# and...
# http://bugs.archlinux.org/task/11194
mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
# add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
# in reference to:
# http://bugs.archlinux.org/task/13146
mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
cp drivers/media/dvb/frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
cp drivers/media/video/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/"
# add dvb headers
# in reference to:
# http://bugs.archlinux.org/task/20402
mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb"
cp drivers/media/dvb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/"
mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends"
......
aufs3.0 base patch
diff --git a/fs/namei.c b/fs/namei.c
index 14ab8d3..eb4aef1 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1697,7 +1697,7 @@ static struct dentry *__lookup_hash(struct qstr *name,
* needs parent already locked. Doesn't follow mounts.
* SMP-safe.
*/
-static struct dentry *lookup_hash(struct nameidata *nd)
+struct dentry *lookup_hash(struct nameidata *nd)
{
return __lookup_hash(&nd->last, nd->path.dentry, nd);
}
diff --git a/fs/splice.c b/fs/splice.c
index aa866d3..19afec6 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1085,8 +1085,8 @@ EXPORT_SYMBOL(generic_splice_sendpage);
/*
* Attempt to initiate a splice from pipe to file.
*/
-static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
- loff_t *ppos, size_t len, unsigned int flags)
+long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
+ loff_t *ppos, size_t len, unsigned int flags)
{
ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
loff_t *, size_t, unsigned int);
@@ -1113,9 +1113,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
/*
* Attempt to initiate a splice from a file to a pipe.
*/
-static long do_splice_to(struct file *in, loff_t *ppos,
- struct pipe_inode_info *pipe, size_t len,
- unsigned int flags)
+long do_splice_to(struct file *in, loff_t *ppos,
+ struct pipe_inode_info *pipe, size_t len,
+ unsigned int flags)
{
ssize_t (*splice_read)(struct file *, loff_t *,
struct pipe_inode_info *, size_t, unsigned int);
diff --git a/include/linux/namei.h b/include/linux/namei.h
index eba45ea..21ed6c9 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -82,6 +82,7 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
int (*open)(struct inode *, struct file *));
+extern struct dentry *lookup_hash(struct nameidata *nd);
extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
extern int follow_down_one(struct path *);
diff --git a/include/linux/splice.h b/include/linux/splice.h
index 997c3b4..be9a153 100644
--- a/include/linux/splice.h
+++ b/include/linux/splice.h
@@ -89,4 +89,10 @@ extern int splice_grow_spd(struct pipe_inode_info *, struct splice_pipe_desc *);
extern void splice_shrink_spd(struct pipe_inode_info *,
struct splice_pipe_desc *);
+extern long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
+ loff_t *ppos, size_t len, unsigned int flags);
+extern long do_splice_to(struct file *in, loff_t *ppos,
+ struct pipe_inode_info *pipe, size_t len,
+ unsigned int flags);
+
#endif
aufs3.0 kbuild patch
diff --git a/fs/Kconfig b/fs/Kconfig
index 19891aa..b660b64 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -208,6 +208,7 @@ source "fs/pstore/Kconfig"
source "fs/sysv/Kconfig"
source "fs/ufs/Kconfig"
source "fs/exofs/Kconfig"
+source "fs/aufs/Kconfig"
endif # MISC_FILESYSTEMS
diff --git a/fs/Makefile b/fs/Makefile
index fb68c2b..c031a85 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -124,3 +124,4 @@ obj-$(CONFIG_GFS2_FS) += gfs2/
obj-$(CONFIG_EXOFS_FS) += exofs/
obj-$(CONFIG_CEPH_FS) += ceph/
obj-$(CONFIG_PSTORE) += pstore/
+obj-$(CONFIG_AUFS_FS) += aufs/
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 01f6362..8b3b9f1 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -65,6 +65,7 @@ header-y += atmppp.h
header-y += atmsap.h
header-y += atmsvc.h
header-y += audit.h
+header-y += aufs_type.h
header-y += auto_fs.h
header-y += auto_fs4.h
header-y += auxvec.h
aufs3.0 loopback patch
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 76c8da7..027b839 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -541,7 +541,7 @@ out:
}
struct switch_request {
- struct file *file;
+ struct file *file, *virt_file;
struct completion wait;
};
@@ -601,7 +601,8 @@ static int loop_thread(void *data)
* First it needs to flush existing IO, it does this by sending a magic
* BIO down the pipe. The completion of this BIO does the actual switch.
*/
-static int loop_switch(struct loop_device *lo, struct file *file)
+static int loop_switch(struct loop_device *lo, struct file *file,
+ struct file *virt_file)
{
struct switch_request w;
struct bio *bio = bio_alloc(GFP_KERNEL, 0);
@@ -609,6 +610,7 @@ static int loop_switch(struct loop_device *lo, struct file *file)
return -ENOMEM;
init_completion(&w.wait);
w.file = file;
+ w.virt_file = virt_file;
bio->bi_private = &w;
bio->bi_bdev = NULL;
loop_make_request(lo->lo_queue, bio);
@@ -625,7 +627,7 @@ static int loop_flush(struct loop_device *lo)
if (!lo->lo_thread)
return 0;
- return loop_switch(lo, NULL);
+ return loop_switch(lo, NULL, NULL);
}
/*
@@ -644,6 +646,7 @@ static void do_loop_switch(struct loop_device *lo, struct switch_request *p)
mapping = file->f_mapping;
mapping_set_gfp_mask(old_file->f_mapping, lo->old_gfp_mask);
lo->lo_backing_file = file;
+ lo->lo_backing_virt_file = p->virt_file;
lo->lo_blocksize = S_ISBLK(mapping->host->i_mode) ?
mapping->host->i_bdev->bd_block_size : PAGE_SIZE;
lo->old_gfp_mask = mapping_gfp_mask(mapping);
@@ -652,6 +655,13 @@ out:
complete(&p->wait);
}
+static struct file *loop_real_file(struct file *file)
+{
+ struct file *f = NULL;
+ if (file->f_dentry->d_sb->s_op->real_loop)
+ f = file->f_dentry->d_sb->s_op->real_loop(file);
+ return f;
+}
/*
* loop_change_fd switched the backing store of a loopback device to
@@ -665,6 +675,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
unsigned int arg)
{
struct file *file, *old_file;
+ struct file *f, *virt_file = NULL, *old_virt_file;
struct inode *inode;
int error;
@@ -681,9 +692,16 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
file = fget(arg);
if (!file)
goto out;
+ f = loop_real_file(file);
+ if (f) {
+ virt_file = file;
+ file = f;
+ get_file(file);
+ }
inode = file->f_mapping->host;
old_file = lo->lo_backing_file;
+ old_virt_file = lo->lo_backing_virt_file;
error = -EINVAL;
@@ -695,17 +713,21 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
goto out_putf;
/* and ... switch */
- error = loop_switch(lo, file);
+ error = loop_switch(lo, file, virt_file);
if (error)
goto out_putf;
fput(old_file);
+ if (old_virt_file)
+ fput(old_virt_file);
if (max_part > 0)
ioctl_by_bdev(bdev, BLKRRPART, 0);
return 0;
out_putf:
fput(file);
+ if (virt_file)
+ fput(virt_file);
out:
return error;
}
@@ -817,7 +839,7 @@ static void loop_sysfs_exit(struct loop_device *lo)
static int loop_set_fd(struct loop_device *lo, fmode_t mode,
struct block_device *bdev, unsigned int arg)
{
- struct file *file, *f;
+ struct file *file, *f, *virt_file = NULL;
struct inode *inode;
struct address_space *mapping;
unsigned lo_blocksize;
@@ -832,6 +854,12 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
file = fget(arg);
if (!file)
goto out;
+ f = loop_real_file(file);
+ if (f) {
+ virt_file = file;
+ file = f;
+ get_file(file);
+ }
error = -EBUSY;
if (lo->lo_state != Lo_unbound)
@@ -892,6 +920,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
lo->lo_device = bdev;
lo->lo_flags = lo_flags;
lo->lo_backing_file = file;
+ lo->lo_backing_virt_file = virt_file;
lo->transfer = transfer_none;
lo->ioctl = NULL;
lo->lo_sizelimit = 0;
@@ -935,6 +964,7 @@ out_clr:
lo->lo_thread = NULL;
lo->lo_device = NULL;
lo->lo_backing_file = NULL;
+ lo->lo_backing_virt_file = NULL;
lo->lo_flags = 0;
set_capacity(lo->lo_disk, 0);
invalidate_bdev(bdev);
@@ -944,6 +974,8 @@ out_clr:
lo->lo_state = Lo_unbound;
out_putf:
fput(file);
+ if (virt_file)
+ fput(virt_file);
out:
/* This is safe: open() is still holding a reference. */
module_put(THIS_MODULE);
@@ -990,6 +1022,7 @@ loop_init_xfer(struct loop_device *lo, struct loop_func_table *xfer,
static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
{
struct file *filp = lo->lo_backing_file;
+ struct file *virt_filp = lo->lo_backing_virt_file;
gfp_t gfp = lo->old_gfp_mask;
if (lo->lo_state != Lo_bound)
@@ -1041,6 +1041,7 @@ static int loop_clr_fd(struct loop_devic
spin_lock_irq(&lo->lo_lock);
lo->lo_backing_file = NULL;
+ lo->lo_backing_virt_file = NULL;
spin_unlock_irq(&lo->lo_lock);
loop_release_xfer(lo);
@@ -1045,6 +1079,8 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
* bd_mutex which is usually taken before lo_ctl_mutex.
*/
fput(filp);
+ if (virt_filp)
+ fput(virt_filp);
return 0;
}
diff --git a/fs/aufs/f_op.c b/fs/aufs/f_op.c