wrapfs-3.5.y.git
3 years agoWrapfs: add ->bmap support wrapfs
Erez Zadok [Fri, 13 May 2022 23:42:34 +0000 (19:42 -0400)]
Wrapfs: add ->bmap support

Signed-off-by: Aditya Sonavane <aditya.sonavane@stonybrook.edu>
Signed-off-by: Erez Zadok <ezk@cs.stonybrook.edu>
3 years agowrapfs: copyright year update
Erez Zadok [Sat, 7 May 2022 22:12:55 +0000 (18:12 -0400)]
wrapfs: copyright year update

3 years agowrapfs: change http URLs to https
Erez Zadok [Sat, 7 May 2022 20:48:49 +0000 (16:48 -0400)]
wrapfs: change http URLs to https

5 years agomerge changes
Erez Zadok [Mon, 16 Dec 2019 00:02:20 +0000 (19:02 -0500)]
merge changes

5 years agowrapfs: update copyright
Erez Zadok [Sat, 14 Dec 2019 05:07:00 +0000 (00:07 -0500)]
wrapfs: update copyright

5 years agowrapfs: remove unused variable
Erez Zadok [Sat, 14 Dec 2019 04:22:24 +0000 (23:22 -0500)]
wrapfs: remove unused variable

6 years agoupdate copyright
Erez Zadok [Fri, 29 Mar 2019 20:46:31 +0000 (16:46 -0400)]
update copyright

6 years agofix spell error
Erez Zadok [Fri, 29 Mar 2019 20:40:38 +0000 (16:40 -0400)]
fix spell error

8 years agoWrapfs: ->iget fixes
Erez Zadok [Sun, 19 Feb 2017 00:11:23 +0000 (19:11 -0500)]
Wrapfs: ->iget fixes

Change where we igrab/iput to ensure we always hold a valid lower_inode.
Return ENOMEM (not EACCES) if iget5_locked returns NULL.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
8 years agoWrapfs: update copyrights for 2017
Erez Zadok [Sat, 18 Feb 2017 20:21:14 +0000 (15:21 -0500)]
Wrapfs: update copyrights for 2017

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
9 years agoWrapfs: support NFS exports
Erez Zadok [Sun, 22 May 2016 05:25:28 +0000 (01:25 -0400)]
Wrapfs: support NFS exports

Based on patch from Sandeep Joshi <sanjos100@gmail.com>.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
9 years agoWrapfs: use d_splice_alias
Erez Zadok [Sun, 22 May 2016 05:25:28 +0000 (01:25 -0400)]
Wrapfs: use d_splice_alias

Refactor interpose code to allow lookup to use d_splice_alias.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
9 years agoWrapfs: update nlinks after rename
Erez Zadok [Mon, 14 Dec 2015 23:37:14 +0000 (18:37 -0500)]
Wrapfs: update nlinks after rename

Signed-off-by: Logeswari P Viswanath <logeswari.pv@hpe.com>
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
9 years agoWrapfs: update copyright year to 2015
Erez Zadok [Wed, 4 Nov 2015 06:11:06 +0000 (01:11 -0500)]
Wrapfs: update copyright year to 2015

9 years agoWrapfs: use vfs xattr helpers
Erez Zadok [Wed, 4 Nov 2015 06:11:06 +0000 (01:11 -0500)]
Wrapfs: use vfs xattr helpers

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
11 years agoWrapfs: properly copy meta-data after AIO operations from lower inode
Erez Zadok [Sat, 16 Aug 2014 03:20:44 +0000 (23:20 -0400)]
Wrapfs: properly copy meta-data after AIO operations from lower inode

Signed-off-by: Mengyang Li <li.mengyang@stonybrook.edu>
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
11 years agoWrapfs: leave placeholders for updating upper inode after AIO
Erez Zadok [Mon, 11 Aug 2014 22:57:34 +0000 (18:57 -0400)]
Wrapfs: leave placeholders for updating upper inode after AIO

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
11 years agoWrapfs: protect lower_file by ref-count during aio operation
Erez Zadok [Sun, 10 Aug 2014 06:20:09 +0000 (02:20 -0400)]
Wrapfs: protect lower_file by ref-count during aio operation

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: Mengyang Li <li.mengyang@stonybrook.edu>
11 years agoWrapfs: fix ->llseek to update upper and lower offsets
Erez Zadok [Thu, 26 Jun 2014 03:20:36 +0000 (23:20 -0400)]
Wrapfs: fix ->llseek to update upper and lower offsets

Fixes bug: xfstests generic/257. f_pos consistently is required by and
only by dir_ops->wrapfs_readdir, main_ops is not affected.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: Mengyang Li <li.mengyang@stonybrook.edu>
11 years ago Wrapfs: support extended attributes (xattr) operations
Erez Zadok [Thu, 26 Jun 2014 03:20:36 +0000 (23:20 -0400)]
 Wrapfs: support extended attributes (xattr) operations

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: Mengyang Li <li.mengyang@stonybrook.edu>
11 years agoWrapfs: support asynchronous-IO (AIO) operations
Erez Zadok [Sat, 21 Jun 2014 00:26:26 +0000 (20:26 -0400)]
Wrapfs: support asynchronous-IO (AIO) operations

Signed-off-by: Li Mengyang <li.mengyang@stonybrook.edu>
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
11 years agoWrapfs: support direct-IO (DIO) operations
Erez Zadok [Sat, 21 Jun 2014 00:26:26 +0000 (20:26 -0400)]
Wrapfs: support direct-IO (DIO) operations

Signed-off-by: Li Mengyang <li.mengyang@stonybrook.edu>
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
11 years agoWrapfs: implement vm_ops->page_mkwrite
Erez Zadok [Thu, 15 May 2014 04:16:05 +0000 (00:16 -0400)]
Wrapfs: implement vm_ops->page_mkwrite

Some file systems (e.g., ext4) require it.  Reported by Ted Ts'o.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
11 years agoWrapfs: update documentation
Erez Zadok [Thu, 3 Apr 2014 18:14:28 +0000 (14:14 -0400)]
Wrapfs: update documentation

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
11 years agoWrapfs: update maintainers
Erez Zadok [Thu, 3 Apr 2014 18:14:19 +0000 (14:14 -0400)]
Wrapfs: update maintainers

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
11 years agoWrapfs: update documentation
Erez Zadok [Tue, 21 Jan 2014 08:24:34 +0000 (03:24 -0500)]
Wrapfs: update documentation

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
11 years agoWrapfs: 2014 Copyright update
Erez Zadok [Tue, 21 Jan 2014 06:18:43 +0000 (01:18 -0500)]
Wrapfs: 2014 Copyright update

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: copy lower inode attributes in ->ioctl
Erez Zadok [Wed, 5 Jun 2013 05:36:58 +0000 (01:36 -0400)]
Wrapfs: copy lower inode attributes in ->ioctl

Some ioctls (e.g., EXT2_IOC_SETFLAGS) can change inode attributes, so copy
them from lower inode.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: remove unnecessary call to vm_unmap in ->mmap
Erez Zadok [Wed, 5 Jun 2013 05:36:58 +0000 (01:36 -0400)]
Wrapfs: remove unnecessary call to vm_unmap in ->mmap

Code is unnecessary and causes deadlocks in newer kernels.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agopatch copyright-2013.patch
Erez Zadok [Mon, 3 Jun 2013 04:23:02 +0000 (00:23 -0400)]
patch copyright-2013.patch

12 years agoWrapfs: use vm_munmap in ->mmap
Erez Zadok [Mon, 3 Jun 2013 04:22:57 +0000 (00:22 -0400)]
Wrapfs: use vm_munmap in ->mmap

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: use clear_inode in evict_inode
Erez Zadok [Sun, 26 May 2013 03:31:06 +0000 (23:31 -0400)]
Wrapfs: use clear_inode in evict_inode

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: use d_make_root
Erez Zadok [Sun, 26 May 2013 03:27:14 +0000 (23:27 -0400)]
Wrapfs: use d_make_root

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: use mode_t
Erez Zadok [Tue, 31 Jan 2012 09:40:19 +0000 (04:40 -0500)]
Wrapfs: use mode_t

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: use set_nlink()
Erez Zadok [Mon, 30 Jan 2012 01:34:27 +0000 (20:34 -0500)]
Wrapfs: use set_nlink()

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: drop our dentry in ->rmdir
Erez Zadok [Fri, 9 Sep 2011 04:47:49 +0000 (00:47 -0400)]
Wrapfs: drop our dentry in ->rmdir

Also clear nlinks on our inode.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: use d_alloc_root
Erez Zadok [Tue, 6 Sep 2011 04:10:32 +0000 (00:10 -0400)]
Wrapfs: use d_alloc_root

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: use d_set_d_op
Erez Zadok [Tue, 6 Sep 2011 04:10:31 +0000 (00:10 -0400)]
Wrapfs: use d_set_d_op

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: use updated vfs_path_lookup prototype
Erez Zadok [Tue, 6 Sep 2011 04:10:30 +0000 (00:10 -0400)]
Wrapfs: use updated vfs_path_lookup prototype

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: ->fsync updates for new prototype
Erez Zadok [Tue, 6 Sep 2011 04:10:30 +0000 (00:10 -0400)]
Wrapfs: ->fsync updates for new prototype

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: support LOOKUP_RCU in ->d_revalidate
Erez Zadok [Tue, 6 Sep 2011 04:10:29 +0000 (00:10 -0400)]
Wrapfs: support LOOKUP_RCU in ->d_revalidate

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: new ->permission prototype and fixes.
Erez Zadok [Tue, 6 Sep 2011 04:10:28 +0000 (00:10 -0400)]
Wrapfs: new ->permission prototype and fixes.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: lookup fixes
Erez Zadok [Mon, 2 May 2011 06:00:02 +0000 (02:00 -0400)]
Wrapfs: lookup fixes

Don't use lookup_one_len any longer (doesn't work for NFS).
Initialize lower wrapfs_dentry_info so lower_path is NULL.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: remove extra debug in rmdir
Erez Zadok [Fri, 18 Mar 2011 17:14:28 +0000 (13:14 -0400)]
Wrapfs: remove extra debug in rmdir

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: checkpatch fixes
Erez Zadok [Fri, 18 Mar 2011 16:38:01 +0000 (12:38 -0400)]
Wrapfs: checkpatch fixes

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: port to 2.6.39
Erez Zadok [Fri, 18 Mar 2011 04:45:17 +0000 (00:45 -0400)]
Wrapfs: port to 2.6.39

Remove lock/unlock_kernel in ->fasync.
Convert from ->get_sb to ->mount op.
Remove include to smp_lock.h, added sched.h.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: copyright update for 2011
Erez Zadok [Fri, 18 Mar 2011 03:21:55 +0000 (23:21 -0400)]
Wrapfs: copyright update for 2011

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: better handling of NFS silly-renamed files
Erez Zadok [Fri, 18 Mar 2011 03:21:55 +0000 (23:21 -0400)]
Wrapfs: better handling of NFS silly-renamed files

In ->unlink, if we try to unlink an NFS silly-renamed file, NFS returns
-EBUSY.  We have to treat it as a success and return 0 to the VFS.  NFS will
remove silly-deleted files later on anyway.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: update parent directory inode size in inode ops
Erez Zadok [Fri, 18 Mar 2011 03:21:55 +0000 (23:21 -0400)]
Wrapfs: update parent directory inode size in inode ops

After ->unlink, ->rmdir, and ->rename, we need to copy the (possibly
changed) inode size of the parent directory(ies) where the operation took
place.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: remove unnecessary calls to copy lower inode->n_links
Erez Zadok [Fri, 18 Mar 2011 03:21:55 +0000 (23:21 -0400)]
Wrapfs: remove unnecessary calls to copy lower inode->n_links

Removed from ->create, ->symlink, and ->mknod.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: ->setattr fixes
Erez Zadok [Tue, 8 Mar 2011 04:20:33 +0000 (23:20 -0500)]
Wrapfs: ->setattr fixes

Call inode_change_ok on our inode, not lower.
Don't copy inode sizes (VFS does it).
Pass lower file in struct iattr passed to notify_change on lower inode.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: update ->permission prototye and code for new iperm flag
Erez Zadok [Sun, 6 Mar 2011 21:23:16 +0000 (16:23 -0500)]
Wrapfs: update ->permission prototye and code for new iperm flag

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: handle maxbytes properly
Erez Zadok [Fri, 12 Nov 2010 23:15:05 +0000 (18:15 -0500)]
Wrapfs: handle maxbytes properly

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: support ->unlocked_ioctl and ->compat_ioctl
Erez Zadok [Sat, 11 Sep 2010 19:49:33 +0000 (15:49 -0400)]
Wrapfs: support ->unlocked_ioctl and ->compat_ioctl

Old ->ioctl was split into ->unlocked_ioctl and ->compat_ioctl.  Compat
version doesn't need to lock_kernel any longer.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: new vfs_statfs and ->evict_inode prototypes
Erez Zadok [Wed, 11 Aug 2010 03:50:14 +0000 (23:50 -0400)]
Wrapfs: new vfs_statfs and ->evict_inode prototypes

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: update ->fsync prototype
Erez Zadok [Sat, 7 Aug 2010 03:37:29 +0000 (23:37 -0400)]
Wrapfs: update ->fsync prototype

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: update documentation
Erez Zadok [Wed, 21 Apr 2010 01:22:02 +0000 (21:22 -0400)]
Wrapfs: update documentation

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: include slab.h
Erez Zadok [Tue, 20 Apr 2010 19:32:09 +0000 (15:32 -0400)]
Wrapfs: include slab.h

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: avoid an extra path_get/put pair in wrapfs_open
Erez Zadok [Tue, 20 Apr 2010 19:26:02 +0000 (15:26 -0400)]
Wrapfs: avoid an extra path_get/put pair in wrapfs_open

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: decrement nd_path on follow_link error
Erez Zadok [Fri, 26 Feb 2010 08:18:04 +0000 (03:18 -0500)]
Wrapfs: decrement nd_path on follow_link error

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: don't mention kernel version in modload message
Erez Zadok [Tue, 5 Jan 2010 09:27:00 +0000 (04:27 -0500)]
Wrapfs: don't mention kernel version in modload message

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs/VFS: remove init_lower_nd and unexport release_lower_nd
Erez Zadok [Tue, 5 Jan 2010 09:28:11 +0000 (04:28 -0500)]
Wrapfs/VFS: remove init_lower_nd and unexport release_lower_nd

Only wrapfs_create used it, and it is unnecessary to init a completely new
nameidata for the lower file system.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoKconfig: hook to configure Wrapfs
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Kconfig: hook to configure Wrapfs

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoMakefile: hook to compile Wrapfs
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Makefile: hook to compile Wrapfs

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoVFS: export release_open_intent symbol
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
VFS: export release_open_intent symbol

Needed to release the resources of the lower nameidata structures that we
create and pass to lower file systems (e.g., when calling vfs_create).

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: file system magic number
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Wrapfs: file system magic number

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: Kconfig options
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Wrapfs: Kconfig options

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: main Makefile
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Wrapfs: main Makefile

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: vm_ops operations
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Wrapfs: vm_ops operations

Includes necessary address_space workaround ops.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: mount-time and module-linkage functions
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Wrapfs: mount-time and module-linkage functions

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: lookup-related functions
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Wrapfs: lookup-related functions

Main lookup function, nameidata helpers, and stacking-interposition
functions.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: file operations
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Wrapfs: file operations

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: dentry operations
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Wrapfs: dentry operations

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: inode operations
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Wrapfs: inode operations

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: superblock operations
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Wrapfs: superblock operations

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: main header file
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Wrapfs: main header file

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: Maintainers
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Wrapfs: Maintainers

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoDocumentation: index entry for Wrapfs
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Documentation: index entry for Wrapfs

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoWrapfs: introduction and usage documentation
Erez Zadok [Tue, 5 Jan 2010 01:45:06 +0000 (20:45 -0500)]
Wrapfs: introduction and usage documentation

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
12 years agoLinux 3.5.7 master v3.5.7
Greg Kroah-Hartman [Fri, 12 Oct 2012 20:48:25 +0000 (05:48 +0900)]
Linux 3.5.7

12 years agoConvert properly UTF-8 to UTF-16
Frediano Ziglio [Tue, 7 Aug 2012 09:33:03 +0000 (04:33 -0500)]
Convert properly UTF-8 to UTF-16

commit fd3ba42c76d3d4b776120c2b24c1791e7bb3deb1 upstream.

wchar_t is currently 16bit so converting a utf8 encoded characters not
in plane 0 (>= 0x10000) to wchar_t (that is calling char2uni) lead to a
-EINVAL return. This patch detect utf8 in cifs_strtoUTF16 and add special
code calling utf8s_to_utf16s.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Acked-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agocifs: reinstate the forcegid option
Jeff Layton [Wed, 3 Oct 2012 20:02:36 +0000 (16:02 -0400)]
cifs: reinstate the forcegid option

commit 72bd481f860f0125c810bb43d878ce5f9c060c58 upstream.

Apparently this was lost when we converted to the standard option
parser in 8830d7e07a5e38bc47650a7554b7c1cfd49902bf

Reported-by: Gregory Lee Bartholomew <gregory.lee.bartholomew@gmail.com>
Cc: Sachin Prabhu <sprabhu@redhat.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agoJFFS2: don't fail on bitflips in OOB
Brian Norris [Fri, 31 Aug 2012 22:01:19 +0000 (15:01 -0700)]
JFFS2: don't fail on bitflips in OOB

commit 74d83beaa229aac7d126ac1ed9414658ff1a89d2 upstream.

JFFS2 was designed without thought for OOB bitflips, it seems, but they
can occur and will be reported to JFFS2 via mtd_read_oob()[1]. We don't
want to fail on these transactions, since the data was corrected.

[1] Few drivers report bitflips for OOB-only transactions. With such
    drivers, this patch should have no effect.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agoJFFS2: fix unmount regression
Artem Bityutskiy [Thu, 23 Aug 2012 07:10:07 +0000 (10:10 +0300)]
JFFS2: fix unmount regression

commit a445f784ae5558a3da680aa6b39ed53c95a551c1 upstream.

This patch fixes regression introduced by
"8bdc81c jffs2: get rid of jffs2_sync_super". We submit a delayed work in order
to make sure the write-buffer is synchronized at some point. But we do not
flush it when we unmount, which causes an oops when we unmount the file-system
and then the delayed work is executed.

This patch fixes the issue by adding a "cancel_delayed_work_sync()" infocation
in the '->sync_fs()' handler. This will make sure the delayed work is canceled
on sync, unmount and re-mount. And because VFS always callse 'sync_fs()' before
unmounting or remounting, this fixes the issue.

Reported-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Tested-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agommc: sh-mmcif: avoid oops on spurious interrupts
Guennadi Liakhovetski [Tue, 18 Sep 2012 06:42:42 +0000 (06:42 +0000)]
mmc: sh-mmcif: avoid oops on spurious interrupts

commit 8464dd52d3198dd05cafb005371d76e5339eb842 upstream.

On some systems, e.g., kzm9g, MMCIF interfaces can produce spurious
interrupts without any active request. To prevent the Oops, that results
in such cases, don't dereference the mmc request pointer until we make
sure, that we are indeed processing such a request.

Reported-by: Tetsuyuki Kobayashi <koba@kmckk.co.jp>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agommc: omap_hsmmc: Pass on the suspend failure to the PM core
Vaibhav Bedia [Thu, 13 Sep 2012 06:31:03 +0000 (06:31 +0000)]
mmc: omap_hsmmc: Pass on the suspend failure to the PM core

commit c4c8eeb4df00aabb641553d6fbcd46f458e56cd9 upstream.

In some cases mmc_suspend_host() is not able to claim the
host and proceed with the suspend process. The core returns
-EBUSY to the host controller driver. Unfortunately, the
host controller driver does not pass on this information
to the PM core and hence the system suspend process continues.

ret = mmc_suspend_host(host->mmc);
if (ret) {
host->suspended = 0;
if (host->pdata->resume) {
ret = host->pdata->resume(dev, host->slot_id);

The return status from mmc_suspend_host() is overwritten by return
status from host->pdata->resume. So the original return status is lost.

In these cases the MMC core gets to an unexpected state
during resume and multiple issues related to MMC crop up.
1. Host controller driver starts accessing the device registers
before the clocks are enabled which leads to a prefetch abort.
2. A file copy thread which was launched before suspend gets
stuck due to the host not being reclaimed during resume.

To avoid such problems pass on the -EBUSY status to the PM core
from the host controller driver. With this change, MMC core
suspend might still fail but it does not end up making the
system unusable. Suspend gets aborted and the user can try
suspending the system again.

Signed-off-by: Vaibhav Bedia <vaibhav.bedia@ti.com>
Signed-off-by: Hebbar, Gururaja <gururaja.hebbar@ti.com>
Acked-by: Venkatraman S <svenkatr@ti.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agomtd: omap2: fix module loading
Andreas Bießmann [Fri, 31 Aug 2012 11:35:42 +0000 (13:35 +0200)]
mtd: omap2: fix module loading

commit 4d3d688da8e7016f15483e9319b41311e1db9515 upstream.

Unloading the omap2 nand driver missed to release the memory region which will
result in not being able to request it again if one want to load the driver
later on.

This patch fixes following error when loading omap2 module after unloading:
---8<---
~ $ rmmod omap2
~ $ modprobe omap2
[   37.420928] omap2-nand: probe of omap2-nand.0 failed with error -16
~ $
--->8---

This error was introduced in 67ce04bf2746f8a1f8c2a104b313d20c63f68378 which
was the first commit of this driver.

Signed-off-by: Andreas Bießmann <andreas@biessmann.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agomtd: omap2: fix omap_nand_remove segfault
Andreas Bießmann [Fri, 31 Aug 2012 11:35:41 +0000 (13:35 +0200)]
mtd: omap2: fix omap_nand_remove segfault

commit 7d9b110269253b1d5858cfa57d68dfc7bf50dd77 upstream.

Do not kfree() the mtd_info; it is handled in the mtd subsystem and
already freed by nand_release(). Instead kfree() the struct
omap_nand_info allocated in omap_nand_probe which was not freed before.

This patch fixes following error when unloading the omap2 module:

---8<---
~ $ rmmod omap2
------------[ cut here ]------------
kernel BUG at mm/slab.c:3126!
Internal error: Oops - BUG: 0 [#1] PREEMPT ARM
Modules linked in: omap2(-)
CPU: 0    Not tainted  (3.6.0-rc3-00230-g155e36d-dirty #3)
PC is at cache_free_debugcheck+0x2d4/0x36c
LR is at kfree+0xc8/0x2ac
pc : [<c01125a0>]    lr : [<c0112efc>]    psr: 200d0193
sp : c521fe08  ip : c0e8ef90  fp : c521fe5c
r10: bf0001fc  r9 : c521e000  r8 : c0d99c8c
r7 : c661ebc0  r6 : c065d5a4  r5 : c65c4060  r4 : c78005c0
r3 : 00000000  r2 : 00001000  r1 : c65c4000  r0 : 00000001
Flags: nzCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment user
Control: 10c5387d  Table: 86694019  DAC: 00000015
Process rmmod (pid: 549, stack limit = 0xc521e2f0)
Stack: (0xc521fe08 to 0xc5220000)
fe00:                   c008a874 c00bf44c c515c6d0 200d0193 c65c4860 c515c240
fe20: c521fe3c c521fe30 c008a9c0 c008a854 c521fe5c c65c4860 c78005c0 bf0001fc
fe40: c780ff40 a00d0113 c521e000 00000000 c521fe84 c521fe60 c0112efc c01122d8
fe60: c65c4860 c0673778 c06737ac 00000000 00070013 00000000 c521fe9c c521fe88
fe80: bf0001fc c0112e40 c0673778 bf001ca8 c521feac c521fea0 c02ca11c bf0001ac
fea0: c521fec4 c521feb0 c02c82c4 c02ca100 c0673778 bf001ca8 c521fee4 c521fec8
fec0: c02c8dd8 c02c8250 00000000 bf001ca8 bf001ca8 c0804ee0 c521ff04 c521fee8
fee0: c02c804c c02c8d20 bf001924 00000000 bf001ca8 c521e000 c521ff1c c521ff08
ff00: c02c950c c02c7fbc bf001d48 00000000 c521ff2c c521ff20 c02ca3a4 c02c94b8
ff20: c521ff3c c521ff30 bf001938 c02ca394 c521ffa4 c521ff40 c009beb4 bf001930
ff40: c521ff6c 70616d6f b6fe0032 c0014f84 70616d6f b6fe0032 00000081 60070010
ff60: c521ff84 c521ff70 c008e1f4 c00bf328 0001a004 70616d6f c521ff94 0021ff88
ff80: c008e368 0001a004 70616d6f b6fe0032 00000081 c0015028 00000000 c521ffa8
ffa0: c0014dc0 c009bcd0 0001a004 70616d6f bec2ab38 00000880 bec2ab38 00000880
ffc0: 0001a004 70616d6f b6fe0032 00000081 00000319 00000000 b6fe1000 00000000
ffe0: bec2ab30 bec2ab20 00019f00 b6f539c0 60070010 bec2ab38 aaaaaaaa aaaaaaaa
Backtrace:
[<c01122cc>] (cache_free_debugcheck+0x0/0x36c) from [<c0112efc>] (kfree+0xc8/0x2ac)
[<c0112e34>] (kfree+0x0/0x2ac) from [<bf0001fc>] (omap_nand_remove+0x5c/0x64 [omap2])
[<bf0001a0>] (omap_nand_remove+0x0/0x64 [omap2]) from [<c02ca11c>] (platform_drv_remove+0x28/0x2c)
 r5:bf001ca8 r4:c0673778
[<c02ca0f4>] (platform_drv_remove+0x0/0x2c) from [<c02c82c4>] (__device_release_driver+0x80/0xdc)
[<c02c8244>] (__device_release_driver+0x0/0xdc) from [<c02c8dd8>] (driver_detach+0xc4/0xc8)
 r5:bf001ca8 r4:c0673778
[<c02c8d14>] (driver_detach+0x0/0xc8) from [<c02c804c>] (bus_remove_driver+0x9c/0x104)
 r6:c0804ee0 r5:bf001ca8 r4:bf001ca8 r3:00000000
[<c02c7fb0>] (bus_remove_driver+0x0/0x104) from [<c02c950c>] (driver_unregister+0x60/0x80)
 r6:c521e000 r5:bf001ca8 r4:00000000 r3:bf001924
[<c02c94ac>] (driver_unregister+0x0/0x80) from [<c02ca3a4>] (platform_driver_unregister+0x1c/0x20)
 r5:00000000 r4:bf001d48
[<c02ca388>] (platform_driver_unregister+0x0/0x20) from [<bf001938>] (omap_nand_driver_exit+0x14/0x1c [omap2])
[<bf001924>] (omap_nand_driver_exit+0x0/0x1c [omap2]) from [<c009beb4>] (sys_delete_module+0x1f0/0x2ec)
[<c009bcc4>] (sys_delete_module+0x0/0x2ec) from [<c0014dc0>] (ret_fast_syscall+0x0/0x48)
 r8:c0015028 r7:00000081 r6:b6fe0032 r5:70616d6f r4:0001a004
Code: e1a00005 eb0d9172 e7f001f2 e7f001f2 (e7f001f2)
---[ end trace 6a30b24d8c0cc2ee ]---
Segmentation fault
--->8---

This error was introduced in 67ce04bf2746f8a1f8c2a104b313d20c63f68378 which
was the first commit of this driver.

Signed-off-by: Andreas Bießmann <andreas@biessmann.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agomtd: nand: Use the mirror BBT descriptor when reading its version
Shmulik Ladkani [Sun, 10 Jun 2012 10:58:12 +0000 (13:58 +0300)]
mtd: nand: Use the mirror BBT descriptor when reading its version

commit 7bb9c75436212813b38700c34df4bbb6eb82debe upstream.

The code responsible for reading the version of the mirror bbt was
incorrectly using the descriptor of the main bbt.

Pass the mirror bbt descriptor to 'scan_read_raw' when reading the
version of the mirror bbt.

Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agomtd: nandsim: bugfix: fail if overridesize is too big
Richard Genoud [Wed, 12 Sep 2012 12:26:26 +0000 (14:26 +0200)]
mtd: nandsim: bugfix: fail if overridesize is too big

commit bb0a13a13411c4ce24c48c8ff3cdf7b48d237240 upstream.

If override size is too big, the module was actually loaded instead of
failing, because retval was not set.

This lead to memory corruption with the use of the freed structs nandsim
and nand_chip.

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agomtd: autcpu12-nvram: Fix compile breakage
Alexander Shiyan [Wed, 15 Aug 2012 16:28:05 +0000 (20:28 +0400)]
mtd: autcpu12-nvram: Fix compile breakage

commit d1f55c680e5d021e7066f4461dd678d42af18898 upstream.

Update driver autcpu12-nvram.c so it compiles; map_read32/map_write32
no longer exist in the kernel so the driver is totally broken.
Additionally, map_info name passed to simple_map_init is incorrect.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agomtd: mtdpart: break it as soon as we parse out the partitions
Huang Shijie [Sat, 18 Aug 2012 17:07:41 +0000 (13:07 -0400)]
mtd: mtdpart: break it as soon as we parse out the partitions

commit c51803ddba10d80d9f246066802c6e359cf1d44c upstream.

We may cause a memory leak when the @types has more then one parser.

Take the `default_mtd_part_types` for example. The default_mtd_part_types has
two parsers now: `cmdlinepart` and `ofpart`.

Assume the following case:
The kernel command line sets the partitions like:
#gpmi-nand:20m(boot),20m(kernel),1g(rootfs),-(user)
But the devicetree file(such as arch/arm/boot/dts/imx28-evk.dts) also sets
the same partitions as the kernel command line does.

In the current code, the partitions parsed out by the `ofpart` will
overwrite the @pparts which has already set by the `cmdlinepart` parser,
and the the partitions parsed out by the `cmdlinepart` is missed.
A memory leak occurs.

So we should break the code as soon as we parse out the partitions,
In actually, this patch makes a priority order between the parsers.
If one parser has already parsed out the partitions successfully,
it's no need to use another parser anymore.

Signed-off-by: Huang Shijie <shijie8@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agoRevert "drm/i915: correctly order the ring init sequence"
Greg Kroah-Hartman [Tue, 7 Aug 2012 07:54:14 +0000 (09:54 +0200)]
Revert "drm/i915: correctly order the ring init sequence"

This reverts 622ecb9ace2ec006b58f6779732961945ea303ca which is
commit 0d8957c8a90bbb5d34fab9a304459448a5131e06 upstream.

We may only start to set up the new register values after having
confirmed that the ring is truely off. Otherwise the hw might lose the
newly written register values. This is caught later on in the init
sequence, when we check whether the register writes have stuck.

Reported-by: Andreas Sturmlechner <andreas.sturmlechner@gmail.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Yang Guang <guang.a.yang@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agoCPU hotplug, cpusets, suspend: Don't modify cpusets during suspend/resume
Srivatsa S. Bhat [Thu, 24 May 2012 14:16:26 +0000 (19:46 +0530)]
CPU hotplug, cpusets, suspend: Don't modify cpusets during suspend/resume

commit d35be8bab9b0ce44bed4b9453f86ebf64062721e upstream.

In the event of CPU hotplug, the kernel modifies the cpusets' cpus_allowed
masks as and when necessary to ensure that the tasks belonging to the cpusets
have some place (online CPUs) to run on. And regular CPU hotplug is
destructive in the sense that the kernel doesn't remember the original cpuset
configurations set by the user, across hotplug operations.

However, suspend/resume (which uses CPU hotplug) is a special case in which
the kernel has the responsibility to restore the system (during resume), to
exactly the same state it was in before suspend.

In order to achieve that, do the following:

1. Don't modify cpusets during suspend/resume. At all.
   In particular, don't move the tasks from one cpuset to another, and
   don't modify any cpuset's cpus_allowed mask. So, simply ignore cpusets
   during the CPU hotplug operations that are carried out in the
   suspend/resume path.

2. However, cpusets and sched domains are related. We just want to avoid
   altering cpusets alone. So, to keep the sched domains updated, build
   a single sched domain (containing all active cpus) during each of the
   CPU hotplug operations carried out in s/r path, effectively ignoring
   the cpusets' cpus_allowed masks.

   (Since userspace is frozen while doing all this, it will go unnoticed.)

3. During the last CPU online operation during resume, build the sched
   domains by looking up the (unaltered) cpusets' cpus_allowed masks.
   That will bring back the system to the same original state as it was in
   before suspend.

Ultimately, this will not only solve the cpuset problem related to suspend
resume (ie., restores the cpusets to exactly what it was before suspend, by
not touching it at all) but also speeds up suspend/resume because we avoid
running cpuset update code for every CPU being offlined/onlined.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20120524141611.3692.20155.stgit@srivatsabhat.in.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agoefi: initialize efi.runtime_version to make query_variable_info/update_capsule workable
Seiji Aguchi [Tue, 24 Jul 2012 13:27:23 +0000 (13:27 +0000)]
efi: initialize efi.runtime_version to make query_variable_info/update_capsule workable

commit d6cf86d8f23253225fe2a763d627ecf7dfee9dae upstream.

A value of efi.runtime_version is checked before calling
update_capsule()/query_variable_info() as follows.
But it isn't initialized anywhere.

<snip>
static efi_status_t virt_efi_query_variable_info(u32 attr,
                                                 u64 *storage_space,
                                                 u64 *remaining_space,
                                                 u64 *max_variable_size)
{
        if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION)
                return EFI_UNSUPPORTED;
<snip>

This patch initializes a value of efi.runtime_version at boot time.

Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
Acked-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agoefi: Build EFI stub with EFI-appropriate options
Matthew Garrett [Thu, 26 Jul 2012 22:00:00 +0000 (18:00 -0400)]
efi: Build EFI stub with EFI-appropriate options

commit 9dead5bbb825d7c25c0400e61de83075046322d0 upstream.

We can't assume the presence of the red zone while we're still in a boot
services environment, so we should build with -fno-red-zone to avoid
problems. Change the size of wchar at the same time to make string handling
simpler.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Acked-by: Josh Boyer <jwboyer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agoRevert "KVM: VMX: Fix KVM_SET_SREGS with big real mode segments"
Avi Kivity [Tue, 9 Oct 2012 10:30:01 +0000 (12:30 +0200)]
Revert "KVM: VMX: Fix KVM_SET_SREGS with big real mode segments"

This reverts commit b398aa3174cd.  It
causes a regression with some versions of ipxe.  3.6 has other fixes
that cannot be backported to 3.5, so it is better to live with the
minor problem that b398aa3174cd fixes.

https://bugzilla.redhat.com/show_bug.cgi?id=854983

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agomempolicy: fix a memory corruption by refcount imbalance in alloc_pages_vma()
Mel Gorman [Mon, 8 Oct 2012 23:29:20 +0000 (16:29 -0700)]
mempolicy: fix a memory corruption by refcount imbalance in alloc_pages_vma()

commit 00442ad04a5eac08a98255697c510e708f6082e2 upstream.

Commit cc9a6c877661 ("cpuset: mm: reduce large amounts of memory barrier
related damage v3") introduced a potential memory corruption.
shmem_alloc_page() uses a pseudo vma and it has one significant unique
combination, vma->vm_ops=NULL and vma->policy->flags & MPOL_F_SHARED.

get_vma_policy() does NOT increase a policy ref when vma->vm_ops=NULL
and mpol_cond_put() DOES decrease a policy ref when a policy has
MPOL_F_SHARED.  Therefore, when a cpuset update race occurs,
alloc_pages_vma() falls in 'goto retry_cpuset' path, decrements the
reference count and frees the policy prematurely.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Reviewed-by: Christoph Lameter <cl@linux.com>
Cc: Josh Boyer <jwboyer@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agomempolicy: fix refcount leak in mpol_set_shared_policy()
KOSAKI Motohiro [Mon, 8 Oct 2012 23:29:19 +0000 (16:29 -0700)]
mempolicy: fix refcount leak in mpol_set_shared_policy()

commit 63f74ca21f1fad36d075e063f06dcc6d39fe86b2 upstream.

When shared_policy_replace() fails to allocate new->policy is not freed
correctly by mpol_set_shared_policy().  The problem is that shared
mempolicy code directly call kmem_cache_free() in multiple places where
it is easy to make a mistake.

This patch creates an sp_free wrapper function and uses it. The bug was
introduced pre-git age (IOW, before 2.6.12-rc2).

[mgorman@suse.de: Editted changelog]
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Reviewed-by: Christoph Lameter <cl@linux.com>
Cc: Josh Boyer <jwboyer@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
12 years agomempolicy: fix a race in shared_policy_replace()
Mel Gorman [Mon, 8 Oct 2012 23:29:17 +0000 (16:29 -0700)]
mempolicy: fix a race in shared_policy_replace()

commit b22d127a39ddd10d93deee3d96e643657ad53a49 upstream.

shared_policy_replace() use of sp_alloc() is unsafe.  1) sp_node cannot
be dereferenced if sp->lock is not held and 2) another thread can modify
sp_node between spin_unlock for allocating a new sp node and next
spin_lock.  The bug was introduced before 2.6.12-rc2.

Kosaki's original patch for this problem was to allocate an sp node and
policy within shared_policy_replace and initialise it when the lock is
reacquired.  I was not keen on this approach because it partially
duplicates sp_alloc().  As the paths were sp->lock is taken are not that
performance critical this patch converts sp->lock to sp->mutex so it can
sleep when calling sp_alloc().

[kosaki.motohiro@jp.fujitsu.com: Original patch]
Signed-off-by: Mel Gorman <mgorman@suse.de>
Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reviewed-by: Christoph Lameter <cl@linux.com>
Cc: Josh Boyer <jwboyer@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>