2.6.29-stable review
Subsystems (38)
PATCH 1/51 fiemap: fix problem with setting FIEMAP_EXTENT_LAST
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Josef Bacik <[email protected]>
commit df3935ffd6166fdd00702cf548fb5bb55737758b upstream.
Fix a problem where the generic block based fiemap stuff would not properly set FIEMAP_EXTENT_LAST on the last extent. I've reworked things to keep track if we go past the EOF, and mark the last extent properly. The problem was reported by and tested by Eric Sandeen.
--- fs/ioctl.c | 75 ++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 20 deletions(-)
fs/ioctl.c +51 -15
@@ -258,7 +258,7 @@ int __generic_block_fiemap(struct inodelong long length =0 , map_len =0 ;u64 logical =0 , phys =0 , size =0 ;u32 flags =FIEMAP_EXTENT_MERGED ; -int ret =0 ; +int ret =0 , past_eof =0 , whole_file =0 ;if ((ret =fiemap_check_flags (fieinfo,FIEMAP_FLAG_SYNC )))return ret;
@@ -266,6 +266,9 @@ int __generic_block_fiemap(struct inode start_blk =logical_to_blk (inode, start); length = (long long )min_t (u64, len,i_size_read (inode)); +if (length < len) + whole_file =1 ; + map_len = length; do {
@@ -282,11 +285,26 @@ int __generic_block_fiemap(struct inode/* HOLE */ if (!buffer_mapped (&tmp)) { + length -=blk_to_logical (inode,1 ); + start_blk++; + +/* +* we want to handle the case where there is an +* allocated block at the front of the file, and then +* nothing but holes up to the end of the file properly, +* to make sure that extent at the front gets properly +* marked with FIEMAP_EXTENT_LAST +*/ +if (!past_eof && +blk_to_logical (inode, start_blk) >= +blk_to_logical (inode,0 )+i_size_read (inode)) + past_eof =1 ; +/* * first hole after going past the EOF, this is our * last extent */ -if (length <=0 ) { +if (past_eof && size) { flags =FIEMAP_EXTENT_MERGED |FIEMAP_EXTENT_LAST ; ret = fiemap_fill_next_extent(fieinfo, logical, phys, size,
@@ -294,15 +312,37 @@ int __generic_block_fiemap(struct inodebreak ; } - length -=blk_to_logical (inode,1 ); -/* if we have holes up to/past EOF then we're done */ -if (length <=0 ) +if (length <=0 || past_eof)break ; - - start_blk++; }else { -if (length <=0 && size) { +/* +* we have gone over the length of what we wanted to +* map, and it wasn't the entire file, so add the extent +* we got last time and exit. +* +* This is for the case where say we want to map all the +* way up to the second to the last block in a file, but +* the last block is a hole, making the second to last +* block FIEMAP_EXTENT_LAST. In this case we want to +* see if there is a hole after the second to last block +* so we can mark it properly. If we found data after +* we exceeded the length we were requesting, then we +* are good to go, just add the extent to the fieinfo +* and break +*/ +if (length <=0 && !whole_file) { + ret =fiemap_fill_next_extent (fieinfo, logical, + phys, size, + flags); +break ; + } + +/* +* if size != 0 then we know we already have an extent +* to add, so add it. +*/ +if (size) { ret =fiemap_fill_next_extent (fieinfo, logical, phys, size, flags);
@@ -319,19 +359,14 @@ int __generic_block_fiemap(struct inode start_blk +=logical_to_blk (inode, size);/* -* if we are past the EOF we need to loop again to see -* if there is a hole so we can mark this extent as the -* last one, and if not keep mapping things until we -* find a hole, or we run out of slots in the extent -* array +* If we are past the EOF, then we need to make sure as +* soon as we find a hole that the last extent we found +* is marked with FIEMAP_EXTENT_LAST */ -if (length <=0 ) -continue ;
cover 2.6.29-stable review
This is the start of the stable review cycle for the 2.6.29.4 release. There are 51 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let us know. If anyone is a maintainer of the proper subsystem, and wants to add a Signed-off-by: line to the patch, please respond with it.
These patches are sent out with a number of different people on the Cc:
line. If you wish to be a reviewer, please email [email protected] to add your name to the list. If you want to be off the reviewer list, also email us.
Responses should be made by Saturday, May 16, 20:00:00 UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v2.6/stable-review/patch-2.6.29.4-rc1.gz
and the diffstat can be found below.
thanks,
greg k-h
Documentation/filesystems/Locking | 26 ++- Makefile | 2 +- arch/x86/kvm/svm.c | 1 - arch/x86/kvm/x86.c | 4 +- drivers/dma/dmatest.c | 4 +- drivers/hid/hid-ids.h | 5 + drivers/hid/usbhid/hid-quirks.c | 3 + drivers/hwmon/w83781d.c | 3 +- drivers/i2c/algos/i2c-algo-bit.c | 2 +- drivers/i2c/algos/i2c-algo-pca.c | 11 ++ drivers/md/bitmap.c | 29 ++-- drivers/md/md.c | 7 +- drivers/md/raid10.c | 12 +- drivers/net/e1000/e1000_main.c | 2 +- drivers/net/ehea/ehea_main.c | 31 +++-- drivers/net/ne2k-pci.c | 7 +- drivers/serial/mpc52xx_uart.c | 2 +- drivers/usb/gadget/usbstring.c | 6 +- drivers/usb/serial/ftdi_sio.c | 18 ++- drivers/video/fb_defio.c | 3 +- fs/btrfs/ctree.h | 2 +- fs/btrfs/inode.c | 12 +- fs/buffer.c | 20 ++- fs/cifs/cifs_unicode.h | 7 + fs/cifs/cifssmb.c | 17 +- fs/cifs/connect.c | 6 +- fs/cifs/misc.c | 5 +- fs/cifs/readdir.c | 2 +- fs/cifs/sess.c | 46 +++--- fs/eventpoll.c | 2 +- fs/ext4/ext4.h | 2 +- fs/ext4/inode.c | 5 +- fs/fcntl.c | 6 +- fs/fuse/file.c | 3 +- fs/fuse/inode.c | 1 + fs/gfs2/ops_file.c | 7 +- fs/ioctl.c | 75 +++++++--- fs/lockd/svc.c | 15 ++- fs/nfs/dir.c | 9 +- fs/nfs/file.c | 9 +- fs/nfsd/nfs4xdr.c | 16 ++- fs/ocfs2/file.c | 94 ++++++++++--- fs/ocfs2/mmap.c | 6 +- fs/splice.c | 276 ++++++++++++++++++++++------------- fs/ubifs/file.c | 9 +- fs/xfs/linux-2.6/xfs_file.c | 4 +- include/linux/buffer_head.h | 2 +- include/linux/compiler.h | 3 +- include/linux/mm.h | 3 +- include/linux/splice.h | 12 ++ include/net/cipso_ipv4.h | 17 ++ include/net/netlabel.h | 15 ++- mm/memory.c | 132 ++++++++++++----- net/ipv4/cipso_ipv4.c | 130 ++++++++++++++++ net/ipv4/syncookies.c | 9 +- net/ipv4/tcp_ipv4.c | 7 +- net/mac80211/rc80211_pid_algo.c | 73 +++++----- net/netlabel/netlabel_kapi.c | 84 +++++++++++ security/selinux/hooks.c | 49 ++----- security/selinux/include/netlabel.h | 23 ++- security/selinux/netlabel.c | 185 +++++++----------------- security/smack/smack.h | 1 - security/smack/smack_lsm.c | 130 ++++++++++------- sound/pci/hda/patch_sigmatel.c | 7 +- sound/soc/codecs/wm8990.c | 40 +++--- 65 files changed, 1131 insertions(+), 625 deletions(-)
PATCH 10/51 e1000: fix virtualization bug
2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Jesse Brandeburg <[email protected]>
[STABLE] backport upstream commit e151a60ad1faffb6241cf7eb6846353df1f33a32
a recent fix to e1000 (commit 15b2bee2) caused KVM/QEMU/VMware based virtualized e1000 interfaces to begin failing when resetting.
This is because the driver in a virtual environment doesn't get to run instructions *AT ALL* when an interrupt is asserted. The interrupt code runs immediately and this recent bug fix allows an interrupt to be possible when the interrupt handler will reject it (due to the new code), when being called from any path in the driver that holds the E1000_RESETTING flag.
the driver should use the __E1000_DOWN flag instead of the __E1000_RESETTING flag to prevent interrupt execution while reconfiguring the hardware.
--- drivers/net/e1000/e1000_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/e1000/e1000_main.c +1 -1
@@ -3712,7 +3712,7 @@ static irqreturn_t e1000_intr(int irq, vstruct e1000_hw *hw = &adapter->hw;u32 rctl, icr =er32 (ICR ); -if (unlikely ((!icr) ||test_bit (__E1000_RESETTING, &adapter->flags))) +if (unlikely ((!icr) ||test_bit (__E1000_DOWN, &adapter->flags)))return IRQ_NONE ;/* Not our interrupt */ /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
PATCH 3/51 md: fix some (more) errors with bitmaps on devices larger than 2TB.
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: NeilBrown <[email protected]>
commit db305e507d554430a69ede901a6308e6ecb72349 upstream.
If a write intent bitmap covers more than 2TB, we sometimes work with values beyond 32bit, so these need to be sector_t. This patches add the required casts to some unsigned longs that are being shifted up.
This will affect any raid10 larger than 2TB, or any raid1/4/5/6 with member devices that are larger than 2TB.
--- drivers/md/bitmap.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/md/bitmap.c +11 -7
@@ -1015,9 +1015,11 @@ static int bitmap_init_from_disk(structkunmap_atomic (paddr,KM_USER0 );if (b) {/* if the disk bit is set, set the memory bit */ -bitmap_set_memory_bits (bitmap, i <<CHUNK_BLOCK_SHIFT (bitmap), - ((i+1 ) << (CHUNK_BLOCK_SHIFT (bitmap)) >= start) - ); +int needed = ((sector_t)(i+1 ) << (CHUNK_BLOCK_SHIFT (bitmap)) + >= start); +bitmap_set_memory_bits (bitmap, + (sector_t )i <<CHUNK_BLOCK_SHIFT (bitmap), + needed); bit_cnt++;set_page_attr (bitmap, page,BITMAP_PAGE_CLEAN ); }
@@ -1153,8 +1155,9 @@ void bitmap_daemon_work(struct bitmap *bspin_lock_irqsave (&bitmap->lock, flags);clear_page_attr (bitmap, page,BITMAP_PAGE_CLEAN ); } - bmc =bitmap_get_counter (bitmap, j <<CHUNK_BLOCK_SHIFT (bitmap), - &blocks,0 ); + bmc =bitmap_get_counter (bitmap, + (sector_t )j <<CHUNK_BLOCK_SHIFT (bitmap), + &blocks,0 );if (bmc) {/* if (j < 100) printk("bitmap: j=%lu, *bmc = 0x%x\n", j, *bmc);
@@ -1168,7 +1171,8 @@ void bitmap_daemon_work(struct bitmap *b }else if (*bmc ==1 ) {/* we can clear the bit */ *bmc =0 ; -bitmap_count_page (bitmap, j <<CHUNK_BLOCK_SHIFT (bitmap), +bitmap_count_page (bitmap, + (sector_t )j <<CHUNK_BLOCK_SHIFT (bitmap),-1 );/* clear the bit */
@@ -1484,7 +1488,7 @@ void bitmap_dirty_bits(struct bitmap *biunsigned long chunk;for (chunk = s; chunk <= e; chunk++) { -sector_t sec = chunk <<CHUNK_BLOCK_SHIFT (bitmap); +sector_t sec = (sector_t )chunk <<CHUNK_BLOCK_SHIFT (bitmap);bitmap_set_memory_bits (bitmap, sec,1 );bitmap_file_set_bit (bitmap, sec); }
PATCH 4/51 md/raid10: dont clear bitmap during recovery if array will still be degraded.
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: NeilBrown <[email protected]>
commit 18055569127253755d01733f6ecc004ed02f88d0 upstream.
If we have a raid10 with multiple missing devices, and we recover just one of these to a spare, then we risk (depending on the bitmap and array chunk size) clearing bits of the bitmap for which recovery isn't complete (because a device is still missing).
This can lead to a subsequent "re-add" being recovered without any IO happening, which would result in loss of data.
This patch takes the safe approach of not clearing bitmap bits if the array will still be degraded.
This patch is suitable for all active -stable kernels.
--- drivers/md/raid10.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/md/raid10.c +6 -6
@@ -1807,17 +1807,17 @@ static sector_t sync_request(mddev_t *md r10_bio->sector = sect;raid10_find_phys (conf, r10_bio); -/* Need to check if this section will still be + +/* Need to check if the array will still be * degraded */ -for (j=0 ; j<conf->copies;j++) { -int d = r10_bio->devs[j].devnum; -if (conf->mirrors[d].rdev ==NULL || -test_bit (Faulty, &conf->mirrors[d].rdev->flags)) { +for (j=0 ; j<conf->raid_disks; j++) +if (conf->mirrors[j].rdev ==NULL || +test_bit (Faulty, &conf->mirrors[j].rdev->flags)) { still_degraded =1 ;break ; } - } + must_sync =bitmap_start_sync (mddev->bitmap, sect, &sync_blocks, still_degraded);
PATCH 2/51 md: remove ability to explicit set an inactive array to clean.
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: NeilBrown <[email protected]>
commit 5bf295975416f8e97117bbbcfb0191c00bc3e2b4 upstream.
Being able to write 'clean' to an 'array_state' of an inactive array to activate it in 'clean' mode is both unnecessary and inconvenient.
It is unnecessary because the same can be achieved by writing 'active'. This activates and array, but it still remains 'clean' until the first write.
It is inconvenient because writing 'clean' is more often used to cause an 'active' array to revert to 'clean' mode (thus blocking any writes until a 'write-pending' is promoted to 'active').
Allowing 'clean' to both activate an array and mark an active array as clean can lead to races: One program writes 'clean' to mark the active array as clean at the same time as another program writes 'inactive' to deactivate (stop) and active array. Depending on which writes first, the array could be deactivated and immediately reactivated which isn't what was desired.
So just disable the use of 'clean' to activate an array.
This avoids a race that can be triggered with mdadm-3.0 and external metadata, so it suitable for -stable.
--- drivers/md/md.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/md/md.c +2 -5
@@ -2844,11 +2844,8 @@ array_state_store(mddev_t *mddev, const }else err = -EBUSY ;spin_unlock_irq (&mddev->write_lock); - }else { - mddev->ro =0 ; - mddev->recovery_cp = MaxSector; - err =do_md_run (mddev); - } + }else + err = -EINVAL ;break ;case active:if (mddev->pers) {
PATCH 5/51 md: fix loading of out-of-date bitmap.
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: NeilBrown <[email protected]>
commit b74fd2826c5acce20e6f691437b2d19372bc2057 upstream.
When md is loading a bitmap which it knows is out of date, it fills each page with 1s and writes it back out again. However the write_page call makes used of bitmap->file_pages and bitmap->last_page_size which haven't been set correctly yet. So this can sometimes fail.
Move the setting of file_pages and last_page_size to before the call to write_page.
This bug can cause the assembly on an array to fail, thus making the data inaccessible. Hence I think it is a suitable candidate for -stable.
--- drivers/md/bitmap.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/md/bitmap.c +4 -7
@@ -985,6 +985,9 @@ static int bitmap_init_from_disk(struct oldindex = index; oldpage = page; + bitmap->filemap[bitmap->file_pages++] = page; + bitmap->last_page_size = count; +if (outofdate) {/* * if bitmap is out of date, dirty the
@@ -997,15 +1000,9 @@ static int bitmap_init_from_disk(structwrite_page (bitmap, page,1 ); ret = -EIO ; -if (bitmap->flags &BITMAP_WRITE_ERROR ) { -/* release, page not in filemap yet */ -put_page (page); +if (bitmap->flags &BITMAP_WRITE_ERROR ) goto err; - } } - - bitmap->filemap[bitmap->file_pages++] = page; - bitmap->last_page_size = count; } paddr =kmap_atomic (page,KM_USER0 );if (bitmap->flags &BITMAP_HOSTENDIAN )
PATCH 6/51 usb-serial: ftdi_sio: fix reference counting of ftdi_private
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Alan Stern <[email protected]>
commit c45d63202fbaccef7ef7946c03f27f72c809b1cc upstream.
This patch (as1238) adds proper reference counting for ftdi_sio's private data structure. Without it, the driver will free the structure while it is still in use if the user unplugs the serial device before closing the device file.
The patch also replaces a slightly dangerous cancel_delayed_work/flush_scheduled_work pair with cancel_delayed_work_sync, which is always safer.
--- drivers/usb/serial/ftdi_sio.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/usb/serial/ftdi_sio.c +14 -4
@@ -56,6 +56,7 @@ static __u16 vendor = FTDI_VID;static __u16 product;struct ftdi_private { +struct kref kref;ftdi_chip_type_t chip_type;/* type of device, either SIO or FT8U232AM */ int baud_base;/* baud base clock for divisor setting */
@@ -1352,6 +1353,7 @@ static int ftdi_sio_port_probe(struct usreturn -ENOMEM ; } +kref_init (&priv->kref);spin_lock_init (&priv->rx_lock);spin_lock_init (&priv->tx_lock);init_waitqueue_head (&priv->delta_msr_wait);
@@ -1468,6 +1470,13 @@ static void ftdi_shutdown(struct usb_serdbg ("%s" , __func__); } +static void ftdi_sio_priv_release (struct kref *k) +{ + struct ftdi_private *priv = container_of(k, struct ftdi_private, kref); + +kfree (priv); +} +static int ftdi_sio_port_remove (struct usb_serial_port *port) {struct ftdi_private *priv =usb_get_serial_port_data (port);
@@ -1482,7 +1491,7 @@ static int ftdi_sio_port_remove(struct uif (priv) {usb_set_serial_port_data (port,NULL ); -kfree (priv); +kref_put (&priv->kref, ftdi_sio_priv_release); }return 0 ;
@@ -1547,7 +1556,8 @@ static int ftdi_open(struct tty_struct *dev_err (&port->dev,"%s - failed submitting read urb, error %d\n" , __func__, result); - + else + kref_get(&priv->kref);return result; }/* ftdi_open */
@@ -1589,11 +1599,11 @@ static void ftdi_close(struct tty_structmutex_unlock (&port->serial->disc_mutex);/* cancel any scheduled reading */ -cancel_delayed_work (&priv->rx_work); -flush_scheduled_work (); +cancel_delayed_work_sync (&priv->rx_work);/* shutdown our bulk read */ usb_kill_urb (port->read_urb); +kref_put (&priv->kref, ftdi_sio_priv_release); }/* ftdi_close */
PATCH 7/51 USB: Gadget: fix UTF conversion in the usbstring library
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Alan Stern <[email protected]>
commit 0f43158caddcbb110916212ebe4e39993ae70864 upstream.
This patch (as1234) fixes a bug in the UTF8 -> UTF-16 conversion routine in the gadget/usbstring library. In a UTF-8 multi-byte sequence, all bytes after the first should have their high-order two bits set to 10, not 11.
--- drivers/usb/gadget/usbstring.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/gadget/usbstring.c +3 -3
@@ -38,7 +38,7 @@ static int utf8_to_utf16le(const char *s uchar = (c &0x1f ) <<6 ; c = (u8) *s++; -if ((c &0xc0 ) !=0xc0 ) +if ((c &0xc0 ) !=0x80 ) goto fail; c &=0x3f ; uchar |= c;
@@ -49,13 +49,13 @@ static int utf8_to_utf16le(const char *s uchar = (c &0x0f ) <<12 ; c = (u8) *s++; -if ((c &0xc0 ) !=0xc0 ) +if ((c &0xc0 ) !=0x80 ) goto fail; c &=0x3f ; uchar |= c <<6 ; c = (u8) *s++; -if ((c &0xc0 ) !=0xc0 ) +if ((c &0xc0 ) !=0x80 ) goto fail; c &=0x3f ; uchar |= c;
PATCH 8/51 ALSA: hda - Fix line-in on Mac Mini Core2 Duo
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Takashi Iwai <[email protected]>
commit 5dd17cb992ef4c1ebb1a2d60cbef4b6967974673 upstream.
BIOS on Mac Mini Core2 Duo sets both INPUT and OUTPUT pinctl bits to the line-in jack, and it confuses the driver as if it's a valid input. This patch adds the check of OUTPUT bit so that the driver fixes the invalid pin setup.
--- sound/pci/hda/patch_sigmatel.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
sound/pci/hda/patch_sigmatel.c +6 -1
@@ -4007,7 +4007,12 @@ static int stac92xx_init(struct hda_code pinctl =snd_hda_codec_read (codec, nid,0 ,AC_VERB_GET_PIN_WIDGET_CONTROL ,0 );/* if PINCTL already set then skip */ -if (!(pinctl &AC_PINCTL_IN_EN )) { +/* Also, if both INPUT and OUTPUT are set, +* it must be a BIOS bug; need to override, too +*/ +if (!(pinctl &AC_PINCTL_IN_EN ) || + (pinctl &AC_PINCTL_OUT_EN )) { + pinctl &= ~AC_PINCTL_OUT_EN ; pinctl |=AC_PINCTL_IN_EN ;stac92xx_auto_set_pinctl (codec, nid, pinctl);
PATCH 11/51 hwmon: (w83781d) Fix W83782D support (NULL pointer dereference)
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Jean Delvare <[email protected]>
Commit 848ddf116b3d1711c956fac8627be12dfe8d736f upstream
Commit 360782dde00a2e6e7d9fd57535f90934707ab8a8 (hwmon: (w83781d) Stop abusing struct i2c_client for ISA devices) broke W83782D support for devices connected on the ISA bus. You will hit a NULL pointer dereference as soon as you read any device attribute. Other devices, and W83782D devices on the SMBus, aren't affected.
--- drivers/hwmon/w83781d.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hwmon/w83781d.c +2 -1
@@ -1462,7 +1462,8 @@ static struct w83781d_data *w83781d_upda data->pwm[i] =w83781d_read_value (data,W83781D_REG_PWM [i]); -if ((data->type != w83782d || !client->driver) +/* Only W83782D on SMBus has PWM3 and PWM4 */ +if ((data->type != w83782d || !client) && i ==1 )break ; }
PATCH 12/51 Fix for enabling branch profiling makes sparse unusable
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Bart Van Assche <[email protected]>
commit d9ad8bc0ca823705413f75b50c442a88cc518b35 upstream.
One of the changes between kernels 2.6.28 and 2.6.29 is that a branch profiler has been added for if() statements. Unfortunately this patch makes the sparse output unusable with CONFIG_TRACE_BRANCH_PROFILING=y: when branch profiling is enabled, sparse prints so much false positives that the real issues are no longer visible. This behavior can be reproduced as follows:
* enable CONFIG_TRACE_BRANCH_PROFILING, e.g. by running make allyesconfig or make allmodconfig.
* run make C=2
Result: a huge number of the following sparse warnings.
...include/linux/cpumask.h:547:2: warning: symbol '______r' shadows an earlier one include/linux/cpumask.h:547:2: originally declared here
...
The patch below fixes this by disabling branch profiling while analyzing the kernel code with sparse.
This patch is already included in 2.6.30-rc1 -- see also
http://lkml.org/lkml/2009/4/5/120.
LKML-Reference: <[email protected]>
--- include/linux/compiler.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/compiler.h +2 -1
@@ -75,7 +75,8 @@ struct ftrace_branch_data {* Note: DISABLE_BRANCH_PROFILING can be used by special lowlevel code * to disable branch tracing on a per file basis. */ -#if defined(CONFIG_TRACE_BRANCH_PROFILING ) && !defined(DISABLE_BRANCH_PROFILING ) +#if defined(CONFIG_TRACE_BRANCH_PROFILING ) \ + && !defined(DISABLE_BRANCH_PROFILING ) && !defined(__CHECKER__)void ftrace_likely_update (struct ftrace_branch_data *f,int val,int expect);#define likely_notrace (x) __builtin_expect(!!(x), 1)
PATCH 9/51 ASoC: Fix errors in WM8990
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Jinyoung Park <[email protected]>
commit 97a775c49c7e1b47b016a492463486a5b86da479 upstream.
The mis-typing exist in dapm controller definitions and dapm route definitions, so happen mis-matched error when snd_soc_dapm_add_routes().
--- sound/soc/codecs/wm8990.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
sound/soc/codecs/wm8990.c +20 -20
@@ -744,7 +744,7 @@ SND_SOC_DAPM_MIXER_E("INMIXL", WM8990_IN inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),/* AINLMUX */ -SND_SOC_DAPM_MUX_E ("AILNMUX" ,WM8990_INTDRIVBITS ,WM8990_AINLMUX_PWR_BIT ,0 , +SND_SOC_DAPM_MUX_E ("AINLMUX" ,WM8990_INTDRIVBITS ,WM8990_AINLMUX_PWR_BIT ,0 , &wm8990_dapm_ainlmux_controls, inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
@@ -755,7 +755,7 @@ SND_SOC_DAPM_MIXER_E("INMIXR", WM8990_IN inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),/* AINRMUX */ -SND_SOC_DAPM_MUX_E ("AIRNMUX" ,WM8990_INTDRIVBITS ,WM8990_AINRMUX_PWR_BIT ,0 , +SND_SOC_DAPM_MUX_E ("AINRMUX" ,WM8990_INTDRIVBITS ,WM8990_AINRMUX_PWR_BIT ,0 , &wm8990_dapm_ainrmux_controls, inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
@@ -863,40 +863,40 @@ static const struct snd_soc_dapm_route a {"LIN12 PGA", "LIN2 Switch", "LIN2"},/* LIN34 PGA */ {"LIN34 PGA", "LIN3 Switch", "LIN3"}, - {"LIN34 PGA", "LIN4 Switch", "LIN4"}, + {"LIN34 PGA", "LIN4 Switch", "LIN4/RXN"},/* INMIXL */ {"INMIXL", "Record Left Volume", "LOMIX"}, {"INMIXL", "LIN2 Volume", "LIN2"}, {"INMIXL", "LINPGA12 Switch", "LIN12 PGA"}, {"INMIXL", "LINPGA34 Switch", "LIN34 PGA"}, -/* AILNMUX */ - {"AILNMUX", "INMIXL Mix", "INMIXL"}, - {"AILNMUX", "DIFFINL Mix", "LIN12PGA"}, - {"AILNMUX", "DIFFINL Mix", "LIN34PGA"}, - {"AILNMUX", "RXVOICE Mix", "LIN4/RXN"}, - {"AILNMUX", "RXVOICE Mix", "RIN4/RXP"}, +/* AINLMUX */ + {"AINLMUX", "INMIXL Mix", "INMIXL"}, + {"AINLMUX", "DIFFINL Mix", "LIN12 PGA"}, + {"AINLMUX", "DIFFINL Mix", "LIN34 PGA"}, + {"AINLMUX", "RXVOICE Mix", "LIN4/RXN"}, + {"AINLMUX", "RXVOICE Mix", "RIN4/RXP"},/* ADC */ - {"Left ADC", NULL, "AILNMUX"}, + {"Left ADC", NULL, "AINLMUX"},/* RIN12 PGA */ {"RIN12 PGA", "RIN1 Switch", "RIN1"}, {"RIN12 PGA", "RIN2 Switch", "RIN2"},/* RIN34 PGA */ {"RIN34 PGA", "RIN3 Switch", "RIN3"}, - {"RIN34 PGA", "RIN4 Switch", "RIN4"}, + {"RIN34 PGA", "RIN4 Switch", "RIN4/RXP"},/* INMIXL */ {"INMIXR", "Record Right Volume", "ROMIX"}, {"INMIXR", "RIN2 Volume", "RIN2"}, {"INMIXR", "RINPGA12 Switch", "RIN12 PGA"}, {"INMIXR", "RINPGA34 Switch", "RIN34 PGA"}, -/* AIRNMUX */ - {"AIRNMUX", "INMIXR Mix", "INMIXR"}, - {"AIRNMUX", "DIFFINR Mix", "RIN12PGA"}, - {"AIRNMUX", "DIFFINR Mix", "RIN34PGA"}, - {"AIRNMUX", "RXVOICE Mix", "RIN4/RXN"}, - {"AIRNMUX", "RXVOICE Mix", "RIN4/RXP"}, +/* AINRMUX */ + {"AINRMUX", "INMIXR Mix", "INMIXR"}, + {"AINRMUX", "DIFFINR Mix", "RIN12 PGA"}, + {"AINRMUX", "DIFFINR Mix", "RIN34 PGA"}, + {"AINRMUX", "RXVOICE Mix", "LIN4/RXN"}, + {"AINRMUX", "RXVOICE Mix", "RIN4/RXP"},/* ADC */ - {"Right ADC", NULL, "AIRNMUX"}, + {"Right ADC", NULL, "AINRMUX"},/* LOMIX */ {"LOMIX", "LOMIX RIN3 Bypass Switch", "RIN3"},
@@ -937,7 +937,7 @@ static const struct snd_soc_dapm_route a {"LOPMIX", "LOPMIX Left Mixer PGA Switch", "LOPGA"},/* OUT3MIX */ - {"OUT3MIX", "OUT3MIX LIN4/RXP Bypass Switch", "LIN4/RXP"}, + {"OUT3MIX", "OUT3MIX LIN4/RXP Bypass Switch", "LIN4/RXN"}, {"OUT3MIX", "OUT3MIX Left Out PGA Switch", "LOPGA"}, /* OUT4MIX */
@@ -964,7 +964,7 @@ static const struct snd_soc_dapm_route a/* Output Pins */ {"LON", NULL, "LONMIX"}, {"LOP", NULL, "LOPMIX"}, - {"OUT", NULL, "OUT3MIX"}, + {"OUT3", NULL, "OUT3MIX"}, {"LOUT", NULL, "LOUT PGA"}, {"SPKN", NULL, "SPKMIX"}, {"ROUT", NULL, "ROUT PGA"},
PATCH 13/51 i2c-algo-bit: Fix timeout test
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Dave Airlie <[email protected]>
commit 0cdba07bb23cdd3e0d64357ec3d983e6b75e541f upstream
When fetching DDC using i2c algo bit, we were often seeing timeouts before getting valid EDID on a retry. The VESA spec states 2ms is the DDC timeout, so when this translates into 1 jiffie and we are close to the end of the time period, it could return with a timeout less than 2ms.
Change this code to use time_after instead of time_after_eq.
--- drivers/i2c/algos/i2c-algo-bit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/algos/i2c-algo-bit.c +1 -1
@@ -104,7 +104,7 @@ static int sclhi(struct i2c_algo_bit_dat* chips may hold it low ("clock stretching") while they * are processing data internally. */ -if (time_after_eq (jiffies, start + adap->timeout)) +if (time_after (jiffies, start + adap->timeout))return -ETIMEDOUT ;cond_resched (); }
PATCH 14/51 i2c-algo-pca: Let PCA9564 recover from unacked data byte (state 0x30)
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Enrik Berkhan <[email protected]>
commit 2196d1cf4afab93fb64c2e5b417096e49b661612 upstream
Currently, the i2c-algo-pca driver does nothing if the chip enters state 0x30 (Data byte in I2CDAT has been transmitted; NOT ACK has been received). Thus, the i2c bus connected to the controller gets stuck afterwards.
I have seen this kind of error on a custom board in certain load situations most probably caused by interference or noise.
A possible reaction is to let the controller generate a STOP condition. This is documented in the PCA9564 data sheet (2006-09-01) and the same is done for other NACK states as well.
Further, state 0x38 isn't handled completely, either. Try to do another START in this case like the data sheet says. As this couldn't be tested, I've added a comment to try to reset the chip if the START doesn't help as suggested by Wolfram Sang.
--- drivers/i2c/algos/i2c-algo-pca.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/i2c/algos/i2c-algo-pca.c +11 -0
@@ -270,10 +270,21 @@ static int pca_xfer(struct i2c_adapter *case 0x30 :/* Data byte in I2CDAT has been transmitted; NOT ACK has been received */ DEB2 ("NOT ACK received after data byte\n" ); +pca_stop (adap); goto out;case 0x38 :/* Arbitration lost during SLA+W, SLA+R or data bytes */ DEB2 ("Arbitration lost\n" ); +/* +* The PCA9564 data sheet (2006-09-01) says "A +* START condition will be transmitted when the +* bus becomes free (STOP or SCL and SDA high)" +* when the STA bit is set (p. 11). +* +* In case this won't work, try pca_reset() +* instead. +*/ +pca_start (adap); goto out;case 0x58 :/* Data byte has been received; NOT ACK has been returned */
PATCH 15/51 dup2: Fix return value with oldfd == newfd and invalid fd
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Jeff Mahoney <[email protected]>
commit 2b79bc4f7ebbd5af3c8b867968f9f15602d5f802 upstream.
The return value of dup2 when oldfd == newfd and the fd isn't valid is not getting properly sign extended. We end up with 4294967287 instead of -EBADF.
I've reproduced this on SLE11 (2.6.27.21), openSUSE Factory (2.6.29-rc5), and Ubuntu 9.04 (2.6.28).
This patch uses a signed int for the error value so it is properly extended.
Commit 6c5d0512a091480c9f981162227fdb1c9d70e555 introduced this regression.
--- fs/fcntl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/fcntl.c +4 -2
@@ -117,11 +117,13 @@ SYSCALL_DEFINE2(dup2, unsigned int, oldf {if (unlikely (newfd == oldfd)) {/* corner case */ struct files_struct *files = current->files; +int retval = oldfd; +rcu_read_lock ();if (!fcheck_files (files, oldfd)) - oldfd = -EBADF ; + retval = -EBADF ;rcu_read_unlock (); -return oldfd; +return retval; }return sys_dup3 (oldfd, newfd,0 ); }
PATCH 17/51 lsm: Relocate the IPv4 security_inet_conn_request() hooks
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Paul Moore <[email protected]>
[NOTE: present in Linus' tree as 284904aa79466a4736f4c775fdbe5c7407fa136c]
The current placement of the security_inet_conn_request() hooks do not allow individual LSMs to override the IP options of the connection's request_sock. This is a problem as both SELinux and Smack have the ability to use labeled networking protocols which make use of IP options to carry security attributes and the inability to set the IP options at the start of the TCP handshake is problematic.
This patch moves the IPv4 security_inet_conn_request() hooks past the code where the request_sock's IP options are set/reset so that the LSM can safely manipulate the IP options as needed. This patch intentionally does not change the related IPv6 hooks as IPv6 based labeling protocols which use IPv6 options are not currently implemented, once they are we will have a better idea of the correct placement for the IPv6 hooks.
--- net/ipv4/syncookies.c | 9 +++++---- net/ipv4/tcp_ipv4.c | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-)
net/ipv4/syncookies.c +5 -4
@@ -288,10 +288,6 @@ struct sock *cookie_v4_check(struct sockif (!req) goto out; -if (security_inet_conn_request (sk, skb, req)) { -reqsk_free (req); - goto out; - } ireq =inet_rsk (req); treq =tcp_rsk (req); treq->rcv_isn =ntohl (th->seq) -1 ;
@@ -322,6 +318,11 @@ struct sock *cookie_v4_check(struct sock } } +if (security_inet_conn_request (sk, skb, req)) { +reqsk_free (req); + goto out; + } + req->expires =0UL ; req->retrans =0 ;
net/ipv4/tcp_ipv4.c +4 -3
@@ -1239,14 +1239,15 @@ int tcp_v4_conn_request(struct sock *sk,tcp_openreq_init (req, &tmp_opt, skb); -if (security_inet_conn_request (sk, skb, req)) - goto drop_and_free; - ireq =inet_rsk (req); ireq->loc_addr = daddr; ireq->rmt_addr = saddr; ireq->no_srccheck =inet_sk (sk)->transparent; ireq->opt =tcp_v4_save_options (sk, skb); + +if (security_inet_conn_request (sk, skb, req)) + goto drop_and_free; +if (!want_cookie)TCP_ECN_create_request (req,tcp_hdr (skb));
PATCH 16/51 ne2k-pci: Do not register device until initialized.
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Lubomir Rintel <[email protected]>
commit 379b026ecc20c4657d37e40ead789f7f28f1a1c1 upstream.
Doing it in reverse order causes uevent to be sent before we have a MAC address, which confuses udev.
--- drivers/net/ne2k-pci.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/ne2k-pci.c +3 -4
@@ -373,18 +373,17 @@ static int __devinit ne2k_pci_init_one ( dev->ethtool_ops = &ne2k_pci_ethtool_ops;NS8390_init (dev,0 ); +memcpy (dev->dev_addr, SA_prom,6 ); +memcpy (dev->perm_addr, dev->dev_addr, dev->addr_len); + i =register_netdev (dev);if (i) goto err_out_free_netdev; -for (i =0 ; i <6 ; i++) - dev->dev_addr[i] = SA_prom[i];printk ("%s: %s found at %#lx, IRQ %d, %pM.\n" , dev->name, pci_clone_list[chip_idx].name, ioaddr, dev->irq, dev->dev_addr); -memcpy (dev->perm_addr, dev->dev_addr, dev->addr_len); -return 0 ; err_out_free_netdev:
PATCH 18/51 netlabel: Add CIPSO {set, del}attr request_sock functions
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Paul Moore <[email protected]>
[NOTE: based on 389fb800ac8be2832efedd19978a2b8ced37eb61]
Add the cipso_v4_req_setattr() and cipso_v4_req_delattr() functions to set and delete the CIPSO security attributes on a request_sock used during a incoming connection request.
---
include/net/cipso_ipv4.h | 17 ++++++ net/ipv4/cipso_ipv4.c | 130 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+)
include/net/cipso_ipv4.h +17 -0
@@ -40,6 +40,7 @@#include <linux/net.h> #include <linux/skbuff.h> #include <net/netlabel.h> +#include <net/request_sock.h> #include <asm/atomic.h> /* known doi values */
@@ -215,6 +216,10 @@ int cipso_v4_sock_setattr(struct sock *s const struct netlbl_lsm_secattr *secattr);void cipso_v4_sock_delattr (struct sock *sk);int cipso_v4_sock_getattr (struct sock *sk,struct netlbl_lsm_secattr *secattr); +int cipso_v4_req_setattr (struct request_sock *req, +const struct cipso_v4_doi *doi_def, +const struct netlbl_lsm_secattr *secattr); +void cipso_v4_req_delattr (struct request_sock *req);int cipso_v4_skbuff_setattr (struct sk_buff *skb,const struct cipso_v4_doi *doi_def,const struct netlbl_lsm_secattr *secattr);
@@ -247,6 +252,18 @@ static inline int cipso_v4_sock_getattr(return -ENOSYS ; } +static inline int cipso_v4_req_setattr (struct request_sock *req, +const struct cipso_v4_doi *doi_def, +const struct netlbl_lsm_secattr *secattr) +{ +return -ENOSYS ; +} + +static inline void cipso_v4_req_delattr (struct request_sock *req) +{ +return ; +} +static inline int cipso_v4_skbuff_setattr (struct sk_buff *skb,const struct cipso_v4_doi *doi_def,const struct netlbl_lsm_secattr *secattr)
net/ipv4/cipso_ipv4.c +130 -0
142 lines not on this page · raw message
PATCH 20/51 selinux: Add new NetLabel glue code to handle labeling of connection requests
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Paul Moore <[email protected]>
[NOTE: based on 389fb800ac8be2832efedd19978a2b8ced37eb61]
This patch provides the missing functions to properly handle the labeling of responses to incoming connection requests within SELinux.
---
security/selinux/hooks.c | 4 - security/selinux/include/netlabel.h | 17 +++-- security/selinux/netlabel.c | 118 ++++++++++++++++++------------------ 3 files changed, 72 insertions(+), 67 deletions(-)
security/selinux/hooks.c +1 -3
@@ -3799,7 +3799,7 @@ static int selinux_socket_post_create(st sksec = sock->sk->sk_security; sksec->sid = isec->sid; sksec->sclass = isec->sclass; - err =selinux_netlbl_socket_post_create (sock); + err =selinux_netlbl_socket_post_create (sock->sk, family); }return err;
@@ -4467,8 +4467,6 @@ static void selinux_inet_conn_establishe family =PF_INET ;selinux_skb_peerlbl_sid (skb, family, &sksec->peer_sid); - -selinux_netlbl_inet_conn_established (sk, family); } static void selinux_req_classify_flow(const struct request_sock *req,
security/selinux/include/netlabel.h +12 -5
@@ -32,6 +32,7 @@#include <linux/net.h> #include <linux/skbuff.h> #include <net/sock.h> +#include <net/request_sock.h> #include "avc.h" #include "objsec.h"
@@ -53,8 +54,9 @@ int selinux_netlbl_skbuff_setsid(structu16 family, u32 sid); -void selinux_netlbl_inet_conn_established (struct sock *sk,u16 family); -int selinux_netlbl_socket_post_create (struct socket *sock); +int selinux_netlbl_inet_conn_request (struct request_sock *req,u16 family); +void selinux_netlbl_inet_csk_clone (struct sock *sk,u16 family); +int selinux_netlbl_socket_post_create (struct sock *sk,u16 family);int selinux_netlbl_inode_permission (struct inode *inode,int mask); int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec, struct sk_buff *skb,
@@ -113,12 +115,17 @@ static inline int selinux_netlbl_conn_sereturn 0 ; } -static inline void selinux_netlbl_inet_conn_established (struct sock *sk, -u16 family) +static inline int selinux_netlbl_inet_conn_request (struct request_sock *req, +u16 family) +{ +return 0 ; +} +static inline void selinux_netlbl_inet_csk_clone (struct sock *sk,u16 family) {return ; } -static inline int selinux_netlbl_socket_post_create (struct socket *sock) +static inline int selinux_netlbl_socket_post_create (struct sock *sk, +u16 family) {return 0 ; }
security/selinux/netlabel.c +59 -59
141 lines not on this page · raw message
PATCH 19/51 netlabel: Add new NetLabel KAPI interfaces for request_sock security attributes
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Paul Moore <[email protected]>
[NOTE: based on 389fb800ac8be2832efedd19978a2b8ced37eb61 and
07feee8f812f7327a46186f7604df312c8c81962]
This patch adds the netlbl_req_setattr() and netlbl_req_delattr() functions which can be used by LSMs to set and remove the NetLabel security attributes from request_sock objects used in incoming connection requests.
---
include/net/netlabel.h | 15 +++++++ net/netlabel/netlabel_kapi.c | 84 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-)
include/net/netlabel.h +14 -1
@@ -36,6 +36,7 @@#include <linux/in.h> #include <linux/in6.h> #include <net/netlink.h> +#include <net/request_sock.h> #include <asm/atomic.h> struct cipso_v4_doi ;
@@ -413,6 +414,9 @@ int netlbl_sock_getattr(struct sock *sk,int netlbl_conn_setattr (struct sock *sk,struct sockaddr *addr,const struct netlbl_lsm_secattr *secattr); +int netlbl_req_setattr (struct request_sock *req, +const struct netlbl_lsm_secattr *secattr); +void netlbl_req_delattr (struct request_sock *req);int netlbl_skbuff_setattr (struct sk_buff *skb,u16 family,const struct netlbl_lsm_secattr *secattr);
@@ -519,7 +523,7 @@ static inline int netlbl_enabled(void)return 0 ; }static inline int netlbl_sock_setattr (struct sock *sk, -const struct netlbl_lsm_secattr *secattr) +const struct netlbl_lsm_secattr *secattr) {return -ENOSYS ; }
@@ -537,6 +541,15 @@ static inline int netlbl_conn_setattr(st {return -ENOSYS ; } +static inline int netlbl_req_setattr (struct request_sock *req, +const struct netlbl_lsm_secattr *secattr) +{ +return -ENOSYS ; +} +static inline void netlbl_req_delattr (struct request_sock *req) +{ +return ; +}static inline int netlbl_skbuff_setattr (struct sk_buff *skb,u16 family,const struct netlbl_lsm_secattr *secattr)
net/netlabel/netlabel_kapi.c +84 -0
90 lines not on this page · raw message
PATCH 23/51 smack: Set the proper NetLabel security attributes for connection requests
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Paul Moore <[email protected]>
[NOTE: based on 07feee8f812f7327a46186f7604df312c8c81962]
This patch ensures the correct labeling of new network connection requests using Smack and NetLabel.
---
security/smack/smack.h | 1 security/smack/smack_lsm.c | 130 +++++++++++++++++++++++++-------------------- 2 files changed, 75 insertions(+), 56 deletions(-)
security/smack/smack.h +0 -1
@@ -40,7 +40,6 @@ struct superblock_smack {struct socket_smack {char *smk_out;/* outbound label */ char *smk_in;/* inbound label */ -int smk_labeled;/* label scheme */ char smk_packet[SMK_LABELLEN ];/* TCP peer label */ };
security/smack/smack_lsm.c +75 -55
213 lines not on this page · raw message
PATCH 25/51 cifs: Increase size of tmp_buf in cifs_readdir to avoid potential overflows
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Suresh Jayaraman <[email protected]>
Commit 7b0c8fcff47a885743125dd843db64af41af5a61 refreshed and use a #define from commit f58841666bc22e827ca0dcef7b71c7bc2758ce82.
cifs: Increase size of tmp_buf in cifs_readdir to avoid potential overflows
Increase size of tmp_buf to possible maximum to avoid potential overflows. Also moved UNICODE_NAME_MAX definition so that it can be used elsewhere.
--- fs/cifs/cifs_unicode.h | 7 +++++++ fs/cifs/readdir.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-)
fs/cifs/cifs_unicode.h +7 -0
@@ -64,6 +64,13 @@ int cifs_strtoUCS(__le16 *, const char *#endif /* +* To be safe - for UCS to UTF-8 with strings loaded with the rare long +* characters alloc more to account for such multibyte target UTF-8 +* characters. +*/ +#define UNICODE_NAME_MAX ((4 * NAME_MAX) + 2) + +/* * UniStrcat: Concatenate the second string to the first * * Returns:
fs/cifs/readdir.c +1 -1
@@ -1072,7 +1072,7 @@ int cifs_readdir(struct file *file, voidwith the rare long characters alloc more to account for such multibyte target UTF-8 characters. cifs_unicode.c, which actually does the conversion, has the same limit */ - tmp_buf =kmalloc ((2 *NAME_MAX ) +4 ,GFP_KERNEL ); + tmp_buf =kmalloc (UNICODE_NAME_MAX ,GFP_KERNEL );for (i =0 ; (i < num_to_fill) && (rc ==0 ); i++) {if (current_entry ==NULL ) {/* evaluate whether this case is an error */
PATCH 24/51 cifs: Fix buffer size for tcon->nativeFileSystem field
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Jeff Layton <[email protected]>
Commit f083def68f84b04fe3f97312498911afce79609e refreshed.
cifs: fix buffer size for tcon->nativeFileSystem field
The buffer for this was resized recently to fix a bug. It's still possible however that a malicious server could overflow this field by sending characters in it that are >2 bytes in the local charset. Double the size of the buffer to account for this possibility.
Also get rid of some really strange and seemingly pointless NULL termination. It's NULL terminating the string in the source buffer, but by the time that happens, we've already copied the string.
--- fs/cifs/connect.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
fs/cifs/connect.c +1 -5
@@ -3667,16 +3667,12 @@ CIFSTCon(unsigned int xid, struct cifsSe BCC(smb_buffer_response)) {kfree (tcon->nativeFileSystem); tcon->nativeFileSystem = -kzalloc (2 *(length +1 ),GFP_KERNEL ); +kzalloc ((4 * length) +2 ,GFP_KERNEL );if (tcon->nativeFileSystem)cifs_strfromUCS_le ( tcon->nativeFileSystem, (__le16 *) bcc_ptr, length, nls_codepage); - bcc_ptr +=2 * length; - bcc_ptr[0 ] =0 ;/* null terminate the string */ - bcc_ptr[1 ] =0 ; - bcc_ptr +=2 ; }/* else do not bother copying these information fields*/ }else {
PATCH 26/51 cifs: Fix incorrect destination buffer size in cifs_strncpy_to_host
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Suresh Jayaraman <[email protected]>
Relevant commits 968460ebd8006d55661dec0fb86712b40d71c413 and 066ce6899484d9026acd6ba3a8dbbedb33d7ae1b. Minimal hunks to fix buffer size and fix an existing problem pointed out by Guenter Kukuk that length of src is used for NULL termination of dst.
cifs: Rename cifs_strncpy_to_host and fix buffer size
There is a possibility for the path_name and node_name buffers to overflow if they contain charcters that are >2 bytes in the local charset. Resize the buffer allocation so to avoid this possibility.
Also, as pointed out by Jeff Layton, it would be appropriate to rename the function to cifs_strlcpy_to_host to reflect the fact that the copied string is always NULL terminated.
--- fs/cifs/cifssmb.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
fs/cifs/cifssmb.c +8 -9
@@ -91,23 +91,22 @@ static int cifs_strncpy_to_host(char **dst, const char *src, const int maxlen, const bool is_unicode, const struct nls_table *nls_codepage) { -int plen; +int src_len, dst_len;if (is_unicode) { - plen =UniStrnlen ((wchar_t *)src, maxlen); - *dst =kmalloc (plen +2 ,GFP_KERNEL ); + src_len =UniStrnlen ((wchar_t *)src, maxlen); + *dst =kmalloc ((4 * src_len) +2 ,GFP_KERNEL );if (!*dst) goto cifs_strncpy_to_host_ErrExit; -cifs_strfromUCS_le (*dst, (__le16 *)src, plen, nls_codepage); + dst_len =cifs_strfromUCS_le (*dst, (__le16 *)src, src_len, nls_codepage); + (*dst)[dst_len +1 ] =0 ; }else { - plen =strnlen (src, maxlen); - *dst =kmalloc (plen +2 ,GFP_KERNEL ); + src_len =strnlen (src, maxlen); + *dst =kmalloc (src_len +1 ,GFP_KERNEL );if (!*dst) goto cifs_strncpy_to_host_ErrExit; -strncpy (*dst, src, plen); +strlcpy (*dst, src, src_len +1 ); } - (*dst)[plen] =0 ; - (*dst)[plen+1 ] =0 ;/* harmless for ASCII case, needed for Unicode */ return 0 ; cifs_strncpy_to_host_ErrExit:
PATCH 27/51 cifs: Fix buffer size in cifs_convertUCSpath
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Suresh Jayaraman <[email protected]>
Relevant commits 7fabf0c9479fef9fdb9528a5fbdb1cb744a744a4 and f58841666bc22e827ca0dcef7b71c7bc2758ce82. The upstream commits adds cifs_from_ucs2 that includes functionality of cifs_convertUCSpath and does cleanup.
--- fs/cifs/misc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/cifs/misc.c +3 -2
@@ -691,14 +691,15 @@ cifs_convertUCSpath(char *target, const NLS_MAX_CHARSET_SIZE);if (len >0 ) { j += len; -continue ; + goto overrun_chk; }else { target[j] ='?' ; } } j++;/* make sure we do not overrun callers allocated temp buffer */ -if (j >= (2 *NAME_MAX )) +overrun_chk: +if (j >=UNICODE_NAME_MAX )break ; } cUCS_out:
PATCH 28/51 cifs: Fix unicode string area word alignment in session setup
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Jeff Layton <[email protected]>
commit 27b87fe52baba0a55e9723030e76fce94fabcea4 refreshed.
cifs: fix unicode string area word alignment in session setup
The handling of unicode string area alignment is wrong. decode_unicode_ssetup improperly assumes that it will always be preceded by a pad byte. This isn't the case if the string area is already word-aligned.
This problem, combined with the bad buffer sizing for the serverDomain string can cause memory corruption. The bad alignment can make it so that the alignment of the characters is off. This can make them translate to characters that are greater than 2 bytes each. If this happens we can overflow the allocation.
Fix this by fixing the alignment in CIFS_SessSetup instead so we can verify it against the head of the response. Also, clean up the workaround for improperly terminated strings by checking for a odd-length unicode buffers and then forcibly terminating them.
Finally, resize the buffer for serverDomain. Now that we've fixed the alignment, it's probably fine, but a malicious server could overflow it.
A better solution for handling these strings is still needed, but this should be a suitable bandaid.
--- fs/cifs/sess.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-)
fs/cifs/sess.c +23 -21
@@ -285,27 +285,26 @@ static int decode_unicode_ssetup(char **int words_left, len;char *data = *pbcc_area; - -cFYI (1 , ("bleft %d" , bleft)); - -/* SMB header is unaligned, so cifs servers word align start of -Unicode strings */ - data++; - bleft--;/* Windows servers do not always double null terminate -their final Unicode string - in which case we -now will not attempt to decode the byte of junk -which follows it */ +/* +* Windows servers do not always double null terminate their final +* Unicode string. Check to see if there are an uneven number of bytes +* left. If so, then add an extra NULL pad byte to the end of the +* response. +* +* See section 2.7.2 in "Implementing CIFS" for details +*/ +if (bleft %2 ) { + data[bleft] =0 ; + ++bleft; + } words_left = bleft /2 ;/* save off server operating system */ len =UniStrnlen ((wchar_t *) data, words_left); -/* We look for obvious messed up bcc or strings in response so we do not go off -the end since (at least) WIN2K and Windows XP have a major bug in not null -terminating last Unicode string in response */ if (len >= words_left)return rc;
@@ -343,13 +342,10 @@ static int decode_unicode_ssetup(char **return rc;kfree (ses->serverDomain); - ses->serverDomain =kzalloc (2 * (len +1 ),GFP_KERNEL );/* BB FIXME wrong length */ -if (ses->serverDomain !=NULL ) { + ses->serverDomain =kzalloc ((4 * len) +2 ,GFP_KERNEL ); +if (ses->serverDomain !=NULL )cifs_strfromUCS_le (ses->serverDomain, (__le16 *)data, len, nls_cp); - ses->serverDomain[2 *len] =0 ; - ses->serverDomain[(2 *len) +1 ] =0 ; - } data +=2 * (len +1 ); words_left -= len +1 ;
@@ -702,12 +698,18 @@ CIFS_SessSetup(unsigned int xid, struct }/* BB check if Unicode and decode strings */ -if (smb_buf->Flags2 &SMBFLG2_UNICODE ) +if (smb_buf->Flags2 &SMBFLG2_UNICODE ) { +/* unicode string area must be word-aligned */ +if (((unsigned long ) bcc_ptr - (unsigned long ) smb_buf) %2 ) { + ++bcc_ptr; + --bytes_remaining; + } rc =decode_unicode_ssetup (&bcc_ptr, bytes_remaining, - ses, nls_cp); -else + ses, nls_cp); + }else { rc =decode_ascii_ssetup (&bcc_ptr, bytes_remaining, ses, nls_cp); + } ssetup_exit:if (spnego_key) {
PATCH 31/51 fs: fix page_mkwrite error cases in core code and btrfs
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Nick Piggin <[email protected]>
commit 56a76f8275c379ed73c8a43cfa1dfa2f5e9cfa19 upstream.
page_mkwrite is called with neither the page lock nor the ptl held. This means a page can be concurrently truncated or invalidated out from underneath it. Callers are supposed to prevent truncate races themselves, however previously the only thing they can do in case they hit one is to raise a SIGBUS. A sigbus is wrong for the case that the page has been invalidated or truncated within i_size (eg. hole punched). Callers may also have to perform memory allocations in this path, where again, SIGBUS would be wrong.
The previous patch ("mm: page_mkwrite change prototype to match fault") made it possible to properly specify errors. Convert the generic buffer.c code and btrfs to return sane error values (in the case of page removed from pagecache, VM_FAULT_NOPAGE will cause the fault handler to exit without doing anything, and the fault will be retried properly).
This fixes core code, and converts btrfs as a template/example. All other filesystems defining their own page_mkwrite should be fixed in a similar manner.
--- fs/btrfs/inode.c | 11 +++++++---- fs/buffer.c | 12 ++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-)
fs/btrfs/inode.c +7 -4
@@ -4307,10 +4307,15 @@ int btrfs_page_mkwrite(struct vm_area_stu64 page_end; ret =btrfs_check_data_free_space (root, inode,PAGE_CACHE_SIZE ); -if (ret) +if (ret) { +if (ret == -ENOMEM ) + ret =VM_FAULT_OOM ; +else /* -ENOSPC, -EIO, etc */ + ret =VM_FAULT_SIGBUS ; goto out; + } - ret = -EINVAL ; + ret =VM_FAULT_NOPAGE ;/* make the VM retry the fault */ again:lock_page (page); size =i_size_read (inode);
@@ -4363,8 +4368,6 @@ again: out_unlock:unlock_page (page); out: -if (ret) - ret =VM_FAULT_SIGBUS ;return ret; }
fs/buffer.c +8 -4
@@ -2472,7 +2472,7 @@ block_page_mkwrite(struct vm_area_structstruct inode *inode = vma->vm_file->f_path.dentry->d_inode;unsigned long end;loff_t size; -int ret = -EINVAL ; +int ret =VM_FAULT_NOPAGE ;/* make the VM retry the fault */ lock_page (page); size =i_size_read (inode);
@@ -2492,10 +2492,14 @@ block_page_mkwrite(struct vm_area_structif (!ret) ret =block_commit_write (page,0 , end); -out_unlock: -if (ret) - ret =VM_FAULT_SIGBUS ; +if (unlikely (ret)) { +if (ret == -ENOMEM ) + ret =VM_FAULT_OOM ; +else /* -ENOSPC, -EIO, etc */ + ret =VM_FAULT_SIGBUS ; + } +out_unlock:unlock_page (page);return ret; }
PATCH 32/51 mm: close page_mkwrite races
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Nick Piggin <[email protected]>
commit b827e496c893de0c0f142abfaeb8730a2fd6b37f upstream.
Change page_mkwrite to allow implementations to return with the page locked, and also change it's callers (in page fault paths) to hold the lock until the page is marked dirty. This allows the filesystem to have full control of page dirtying events coming from the VM.
Rather than simply hold the page locked over the page_mkwrite call, we call page_mkwrite with the page unlocked and allow callers to return with it locked, so filesystems can avoid LOR conditions with page lock.
The problem with the current scheme is this: a filesystem that wants to associate some metadata with a page as long as the page is dirty, will perform this manipulation in its ->page_mkwrite. It currently then must return with the page unlocked and may not hold any other locks (according to existing page_mkwrite convention).
In this window, the VM could write out the page, clearing page-dirty. The filesystem has no good way to detect that a dirty pte is about to be attached, so it will happily write out the page, at which point, the filesystem may manipulate the metadata to reflect that the page is no longer dirty.
It is not always possible to perform the required metadata manipulation in ->set_page_dirty, because that function cannot block or fail. The filesystem may need to allocate some data structure, for example.
And the VM cannot mark the pte dirty before page_mkwrite, because page_mkwrite is allowed to fail, so we must not allow any window where the page could be written to if page_mkwrite does fail.
This solution of holding the page locked over the 3 critical operations (page_mkwrite, setting the pte dirty, and finally setting the page dirty) closes out races nicely, preventing page cleaning for writeout being initiated in that window. This provides the filesystem with a strong synchronisation against the VM here.
- Sage needs this race closed for ceph filesystem.
- Trond for NFS (http://bugzilla.kernel.org/show_bug.cgi?id=12913).
- I need it for fsblock.
- I suspect other filesystems may need it too (eg. btrfs).
- I have converted buffer.c to the new locking. Even simple block allocation under dirty pages might be susceptible to i_size changing under partial page at the end of file (we also have a buffer.c-side problem here, but it cannot be fixed properly without this patch).
- Other filesystems (eg. NFS, maybe btrfs) will need to change their page_mkwrite functions themselves.
[ This also moves page_mkwrite another step closer to fault, which should
eventually allow page_mkwrite to be moved into ->fault, and thus avoiding a filesystem calldown and page lock/unlock cycle in __do_fault. ]
--- Documentation/filesystems/Locking | 24 +++++--- fs/buffer.c | 10 ++- mm/memory.c | 108 ++++++++++++++++++++++++++------------ 3 files changed, 98 insertions(+), 44 deletions(-)
Documentation/filesystems/Locking +16 -8
@@ -509,16 +509,24 @@ locking rules: BKL mmap_sem PageLocked(page) open: no yes close: no yes -fault: no yes -page_mkwrite: no yes no +fault: no yes can return with page locked +page_mkwrite: no yes can return with page locked access: no yes - ->page_mkwrite() is called when a previously read-only page is -about to become writeable. The file system is responsible for -protecting against truncate races. Once appropriate action has been -taking to lock out truncate, the page range should be verified to be -within i_size. The page mapping should also be checked that it is not -NULL. + ->fault() is called when a previously not present pte is about +to be faulted in. The filesystem must find and return the page associated +with the passed in "pgoff" in the vm_fault structure. If it is possible that +the page may be truncated and/or invalidated, then the filesystem must lock +the page, then ensure it is not already truncated (the page lock will block +subsequent truncate), and then return with VM_FAULT_LOCKED, and the page +locked. The VM will unlock the page. + + ->page_mkwrite() is called when a previously read-only pte is +about to become writeable. The filesystem again must ensure that there are +no truncate/invalidate races, and then return with the page locked. If +the page has been truncated, the filesystem should not look up a new page +like the ->fault() handler, but simply return with VM_FAULT_NOPAGE, which +will cause the VM to retry the fault. ->access() is called when get_user_pages() fails in acces_process_vm(), typically used to debug a process through
fs/buffer.c +6 -4
@@ -2479,7 +2479,8 @@ block_page_mkwrite(struct vm_area_structif ((page->mapping != inode->i_mapping) || (page_offset (page) > size)) {/* page got truncated out from underneath us */ - goto out_unlock; +unlock_page (page); + goto out; }/* page is wholly or partially inside EOF */
@@ -2493,14 +2494,15 @@ block_page_mkwrite(struct vm_area_struct ret =block_commit_write (page,0 , end);if (unlikely (ret)) { +unlock_page (page);if (ret == -ENOMEM ) ret =VM_FAULT_OOM ;else /* -ENOSPC, -EIO, etc */ ret =VM_FAULT_SIGBUS ; - } + }else + ret =VM_FAULT_LOCKED ; -out_unlock: -unlock_page (page); +out:return ret; }
mm/memory.c +76 -32
162 lines not on this page · raw message
PATCH 33/51 GFS2: Fix page_mkwrite() return code
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Steven Whitehouse <[email protected]>
commit e56985da455b9dc0591b8cb2006cc94b6f4fb0f4 upstream.
This allows for the possibility of returning VM_FAULT_OOM as well as VM_FAULT_SIGBUS. This ensures that the correct action is taken.
--- fs/gfs2/ops_file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/gfs2/ops_file.c +3 -1
@@ -410,7 +410,9 @@ out_unlock:gfs2_glock_dq (&gh); out:gfs2_holder_uninit (&gh); -if (ret) +if (ret == -ENOMEM ) + ret =VM_FAULT_OOM ; +else if (ret) ret =VM_FAULT_SIGBUS ;return ret; }
PATCH 30/51 mm: page_mkwrite change prototype to match fault
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Nick Piggin <[email protected]>
commit c2ec175c39f62949438354f603f4aa170846aabb upstream.
Change the page_mkwrite prototype to take a struct vm_fault, and return VM_FAULT_xxx flags. There should be no functional change.
This makes it possible to return much more detailed error information to the VM (and also can provide more information eg. virtual_address to the driver, which might be important in some special cases).
This is required for a subsequent fix. And will also make it easier to merge page_mkwrite() with fault() in future.
--- Documentation/filesystems/Locking | 2 +- drivers/video/fb_defio.c | 3 ++- fs/btrfs/ctree.h | 2 +- fs/btrfs/inode.c | 5 ++++- fs/buffer.c | 6 +++++- fs/ext4/ext4.h | 2 +- fs/ext4/inode.c | 5 ++++- fs/fuse/file.c | 3 ++- fs/gfs2/ops_file.c | 5 ++++- fs/nfs/file.c | 5 ++++- fs/ocfs2/mmap.c | 6 ++++-- fs/ubifs/file.c | 9 ++++++--- fs/xfs/linux-2.6/xfs_file.c | 4 ++-- include/linux/buffer_head.h | 2 +- include/linux/mm.h | 3 ++- mm/memory.c | 26 ++++++++++++++++++++++---- 16 files changed, 65 insertions(+), 23 deletions(-)
Documentation/filesystems/Locking +1 -1
@@ -502,7 +502,7 @@ prototypes: void (*open)(struct vm_area_struct*); void (*close)(struct vm_area_struct*); int (*fault)(struct vm_area_struct*, struct vm_fault *); - int (*page_mkwrite)(struct vm_area_struct *, struct page *); + int (*page_mkwrite)(struct vm_area_struct *, struct vm_fault *); int (*access)(struct vm_area_struct *, unsigned long, void*, int, int); locking rules:
drivers/video/fb_defio.c +2 -1
@@ -85,8 +85,9 @@ EXPORT_SYMBOL_GPL(fb_deferred_io_fsync);/* vm_ops->page_mkwrite handler */ static int fb_deferred_io_mkwrite (struct vm_area_struct *vma, -struct page *page) +struct vm_fault *vmf) { +struct page *page = vmf->page;struct fb_info *info = vma->vm_private_data;struct fb_deferred_io *fbdefio = info->fbdefio;struct page *cur;
fs/btrfs/ctree.h +1 -1
@@ -2060,7 +2060,7 @@ int btrfs_merge_bio_hook(struct page *paunsigned long btrfs_force_ra (struct address_space *mapping,struct file_ra_state *ra,struct file *file,pgoff_t offset,pgoff_t last_index); -int btrfs_page_mkwrite (struct vm_area_struct *vma,struct page *page); +int btrfs_page_mkwrite (struct vm_area_struct *vma,struct vm_fault *vmf);int btrfs_readpage (struct file *file,struct page *page);void btrfs_delete_inode (struct inode *inode);void btrfs_put_inode (struct inode *inode);
fs/btrfs/inode.c +4 -1
@@ -4292,8 +4292,9 @@ static void btrfs_invalidatepage(struct* beyond EOF, then the page is guaranteed safe against truncation until we * unlock the page. */ -int btrfs_page_mkwrite (struct vm_area_struct *vma,struct page *page) +int btrfs_page_mkwrite (struct vm_area_struct *vma,struct vm_fault *vmf) { +struct page *page = vmf->page;struct inode *inode =fdentry (vma->vm_file)->d_inode;struct btrfs_root *root =BTRFS_I (inode)->root;struct extent_io_tree *io_tree = &BTRFS_I (inode)->io_tree;
@@ -4362,6 +4363,8 @@ again: out_unlock:unlock_page (page); out: +if (ret) + ret =VM_FAULT_SIGBUS ;return ret; }
fs/buffer.c +5 -1
@@ -2465,9 +2465,10 @@ int block_commit_write(struct page *page* unlock the page. */ int -block_page_mkwrite (struct vm_area_struct *vma,struct page *page, +block_page_mkwrite (struct vm_area_struct *vma,struct vm_fault *vmf,get_block_t get_block) { +struct page *page = vmf->page;struct inode *inode = vma->vm_file->f_path.dentry->d_inode;unsigned long end;loff_t size;
@@ -2492,6 +2493,9 @@ block_page_mkwrite(struct vm_area_struct ret =block_commit_write (page,0 , end); out_unlock: +if (ret) + ret =VM_FAULT_SIGBUS ; +unlock_page (page);return ret; }
fs/ext4/ext4.h +1 -1
@@ -1097,7 +1097,7 @@ extern int ext4_meta_trans_blocks(structextern int ext4_chunk_trans_blocks (struct inode *,int nrblocks);extern int ext4_block_truncate_page (handle_t *handle,struct address_space *mapping,loff_t from); -extern int ext4_page_mkwrite (struct vm_area_struct *vma,struct page *page); +extern int ext4_page_mkwrite (struct vm_area_struct *vma,struct vm_fault *vmf);/* ioctl.c */ extern long ext4_ioctl (struct file *,unsigned int ,unsigned long );
fs/ext4/inode.c +4 -1
@@ -5116,8 +5116,9 @@ static int ext4_bh_unmapped(handle_t *hareturn !buffer_mapped (bh); } -int ext4_page_mkwrite (struct vm_area_struct *vma,struct page *page) +int ext4_page_mkwrite (struct vm_area_struct *vma,struct vm_fault *vmf) { +struct page *page = vmf->page;loff_t size;unsigned long len;int ret = -EINVAL ;
@@ -5169,6 +5170,8 @@ int ext4_page_mkwrite(struct vm_area_str goto out_unlock; ret =0 ; out_unlock: +if (ret) + ret =VM_FAULT_SIGBUS ;up_read (&inode->i_alloc_sem);return ret; }
fs/fuse/file.c +2 -1
@@ -1234,8 +1234,9 @@ static void fuse_vma_close(struct vm_are* - sync(2) * - try_to_free_pages() with order > PAGE_ALLOC_COSTLY_ORDER */ -static int fuse_page_mkwrite (struct vm_area_struct *vma,struct page *page) +static int fuse_page_mkwrite (struct vm_area_struct *vma,struct vm_fault *vmf) { +struct page *page = vmf->page;/* * Don't use page->mapping as it may become NULL from a * concurrent truncate.
fs/gfs2/ops_file.c +4 -1
@@ -336,8 +336,9 @@ static int gfs2_allocate_page_backing(st* blocks allocated on disk to back that page. */ -static int gfs2_page_mkwrite (struct vm_area_struct *vma,struct page *page) +static int gfs2_page_mkwrite (struct vm_area_struct *vma,struct vm_fault *vmf) { +struct page *page = vmf->page;struct inode *inode = vma->vm_file->f_path.dentry->d_inode;struct gfs2_inode *ip =GFS2_I (inode);struct gfs2_sbd *sdp =GFS2_SB (inode);
@@ -409,6 +410,8 @@ out_unlock:gfs2_glock_dq (&gh); out:gfs2_holder_uninit (&gh); +if (ret) + ret =VM_FAULT_SIGBUS ;return ret; }
fs/nfs/file.c +4 -1
@@ -451,8 +451,9 @@ const struct address_space_operations nf .launder_page = nfs_launder_page, }; -static int nfs_vm_page_mkwrite (struct vm_area_struct *vma,struct page *page) +static int nfs_vm_page_mkwrite (struct vm_area_struct *vma,struct vm_fault *vmf) { +struct page *page = vmf->page;struct file *filp = vma->vm_file;struct dentry *dentry = filp->f_path.dentry;unsigned pagelen;
@@ -483,6 +484,8 @@ static int nfs_vm_page_mkwrite(struct vm ret = pagelen; out_unlock:unlock_page (page); +if (ret) + ret =VM_FAULT_SIGBUS ;return ret; }
fs/ocfs2/mmap.c +4 -2
@@ -154,8 +154,9 @@ out:return ret; } -static int ocfs2_page_mkwrite (struct vm_area_struct *vma,struct page *page) +static int ocfs2_page_mkwrite (struct vm_area_struct *vma,struct vm_fault *vmf) { +struct page *page = vmf->page;struct inode *inode = vma->vm_file->f_path.dentry->d_inode;struct buffer_head *di_bh =NULL ;sigset_t blocked, oldset;
@@ -196,7 +197,8 @@ out: ret2 =ocfs2_vm_op_unblock_sigs (&oldset);if (ret2 <0 )mlog_errno (ret2); - +if (ret) + ret =VM_FAULT_SIGBUS ;return ret; }
fs/ubifs/file.c +6 -3
@@ -1434,8 +1434,9 @@ static int ubifs_releasepage(struct page* mmap()d file has taken write protection fault and is being made * writable. UBIFS must ensure page is budgeted for. */ -static int ubifs_vm_page_mkwrite (struct vm_area_struct *vma,struct page *page) +static int ubifs_vm_page_mkwrite (struct vm_area_struct *vma,struct vm_fault *vmf) { +struct page *page = vmf->page;struct inode *inode = vma->vm_file->f_path.dentry->d_inode;struct ubifs_info *c = inode->i_sb->s_fs_info;struct timespec now =ubifs_current_time (inode);
@@ -1447,7 +1448,7 @@ static int ubifs_vm_page_mkwrite(structubifs_assert (!(inode->i_sb->s_flags &MS_RDONLY ));if (unlikely (c->ro_media)) -return -EROFS ; +return VM_FAULT_SIGBUS ;/* -EROFS */ /* * We have not locked @page so far so we may budget for changing the
@@ -1480,7 +1481,7 @@ static int ubifs_vm_page_mkwrite(structif (err == -ENOSPC )ubifs_warn ("out of space for mmapped file " "(inode number %lu)" , inode->i_ino); -return err; +return VM_FAULT_SIGBUS ; }lock_page (page);
@@ -1520,6 +1521,8 @@ static int ubifs_vm_page_mkwrite(struct out_unlock:unlock_page (page);ubifs_release_budget (c, &req); +if (err) + err =VM_FAULT_SIGBUS ;return err; }
fs/xfs/linux-2.6/xfs_file.c +2 -2
@@ -234,9 +234,9 @@ xfs_file_mmap( STATIC intxfs_vm_page_mkwrite (struct vm_area_struct *vma, -struct page *page) +struct vm_fault *vmf) { -return block_page_mkwrite (vma, page, xfs_get_blocks); +return block_page_mkwrite (vma, vmf, xfs_get_blocks); }const struct file_operations xfs_file_operations = {
include/linux/buffer_head.h +1 -1
@@ -223,7 +223,7 @@ int cont_write_begin(struct file *, stru get_block_t *, loff_t *);int generic_cont_expand_simple (struct inode *inode,loff_t size);int block_commit_write (struct page *page,unsigned from,unsigned to); -int block_page_mkwrite (struct vm_area_struct *vma,struct page *page, +int block_page_mkwrite (struct vm_area_struct *vma,struct vm_fault *vmf,get_block_t get_block);void block_sync_page (struct page *);sector_t generic_block_bmap (struct address_space *,sector_t ,get_block_t *);
include/linux/mm.h +2 -1
@@ -145,6 +145,7 @@ extern pgprot_t protection_map[16];#define FAULT_FLAG_WRITE 0x01/* Fault was a write access */ #define FAULT_FLAG_NONLINEAR 0x02/* Fault was via a nonlinear mapping */ +#define FAULT_FLAG_MKWRITE 0x04/* Fault was mkwrite of existing pte */ /* * This interface is used by x86 PAT code to identify a pfn mapping that is
@@ -197,7 +198,7 @@ struct vm_operations_struct {/* notification that a previously read-only page is about to become * writable, if an error is returned it will cause a SIGBUS */ -int (*page_mkwrite)(struct vm_area_struct *vma,struct page *page); +int (*page_mkwrite)(struct vm_area_struct *vma,struct vm_fault *vmf);/* called by access_process_vm when get_user_pages() fails, typically * for use by special VMAs that can switch between memory and hardware
mm/memory.c +22 -4
@@ -1940,6 +1940,15 @@ static int do_wp_page(struct mm_struct ** get_user_pages(.write=1, .force=1). */ if (vma->vm_ops && vma->vm_ops->page_mkwrite) { +struct vm_fault vmf; +int tmp; + + vmf.virtual_address = (void __user *)(address & +PAGE_MASK ); + vmf.pgoff = old_page->index; + vmf.flags =FAULT_FLAG_WRITE |FAULT_FLAG_MKWRITE ; + vmf.page = old_page; +/* * Notify the address space that the page is about to * become writable so that it can prohibit this or wait
@@ -1951,8 +1960,12 @@ static int do_wp_page(struct mm_struct *page_cache_get (old_page);pte_unmap_unlock (page_table, ptl); -if (vma->vm_ops->page_mkwrite (vma, old_page) <0 ) + tmp = vma->vm_ops->page_mkwrite (vma, &vmf); +if (unlikely (tmp & + (VM_FAULT_ERROR |VM_FAULT_NOPAGE ))) { + ret = tmp; goto unwritable_page; + }/* * Since we dropped the lock we need to revalidate
@@ -2101,7 +2114,7 @@ oom: unwritable_page:page_cache_release (old_page); -return VM_FAULT_SIGBUS ; +return ret; }/*
@@ -2645,9 +2658,14 @@ static int __do_fault(struct mm_struct ** to become writable */ if (vma->vm_ops->page_mkwrite) { +int tmp; +unlock_page (page); -if (vma->vm_ops->page_mkwrite (vma, page) <0 ) { - ret =VM_FAULT_SIGBUS ; + vmf.flags |=FAULT_FLAG_MKWRITE ; + tmp = vma->vm_ops->page_mkwrite (vma, &vmf); +if (unlikely (tmp & + (VM_FAULT_ERROR |VM_FAULT_NOPAGE ))) { + ret = tmp; anon =1 ;/* no anon but release vmf.page */ goto out_unlocked; }
PATCH 34/51 NFS: Fix the return value in nfs_page_mkwrite()
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Trond Myklebust <[email protected]>
commit 2b2ec7554cf7ec5e4412f89a5af6abe8ce950700 upstream.
Commit c2ec175c39f62949438354f603f4aa170846aabb ("mm: page_mkwrite change prototype to match fault") exposed a bug in the NFS implementation of page_mkwrite. We should be returning 0 on success...
--- fs/nfs/file.c | 2 -- 1 file changed, 2 deletions(-)
fs/nfs/file.c +0 -2
@@ -480,8 +480,6 @@ static int nfs_vm_page_mkwrite(struct vm goto out_unlock; ret =nfs_updatepage (filp, page,0 , pagelen); -if (ret ==0 ) - ret = pagelen; out_unlock:unlock_page (page);if (ret)
PATCH 29/51 mac80211: pid, fix memory corruption
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Jiri Slaby <[email protected]>
commit 6909268dc93ae4b0b8e1ebb4b2fa70b1a47dd347 upstream.
pid doesn't count with some band having more bitrates than the one associated the first time.
Fix that by counting the maximal available bitrate count and allocate big enough space.
Secondly, fix touching uninitialized memory which causes panics. Index sucked from this random memory points to the hell. The fix is to sort the rates on each band change.
--- net/mac80211/rc80211_pid_algo.c | 73 +++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 34 deletions(-)
net/mac80211/rc80211_pid_algo.c +39 -34
@@ -317,13 +317,44 @@ rate_control_pid_rate_init(void *priv, s struct ieee80211_sta *sta, void *priv_sta) { struct rc_pid_sta_info *spinfo = priv_sta; +struct rc_pid_info *pinfo = priv; +struct rc_pid_rateinfo *rinfo = pinfo->rinfo;struct sta_info *si; +int i, j, tmp; +bool s;/* TODO: This routine should consider using RSSI from previous packets * as we need to have IEEE 802.1X auth succeed immediately after assoc.. * Until that method is implemented, we will use the lowest supported * rate as a workaround. */ +/* Sort the rates. This is optimized for the most common case (i.e. +* almost-sorted CCK+OFDM rates). Kind of bubble-sort with reversed +* mapping too. */ +for (i =0 ; i < sband->n_bitrates; i++) { + rinfo[i].index = i; + rinfo[i].rev_index = i; +if (RC_PID_FAST_START ) + rinfo[i].diff =0 ; +else + rinfo[i].diff = i * pinfo->norm_offset; + } +for (i =1 ; i < sband->n_bitrates; i++) { + s =0 ; +for (j =0 ; j < sband->n_bitrates - i; j++) +if (unlikely (sband->bitrates[rinfo[j].index].bitrate > + sband->bitrates[rinfo[j +1 ].index].bitrate)) { + tmp = rinfo[j].index; + rinfo[j].index = rinfo[j +1 ].index; + rinfo[j +1 ].index = tmp; + rinfo[rinfo[j].index].rev_index = j; + rinfo[rinfo[j +1 ].index].rev_index = j +1 ; + s =1 ; + } +if (!s) +break ; + } + spinfo->txrate_idx =rate_lowest_index (sband, sta);/* HACK */ si = container_of(sta, struct sta_info, sta);
@@ -336,21 +367,22 @@ static void *rate_control_pid_alloc(strustruct rc_pid_info *pinfo;struct rc_pid_rateinfo *rinfo;struct ieee80211_supported_band *sband; -int i, j, tmp; -bool s; +int i, max_rates =0 ;#ifdef CONFIG_MAC80211_DEBUGFS struct rc_pid_debugfs_entries *de;#endif - sband = hw->wiphy->bands[hw->conf.channel->band]; - pinfo =kmalloc (sizeof (*pinfo),GFP_ATOMIC );if (!pinfo)return NULL ; -/* We can safely assume that sband won't change unless we get -* reinitialized. */ - rinfo =kmalloc (sizeof (*rinfo) * sband->n_bitrates,GFP_ATOMIC ); +for (i =0 ; i <IEEE80211_NUM_BANDS ; i++) { + sband = hw->wiphy->bands[i]; +if (sband->n_bitrates > max_rates) + max_rates = sband->n_bitrates; + } + + rinfo =kmalloc (sizeof (*rinfo) * max_rates,GFP_ATOMIC );if (!rinfo) {kfree (pinfo);return NULL ;
@@ -368,33 +400,6 @@ static void *rate_control_pid_alloc(stru pinfo->rinfo = rinfo; pinfo->oldrate =0 ; -/* Sort the rates. This is optimized for the most common case (i.e. -* almost-sorted CCK+OFDM rates). Kind of bubble-sort with reversed -* mapping too. */ -for (i =0 ; i < sband->n_bitrates; i++) { - rinfo[i].index = i; - rinfo[i].rev_index = i; -if (RC_PID_FAST_START ) - rinfo[i].diff =0 ; -else - rinfo[i].diff = i * pinfo->norm_offset; - } -for (i =1 ; i < sband->n_bitrates; i++) { - s =0 ; -for (j =0 ; j < sband->n_bitrates - i; j++) -if (unlikely (sband->bitrates[rinfo[j].index].bitrate > - sband->bitrates[rinfo[j +1 ].index].bitrate)) { - tmp = rinfo[j].index; - rinfo[j].index = rinfo[j +1 ].index; - rinfo[j +1 ].index = tmp; - rinfo[rinfo[j].index].rev_index = j; - rinfo[rinfo[j +1 ].index].rev_index = j +1 ; - s =1 ; - } -if (!s) -break ; - } -#ifdef CONFIG_MAC80211_DEBUGFS de = &pinfo->dentries; de->target = debugfs_create_u32("target_pf", S_IRUSR | S_IWUSR,
PATCH 22/51 selinux: Remove dead code labeled networking code
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Paul Moore <[email protected]>
[NOTE: based on 389fb800ac8be2832efedd19978a2b8ced37eb61]
Remove code that is no longer needed by NetLabel and/or SELinux.
---
security/selinux/netlabel.c | 77 -------------------------------------------- 1 file changed, 77 deletions(-)
security/selinux/netlabel.c +0 -77
@@ -100,41 +100,6 @@ static struct netlbl_lsm_secattr *selinu }/** -* selinux_netlbl_sock_setsid - Label a socket using the NetLabel mechanism -* @sk: the socket to label -* -* Description: -* Attempt to label a socket using the NetLabel mechanism. Returns zero values -* on success, negative values on failure. -* -*/ -static int selinux_netlbl_sock_setsid (struct sock *sk) -{ -int rc; -struct sk_security_struct *sksec = sk->sk_security; -struct netlbl_lsm_secattr *secattr; - -if (sksec->nlbl_state !=NLBL_REQUIRE ) -return 0 ; - - secattr =selinux_netlbl_sock_genattr (sk); -if (secattr ==NULL ) -return -ENOMEM ; - rc =netlbl_sock_setattr (sk, secattr); -switch (rc) { -case 0 : - sksec->nlbl_state =NLBL_LABELED ; -break ; -case -EDESTADDRREQ : - sksec->nlbl_state =NLBL_REQSKB ; - rc =0 ; -break ; - } - -return rc; -} - -/** * selinux_netlbl_cache_invalidate - Invalidate the NetLabel cache * * Description:
@@ -361,48 +326,6 @@ int selinux_netlbl_socket_post_create(st }/** -* selinux_netlbl_inode_permission - Verify the socket is NetLabel labeled -* @inode: the file descriptor's inode -* @mask: the permission mask -* -* Description: -* Looks at a file's inode and if it is marked as a socket protected by -* NetLabel then verify that the socket has been labeled, if not try to label -* the socket now with the inode's SID. Returns zero on success, negative -* values on failure. -* -*/ -int selinux_netlbl_inode_permission (struct inode *inode,int mask) -{ -int rc; -struct sock *sk; -struct socket *sock; -struct sk_security_struct *sksec; - -if (!S_ISSOCK (inode->i_mode) || - ((mask & (MAY_WRITE |MAY_APPEND )) ==0 )) -return 0 ; - sock =SOCKET_I (inode); - sk = sock->sk; -if (sk ==NULL ) -return 0 ; - sksec = sk->sk_security; -if (sksec ==NULL || sksec->nlbl_state !=NLBL_REQUIRE ) -return 0 ; - -local_bh_disable (); -bh_lock_sock_nested (sk); -if (likely (sksec->nlbl_state ==NLBL_REQUIRE )) - rc =selinux_netlbl_sock_setsid (sk); -else - rc =0 ; -bh_unlock_sock (sk); -local_bh_enable (); - -return rc; -} - -/** * selinux_netlbl_sock_rcv_skb - Do an inbound access check using NetLabel * @sksec: the sock's sk_security_struct * @skb: the packet
PATCH 21/51 selinux: Set the proper NetLabel security attributes for connection requests
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Paul Moore <[email protected]>
[NOTE: based on 389fb800ac8be2832efedd19978a2b8ced37eb61]
This patch ensures the correct labeling of incoming connection requests responses via NetLabel by enabling the recent changes to NetLabel and the SELinux/Netlabel glue code.
---
security/selinux/hooks.c | 45 +++++++++--------------------------- security/selinux/include/netlabel.h | 6 +--- security/selinux/netlabel.c | 8 +----- 3 files changed, 16 insertions(+), 43 deletions(-)
security/selinux/hooks.c +12 -33
@@ -311,7 +311,7 @@ static int sk_alloc_security(struct sock ssec->sid =SECINITSID_UNLABELED ; sk->sk_security = ssec; -selinux_netlbl_sk_security_reset (ssec, family); +selinux_netlbl_sk_security_reset (ssec);return 0 ; }
@@ -2952,7 +2952,6 @@ static void selinux_inode_getsecid(conststatic int selinux_revalidate_file_permission (struct file *file,int mask) {const struct cred *cred =current_cred (); -int rc;struct inode *inode = file->f_path.dentry->d_inode;if (!mask) {
@@ -2964,30 +2963,16 @@ static int selinux_revalidate_file_permiif ((file->f_flags &O_APPEND ) && (mask &MAY_WRITE )) mask |=MAY_APPEND ; - rc =file_has_perm (cred, file, -file_mask_to_av (inode->i_mode, mask)); -if (rc) -return rc; - -return selinux_netlbl_inode_permission (inode, mask); +return file_has_perm (cred, file,file_mask_to_av (inode->i_mode, mask)); }static int selinux_file_permission (struct file *file,int mask) { -struct inode *inode = file->f_path.dentry->d_inode; -struct file_security_struct *fsec = file->f_security; -struct inode_security_struct *isec = inode->i_security; -u32 sid =current_sid (); -if (!mask) {/* No permission to check. Existence test. */ return 0 ; } -if (sid == fsec->sid && fsec->isid == isec->sid - && fsec->pseqno ==avc_policy_seqno ()) -return selinux_netlbl_inode_permission (inode, mask); -return selinux_revalidate_file_permission (file, mask); }
@@ -3990,13 +3975,7 @@ static int selinux_socket_accept(structstatic int selinux_socket_sendmsg (struct socket *sock,struct msghdr *msg,int size) { -int rc; - - rc =socket_has_perm (current, sock,SOCKET__WRITE ); -if (rc) -return rc; - -return selinux_netlbl_inode_permission (SOCK_INODE (sock),MAY_WRITE ); +return socket_has_perm (current, sock,SOCKET__WRITE ); } static int selinux_socket_recvmsg(struct socket *sock, struct msghdr *msg,
@@ -4384,7 +4363,7 @@ static void selinux_sk_clone_security(co newssec->peer_sid = ssec->peer_sid; newssec->sclass = ssec->sclass; -selinux_netlbl_sk_security_reset (newssec, newsk->sk_family); +selinux_netlbl_sk_security_reset (newssec); }static void selinux_sk_getsecid (struct sock *sk,u32 *secid)
@@ -4429,15 +4408,15 @@ static int selinux_inet_conn_request(str req->secid = sksec->sid; req->peer_secid =SECSID_NULL ;return 0 ; + }else { + err =security_sid_mls_copy (sksec->sid, peersid, &newsid); +if (err) +return err; + req->secid = newsid; + req->peer_secid = peersid; } - err =security_sid_mls_copy (sksec->sid, peersid, &newsid); -if (err) -return err; - - req->secid = newsid; - req->peer_secid = peersid; -return 0 ; +return selinux_netlbl_inet_conn_request (req, family); } static void selinux_inet_csk_clone(struct sock *newsk,
@@ -4454,7 +4433,7 @@ static void selinux_inet_csk_clone(struc/* We don't need to take any sort of lock here as we are the only * thread with access to newsksec */ -selinux_netlbl_sk_security_reset (newsksec, req->rsk_ops->family); +selinux_netlbl_inet_csk_clone (newsk, req->rsk_ops->family); }static void selinux_inet_conn_established (struct sock *sk,struct sk_buff *skb)
security/selinux/include/netlabel.h +2 -4
@@ -43,8 +43,7 @@ void selinux_netlbl_cache_invalidate(voivoid selinux_netlbl_err (struct sk_buff *skb,int error,int gateway);void selinux_netlbl_sk_security_free (struct sk_security_struct *ssec); -void selinux_netlbl_sk_security_reset (struct sk_security_struct *ssec, -int family); +void selinux_netlbl_sk_security_reset (struct sk_security_struct *ssec); int selinux_netlbl_skbuff_getsid(struct sk_buff *skb, u16 family,
@@ -87,8 +86,7 @@ static inline void selinux_netlbl_sk_sec }static inline void selinux_netlbl_sk_security_reset ( -struct sk_security_struct *ssec, -int family) +struct sk_security_struct *ssec) {return ; }
security/selinux/netlabel.c +2 -6
@@ -188,13 +188,9 @@ void selinux_netlbl_sk_security_free(str* The caller is responsibile for all the NetLabel sk_security_struct locking. * */ -void selinux_netlbl_sk_security_reset (struct sk_security_struct *ssec, -int family) +void selinux_netlbl_sk_security_reset (struct sk_security_struct *ssec) { -if (family ==PF_INET ) - ssec->nlbl_state =NLBL_REQUIRE ; -else - ssec->nlbl_state =NLBL_UNSET ; + ssec->nlbl_state =NLBL_UNSET ; }/**
PATCH 36/51 CIFS: Fix endian conversion of vcnum field
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Steve French <[email protected]>
commit 051a2a0d3242b448281376bb63cfa9385e0b6c68 upstream.
When multiply mounting from the same client to the same server, with different userids, we create a vcnum which should be unique if possible (this is not the same as the smb uid, which is the handle to the security context). We were not endian converting additional (beyond the first which is zero) vcnum properly.
--- fs/cifs/sess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/sess.c +1 -1
@@ -111,7 +111,7 @@ static __le16 get_next_vcnum(struct cifs get_vc_num_exit:write_unlock (&cifs_tcp_ses_lock); -return le16_to_cpu (vcnum); +return cpu_to_le16 (vcnum); }static __u32 cifs_ssetup_hdr (struct cifsSesInfo *ses,SESSION_SETUP_ANDX *pSMB)
PATCH 35/51 NFS: Close page_mkwrite() races
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Trond Myklebust <[email protected]>
commit 7fdf523067666b0eaff330f362401ee50ce187c4 upstream.
Follow up to Nick Piggin's patches to ensure that nfs_vm_page_mkwrite returns with the page lock held, and sets the VM_FAULT_LOCKED flag.
See http://bugzilla.kernel.org/show_bug.cgi?id=12913
--- fs/nfs/file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/nfs/file.c +3 -3
@@ -481,10 +481,10 @@ static int nfs_vm_page_mkwrite(struct vm ret =nfs_updatepage (filp, page,0 , pagelen); out_unlock: +if (!ret) +return VM_FAULT_LOCKED ;unlock_page (page); -if (ret) - ret =VM_FAULT_SIGBUS ; -return ret; +return VM_FAULT_SIGBUS ; }static struct vm_operations_struct nfs_file_vm_ops = {
PATCH 37/51 epoll: fix size check in epoll_create()
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Davide Libenzi <[email protected]>
commit bfe3891a5f5d3b78146a45f40e435d14f5ae39dd upstream.
Fix a size check WRT the manual pages. This was inadvertently broken by commit 9fe5ad9c8cef9ad5873d8ee55d1cf00d9b607df0 ("flag parameters
add-on: remove epoll_create size param").
--- fs/eventpoll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/eventpoll.c +1 -1
@@ -1136,7 +1136,7 @@ error_return: SYSCALL_DEFINE1(epoll_create, int, size) { -if (size <0 ) +if (size <=0 )return -EINVAL ;return sys_epoll_create1 (0 );
PATCH 40/51 lockd: fix list corruption on lockd restart
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: J. Bruce Fields <[email protected]>
commit 89996df4b5b1a09c279f50b3fd03aa9df735f5cb upstream.
If lockd is signalled soon enough after restart then locks_start_grace() will try to re-add an entry to a list and trigger a lock corruption warning.
Thanks to Wang Chen for the problem report and diagnosis.
WARNING: at lib/list_debug.c:26 __list_add+0x27/0x5c()
...list_add corruption. next->prev should be prev (ef8fe958), but was ef8ff128. (next=ef8ff128).
...
Pid: 23062, comm: lockd Tainted: G W 2.6.30-rc2 #3
Call Trace: [<c042d5b5>] warn_slowpath+0x71/0xa0 [<c0422a96>] ? update_curr+0x11d/0x125 [<c044b12d>] ? trace_hardirqs_on_caller+0x18/0x150 [<c044b270>] ? trace_hardirqs_on+0xb/0xd [<c051c61a>] ? _raw_spin_lock+0x53/0xfa [<c051c89f>] __list_add+0x27/0x5c [<ef8f6daa>] locks_start_grace+0x22/0x30 [lockd] [<ef8f34da>] set_grace_period+0x39/0x53 [lockd] [<c06b8921>] ? lock_kernel+0x1c/0x28 [<ef8f3558>] lockd+0x64/0x164 [lockd] [<c044b12d>] ? trace_hardirqs_on_caller+0x18/0x150 [<c04227b0>] ? complete+0x34/0x3e [<ef8f34f4>] ? lockd+0x0/0x164 [lockd] [<ef8f34f4>] ? lockd+0x0/0x164 [lockd] [<c043dd42>] kthread+0x45/0x6b [<c043dcfd>] ? kthread+0x0/0x6b [<c0403c23>] kernel_thread_helper+0x7/0x10
--- fs/lockd/svc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
fs/lockd/svc.c +11 -4
@@ -115,6 +115,16 @@ static void set_grace_period(void)schedule_delayed_work (&grace_period_end, grace_period); } +static void restart_grace (void ) +{ +if (nlmsvc_ops) { +cancel_delayed_work_sync (&grace_period_end); +locks_end_grace (&lockd_manager); +nlmsvc_invalidate_all (); +set_grace_period (); + } +} +/* * This is the lockd kernel thread */
@@ -160,10 +170,7 @@ lockd(void *vrqstp)if (signalled ()) {flush_signals (current); -if (nlmsvc_ops) { -nlmsvc_invalidate_all (); -set_grace_period (); - } +restart_grace ();continue ; }
PATCH 41/51 dmatest: fix max channels handling
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Dan Williams <[email protected]>
commit c56c81abe7e684bc6203632d807303eb765690dc upstream.
The check for reaching max_channels is short circuited by 'continuing' after successfully adding a channel.
[ Impact: make the 'max_channels' module parameter actually have an effect ]
--- drivers/dma/dmatest.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/dma/dmatest.c +1 -3
@@ -410,9 +410,7 @@ static int __init dmatest_init(void) chan =dma_request_channel (mask, filter,NULL );if (chan) { err =dmatest_add_channel (chan); -if (err ==0 ) -continue ; -else { +if (err) {dma_release_channel (chan);break ;/* add_channel failed, punt */ }
PATCH 39/51 NFS: Fix the notifications when renaming onto an existing file
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Trond Myklebust <[email protected]>
commit b1e4adf4ea41bb8b5a7bfc1a7001f137e65495df upstream.
NFS appears to be returning an unnecessary "delete" notification when we're doing an atomic rename. See
http://bugzilla.gnome.org/show_bug.cgi?id=575684
The fix is to get rid of the redundant call to d_delete().
--- fs/nfs/dir.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/nfs/dir.c +4 -5
@@ -1624,8 +1624,7 @@ static int nfs_rename(struct inode *old_ }else if (atomic_read (&new_dentry->d_count) >1 )/* dentry still busy? */ goto out; - }else -nfs_drop_nlink (new_inode); + } go_ahead:/*
@@ -1638,10 +1637,8 @@ go_ahead: }nfs_inode_return_delegation (old_inode); -if (new_inode !=NULL ) { +if (new_inode !=NULL )nfs_inode_return_delegation (new_inode); -d_delete (new_dentry); - } error =NFS_PROTO (old_dir)->rename (old_dir, &old_dentry->d_name, new_dir, &new_dentry->d_name);
@@ -1650,6 +1647,8 @@ out:if (rehash)d_rehash (rehash);if (!error) { +if (new_inode !=NULL ) +nfs_drop_nlink (new_inode);d_move (old_dentry, new_dentry);nfs_set_verifier (new_dentry,nfs_save_change_attribute (new_dir));
PATCH 43/51 KVM: SVM: Remove port 80 passthrough
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Avi Kivity <[email protected]>
commit 99f85a28a78e96d28907fe036e1671a218fee597 upstream.
KVM optimizes guest port 80 accesses by passthing them through to the host. Some AMD machines die on port 80 writes, allowing the guest to hard-lock the host.
Remove the port passthrough to avoid the problem.
--- arch/x86/kvm/svm.c | 1 - 1 file changed, 1 deletion(-)
arch/x86/kvm/svm.c +0 -1
@@ -411,7 +411,6 @@ static __init int svm_hardware_setup(voi iopm_va =page_address (iopm_pages);memset (iopm_va,0xff ,PAGE_SIZE * (1 <<IOPM_ALLOC_ORDER )); -clear_bit (0x80 , iopm_va);/* allow direct access to PC debug port */ iopm_base =page_to_pfn (iopm_pages) <<PAGE_SHIFT ;if (boot_cpu_has (X86_FEATURE_NX ))
PATCH 38/51 nfsd4: check for negative dentry before use in nfsv4 readdir
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: J. Bruce Fields <[email protected]>
commit b2c0cea6b1cb210e962f07047df602875564069e upstream.
After 2f9092e1020246168b1309b35e085ecd7ff9ff72 "Fix i_mutex vs. readdir handling in nfsd" (and 14f7dd63 "Copy XFS readdir hack into nfsd code"), an entry may be removed between the first mutex_unlock and the second mutex_lock. In this case, lookup_one_len() will return a negative dentry. Check for this case to avoid a NULL dereference.
--- fs/nfsd/nfs4xdr.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
fs/nfsd/nfs4xdr.c +15 -1
@@ -1843,6 +1843,15 @@ nfsd4_encode_dirent_fattr(struct nfsd4_r dentry =lookup_one_len (name, cd->rd_fhp->fh_dentry, namlen);if (IS_ERR (dentry))return nfserrno (PTR_ERR (dentry)); +if (!dentry->d_inode) { +/* +* nfsd_buffered_readdir drops the i_mutex between +* readdir and calling this callback, leaving a window +* where this directory entry could have gone away. +*/ +dput (dentry); +return nfserr_noent; + }exp_get (exp);/*
@@ -1905,6 +1914,7 @@ nfsd4_encode_dirent(void *ccdv, const ch struct nfsd4_readdir *cd = container_of(ccd, struct nfsd4_readdir, common);int buflen;__be32 *p = cd->buffer; +__be32 *cookiep;__be32 nfserr = nfserr_toosmall;/* In nfsv4, "." and ".." never make it onto the wire.. */
@@ -1921,7 +1931,7 @@ nfsd4_encode_dirent(void *ccdv, const ch goto fail; *p++ = xdr_one;/* mark entry present */ - cd->offset = p;/* remember pointer */ + cookiep = p; p =xdr_encode_hyper (p,NFS_OFFSET_MAX );/* offset of next entry */ p =xdr_encode_array (p, name, namlen);/* name length & name */
@@ -1935,6 +1945,8 @@ nfsd4_encode_dirent(void *ccdv, const ch goto fail;case nfserr_dropit: goto fail; +case nfserr_noent: + goto skip_entry;default :/* * If the client requested the RDATTR_ERROR attribute,
@@ -1953,6 +1965,8 @@ nfsd4_encode_dirent(void *ccdv, const ch } cd->buflen -= (p - cd->buffer); cd->buffer = p; + cd->offset = cookiep; +skip_entry: cd->common.err = nfs_ok;return 0 ; fail:
PATCH 45/51 fuse: destroy bdi on error
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Miklos Szeredi <[email protected]>
commit fd9db7297749c05fcf5721ce5393a5a8b8772f2a upstream.
Destroy bdi on error in fuse_fill_super().
This was an omission from commit 26c3679101dbccc054dcf370143941844ba70531 "fuse: destroy bdi on umount", which moved the bdi_destroy() call from fuse_conn_put() to fuse_put_super().
--- fs/fuse/inode.c | 1 + 1 file changed, 1 insertion(+)
fs/fuse/inode.c +1 -0
@@ -908,6 +908,7 @@ static int fuse_fill_super(struct super_ err_put_root:dput (root_dentry); err_put_conn: +bdi_destroy (&fc->bdi);fuse_conn_put (fc); err_fput:fput (file);
PATCH 47/51 splice: remove i_mutex locking in splice_from_pipe()
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Miklos Szeredi <[email protected]>
commit 2933970b960223076d6affcf7a77e2bc546b8102 upstream.
splice_from_pipe() is only called from two places:
- generic_splice_sendpage()
- splice_write_null()
Neither of these require i_mutex to be taken on the destination inode.
--- fs/splice.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
fs/splice.c +2 -16
@@ -783,7 +783,7 @@ EXPORT_SYMBOL(__splice_from_pipe);* @actor: handler that splices the data * * Description: -* See __splice_from_pipe. This function locks the input and output inodes, +* See __splice_from_pipe. This function locks the pipe inode, * otherwise it's identical to __splice_from_pipe(). * */
@@ -792,7 +792,6 @@ ssize_t splice_from_pipe(struct pipe_ino splice_actor *actor) {ssize_t ret; -struct inode *inode = out->f_mapping->host;struct splice_desc sd = { .total_len = len, .flags = flags,
@@ -800,24 +799,11 @@ ssize_t splice_from_pipe(struct pipe_ino .u.file = out, }; -/* -* The actor worker might be calling ->write_begin and -* ->write_end. Most of the time, these expect i_mutex to -* be held. Since this may result in an ABBA deadlock with -* pipe->inode, we have to order lock acquiry here. -* -* Outer lock must be inode->i_mutex, as pipe_wait() will -* release and reacquire pipe->inode->i_mutex, AND inode must -* never be a pipe. -*/ -WARN_ON (S_ISFIFO (inode->i_mode)); -mutex_lock_nested (&inode->i_mutex,I_MUTEX_PARENT );if (pipe->inode) -mutex_lock_nested (&pipe->inode->i_mutex,I_MUTEX_CHILD ); +mutex_lock (&pipe->inode->i_mutex); ret =__splice_from_pipe (pipe, &sd, actor);if (pipe->inode)mutex_unlock (&pipe->inode->i_mutex); -mutex_unlock (&inode->i_mutex);return ret; }
PATCH 49/51 ocfs2: fix i_mutex locking in ocfs2_splice_to_file()
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Miklos Szeredi <[email protected]>
commit 328eaaba4e41a04c1dc4679d65bea3fee4349d86 upstream.
Rearrange locking of i_mutex on destination and call to ocfs2_rw_lock() so locks are only held while buffers are copied with the pipe_to_file() actor, and not while waiting for more data on the pipe.
--- fs/ocfs2/file.c | 96 ++++++++++++++++++++++++++++++++++++++----------- fs/splice.c | 5 +- include/linux/splice.h | 2 + 3 files changed, 80 insertions(+), 23 deletions(-)
fs/ocfs2/file.c +75 -21
@@ -1912,6 +1912,22 @@ out_sems:return written ? written : ret; } +static int ocfs2_splice_to_file (struct pipe_inode_info *pipe, +struct file *out, +struct splice_desc *sd) +{ +int ret; + + ret =ocfs2_prepare_inode_for_write (out->f_path.dentry, &sd->pos, + sd->total_len,0 ,NULL ); +if (ret <0 ) { +mlog_errno (ret); +return ret; + } + +return splice_from_pipe_feed (pipe, sd, pipe_to_file); +} + static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe, struct file *out, loff_t *ppos,
@@ -1919,38 +1935,76 @@ static ssize_t ocfs2_file_splice_write(s unsigned int flags) {int ret; -struct inode *inode = out->f_path.dentry->d_inode; +struct address_space *mapping = out->f_mapping; +struct inode *inode = mapping->host; +struct splice_desc sd = { + .total_len = len, + .flags = flags, + .pos = *ppos, + .u.file = out, + };mlog_entry ("(0x%p, 0x%p, %u, '%.*s')\n" , out, pipe, (unsigned int )len, out->f_path.dentry->d_name.len, out->f_path.dentry->d_name.name); -mutex_lock_nested (&inode->i_mutex,I_MUTEX_PARENT ); - - ret =ocfs2_rw_lock (inode,1 ); -if (ret <0 ) { -mlog_errno (ret); - goto out; - } +if (pipe->inode) +mutex_lock_nested (&pipe->inode->i_mutex,I_MUTEX_PARENT ); - ret =ocfs2_prepare_inode_for_write (out->f_path.dentry, ppos, len,0 , -NULL ); -if (ret <0 ) { -mlog_errno (ret); - goto out_unlock; - } +splice_from_pipe_begin (&sd); +do { + ret =splice_from_pipe_next (pipe, &sd); +if (ret <=0 ) +break ; + +mutex_lock_nested (&inode->i_mutex,I_MUTEX_CHILD ); + ret =ocfs2_rw_lock (inode,1 ); +if (ret <0 ) +mlog_errno (ret); +else { + ret =ocfs2_splice_to_file (pipe, out, &sd); +ocfs2_rw_unlock (inode,1 ); + } +mutex_unlock (&inode->i_mutex); + }while (ret >0 ); +splice_from_pipe_end (pipe, &sd);if (pipe->inode) -mutex_lock_nested (&pipe->inode->i_mutex,I_MUTEX_CHILD ); - ret =generic_file_splice_write_nolock (pipe, out, ppos, len, flags); -if (pipe->inode)mutex_unlock (&pipe->inode->i_mutex); -out_unlock: -ocfs2_rw_unlock (inode,1 ); -out: -mutex_unlock (&inode->i_mutex); +if (sd.num_spliced) + ret = sd.num_spliced; + +if (ret >0 ) { +unsigned long nr_pages; + + *ppos += ret; + nr_pages = (ret +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; + +/* +* If file or inode is SYNC and we actually wrote some data, +* sync it. +*/ +if (unlikely ((out->f_flags &O_SYNC ) ||IS_SYNC (inode))) { +int err; + +mutex_lock (&inode->i_mutex); + err =ocfs2_rw_lock (inode,1 ); +if (err <0 ) { +mlog_errno (err); + }else { + err =generic_osync_inode (inode, mapping, +OSYNC_METADATA |OSYNC_DATA ); +ocfs2_rw_unlock (inode,1 ); + } +mutex_unlock (&inode->i_mutex); + +if (err) + ret = err; + } +balance_dirty_pages_ratelimited_nr (mapping, nr_pages); + }mlog_exit (ret);return ret;
fs/splice.c +3 -2
@@ -554,8 +554,8 @@ static int pipe_to_sendpage(struct pipe_* SPLICE_F_MOVE isn't set, or we cannot move the page, we simply create * a new page in the output file page cache and fill/dirty that. */ -static int pipe_to_file (struct pipe_inode_info *pipe,struct pipe_buffer *buf, -struct splice_desc *sd) +int pipe_to_file (struct pipe_inode_info *pipe,struct pipe_buffer *buf, +struct splice_desc *sd) {struct file *file = sd->u.file;struct address_space *mapping = file->f_mapping;
@@ -599,6 +599,7 @@ static int pipe_to_file(struct pipe_inod out:return ret; } +EXPORT_SYMBOL (pipe_to_file);static void wakeup_pipe_writers (struct pipe_inode_info *pipe) {
include/linux/splice.h +2 -0
@@ -75,6 +75,8 @@ extern int splice_from_pipe_next(structextern void splice_from_pipe_begin (struct splice_desc *);extern void splice_from_pipe_end (struct pipe_inode_info *,struct splice_desc *); +extern int pipe_to_file (struct pipe_inode_info *,struct pipe_buffer *, +struct splice_desc *);extern ssize_t splice_to_pipe (struct pipe_inode_info *,struct splice_pipe_desc *);
PATCH 48/51 splice: fix i_mutex locking in generic_splice_write()
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Miklos Szeredi <[email protected]>
commit eb443e5a25d43996deb62b9bcee1a4ce5dea2ead upstream.
Rearrange locking of i_mutex on destination so it's only held while buffers are copied with the pipe_to_file() actor, and not while waiting for more data on the pipe.
--- fs/splice.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-)
fs/splice.c +23 -11
@@ -894,17 +894,29 @@ generic_file_splice_write(struct pipe_in };ssize_t ret; -WARN_ON (S_ISFIFO (inode->i_mode)); -mutex_lock_nested (&inode->i_mutex,I_MUTEX_PARENT ); - ret =file_remove_suid (out); -if (likely (!ret)) { -if (pipe->inode) -mutex_lock_nested (&pipe->inode->i_mutex,I_MUTEX_CHILD ); - ret =__splice_from_pipe (pipe, &sd, pipe_to_file); -if (pipe->inode) -mutex_unlock (&pipe->inode->i_mutex); - } -mutex_unlock (&inode->i_mutex); +if (pipe->inode) +mutex_lock_nested (&pipe->inode->i_mutex,I_MUTEX_PARENT ); + +splice_from_pipe_begin (&sd); +do { + ret =splice_from_pipe_next (pipe, &sd); +if (ret <=0 ) +break ; + +mutex_lock_nested (&inode->i_mutex,I_MUTEX_CHILD ); + ret =file_remove_suid (out); +if (!ret) + ret =splice_from_pipe_feed (pipe, &sd, pipe_to_file); +mutex_unlock (&inode->i_mutex); + }while (ret >0 ); +splice_from_pipe_end (pipe, &sd); + +if (pipe->inode) +mutex_unlock (&pipe->inode->i_mutex); + +if (sd.num_spliced) + ret = sd.num_spliced; +if (ret >0 ) {unsigned long nr_pages;
PATCH 46/51 splice: split up __splice_from_pipe()
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Miklos Szeredi <[email protected]>
commit b3c2d2ddd63944ef2a1e4a43077b602288107e01 upstream.
Split up __splice_from_pipe() into four helper functions:
splice_from_pipe_begin()
splice_from_pipe_next()
splice_from_pipe_feed()
splice_from_pipe_end()
splice_from_pipe_next() will wait (if necessary) for more buffers to be added to the pipe. splice_from_pipe_feed() will feed the buffers to the supplied actor and return when there's no more data available (or if all of the requested data has been copied).
This is necessary so that implementations can do locking around the non-waiting splice_from_pipe_feed().
This patch should not cause any change in behavior.
--- fs/splice.c | 223 ++++++++++++++++++++++++++++++++----------------- include/linux/splice.h | 10 ++ 2 files changed, 156 insertions(+), 77 deletions(-)
fs/splice.c +146 -77
@@ -600,107 +600,176 @@ out:return ret; } +static void wakeup_pipe_writers (struct pipe_inode_info *pipe) +{ +smp_mb (); +if (waitqueue_active (&pipe->wait)) +wake_up_interruptible (&pipe->wait); +kill_fasync (&pipe->fasync_writers,SIGIO ,POLL_OUT ); +} +/** -* __splice_from_pipe - splice data from a pipe to given actor +* splice_from_pipe_feed - feed available data from a pipe to a file * @pipe: pipe to splice from * @sd: information to @actor * @actor: handler that splices the data * * Description: -* This function does little more than loop over the pipe and call -* @actor to do the actual moving of a single struct pipe_buffer to -* the desired destination. See pipe_to_file, pipe_to_sendpage, or -* pipe_to_user. + +* This function loops over the pipe and calls @actor to do the +* actual moving of a single struct pipe_buffer to the desired +* destination. It returns when there's no more buffers left in +* the pipe or if the requested number of bytes (@sd->total_len) +* have been copied. It returns a positive number (one) if the +* pipe needs to be filled with more data, zero if the required +* number of bytes have been copied and -errno on error. * +* This, together with splice_from_pipe_{begin,end,next}, may be +* used to implement the functionality of __splice_from_pipe() when +* locking is required around copying the pipe buffers to the +* destination. */ -ssize_t __splice_from_pipe (struct pipe_inode_info *pipe,struct splice_desc *sd, -splice_actor *actor) +int splice_from_pipe_feed (struct pipe_inode_info *pipe,struct splice_desc *sd, +splice_actor *actor) { -int ret, do_wakeup, err; - - ret =0 ; - do_wakeup =0 ; +int ret; -for (;;) { -if (pipe->nrbufs) { -struct pipe_buffer *buf = pipe->bufs + pipe->curbuf; -const struct pipe_buf_operations *ops = buf->ops; - - sd->len = buf->len; -if (sd->len > sd->total_len) - sd->len = sd->total_len; - - err =actor (pipe, buf, sd); -if (err <=0 ) { -if (!ret && err != -ENODATA ) - ret = err; +while (pipe->nrbufs) { +struct pipe_buffer *buf = pipe->bufs + pipe->curbuf; +const struct pipe_buf_operations *ops = buf->ops; + + sd->len = buf->len; +if (sd->len > sd->total_len) + sd->len = sd->total_len; + + ret =actor (pipe, buf, sd); +if (ret <=0 ) { +if (ret == -ENODATA ) + ret =0 ; +return ret; + } + buf->offset += ret; + buf->len -= ret; + + sd->num_spliced += ret; + sd->len -= ret; + sd->pos += ret; + sd->total_len -= ret; -break ; - } +if (!buf->len) { + buf->ops =NULL ; + ops->release (pipe, buf); + pipe->curbuf = (pipe->curbuf +1 ) & (PIPE_BUFFERS -1 ); + pipe->nrbufs--; +if (pipe->inode) + sd->need_wakeup = true; + } - ret += err; - buf->offset += err; - buf->len -= err; - - sd->len -= err; - sd->pos += err; - sd->total_len -= err; -if (sd->len) -continue ; - -if (!buf->len) { - buf->ops =NULL ; - ops->release (pipe, buf); - pipe->curbuf = (pipe->curbuf +1 ) & (PIPE_BUFFERS -1 ); - pipe->nrbufs--; -if (pipe->inode) - do_wakeup =1 ; - } +if (!sd->total_len) +return 0 ; + } -if (!sd->total_len) -break ; - } +return 1 ; +} +EXPORT_SYMBOL (splice_from_pipe_feed); -if (pipe->nrbufs) -continue ; +/** +* splice_from_pipe_next - wait for some data to splice from +* @pipe: pipe to splice from +* @sd: information about the splice operation +* +* Description: +* This function will wait for some data and return a positive +* value (one) if pipe buffers are available. It will return zero +* or -errno if no more data needs to be spliced. +*/ +int splice_from_pipe_next (struct pipe_inode_info *pipe,struct splice_desc *sd) +{ +while (!pipe->nrbufs) {if (!pipe->writers) -break ; -if (!pipe->waiting_writers) { -if (ret) -break ; - } +return 0 ; -if (sd->flags &SPLICE_F_NONBLOCK ) { -if (!ret) - ret = -EAGAIN ; -break ; - } +if (!pipe->waiting_writers && sd->num_spliced) +return 0 ; -if (signal_pending (current)) { -if (!ret) - ret = -ERESTARTSYS ; -break ; - } +if (sd->flags &SPLICE_F_NONBLOCK ) +return -EAGAIN ; -if (do_wakeup) { -smp_mb (); -if (waitqueue_active (&pipe->wait)) -wake_up_interruptible_sync (&pipe->wait); -kill_fasync (&pipe->fasync_writers,SIGIO ,POLL_OUT ); - do_wakeup =0 ; +if (signal_pending (current)) +return -ERESTARTSYS ; + +if (sd->need_wakeup) { +wakeup_pipe_writers (pipe); + sd->need_wakeup = false; }pipe_wait (pipe); } -if (do_wakeup) { -smp_mb (); -if (waitqueue_active (&pipe->wait)) -wake_up_interruptible (&pipe->wait); -kill_fasync (&pipe->fasync_writers,SIGIO ,POLL_OUT ); - } +return 1 ; +} +EXPORT_SYMBOL (splice_from_pipe_next); -return ret; +/** +* splice_from_pipe_begin - start splicing from pipe +* @pipe: pipe to splice from +* +* Description: +* This function should be called before a loop containing +* splice_from_pipe_next() and splice_from_pipe_feed() to +* initialize the necessary fields of @sd. +*/ +void splice_from_pipe_begin (struct splice_desc *sd) +{ + sd->num_spliced =0 ; + sd->need_wakeup = false; +} +EXPORT_SYMBOL (splice_from_pipe_begin); + +/** +* splice_from_pipe_end - finish splicing from pipe +* @pipe: pipe to splice from +* @sd: information about the splice operation +* +* Description: +* This function will wake up pipe writers if necessary. It should +* be called after a loop containing splice_from_pipe_next() and +* splice_from_pipe_feed(). +*/ +void splice_from_pipe_end (struct pipe_inode_info *pipe,struct splice_desc *sd) +{ +if (sd->need_wakeup) +wakeup_pipe_writers (pipe); +} +EXPORT_SYMBOL (splice_from_pipe_end); + +/** +* __splice_from_pipe - splice data from a pipe to given actor +* @pipe: pipe to splice from +* @sd: information to @actor +* @actor: handler that splices the data +* +* Description: +* This function does little more than loop over the pipe and call +* @actor to do the actual moving of a single struct pipe_buffer to +* the desired destination. See pipe_to_file, pipe_to_sendpage, or +* pipe_to_user. +* +*/ +ssize_t __splice_from_pipe (struct pipe_inode_info *pipe,struct splice_desc *sd, +splice_actor *actor) +{ +int ret; + +splice_from_pipe_begin (sd); +do { + ret =splice_from_pipe_next (pipe, sd); +if (ret >0 ) + ret =splice_from_pipe_feed (pipe, sd, actor); + }while (ret >0 ); +splice_from_pipe_end (pipe, sd); + +return sd->num_spliced ? sd->num_spliced : ret; }EXPORT_SYMBOL (__splice_from_pipe);
include/linux/splice.h +10 -0
@@ -36,6 +36,8 @@ struct splice_desc {void *data;/* cookie */ } u;loff_t pos;/* file position */ +size_t num_spliced;/* number of bytes already spliced */ +bool need_wakeup;/* need to wake up writer */ };struct partial_page {
@@ -66,6 +68,14 @@ extern ssize_t splice_from_pipe(struct p splice_actor *);extern ssize_t __splice_from_pipe (struct pipe_inode_info *,struct splice_desc *,splice_actor *); +extern int splice_from_pipe_feed (struct pipe_inode_info *,struct splice_desc *, +splice_actor *); +extern int splice_from_pipe_next (struct pipe_inode_info *, +struct splice_desc *); +extern void splice_from_pipe_begin (struct splice_desc *); +extern void splice_from_pipe_end (struct pipe_inode_info *, +struct splice_desc *); +extern ssize_t splice_to_pipe (struct pipe_inode_info *,struct splice_pipe_desc *); extern ssize_t splice_direct_to_actor(struct file *, struct splice_desc *,
PATCH 50/51 ehea: fix invalid pointer access
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Hannes Hering <[email protected]>
commit 0b2febf38a33d7c40fb7bb4a58c113a1fa33c412 upstream.
This patch fixes an invalid pointer access in case the receive queue holds no pointer to the next skb when the queue is empty.
--- drivers/net/ehea/ehea_main.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
drivers/net/ehea/ehea_main.c +18 -13
@@ -529,14 +529,17 @@ static inline struct sk_buff *get_skb_by x &= (arr_len -1 ); pref = skb_array[x]; -prefetchw (pref); -prefetchw (pref +EHEA_CACHE_LINE ); +if (pref) { +prefetchw (pref); +prefetchw (pref +EHEA_CACHE_LINE ); + + pref = (skb_array[x]->data); +prefetch (pref); +prefetch (pref +EHEA_CACHE_LINE ); +prefetch (pref +EHEA_CACHE_LINE *2 ); +prefetch (pref +EHEA_CACHE_LINE *3 ); + } - pref = (skb_array[x]->data); -prefetch (pref); -prefetch (pref +EHEA_CACHE_LINE ); -prefetch (pref +EHEA_CACHE_LINE *2 ); -prefetch (pref +EHEA_CACHE_LINE *3 ); skb = skb_array[skb_index]; skb_array[skb_index] =NULL ;return skb;
@@ -553,12 +556,14 @@ static inline struct sk_buff *get_skb_by x &= (arr_len -1 ); pref = skb_array[x]; -prefetchw (pref); -prefetchw (pref +EHEA_CACHE_LINE ); - - pref = (skb_array[x]->data); -prefetchw (pref); -prefetchw (pref +EHEA_CACHE_LINE ); +if (pref) { +prefetchw (pref); +prefetchw (pref +EHEA_CACHE_LINE ); + + pref = (skb_array[x]->data); +prefetchw (pref); +prefetchw (pref +EHEA_CACHE_LINE ); + } skb = skb_array[wqe_index]; skb_array[wqe_index] =NULL ;
PATCH 44/51 KVM: Make EFER reads safe when EFER does not exist
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Avi Kivity <[email protected]>
commit e286e86e6d2042d67d09244aa0e05ffef75c9d54 upstream.
Some processors don't have EFER; don't oops if userspace wants us to read EFER when we check NX.
--- arch/x86/kvm/x86.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/x86.c +2 -2
@@ -1075,9 +1075,9 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *static int is_efer_nx (void ) { -u64 efer; +unsigned long long efer =0 ; -rdmsrl (MSR_EFER , efer); +rdmsrl_safe (MSR_EFER , &efer);return efer &EFER_NX ; }
PATCH 51/51 powerpc/5200: Dont specify IRQF_SHARED in PSC UART driver
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Grant Likely <[email protected]>
commit d9f0c5f9bc74f16d0ea0f6c518b209e48783a796 upstream.
The MPC5200 PSC device is wired up to a dedicated interrupt line which is never shared. This patch removes the IRQF_SHARED flag from the request_irq() call which eliminates the "IRQF_DISABLED is not guaranteed on shared IRQs" warning message from the console output.
--- drivers/serial/mpc52xx_uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/serial/mpc52xx_uart.c +1 -1
@@ -522,7 +522,7 @@ mpc52xx_uart_startup(struct uart_port *p/* Request IRQ */ ret =request_irq (port->irq, mpc52xx_uart_int, -IRQF_DISABLED |IRQF_SAMPLE_RANDOM |IRQF_SHARED , +IRQF_DISABLED |IRQF_SAMPLE_RANDOM ,"mpc52xx_psc_uart" , port);if (ret)return ret;
PATCH 42/51 HID: add NOGET quirk for devices from CH Products
In reply to Greg KH2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Alan Stern <[email protected]>
commit b820aabf6cb987fd03d85b0b5f599685051e0426 upstream.
This patch (as1240) adds the NOGET quirk for three devices from CH
Products: the Pro pedals, the Combatstick joystick, and the Flight-Sim yoke. Without these quirks, the devices haven't worked for many kernel releases. Sometimes replugging them after boot-up would get them to work and sometimes they wouldn't work at all.
--- drivers/hid/hid-ids.h | 5 +++++ drivers/hid/usbhid/hid-quirks.c | 3 +++ 2 files changed, 8 insertions(+)
drivers/hid/hid-ids.h +5 -0
@@ -110,6 +110,11 @@#define USB_VENDOR_ID_BERKSHIRE 0x0c98#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140 +#define USB_VENDOR_ID_CH 0x068e +#define USB_DEVICE_ID_CH_PRO_PEDALS 0x00f2 +#define USB_DEVICE_ID_CH_COMBATSTICK 0x00f4 +#define USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE 0x00ff +#define USB_VENDOR_ID_CHERRY 0x046a#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023
drivers/hid/usbhid/hid-quirks.c +3 -0
@@ -50,6 +50,9 @@ static const struct hid_blacklist { { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, + { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_COMBATSTICK, HID_QUIRK_NOGET }, + { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE, HID_QUIRK_NOGET }, + { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_PEDALS, HID_QUIRK_NOGET }, { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
Re: [patch 29/51] mac80211: pid, fix memory corruption
In reply to Greg KHHi,
note that you were about to drop this one now because of waiting for a fixup which is not upstream so far. Did anything change?
(This is the one which fixes a memory corruption, but triggers a bug causing oopses on single band cards.)
On 05/15/2009 12:33 AM, Greg KH wrote:
From: Jiri Slaby <[email protected]>
commit 6909268dc93ae4b0b8e1ebb4b2fa70b1a47dd347 upstream.
pid doesn't count with some band having more bitrates than the one associated the first time.
Fix that by counting the maximal available bitrate count and allocate big enough space.
Secondly, fix touching uninitialized memory which causes panics. Index sucked from this random memory points to the hell. The fix is to sort the rates on each band change.
Re: [patch 29/51] mac80211: pid, fix memory corruption
Quoted 4 lines · Jiri Slaby
Hi,
note that you were about to drop this one now because of waiting for a fixup which is not upstream so far. Did anything change?
Hm, no, I dropped a different patch,
mac80211-minstrel-fix-memory-corruption.patch
did I drop the wrong one?
Should I bring that one back and drop the one below?
confused,
greg k-h
Quoted 20 lines
(This is the one which fixes a memory corruption, but triggers a bug causing oopses on single band cards.)
On 05/15/2009 12:33 AM, Greg KH wrote:
From: Jiri Slaby <[email protected]>commit
6909268dc93ae4b0b8e1ebb4b2fa70b1a47dd347upstream.pid doesn't count with some band having more bitrates than the one associated the first time.
Fix that by counting the maximal available bitrate count and allocate big enough space.Secondly, fix touching uninitialized memory which causes panics. Index sucked from this random memory points to the hell. The fix is to sort the rates on each band change.
Signed-off-by Jiri Slaby <[email protected]>Signed-off-by John W. Linville <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Re: [patch 29/51] mac80211: pid, fix memory corruption
Quoted 6 lines · Greg KH
Quoted 4 lines · Jiri Slaby
Hi,
note that you were about to drop this one now because of waiting for a fixup which is not upstream so far. Did anything change?
Quoted 8 lines
Hm, no, I dropped a different patch,
mac80211-minstrel-fix-memory-corruption.patch
did I drop the wrong one?Should I bring that one back and drop the one below?
confused,
Ah, sorry for the confusion, I didn't realize there are 2 of them. Both suffer from the same, because it's a cut&paste code.
Please drop this one too.
Thanks.
Re: [patch 29/51] mac80211: pid, fix memory corruption
In reply to Greg KHCCs chopped.
Quoted 7 lines · Greg KH
Quoted 2 lines · Jiri Slaby
note that you were about to drop this one now because of waiting for a fixup which is not upstream so far. Did anything change?
Hm, no, I dropped a different patch,
mac80211-minstrel-fix-memory-corruption.patch
did I drop the wrong one?
The aforementioned fix finally did it in. Please, apply 8e532175277d9a5eae49768ed086555081f741a7 (mac80211: minstrel, fix memory corruption)
6909268dc93ae4b0b8e1ebb4b2fa70b1a47dd347
(mac80211: pid, fix memory corruption)
621ad7c96aa138cfeab53cd4debc5a4e08b2189b
(mac80211: avoid NULL ptr deref when finding max_rates in PID and minstrel)
Thanks and sorry for the chaos.
Re: [patch 06/51] usb-serial: ftdi_sio: fix reference counting of ftdi_private
In reply to Greg KHQuoted 14 lines · Greg KH
2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Alan Stern <[email protected]>
commit
c45d63202fbaccef7ef7946c03f27f72c809b1ccupstream.This patch (as1238) adds proper reference counting for ftdi_sio's private data structure. Without it, the driver will free the structure while it is still in use if the user unplugs the serial device before closing the device file.
Quoted 8 lines
The patch also replaces a slightly dangerous cancel_delayed_work/flush_scheduled_work pair with
cancel_delayed_work_sync, which is always safer.Signed-off-by Alan Stern <[email protected]>Reported-by Daniel Mack <[email protected]>Tested-by Daniel Mack <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Works for me as long as you include the incremental patch I just sent.
Signature · 2 lines
David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
Re: [stable] [patch 29/51] mac80211: pid, fix memory corruption
In reply to Jiri SlabyQuoted 12 lines · Jiri Slaby
Quoted 11 lines · Greg KH
Quoted 4 lines · Jiri Slaby
Hi,
note that you were about to drop this one now because of waiting for a fixup which is not upstream so far. Did anything change?
Hm, no, I dropped a different patch,
mac80211-minstrel-fix-memory-corruption.patch
did I drop the wrong one?
Quoted 8 lines
Quoted 3 lines
Should I bring that one back and drop the one below?
confused,
Ah, sorry for the confusion, I didn't realize there are 2 of them. Both suffer from the same, because it's a cut&paste code.
Please drop this one too.
Ok, I've dropped it too, and will pick up all 3 for the next .29-stable release.
thanks,
greg k-h
Re: [stable] [patch 06/51] usb-serial: ftdi_sio: fix reference counting of ftdi_private
In reply to David WoodhouseQuoted 19 lines · David Woodhouse
Quoted 18 lines · Greg KH
2.6.29-stable review patch. If anyone has any objections, please let us know.
------------------
From: Alan Stern <[email protected]>
commit
c45d63202fbaccef7ef7946c03f27f72c809b1ccupstream.This patch (as1238) adds proper reference counting for ftdi_sio's private data structure. Without it, the driver will free the structure while it is still in use if the user unplugs the serial device before closing the device file.
The patch also replaces a slightly dangerous cancel_delayed_work/flush_scheduled_work pair with
cancel_delayed_work_sync, which is always safer.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Alan Stern <[email protected]>Reported-by Daniel Mack <[email protected]>Tested-by Daniel Mack <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Works for me as long as you include the incremental patch I just sent.
I'll queue that one up for the next .29-stable release.
thanks,
greg k-h
Re: [stable] [patch 29/51] mac80211: pid, fix memory corruption
In reply to Jiri SlabyQuoted 15 lines · Jiri Slaby
CCs chopped.
Quoted 7 lines · Greg KH
Quoted 2 lines · Jiri Slaby
note that you were about to drop this one now because of waiting for a fixup which is not upstream so far. Did anything change?
Hm, no, I dropped a different patch,
mac80211-minstrel-fix-memory-corruption.patch
did I drop the wrong one?The aforementioned fix finally did it in. Please, apply
8e532175277d9a5eae49768ed086555081f741a7(mac80211: minstrel, fix memory corruption)
Quoted 7 lines
6909268dc93ae4b0b8e1ebb4b2fa70b1a47dd347
(mac80211: pid, fix memory corruption)
621ad7c96aa138cfeab53cd4debc5a4e08b2189b
(mac80211: avoid NULL ptr deref when findingmax_ratesin PID and minstrel)Thanks and sorry for the chaos.
Heh, no problem. All of these are now queued up.
thanks,
greg k-h