v2.6.34.15 longterm review
Subsystems (92)
PATCH 153/213 USB: kaweth.c: use GFP_ATOMIC under spin_lock
In reply to Paul GortmakerFrom: Dan Carpenter <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit e4c7f259c5be99dcfc3d98f913590663b0305bf8 upstream.
The problem is that we call this with a spin lock held. The call tree is:
kaweth_start_xmit() holds kaweth->device_lock. -> kaweth_async_set_rx_mode() -> kaweth_control() -> kaweth_internal_control_msg()
The kaweth_internal_control_msg() function is only called from kaweth_control() which used GFP_ATOMIC for its allocations.
--- drivers/net/usb/kaweth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/kaweth.c +1 -1
@@ -1317,7 +1317,7 @@ static int kaweth_internal_control_msg(struct usb_device *usb_dev,int retv;int length =0 ;/* shut up GCC */ - urb =usb_alloc_urb (0 ,GFP_NOIO ); + urb =usb_alloc_urb (0 ,GFP_ATOMIC );if (!urb)return -ENOMEM ;
Signature · 1 line
1.8.5.2
PATCH 154/213 USB: cdc-wdm: fix lockup on error in wdm_read
In reply to Paul GortmakerFrom: Bjørn Mork <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit b086b6b10d9f182cd8d2f0dcfd7fd11edba93fc9 upstream.
Clear the WDM_READ flag on empty reads to avoid running forever in an infinite tight loop, causing lockups:
Jul 1 21:58:11 nemi kernel: [ 3658.898647] qmi_wwan 2-1:1.2: Unexpected error -71 Jul 1 21:58:36 nemi kernel: [ 3684.072021] BUG: soft lockup - CPU#0 stuck for 23s! [qmi.pl:12235] Jul 1 21:58:36 nemi kernel: [ 3684.072212] CPU 0 Jul 1 21:58:36 nemi kernel: [ 3684.072355] Jul 1 21:58:36 nemi kernel: [ 3684.072367] Pid: 12235, comm: qmi.pl Tainted: P O 3.5.0-rc2+ #13 LENOVO 2776LEG/2776LEG Jul 1 21:58:36 nemi kernel: [ 3684.072383] RIP: 0010:[<ffffffffa0635008>] [<ffffffffa0635008>] spin_unlock_irq+0x8/0xc [cdc_wdm] Jul 1 21:58:36 nemi kernel: [ 3684.072388] RSP: 0018:ffff88022dca1e70 EFLAGS: 00000282 Jul 1 21:58:36 nemi kernel: [ 3684.072393] RAX: ffff88022fc3f650 RBX: ffffffff811c56f7 RCX: 00000001000ce8c1 Jul 1 21:58:36 nemi kernel: [ 3684.072398] RDX: 0000000000000010 RSI: 000000000267d810 RDI: ffff88022fc3f650 Jul 1 21:58:36 nemi kernel: [ 3684.072403] RBP: ffff88022dca1eb0 R08: ffffffffa063578e R09: 0000000000000000 Jul 1 21:58:36 nemi kernel: [ 3684.072407] R10: 0000000000000008 R11: 0000000000000246 R12: 0000000000000002 Jul 1 21:58:36 nemi kernel: [ 3684.072412] R13: 0000000000000246 R14: ffffffff00000002 R15: ffff8802281d8c88 Jul 1 21:58:36 nemi kernel: [ 3684.072418] FS: 00007f666a260700(0000) GS:ffff88023bc00000(0000) knlGS:0000000000000000 Jul 1 21:58:36 nemi kernel: [ 3684.072423] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 Jul 1 21:58:36 nemi kernel: [ 3684.072428] CR2: 000000000270d9d8 CR3: 000000022e865000 CR4: 00000000000007f0 Jul 1 21:58:36 nemi kernel: [ 3684.072433] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 Jul 1 21:58:36 nemi kernel: [ 3684.072438] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Jul 1 21:58:36 nemi kernel: [ 3684.072444] Process qmi.pl (pid: 12235, threadinfo ffff88022dca0000, task ffff88022ff76380) Jul 1 21:58:36 nemi kernel: [ 3684.072448] Stack: Jul 1 21:58:36 nemi kernel: [ 3684.072458] ffffffffa063592e 0000000100020000 ffff88022fc3f650 ffff88022fc3f6a8 Jul 1 21:58:36 nemi kernel: [ 3684.072466] 0000000000000200 0000000100000000 000000000267d810 0000000000000000 Jul 1 21:58:36 nemi kernel: [ 3684.072475] 0000000000000000 ffff880212cfb6d0 0000000000000200 ffff880212cfb6c0 Jul 1 21:58:36 nemi kernel: [ 3684.072479] Call Trace: Jul 1 21:58:36 nemi kernel: [ 3684.072489] [<ffffffffa063592e>] ? wdm_read+0x1a0/0x263 [cdc_wdm] Jul 1 21:58:36 nemi kernel: [ 3684.072500] [<ffffffff8110adb7>] ? vfs_read+0xa1/0xfb Jul 1 21:58:36 nemi kernel: [ 3684.072509] [<ffffffff81040589>] ? alarm_setitimer+0x35/0x64 Jul 1 21:58:36 nemi kernel: [ 3684.072517] [<ffffffff8110aec7>] ? sys_read+0x45/0x6e Jul 1 21:58:36 nemi kernel: [ 3684.072525] [<ffffffff813725f9>] ? system_call_fastpath+0x16/0x1b Jul 1 21:58:36 nemi kernel: [ 3684.072557] Code: <66> 66 90 c3 83 ff ed 89 f8 74 16 7f 06 83 ff a1 75 0a c3 83 ff f4
The WDM_READ flag is normally cleared by wdm_int_callback before resubmitting the read urb, and set by wdm_in_callback when this urb returns with data or an error. But a crashing device may cause both a read error and cancelling all urbs. Make sure that the flag is cleared by wdm_read if the buffer is empty.
We don't clear the flag on errors, as there may be pending data in the buffer which should be processed. The flag will instead be cleared on the next wdm_read call.
--- drivers/usb/class/cdc-wdm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/class/cdc-wdm.c +2 -0
@@ -466,6 +466,8 @@ retry: }if (!desc->reslength) {/* zero length read */ +dev_dbg (&desc->intf->dev,"%s: zero length - clearing WDM_READ\n" , __func__); +clear_bit (WDM_READ , &desc->flags);spin_unlock_irq (&desc->iuspin); goto retry; }
Signature · 1 line
1.8.5.2
PATCH 155/213 USB: serial: fix race between probe and open
In reply to Paul GortmakerFrom: Johan Hovold <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit a65a6f14dc24a90bde3f5d0073ba2364476200bf upstream.
Fix race between probe and open by making sure that the disconnected flag is not cleared until all ports have been registered.
A call to tty_open while probe is running may get a reference to the serial structure in serial_install before its ports have been registered. This may lead to usb_serial_core calling driver open before port is fully initialised.
With ftdi_sio this result in the following NULL-pointer dereference as the private data has not been initialised at open:
[ 199.698286] IP: [<f811a089>] ftdi_open+0x59/0xe0 [ftdi_sio] [ 199.698297] *pde = 00000000 [ 199.698303] Oops: 0000 [#1] PREEMPT SMP [ 199.698313] Modules linked in: ftdi_sio usbserial [ 199.698323] [ 199.698327] Pid: 1146, comm: ftdi_open Not tainted 3.2.11 #70 Dell Inc. Vostro 1520/0T816J [ 199.698339] EIP: 0060:[<f811a089>] EFLAGS: 00010286 CPU: 0 [ 199.698344] EIP is at ftdi_open+0x59/0xe0 [ftdi_sio] [ 199.698348] EAX: 0000003e EBX: f5067000 ECX: 00000000 EDX: 80000600 [ 199.698352] ESI: f48d8800 EDI: 00000001 EBP: f515dd54 ESP: f515dcfc [ 199.698356] DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068 [ 199.698361] Process ftdi_open (pid: 1146, ti=f515c000 task=f481e040 task.ti=f515c000) [ 199.698364] Stack: [ 199.698368] f811a9fe f811a9e0 f811b3ef 00000000 00000000 00001388 00000000 f4a86800 [ 199.698387] 00000002 00000000 f806e68e 00000000 f532765c f481e040 00000246 22222222 [ 199.698479] 22222222 22222222 22222222 f5067004 f5327600 f5327638 f515dd74 f806e6ab [ 199.698496] Call Trace: [ 199.698504] [<f806e68e>] ? serial_activate+0x2e/0x70 [usbserial] [ 199.698511] [<f806e6ab>] serial_activate+0x4b/0x70 [usbserial] [ 199.698521] [<c126380c>] tty_port_open+0x7c/0xd0 [ 199.698527] [<f806e660>] ? serial_set_termios+0xa0/0xa0 [usbserial] [ 199.698534] [<f806e76f>] serial_open+0x2f/0x70 [usbserial] [ 199.698540] [<c125d07c>] tty_open+0x20c/0x510 [ 199.698546] [<c10e9eb7>] chrdev_open+0xe7/0x230 [ 199.698553] [<c10e48f2>] __dentry_open+0x1f2/0x390 [ 199.698559] [<c144bfec>] ? _raw_spin_unlock+0x2c/0x50 [ 199.698565] [<c10e4b76>] nameidata_to_filp+0x66/0x80 [ 199.698570] [<c10e9dd0>] ? cdev_put+0x20/0x20 [ 199.698576] [<c10f3e08>] do_last+0x198/0x730 [ 199.698581] [<c10f4440>] path_openat+0xa0/0x350 [ 199.698587] [<c10f47d5>] do_filp_open+0x35/0x80 [ 199.698593] [<c144bfec>] ? _raw_spin_unlock+0x2c/0x50 [ 199.698599] [<c10ff110>] ? alloc_fd+0xc0/0x100 [ 199.698605] [<c10f0b72>] ? getname_flags+0x72/0x120 [ 199.698611] [<c10e4450>] do_sys_open+0xf0/0x1c0 [ 199.698617] [<c11fcc08>] ? trace_hardirqs_on_thunk+0xc/0x10 [ 199.698623] [<c10e458e>] sys_open+0x2e/0x40 [ 199.698628] [<c144c990>] sysenter_do_call+0x12/0x36 [ 199.698632] Code: 85 89 00 00 00 8b 16 8b 4d c0 c1 e2 08 c7 44 24 14 88 13 00 00 81 ca 00 00 00 80 c7 44 24 10 00 00 00 00 c7 44 24 0c 00 00 00 00 <0f> b7 41 78 31 c9 89 44 24 08 c7 44 24 04 00 00 00 00 c7 04 24 [ 199.698884] EIP: [<f811a089>] ftdi_open+0x59/0xe0 [ftdi_sio] SS:ESP 0068:f515dcfc [ 199.698893] CR2: 0000000000000078 [ 199.698925] ---[ end trace 77c43ec023940cff ]---
--- drivers/usb/serial/usb-serial.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/serial/usb-serial.c +8 -0
@@ -1040,6 +1040,12 @@ int usb_serial_probe(struct usb_interface *interface, serial->attached =1 ; } +/* Avoid race with tty_open and serial_install by setting the +* disconnected flag and not clearing it until all ports have been +* registered. +*/ + serial->disconnected =1 ; +if (get_free_serial (serial, num_ports, &minor) ==NULL ) {dev_err (&interface->dev,"No more free serial devices\n" ); goto probe_error;
@@ -1062,6 +1068,8 @@ int usb_serial_probe(struct usb_interface *interface, } } + serial->disconnected =0 ; +usb_serial_console_init (debug, minor); exit:
Signature · 1 line
1.8.5.2
PATCH 156/213 usbdevfs: Correct amount of data copied to user in processcompl_compat
In reply to Paul GortmakerFrom: Hans de Goede <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 2102e06a5f2e414694921f23591f072a5ba7db9f upstream.
iso data buffers may have holes in them if some packets were short, so for iso urbs we should always copy the entire buffer, just like the regular processcompl does.
--- drivers/usb/core/devio.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/usb/core/devio.c +7 -3
@@ -1527,10 +1527,14 @@ static int processcompl_compat(struct async *as, void __user * __user *arg)void __user *addr = as->userurb;unsigned int i; -if (as->userbuffer && urb->actual_length) -if (copy_to_user (as->userbuffer, urb->transfer_buffer, - urb->actual_length)) +if (as->userbuffer && urb->actual_length) { +if (urb->number_of_packets >0 )/* Isochronous */ + i = urb->transfer_buffer_length; +else /* Non-Isoc */ + i = urb->actual_length; +if (copy_to_user (as->userbuffer, urb->transfer_buffer, i))return -EFAULT ; + }if (put_user (as->status, &userurb->status))return -EFAULT ;if (put_user (urb->actual_length, &userurb->actual_length))
Signature · 1 line
1.8.5.2
PATCH 157/213 epoll: prevent missed events on EPOLL_CTL_MOD
In reply to Paul GortmakerFrom: Eric Wong <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 128dd1759d96ad36c379240f8b9463e8acfd37a1 upstream.
EPOLL_CTL_MOD sets the interest mask before calling f_op->poll() to ensure events are not missed. Since the modifications to the interest mask are not protected by the same lock as ep_poll_callback, we need to ensure the change is visible to other CPUs calling ep_poll_callback.
We also need to ensure f_op->poll() has an up-to-date view of past events which occured before we modified the interest mask. So this barrier also pairs with the barrier in wq_has_sleeper().
This should guarantee either ep_poll_callback or f_op->poll() (or both) will notice the readiness of a recently-ready/modified item.
This issue was encountered by Andreas Voellmy and Junchang(Jason) Wang in:
http://thread.gmane.org/gmane.linux.kernel/1408782/
--- fs/eventpoll.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
fs/eventpoll.c +21 -1
@@ -1033,10 +1033,30 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_even* otherwise we might miss an event that happens between the * f_op->poll() call and the new event set registering. */ - epi->event.events = event->events; + epi->event.events = event->events;/* need barrier below */ epi->event.data = event->data;/* protected by mtx */ /* +* The following barrier has two effects: +* +* 1) Flush epi changes above to other CPUs. This ensures +* we do not miss events from ep_poll_callback if an +* event occurs immediately after we call f_op->poll(). +* We need this because we did not take ep->lock while +* changing epi above (but ep_poll_callback does take +* ep->lock). +* +* 2) We also need to ensure we do not miss _past_ events +* when calling f_op->poll(). This barrier also +* pairs with the barrier in wq_has_sleeper (see +* comments for wq_has_sleeper). +* +* This barrier will now guarantee ep_poll_callback or f_op->poll +* (or both) will notice the readiness of an item. +*/ +smp_mb (); + +/* * Get current event bits. We can safely use the file* here because * its usage count has been increased by the caller of this function. */
Signature · 1 line
1.8.5.2
PATCH 158/213 fs/compat_ioctl.c: VIDEO_SET_SPU_PALETTE missing error check
In reply to Paul GortmakerFrom: Kees Cook <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 12176503366885edd542389eed3aaf94be163fdb upstream.
The compat ioctl for VIDEO_SET_SPU_PALETTE was missing an error check while converting ioctl arguments. This could lead to leaking kernel stack contents into userspace.
Patch extracted from existing fix in grsecurity.
--- fs/compat_ioctl.c | 2 ++ 1 file changed, 2 insertions(+)
fs/compat_ioctl.c +2 -0
@@ -227,6 +227,8 @@ static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, err =get_user (palp, &up->palette); err |=get_user (length, &up->length); +if (err) +return -EFAULT ; up_native =compat_alloc_user_space (sizeof (struct video_spu_palette )); err =put_user (compat_ptr (palp), &up_native->palette);
Signature · 1 line
1.8.5.2
PATCH 159/213 fs/fscache/stats.c: fix memory leak
In reply to Paul GortmakerFrom: Anurup m <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit ec686c9239b4d472052a271c505d04dae84214cc upstream.
There is a kernel memory leak observed when the proc file /proc/fs/fscache/stats is read.
The reason is that in fscache_stats_open, single_open is called and the respective release function is not called during release. Hence fix with correct release function - single_release().
Addresses https://bugzilla.kernel.org/show_bug.cgi?id=57101
--- fs/fscache/stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fscache/stats.c +1 -1
@@ -276,5 +276,5 @@ const struct file_operations fscache_stats_fops = { .open = fscache_stats_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release, + .release = single_release, };
Signature · 1 line
1.8.5.2
PATCH 160/213 sysfs: sysfs_pathname/sysfs_add_one: Use strlcat() instead of strcat()
In reply to Paul GortmakerFrom: Geert Uytterhoeven <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 66081a72517a131430dcf986775f3268aafcb546 upstream.
The warning check for duplicate sysfs entries can cause a buffer overflow when printing the warning, as strcat() doesn't check buffer sizes. Use strlcat() instead.
Since strlcat() doesn't return a pointer to the passed buffer, unlike strcat(), I had to convert the nested concatenation in sysfs_add_one() to an admittedly more obscure comma operator construct, to avoid emitting code for the concatenation if CONFIG_BUG is disabled.
--- fs/sysfs/dir.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
fs/sysfs/dir.c +8 -8
@@ -400,20 +400,18 @@ int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)/** * sysfs_pathname - return full path to sysfs dirent * @sd: sysfs_dirent whose path we want -* @path: caller allocated buffer +* @path: caller allocated buffer of size PATH_MAX * * Gives the name "/" to the sysfs_root entry; any path returned * is relative to wherever sysfs is mounted. -* -* XXX: does no error checking on @path size */ static char *sysfs_pathname (struct sysfs_dirent *sd,char *path) {if (sd->s_parent) {sysfs_pathname (sd->s_parent, path); -strcat (path,"/" ); +strlcat (path,"/" ,PATH_MAX ); } -strcat (path, sd->s_name); +strlcat (path, sd->s_name,PATH_MAX );return path; }
@@ -446,9 +444,11 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)char *path =kzalloc (PATH_MAX ,GFP_KERNEL );WARN (1 ,KERN_WARNING "sysfs: cannot create duplicate filename '%s'\n" , - (path ==NULL ) ? sd->s_name : -strcat (strcat (sysfs_pathname (acxt->parent_sd, path),"/" ), - sd->s_name)); + (path ==NULL ) ? sd->s_name + : (sysfs_pathname (acxt->parent_sd, path), +strlcat (path,"/" ,PATH_MAX ), +strlcat (path, sd->s_name,PATH_MAX ), + path));kfree (path); }
Signature · 1 line
1.8.5.2
PATCH 161/213 tmpfs: fix use-after-free of mempolicy object
In reply to Paul GortmakerFrom: Greg Thelen <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 5f00110f7273f9ff04ac69a5f85bb535a4fd0987 upstream.
The tmpfs remount logic preserves filesystem mempolicy if the mpol=M option is not specified in the remount request. A new policy can be specified if mpol=M is given.
Before this patch remounting an mpol bound tmpfs without specifying mpol= mount option in the remount request would set the filesystem's mempolicy object to a freed mempolicy object.
To reproduce the problem boot a DEBUG_PAGEALLOC kernel and run:
# mkdir /tmp/x
# mount -t tmpfs -o size=100M,mpol=interleave nodev /tmp/x
# grep /tmp/x /proc/mounts
nodev /tmp/x tmpfs rw,relatime,size=102400k,mpol=interleave:0-3 0 0# mount -o remount,size=200M nodev /tmp/x
# grep /tmp/x /proc/mounts
nodev /tmp/x tmpfs rw,relatime,size=204800k,mpol=??? 0 0
# note ? garbage in mpol=... output above # dd if=/dev/zero of=/tmp/x/f count=1
# panic herePanic:
BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [< (null)>] (null)
[...]
Oops: 0010 [#1] SMP DEBUG_PAGEALLOC
Call Trace:
mpol_shared_policy_init+0xa5/0x160
shmem_get_inode+0x209/0x270
shmem_mknod+0x3e/0xf0
shmem_create+0x18/0x20
vfs_create+0xb5/0x130
do_last+0x9a1/0xea0
path_openat+0xb3/0x4d0
do_filp_open+0x42/0xa0
do_sys_open+0xfe/0x1e0
compat_sys_open+0x1b/0x20
cstar_dispatch+0x7/0x1fNon-debug kernels will not crash immediately because referencing the dangling mpol will not cause a fault. Instead the filesystem will reference a freed mempolicy object, which will cause unpredictable behavior.
The problem boils down to a dropped mpol reference below if shmem_parse_options() does not allocate a new mpol:
config = *sbinfo
shmem_parse_options(data, &config, true) mpol_put(sbinfo->mpol)
sbinfo->mpol = config.mpol /* BUG: saves unreferenced mpol */
This patch avoids the crash by not releasing the mempolicy if shmem_parse_options() doesn't create a new mpol.
How far back does this issue go? I see it in both 2.6.36 and 3.3. I did not look back further.
--- mm/shmem.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
mm/shmem.c +8 -2
@@ -2254,6 +2254,7 @@ static int shmem_remount_fs(struct super_block *sb, int *flags, char *data)unsigned long inodes;int error = -EINVAL ; + config.mpol =NULL ;if (shmem_parse_options (data, &config, true))return error;
@@ -2281,8 +2282,13 @@ static int shmem_remount_fs(struct super_block *sb, int *flags, char *data) sbinfo->max_inodes = config.max_inodes; sbinfo->free_inodes = config.max_inodes - inodes; -mpol_put (sbinfo->mpol); - sbinfo->mpol = config.mpol;/* transfers initial ref */ +/* +* Preserve previous mempolicy unless mpol remount option was specified. +*/ +if (config.mpol) { +mpol_put (sbinfo->mpol); + sbinfo->mpol = config.mpol;/* transfers initial ref */ + } out:spin_unlock (&sbinfo->stat_lock);return error;
Signature · 1 line
1.8.5.2
PATCH 162/213 fs/cifs/cifs_dfs_ref.c: fix potential memory leakage
In reply to Paul GortmakerFrom: Cong Ding <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 10b8c7dff5d3633b69e77f57d404dab54ead3787 upstream.
When it goes to error through line 144, the memory allocated to *devname is not freed, and the caller doesn't free it either in line 250. So we free the memroy of *devname in function cifs_compose_mount_options() when it goes to error.
--- fs/cifs/cifs_dfs_ref.c | 2 ++ 1 file changed, 2 insertions(+)
fs/cifs/cifs_dfs_ref.c +2 -0
@@ -227,6 +227,8 @@ compose_mount_options_out: compose_mount_options_err:kfree (mountdata); mountdata =ERR_PTR (rc); +kfree (*devname); + *devname =NULL ; goto compose_mount_options_out; }
Signature · 1 line
1.8.5.2
PATCH 163/213 isofs: avoid info leak on export
In reply to Paul GortmakerFrom: Mathias Krause <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit fe685aabf7c8c9f138e5ea900954d295bf229175 upstream.
For type 1 the parent_offset member in struct isofs_fid gets copied uninitialized to userland. Fix this by initializing it to 0.
--- fs/isofs/export.c | 1 + 1 file changed, 1 insertion(+)
fs/isofs/export.c +1 -0
@@ -131,6 +131,7 @@ isofs_export_encode_fh(struct dentry *dentry, len =3 ; fh32[0 ] = ei->i_iget5_block; fh16[2 ] = (__u16 )ei->i_iget5_offset;/* fh16 [sic] */ + fh16[3 ] =0 ;/* avoid leaking uninitialized data */ fh32[2 ] = inode->i_generation;if (connectable && !S_ISDIR (inode->i_mode)) {struct inode *parent;
Signature · 1 line
1.8.5.2
PATCH 164/213 jbd: Fix assertion failure in commit code due to lacking transaction credits
In reply to Paul GortmakerFrom: Jan Kara <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 09e05d4805e6c524c1af74e524e5d0528bb3fef3 upstream.
ext3 users of data=journal mode with blocksize < pagesize were occasionally hitting assertion failure in journal_commit_transaction() checking whether the transaction has at least as many credits reserved as buffers attached. The core of the problem is that when a file gets truncated, buffers that still need checkpointing or that are attached to the committing transaction are left with buffer_mapped set. When this happens to buffers beyond i_size attached to a page stradding i_size, subsequent write extending the file will see these buffers and as they are mapped (but underlying blocks were freed) things go awry from here.
The assertion failure just coincidentally (and in this case luckily as we would start corrupting filesystem) triggers due to journal_head not being properly cleaned up as well.
Under some rare circumstances this bug could even hit data=ordered mode users. There the assertion won't trigger and we would end up corrupting the filesystem.
We fix the problem by unmapping buffers if possible (in lots of cases we just need a buffer attached to a transaction as a place holder but it must not be written out anyway). And in one case, we just have to bite the bullet and wait for transaction commit to finish.
--- fs/jbd/commit.c | 45 +++++++++++++++++++++++++++--------- fs/jbd/transaction.c | 64 ++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 78 insertions(+), 31 deletions(-)
fs/jbd/commit.c +34 -11
@@ -84,7 +84,12 @@ nope:static void release_data_buffer (struct buffer_head *bh) {if (buffer_freed (bh)) { +WARN_ON_ONCE (buffer_dirty (bh));clear_buffer_freed (bh); +clear_buffer_mapped (bh); +clear_buffer_new (bh); +clear_buffer_req (bh); + bh->b_bdev =NULL ;release_buffer_page (bh); }else put_bh (bh);
@@ -863,17 +868,35 @@ restart_loop:* there's no point in keeping a checkpoint record for * it. */ -/* A buffer which has been freed while still being -* journaled by a previous transaction may end up still -* being dirty here, but we want to avoid writing back -* that buffer in the future after the "add to orphan" -* operation been committed, That's not only a performance -* gain, it also stops aliasing problems if the buffer is -* left behind for writeback and gets reallocated for another -* use in a different page. */ -if (buffer_freed (bh) && !jh->b_next_transaction) { -clear_buffer_freed (bh); -clear_buffer_jbddirty (bh); +/* +* A buffer which has been freed while still being journaled by +* a previous transaction. +*/ +if (buffer_freed (bh)) { +/* +* If the running transaction is the one containing +* "add to orphan" operation (b_next_transaction != +* NULL), we have to wait for that transaction to +* commit before we can really get rid of the buffer. +* So just clear b_modified to not confuse transaction +* credit accounting and refile the buffer to +* BJ_Forget of the running transaction. If the just +* committed transaction contains "add to orphan" +* operation, we can completely invalidate the buffer +* now. We are rather throughout in that since the +* buffer may be still accessible when blocksize < +* pagesize and it is attached to the last partial +* page. +*/ + jh->b_modified =0 ; +if (!jh->b_next_transaction) { +clear_buffer_freed (bh); +clear_buffer_jbddirty (bh); +clear_buffer_mapped (bh); +clear_buffer_new (bh); +clear_buffer_req (bh); + bh->b_bdev =NULL ; + } }if (buffer_jbddirty (bh)) {
fs/jbd/transaction.c +44 -20
118 lines not on this page · raw message
Signature · 1 line
1.8.5.2
PATCH 165/213 jbd: Fix lock ordering bug in journal_unmap_buffer()
In reply to Paul GortmakerFrom: Jan Kara <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 25389bb207987b5774182f763b9fb65ff08761c8 upstream.
Commit 09e05d48 introduced a wait for transaction commit into journal_unmap_buffer() in the case we are truncating a buffer undergoing commit in the page stradding i_size on a filesystem with blocksize < pagesize. Sadly we forgot to drop buffer lock before waiting for transaction commit and thus deadlock is possible when kjournald wants to lock the buffer.
Fix the problem by dropping the buffer lock before waiting for transaction commit. Since we are still holding page lock (and that is OK), buffer cannot disappear under us.
--- fs/jbd/transaction.c | 2 ++ 1 file changed, 2 insertions(+)
fs/jbd/transaction.c +2 -0
@@ -1956,7 +1956,9 @@ retry:spin_unlock (&journal->j_list_lock);jbd_unlock_bh_state (bh);spin_unlock (&journal->j_state_lock); +unlock_buffer (bh);log_wait_commit (journal, tid); +lock_buffer (bh); goto retry; }/*
Signature · 1 line
1.8.5.2
PATCH 166/213 jbd2: clear BH_Delay & BH_Unwritten in journal_unmap_buffer
In reply to Paul GortmakerFrom: Eric Sandeen <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 15291164b22a357cb211b618adfef4fa82fc0de3 upstream.
journal_unmap_buffer()'s zap_buffer: code clears a lot of buffer head state ala discard_buffer(), but does not touch _Delay or _Unwritten as discard_buffer() does.
This can be problematic in some areas of the ext4 code which assume that if they have found a buffer marked unwritten or delay, then it's a live one. Perhaps those spots should check whether it is mapped as well, but if jbd2 is going to tear down a buffer, let's really tear it down completely.
Without this I get some fsx failures on sub-page-block filesystems up until v3.2, at which point 4e96b2dbbf1d7e81f22047a50f862555a6cb87cb and 189e868fa8fdca702eb9db9d8afc46b5cb9144c9 make the failures go away, because buried within that large change is some more flag clearing. I still think it's worth doing in jbd2, since ->invalidatepage leads here directly, and it's the right place to clear away these flags.
--- fs/jbd2/transaction.c | 2 ++ 1 file changed, 2 insertions(+)
fs/jbd2/transaction.c +2 -0
@@ -1836,6 +1836,8 @@ zap_buffer_unlocked:clear_buffer_mapped (bh);clear_buffer_req (bh);clear_buffer_new (bh); +clear_buffer_delay (bh); +clear_buffer_unwritten (bh); bh->b_bdev =NULL ;return may_free; }
Signature · 1 line
1.8.5.2
PATCH 167/213 ecryptfs: call vfs_setxattr() in ecryptfs_setxattr()
In reply to Paul GortmakerFrom: Roberto Sassu <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 48b512e6857139393cdfce26348c362b87537018 upstream.
Ecryptfs is a stackable filesystem which relies on lower filesystems the ability of setting/getting extended attributes.
If there is a security module enabled on the system it updates the 'security' field of inodes according to the owned extended attribute set with the function vfs_setxattr(). When this function is performed on a ecryptfs filesystem the 'security' field is not updated for the lower filesystem since the call security_inode_post_setxattr() is missing for the lower inode.
Further, the call security_inode_setxattr() is missing for the lower inode, leading to policy violations in the security module because specific checks for this hook are not performed (i. e. filesystem 'associate' permission on SELinux is not checked for the lower filesystem).
This patch replaces the call of the setxattr() method of the lower inode in the function ecryptfs_setxattr() with vfs_setxattr().
--- fs/ecryptfs/inode.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/ecryptfs/inode.c +3 -4
@@ -32,6 +32,7 @@#include <linux/crypto.h> #include <linux/fs_stack.h> #include <linux/slab.h> +#include <linux/xattr.h> #include <asm/unaligned.h> #include "ecryptfs_kernel.h"
@@ -1054,10 +1055,8 @@ ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, rc = -EOPNOTSUPP ; goto out; } -mutex_lock (&lower_dentry->d_inode->i_mutex); - rc = lower_dentry->d_inode->i_op->setxattr (lower_dentry, name, value, - size, flags); -mutex_unlock (&lower_dentry->d_inode->i_mutex); + + rc =vfs_setxattr (lower_dentry, name, value, size, flags); out:return rc; }
Signature · 1 line
1.8.5.2
PATCH 168/213 eCryptfs: Copy up lower inode attrs after setting lower xattr
In reply to Paul GortmakerFrom: Tyler Hicks <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 545d680938be1e86a6c5250701ce9abaf360c495 upstream.
After passing through a ->setxattr() call, eCryptfs needs to copy the inode attributes from the lower inode to the eCryptfs inode, as they may have changed in the lower filesystem's ->setxattr() path.
One example is if an extended attribute containing a POSIX Access Control List is being set. The new ACL may cause the lower filesystem to modify the mode of the lower inode and the eCryptfs inode would need to be updated to reflect the new mode.
https://launchpad.net/bugs/926292
--- fs/ecryptfs/inode.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ecryptfs/inode.c +2 -0
@@ -1057,6 +1057,8 @@ ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, } rc =vfs_setxattr (lower_dentry, name, value, size, flags); +if (!rc) +fsstack_copy_attr_all (dentry->d_inode, lower_dentry->d_inode); out:return rc; }
Signature · 1 line
1.8.5.2
PATCH 169/213 ext3: Fix fdatasync() for files with only i_size changes
In reply to Paul GortmakerFrom: Jan Kara <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 156bddd8e505b295540f3ca0e27dda68cb0d49aa upstream.
Code tracking when transaction needs to be committed on fdatasync(2) forgets to handle a situation when only inode's i_size is changed. Thus in such situations fdatasync(2) doesn't force transaction with new i_size to disk and that can result in wrong i_size after a crash.
Fix the issue by updating inode's i_datasync_tid whenever its size is updated.
--- fs/ext3/inode.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
fs/ext3/inode.c +14 -3
@@ -2959,6 +2959,8 @@ static int ext3_do_update_inode(handle_t *handle,struct ext3_inode_info *ei =EXT3_I (inode);struct buffer_head *bh = iloc->bh;int err =0 , rc, block; +int need_datasync =0 ; +__le32 disksize; again:/* we can't allow multiple procs in here at once, its a bit racey */
@@ -2996,7 +2998,11 @@ again: raw_inode->i_gid_high =0 ; } raw_inode->i_links_count =cpu_to_le16 (inode->i_nlink); - raw_inode->i_size =cpu_to_le32 (ei->i_disksize); + disksize =cpu_to_le32 (ei->i_disksize); +if (disksize != raw_inode->i_size) { + need_datasync =1 ; + raw_inode->i_size = disksize; + } raw_inode->i_atime =cpu_to_le32 (inode->i_atime.tv_sec); raw_inode->i_ctime =cpu_to_le32 (inode->i_ctime.tv_sec); raw_inode->i_mtime =cpu_to_le32 (inode->i_mtime.tv_sec);
@@ -3012,8 +3018,11 @@ again:if (!S_ISREG (inode->i_mode)) { raw_inode->i_dir_acl =cpu_to_le32 (ei->i_dir_acl); } else { - raw_inode->i_size_high = - cpu_to_le32(ei->i_disksize >> 32); + disksize = cpu_to_le32(ei->i_disksize >> 32); + if (disksize != raw_inode->i_size_high) { + raw_inode->i_size_high = disksize; + need_datasync = 1; + } if (ei->i_disksize > 0x7fffffffULL) { struct super_block *sb = inode->i_sb; if (!EXT3_HAS_RO_COMPAT_FEATURE(sb,
@@ -3066,6 +3075,8 @@ again:ext3_clear_inode_state (inode,EXT3_STATE_NEW );atomic_set (&ei->i_sync_tid, handle->h_transaction->t_tid); +if (need_datasync) +atomic_set (&ei->i_datasync_tid, handle->h_transaction->t_tid); out_brelse:brelse (bh);ext3_std_error (inode->i_sb, err);
Signature · 1 line
1.8.5.2
PATCH 170/213 ext3: Fix error handling on inode bitmap corruption
In reply to Paul GortmakerFrom: Jan Kara <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 1415dd8705394399d59a3df1ab48d149e1e41e77 upstream.
When insert_inode_locked() fails in ext3_new_inode() it most likely means inode bitmap got corrupted and we allocated again inode which is already in use. Also doing unlock_new_inode() during error recovery is wrong since inode does not have I_NEW set. Fix the problem by jumping to fail: (instead of fail_drop:) which declares filesystem error and does not call unlock_new_inode().
--- fs/ext3/ialloc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/ext3/ialloc.c +6 -2
@@ -575,8 +575,12 @@ got:if (IS_DIRSYNC (inode)) handle->h_sync =1 ;if (insert_inode_locked (inode) <0 ) { - err = -EINVAL ; - goto fail_drop; +/* +* Likely a bitmap corruption causing inode to be allocated +* twice. +*/ + err = -EIO ; + goto fail; }spin_lock (&sbi->s_next_gen_lock); inode->i_generation = sbi->s_next_generation++;
Signature · 1 line
1.8.5.2
PATCH 171/213 ext4: don't let i_reserved_meta_blocks go negative
In reply to Paul GortmakerFrom: Brian Foster <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 97795d2a5b8d3c8dc4365d4bd3404191840453ba upstream.
If we hit a condition where we have allocated metadata blocks that were not appropriately reserved, we risk underflow of ei->i_reserved_meta_blocks. In turn, this can throw sbi->s_dirtyclusters_counter significantly out of whack and undermine the nondelalloc fallback logic in ext4_nonda_switch(). Warn if this occurs and set i_allocated_meta_blocks to avoid this problem.
This condition is reproduced by xfstests 270 against ext2 with delalloc enabled:
Mar 28 08:58:02 localhost kernel: [ 171.526344] EXT4-fs (loop1): delayed block allocation failed for inode 14 at logical offset 64486 with max blocks 64 with error -28 Mar 28 08:58:02 localhost kernel: [ 171.526346] EXT4-fs (loop1): This should not happen!! Data will be lost
270 ultimately fails with an inconsistent filesystem and requires an fsck to repair. The cause of the error is an underflow in ext4_da_update_reserve_space() due to an unreserved meta block allocation.
--- fs/ext4/inode.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/ext4/inode.c +9 -0
@@ -1089,6 +1089,15 @@ void ext4_da_update_reserve_space(struct inode *inode, used = ei->i_reserved_data_blocks; } +if (unlikely (ei->i_allocated_meta_blocks > ei->i_reserved_meta_blocks)) { +ext4_msg (inode->i_sb,KERN_NOTICE ,"%s: ino %lu, allocated %d " +"with only %d reserved metadata blocks\n" , __func__, + inode->i_ino, ei->i_allocated_meta_blocks, + ei->i_reserved_meta_blocks); +WARN_ON (1 ); + ei->i_allocated_meta_blocks = ei->i_reserved_meta_blocks; + } +/* Update per-inode reservations */ ei->i_reserved_data_blocks -= used; used += ei->i_allocated_meta_blocks;
Signature · 1 line
1.8.5.2
PATCH 172/213 ext4: Fix fs corruption when make_indexed_dir() fails
In reply to Paul GortmakerFrom: Jan Kara <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 7ad8e4e6ae2a7c95445ee1715b1714106fb95037 upstream.
When make_indexed_dir() fails (e.g. because of ENOSPC) after it has allocated block for index tree root, we did not properly mark all changed buffers dirty. This lead to only some of these buffers being written out and thus effectively corrupting the directory.
Fix the issue by marking all changed data dirty even in the error failure case.
--- fs/ext4/namei.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
fs/ext4/namei.c +12 -2
@@ -1452,9 +1452,19 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry, frame->bh = bh; bh = bh2; de =do_split (handle,dir, &bh, frame, &hinfo, &retval); -dx_release (frames); -if (!(de)) +if (!de) { +/* +* Even if the block split failed, we have to properly write +* out all the changes we did so far. Otherwise we can end up +* with corrupted filesystem. +*/ +ext4_mark_inode_dirty (handle, dir); +ext4_handle_dirty_metadata (handle, dir, frame->bh); +ext4_handle_dirty_metadata (handle, dir, bh); +dx_release (frames);return retval; + } +dx_release (frames); retval =add_dirent_to_buf (handle, dentry, inode, de, bh);brelse (bh);
Signature · 1 line
1.8.5.2
PATCH 173/213 ext4: don't dereference null pointer when make_indexed_dir() fails
In reply to Paul GortmakerFrom: Allison Henderson <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 6976a6f2acde2b0443cd64f1d08af90630e4ce81 upstream.
Fix for a null pointer bug found while running punch hole tests
--- fs/ext4/namei.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/ext4/namei.c +4 -2
@@ -1451,6 +1451,10 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry, frame->at = entries; frame->bh = bh; bh = bh2; + +ext4_handle_dirty_metadata (handle, dir, frame->bh); +ext4_handle_dirty_metadata (handle, dir, bh); + de =do_split (handle,dir, &bh, frame, &hinfo, &retval);if (!de) {/*
@@ -1459,8 +1463,6 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,* with corrupted filesystem. */ ext4_mark_inode_dirty (handle, dir); -ext4_handle_dirty_metadata (handle, dir, frame->bh); -ext4_handle_dirty_metadata (handle, dir, bh);dx_release (frames);return retval; }
Signature · 1 line
1.8.5.2
PATCH 174/213 ext4: fix memory leak in ext4_xattr_set_acl()'s error path
In reply to Paul GortmakerFrom: Eugene Shatokhin <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 24ec19b0ae83a385ad9c55520716da671274b96c upstream.
In ext4_xattr_set_acl(), if ext4_journal_start() returns an error, posix_acl_release() will not be called for 'acl' which may result in a memory leak.
This patch fixes that.
--- fs/ext4/acl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/ext4/acl.c +4 -2
@@ -442,8 +442,10 @@ ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, retry: handle =ext4_journal_start (inode,EXT4_DATA_TRANS_BLOCKS (inode->i_sb)); -if (IS_ERR (handle)) -return PTR_ERR (handle); +if (IS_ERR (handle)) { + error =PTR_ERR (handle); + goto release_and_out; + } error =ext4_set_acl (handle, inode, type, acl);ext4_journal_stop (handle);if (error == -ENOSPC &&ext4_should_retry_alloc (inode->i_sb, &retries))
Signature · 1 line
1.8.5.2
PATCH 175/213 ext4: online defrag is not supported for journaled files
In reply to Paul GortmakerFrom: Dmitry Monakhov <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit f066055a3449f0e5b0ae4f3ceab4445bead47638 upstream.
Proper block swap for inodes with full journaling enabled is truly non obvious task. In order to be on a safe side let's explicitly disable it for now.
--- fs/ext4/move_extent.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/ext4/move_extent.c +6 -1
@@ -1209,7 +1209,12 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, orig_inode->i_ino, donor_inode->i_ino);return -EINVAL ; } - +/* TODO: This is non obvious task to swap blocks for inodes with full +jornaling enabled */ +if (ext4_should_journal_data (orig_inode) || +ext4_should_journal_data (donor_inode)) { +return -EINVAL ; + }/* Protect orig and donor inodes against a truncate */ ret1 =mext_inode_double_lock (orig_inode, donor_inode);if (ret1 <0 )
Signature · 1 line
1.8.5.2
PATCH 176/213 ext4: always set i_op in ext4_mknod()
In reply to Paul GortmakerFrom: Bernd Schubert <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 6a08f447facb4f9e29fcc30fb68060bb5a0d21c2 upstream.
ext4_special_inode_operations have their own ifdef CONFIG_EXT4_FS_XATTR to mask those methods. And ext4_iget also always sets it, so there is an inconsistency.
--- fs/ext4/namei.c | 2 -- 1 file changed, 2 deletions(-)
fs/ext4/namei.c +0 -2
@@ -1825,9 +1825,7 @@ retry: err =PTR_ERR (inode);if (!IS_ERR (inode)) {init_special_inode (inode, inode->i_mode, rdev); -#ifdef CONFIG_EXT4_FS_XATTR inode->i_op = &ext4_special_inode_operations; -#endif err =ext4_add_nondir (handle, dentry, inode); }ext4_journal_stop (handle);
Signature · 1 line
1.8.5.2
PATCH 177/213 ext4: fix fdatasync() for files with only i_size changes
In reply to Paul GortmakerFrom: Jan Kara <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit b71fc079b5d8f42b2a52743c8d2f1d35d655b1c5 upstream.
Code tracking when transaction needs to be committed on fdatasync(2) forgets to handle a situation when only inode's i_size is changed. Thus in such situations fdatasync(2) doesn't force transaction with new i_size to disk and that can result in wrong i_size after a crash.
Fix the issue by updating inode's i_datasync_tid whenever its size is updated.
--- fs/ext4/inode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/ext4/inode.c +6 -2
@@ -5236,6 +5236,7 @@ static int ext4_do_update_inode(handle_t *handle,struct ext4_inode_info *ei =EXT4_I (inode);struct buffer_head *bh = iloc->bh;int err =0 , rc, block; +int need_datasync =0 ;/* For fields not not tracking in the in-memory inode, * initialise them to zero for new inodes. */
@@ -5284,7 +5285,10 @@ static int ext4_do_update_inode(handle_t *handle, raw_inode->i_file_acl_high =cpu_to_le16 (ei->i_file_acl >>32 ); raw_inode->i_file_acl_lo =cpu_to_le32 (ei->i_file_acl); -ext4_isize_set (raw_inode, ei->i_disksize); +if (ei->i_disksize !=ext4_isize (raw_inode)) { +ext4_isize_set (raw_inode, ei->i_disksize); + need_datasync =1 ; + } if (ei->i_disksize > 0x7fffffffULL) { struct super_block *sb = inode->i_sb; if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
@@ -5337,7 +5341,7 @@ static int ext4_do_update_inode(handle_t *handle, err = rc;ext4_clear_inode_state (inode,EXT4_STATE_NEW ); -ext4_update_inode_fsync_trans (handle, inode,0 ); +ext4_update_inode_fsync_trans (handle, inode, need_datasync); out_brelse:brelse (bh);ext4_std_error (inode->i_sb, err);
Signature · 1 line
1.8.5.2
PATCH 178/213 ext4: lock i_mutex when truncating orphan inodes
In reply to Paul GortmakerFrom: Theodore Ts'o <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 721e3eba21e43532e438652dd8f1fcdfce3187e7 upstream.
Commit c278531d39 added a warning when ext4_flush_unwritten_io() is called without i_mutex being taken. It had previously not been taken during orphan cleanup since races weren't possible at that point in the mount process, but as a result of this c278531d39, we will now see a kernel WARN_ON in this case. Take the i_mutex in ext4_orphan_cleanup() to suppress this warning.
--- fs/ext4/super.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ext4/super.c +2 -0
@@ -2028,7 +2028,9 @@ static void ext4_orphan_cleanup(struct super_block *sb, __func__, inode->i_ino, inode->i_size);jbd_debug (2 ,"truncating inode %lu to %lld bytes\n" , inode->i_ino, inode->i_size); +mutex_lock (&inode->i_mutex);ext4_truncate (inode); +mutex_unlock (&inode->i_mutex); nr_truncates++; }else { ext4_msg(sb, KERN_DEBUG,
Signature · 1 line
1.8.5.2
PATCH 179/213 ext4: fix race in ext4_mb_add_n_trim()
In reply to Paul GortmakerFrom: Niu Yawei <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit f1167009711032b0d747ec89a632a626c901a1ad upstream.
In ext4_mb_add_n_trim(), lg_prealloc_lock should be taken when changing the lg_prealloc_list.
--- fs/ext4/mballoc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/ext4/mballoc.c +3 -3
@@ -4153,7 +4153,7 @@ static void ext4_mb_add_n_trim(struct ext4_allocation_context *ac)/* The max size of hash table is PREALLOC_TB_SIZE */ order =PREALLOC_TB_SIZE -1 ;/* Add the prealloc space to lg */ -rcu_read_lock (); +spin_lock (&lg->lg_prealloc_lock);list_for_each_entry_rcu (tmp_pa, &lg->lg_prealloc_list[order], pa_inode_list) {spin_lock (&tmp_pa->pa_lock);
@@ -4177,12 +4177,12 @@ static void ext4_mb_add_n_trim(struct ext4_allocation_context *ac)if (!added)list_add_tail_rcu (&pa->pa_inode_list, &lg->lg_prealloc_list[order]); -rcu_read_unlock (); +spin_unlock (&lg->lg_prealloc_lock);/* Now trim the list to be not more than 8 elements */ if (lg_prealloc_count >8 ) {ext4_mb_discard_lg_preallocations (sb, lg, - order, lg_prealloc_count); + order, lg_prealloc_count);return ; }return ;
Signature · 1 line
1.8.5.2
PATCH 180/213 ext4: limit group search loop for non-extent files
In reply to Paul GortmakerFrom: Lachlan McIlroy <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit e6155736ad76b2070652745f9e54cdea3f0d8567 upstream.
In the case where we are allocating for a non-extent file, we must limit the groups we allocate from to those below 2^32 blocks, and ext4_mb_regular_allocator() attempts to do this initially by putting a cap on ngroups for the subsequent search loop.
However, the initial target group comes in from the allocation context (ac), and it may already be beyond the artificially limited ngroups. In this case, the limit
if (group == ngroups) group = 0;
at the top of the loop is never true, and the loop will run away.
Catch this case inside the loop and reset the search to start at group 0.
[[email protected]: add commit msg & comments]
--- fs/ext4/mballoc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ext4/mballoc.c +5 -1
@@ -2068,7 +2068,11 @@ repeat: group = ac->ac_g_ex.fe_group;for (i =0 ; i < ngroups; group++, i++) { -if (group == ngroups) +/* +* Artificially restricted ngroups for non-extent +* files makes group > ngroups possible on first loop. +*/ +if (group >= ngroups) group =0 ;/* This now checks without needing the buddy page */
Signature · 1 line
1.8.5.2
PATCH 181/213 ext4: make orphan functions be no-op in no-journal mode
In reply to Paul GortmakerFrom: Anatol Pomozov <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit c9b92530a723ac5ef8e352885a1862b18f31b2f5 upstream.
Instead of checking whether the handle is valid, we check if journal is enabled. This avoids taking the s_orphan_lock mutex in all cases when there is no journal in use, including the error paths where ext4_orphan_del() is called with a handle set to NULL.
--- fs/ext4/namei.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/ext4/namei.c +3 -4
@@ -2000,7 +2000,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)struct ext4_iloc iloc;int err =0 , rc; -if (!ext4_handle_valid (handle)) +if (!EXT4_SB (sb)->s_journal)return 0 ;mutex_lock (&EXT4_SB (sb)->s_orphan_lock);
@@ -2081,8 +2081,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)struct ext4_iloc iloc;int err =0 ; -/* ext4_handle_valid() assumes a valid handle_t pointer */ -if (handle && !ext4_handle_valid (handle)) +if (!EXT4_SB (inode->i_sb)->s_journal)return 0 ;mutex_lock (&EXT4_SB (inode->i_sb)->s_orphan_lock);
@@ -2101,7 +2100,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)* transaction handle with which to update the orphan list on * disk, but we still need to remove the inode from the linked * list in memory. */ -if (sbi->s_journal && !handle) +if (!handle) goto out; err =ext4_reserve_inode_write (handle, inode, &iloc);
Signature · 1 line
1.8.5.2
PATCH 182/213 ext4: avoid hang when mounting non-journal filesystems with orphan list
In reply to Paul GortmakerFrom: Theodore Ts'o <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 0e9a9a1ad619e7e987815d20262d36a2f95717ca upstream.
When trying to mount a file system which does not contain a journal, but which does have a orphan list containing an inode which needs to be truncated, the mount call with hang forever in ext4_orphan_cleanup() because ext4_orphan_del() will return immediately without removing the inode from the orphan list, leading to an uninterruptible loop in kernel code which will busy out one of the CPU's on the system.
This can be trivially reproduced by trying to mount the file system found in tests/f_orphan_extents_inode/image.gz from the e2fsprogs source tree. If a malicious user were to put this on a USB stick, and mount it on a Linux desktop which has automatic mounts enabled, this could be considered a potential denial of service attack. (Not a big deal in practice, but professional paranoids worry about such things, and have even been known to allocate CVE numbers for such problems.)
--- fs/ext4/namei.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/namei.c +2 -1
@@ -2081,7 +2081,8 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)struct ext4_iloc iloc;int err =0 ; -if (!EXT4_SB (inode->i_sb)->s_journal) +if ((!EXT4_SB (inode->i_sb)->s_journal) && + !(EXT4_SB (inode->i_sb)->s_mount_state &EXT4_ORPHAN_FS ))return 0 ;mutex_lock (&EXT4_SB (inode->i_sb)->s_orphan_lock);
Signature · 1 line
1.8.5.2
PATCH 183/213 ext4: fix error handling on inode bitmap corruption
In reply to Paul GortmakerFrom: Jan Kara <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit acd6ad83517639e8f09a8c5525b1dccd81cd2a10 upstream.
When insert_inode_locked() fails in ext4_new_inode() it most likely means inode bitmap got corrupted and we allocated again inode which is already in use. Also doing unlock_new_inode() during error recovery is wrong since the inode does not have I_NEW set. Fix the problem by jumping to fail: (instead of fail_drop:) which declares filesystem error and does not call unlock_new_inode().
--- fs/ext4/ialloc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/ext4/ialloc.c +6 -2
@@ -1009,8 +1009,12 @@ got:if (IS_DIRSYNC (inode))ext4_handle_sync (handle);if (insert_inode_locked (inode) <0 ) { - err = -EINVAL ; - goto fail_drop; +/* +* Likely a bitmap corruption causing inode to be allocated +* twice. +*/ + err = -EIO ; + goto fail; }spin_lock (&sbi->s_next_gen_lock); inode->i_generation = sbi->s_next_generation++;
Signature · 1 line
1.8.5.2
PATCH 184/213 btrfs: use rcu_barrier() to wait for bdev puts at unmount
In reply to Paul GortmakerFrom: Eric Sandeen <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit bc178622d40d87e75abc131007342429c9b03351 upstream.
Doing this would reliably fail with -EBUSY for me:
# mount /dev/sdb2 /mnt/scratch; umount /mnt/scratch; mkfs.btrfs -f /dev/sdb2 ... unable to open /dev/sdb2: Device or resource busy
because mkfs.btrfs tries to open the device O_EXCL, and somebody still has it.
Using systemtap to track bdev gets & puts shows a kworker thread doing a blkdev put after mkfs attempts a get; this is left over from the unmount path:
btrfs_close_devices
__btrfs_close_devices call_rcu(&device->rcu, free_device); free_device INIT_WORK(&device->rcu_work, __free_device); schedule_work(&device->rcu_work);
so unmount might complete before __free_device fires & does its blkdev_put.
Adding an rcu_barrier() to btrfs_close_devices() causes unmount to wait until all blkdev_put()s are done, and the device is truly free once unmount completes.
--- fs/btrfs/volumes.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/btrfs/volumes.c +6 -0
@@ -565,6 +565,12 @@ int btrfs_close_devices(struct btrfs_fs_devices *fs_devices)__btrfs_close_devices (fs_devices);free_fs_devices (fs_devices); } +/* +* Wait for rcu kworkers under __btrfs_close_devices +* to finish all blkdev_puts so device is really +* free when umount is done. +*/ +rcu_barrier ();return ret; }
Signature · 1 line
1.8.5.2
PATCH 185/213 Btrfs: call the ordered free operation without any locks held
In reply to Paul GortmakerFrom: Chris Mason <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit e9fbcb42201c862fd6ab45c48ead4f47bb2dea9d upstream.
Each ordered operation has a free callback, and this was called with the worker spinlock held. Josef made the free callback also call iput, which we can't do with the spinlock.
This drops the spinlock for the free operation and grabs it again before moving through the rest of the list. We'll circle back around to this and find a cleaner way that doesn't bounce the lock around so much.
--- fs/btrfs/async-thread.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/btrfs/async-thread.c +8 -1
@@ -212,10 +212,17 @@ static noinline int run_ordered_completions(struct btrfs_workers *workers, work->ordered_func (work); -/* now take the lock again and call the freeing code */ +/* now take the lock again and drop our item from the list */ spin_lock (&workers->order_lock);list_del (&work->order_list); +spin_unlock (&workers->order_lock); + +/* +* we don't want to call the ordered free functions +* with the lock held though +*/ work->ordered_free (work); +spin_lock (&workers->order_lock); }spin_unlock (&workers->order_lock);
Signature · 1 line
1.8.5.2
PATCH 186/213 udf: fix memory leak while allocating blocks during write
In reply to Paul GortmakerFrom: Namjae Jeon <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 2fb7d99d0de3fd8ae869f35ab682581d8455887a upstream.
Need to brelse the buffer_head stored in cur_epos and next_epos.
--- fs/udf/inode.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/udf/inode.c +4 -0
@@ -654,6 +654,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, goal, err);if (!newblocknum) {brelse (prev_epos.bh); +brelse (cur_epos.bh); +brelse (next_epos.bh); *err = -ENOSPC ;return NULL ; }
@@ -684,6 +686,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,udf_update_extents (inode, laarr, startnum, endnum, &prev_epos);brelse (prev_epos.bh); +brelse (cur_epos.bh); +brelse (next_epos.bh); newblock =udf_get_pblock (inode->i_sb, newblocknum, iinfo->i_location.partitionReferenceNum,0 );
Signature · 1 line
1.8.5.2
PATCH 187/213 udf: avoid info leak on export
In reply to Paul GortmakerFrom: Mathias Krause <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 0143fc5e9f6f5aad4764801015bc8d4b4a278200 upstream.
For type 0x51 the udf.parent_partref member in struct fid gets copied uninitialized to userland. Fix this by initializing it to 0.
--- fs/udf/namei.c | 1 + 1 file changed, 1 insertion(+)
fs/udf/namei.c +1 -0
@@ -1366,6 +1366,7 @@ static int udf_encode_fh(struct dentry *de, __u32 *fh, int *lenp, *lenp =3 ; fid->udf.block = location.logicalBlockNum; fid->udf.partref = location.partitionReferenceNum; + fid->udf.parent_partref =0 ; fid->udf.generation = inode->i_generation;if (connectable && !S_ISDIR (inode->i_mode)) {
Signature · 1 line
1.8.5.2
PATCH 188/213 udf: Fix bitmap overflow on large filesystems with small block size
In reply to Paul GortmakerFrom: Jan Kara <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 89b1f39eb4189de745fae554b0d614d87c8d5c63 upstream.
For large UDF filesystems with 512-byte blocks the number of necessary bitmap blocks is larger than 2^16 so s_nr_groups in udf_bitmap overflows (the number will overflow for filesystems larger than 128 GB with 512-byte blocks). That results in ENOSPC errors despite the filesystem has plenty of free space.
Fix the problem by changing s_nr_groups' type to 'int'. That is enough even for filesystems 2^32 blocks (UDF maximum) and 512-byte blocksize.
--- fs/udf/udf_sb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/udf/udf_sb.h +1 -1
@@ -78,7 +78,7 @@ struct udf_virtual_data {struct udf_bitmap {__u32 s_extLength;__u32 s_extPosition; -__u16 s_nr_groups; +int s_nr_groups;struct buffer_head **s_block_bitmap; };
Signature · 1 line
1.8.5.2
PATCH 189/213 udf: Fix data corruption for files in ICB
In reply to Paul GortmakerFrom: Jan Kara <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 9c2fc0de1a6e638fe58c354a463f544f42a90a09 upstream.
When a file is stored in ICB (inode), we overwrite part of the file, and the page containing file's data is not in page cache, we end up corrupting file's data by overwriting them with zeros. The problem is we use simple_write_begin() which simply zeroes parts of the page which are not written to. The problem has been introduced by be021ee4 (udf: convert to new aops).
Fix the problem by providing a ->write_begin function which makes the page properly uptodate.
--- fs/udf/file.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-)
fs/udf/file.c +29 -6
@@ -41,20 +41,24 @@#include "udf_i.h" #include "udf_sb.h" -static int udf_adinicb_readpage (struct file *file,struct page *page) +static void __udf_adinicb_readpage (struct page *page) {struct inode *inode = page->mapping->host;char *kaddr;struct udf_inode_info *iinfo =UDF_I (inode); -BUG_ON (!PageLocked (page)); - kaddr =kmap (page); -memset (kaddr,0 ,PAGE_CACHE_SIZE );memcpy (kaddr, iinfo->i_ext.i_data + iinfo->i_lenEAttr, inode->i_size); +memset (kaddr + inode->i_size,0 ,PAGE_CACHE_SIZE - inode->i_size);flush_dcache_page (page);SetPageUptodate (page);kunmap (page); +} + +static int udf_adinicb_readpage (struct file *file,struct page *page) +{ +BUG_ON (!PageLocked (page)); +__udf_adinicb_readpage (page);unlock_page (page);return 0 ;
@@ -79,6 +83,25 @@ static int udf_adinicb_writepage(struct page *page,return 0 ; } +static int udf_adinicb_write_begin (struct file *file, +struct address_space *mapping,loff_t pos, +unsigned len,unsigned flags,struct page **pagep, +void **fsdata) +{ +struct page *page; + +if (WARN_ON_ONCE (pos >=PAGE_CACHE_SIZE )) +return -EIO ; + page =grab_cache_page_write_begin (mapping,0 , flags); +if (!page) +return -ENOMEM ; + *pagep = page; + +if (!PageUptodate (page) && len !=PAGE_CACHE_SIZE ) +__udf_adinicb_readpage (page); +return 0 ; +} + static int udf_adinicb_write_end(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned copied,
@@ -101,8 +124,8 @@ const struct address_space_operations udf_adinicb_aops = { .readpage = udf_adinicb_readpage, .writepage = udf_adinicb_writepage, .sync_page = block_sync_page, - .write_begin = simple_write_begin, - .write_end = udf_adinicb_write_end, + .write_begin = udf_adinicb_write_begin, + .write_end = udf_adinicb_write_end, }; static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
Signature · 1 line
1.8.5.2
PATCH 190/213 udf: fix retun value on error path in udf_load_logicalvol
In reply to Paul GortmakerFrom: Nikola Pajkovsky <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 68766a2edcd5cd744262a70a2f67a320ac944760 upstream.
In case we detect a problem and bail out, we fail to set "ret" to a nonzero value, and udf_load_logicalvol will mistakenly report success.
--- fs/udf/super.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/udf/super.c +4 -1
@@ -1314,6 +1314,7 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,"error loading logical volume descriptor: " "Partition table too long (%u > %lu)\n" , table_len, sb->s_blocksize - sizeof(*lvd)); + ret =1 ; goto out_bh; }
@@ -1360,8 +1361,10 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE))) {if (udf_load_sparable_map (sb, map, - (struct sparablePartitionMap *)gpm) <0 ) + (struct sparablePartitionMap *)gpm) <0 ) { + ret =1 ; goto out_bh; + } } else if (!strncmp(upm2->partIdent.ident, UDF_ID_METADATA, strlen(UDF_ID_METADATA))) {
Signature · 1 line
1.8.5.2
PATCH 191/213 Fix install_process_keyring error handling
In reply to Paul GortmakerFrom: Andi Kleen <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 27d6379894be4a81984da4d48002196a83939ca9 upstream.
Fix an incorrect error check that returns 1 for error instead of the expected error code.
--- security/keys/process_keys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/process_keys.c +1 -1
@@ -207,7 +207,7 @@ static int install_process_keyring(void) ret =install_process_keyring_to_cred (new);if (ret <0 ) {abort_creds (new); -return ret != -EEXIST ?:0 ; +return ret != -EEXIST ? ret :0 ; }return commit_creds (new);
Signature · 1 line
1.8.5.2
PATCH 192/213 mtd: cafe_nand: fix an & vs | mistake
In reply to Paul GortmakerFrom: Dan Carpenter <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 48f8b641297df49021093763a3271119a84990a2 upstream.
The intent here was clearly to set result to true if the 0x40000000 flag was set. But instead there was a | vs & typo and we always set result to true.
Artem: check the spec at wiki.laptop.org/images/5/5c/88ALP01_Datasheet_July_2007.pdf and this fix looks correct.
--- drivers/mtd/nand/cafe_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/cafe_nand.c +1 -1
@@ -104,7 +104,7 @@ static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };static int cafe_device_ready (struct mtd_info *mtd) {struct cafe_priv *cafe = mtd->priv; -int result = !!(cafe_readl (cafe,NAND_STATUS ) |0x40000000 ); +int result = !!(cafe_readl (cafe,NAND_STATUS ) &0x40000000 );uint32_t irqs =cafe_readl (cafe,NAND_IRQ );cafe_writel (cafe, irqs,NAND_IRQ );
Signature · 1 line
1.8.5.2
PATCH 193/213 dccp: check ccid before dereferencing
In reply to Paul GortmakerFrom: Mathias Krause <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 276bdb82dedb290511467a5a4fdbe9f0b52dce6f upstream.
ccid_hc_rx_getsockopt() and ccid_hc_tx_getsockopt() might be called with a NULL ccid pointer leading to a NULL pointer dereference. This could lead to a privilege escalation if the attacker is able to map page 0 and prepare it with a fake ccid_ops pointer.
--- net/dccp/ccid.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/dccp/ccid.h +2 -2
@@ -218,7 +218,7 @@ static inline int ccid_hc_rx_getsockopt(struct ccid *ccid, struct sock *sk, u32 __user *optval, int __user *optlen) {int rc = -ENOPROTOOPT ; -if (ccid->ccid_ops->ccid_hc_rx_getsockopt !=NULL ) +if (ccid !=NULL && ccid->ccid_ops->ccid_hc_rx_getsockopt !=NULL ) rc = ccid->ccid_ops->ccid_hc_rx_getsockopt (sk, optname, len, optval, optlen);return rc;
@@ -229,7 +229,7 @@ static inline int ccid_hc_tx_getsockopt(struct ccid *ccid, struct sock *sk, u32 __user *optval, int __user *optlen) {int rc = -ENOPROTOOPT ; -if (ccid->ccid_ops->ccid_hc_tx_getsockopt !=NULL ) +if (ccid !=NULL && ccid->ccid_ops->ccid_hc_tx_getsockopt !=NULL ) rc = ccid->ccid_ops->ccid_hc_tx_getsockopt (sk, optname, len, optval, optlen);return rc;
Signature · 1 line
1.8.5.2
PATCH 194/213 Remove user-triggerable BUG from mpol_to_str
In reply to Paul GortmakerFrom: Dave Jones <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 80de7c3138ee9fd86a98696fd2cf7ad89b995d0a upstream.
Trivially triggerable, found by trinity:
kernel BUG at mm/mempolicy.c:2546!
Process trinity-child2 (pid: 23988, threadinfo ffff88010197e000, task ffff88007821a670)
Call Trace:
show_numa_map+0xd5/0x450
show_pid_numa_map+0x13/0x20
traverse+0xf2/0x230
seq_read+0x34b/0x3e0
vfs_read+0xac/0x180
sys_pread64+0xa2/0xc0
system_call_fastpath+0x1a/0x1f
RIP: mpol_to_str+0x156/0x360--- mm/mempolicy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mempolicy.c +1 -1
@@ -2330,7 +2330,7 @@ int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, int no_context)break ;default : -BUG (); +return -EINVAL ; } l =strlen (policy_types[mode]);
Signature · 1 line
1.8.5.2
PATCH 195/213 svcrpc: sends on closed socket should stop immediately
In reply to Paul GortmakerFrom: "J. Bruce Fields" <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit f06f00a24d76e168ecb38d352126fd203937b601 upstream.
svc_tcp_sendto sets XPT_CLOSE if we fail to transmit the entire reply. However, the XPT_CLOSE won't be acted on immediately. Meanwhile other threads could send further replies before the socket is really shut down. This can manifest as data corruption: for example, if a truncated read reply is followed by another rpc reply, that second reply will look to the client like further read data.
Symptoms were data corruption preceded by svc_tcp_sendto logging something like
kernel: rpc-srv/tcp: nfsd: sent only 963696 when sending 1048708 bytes - shutting down socket
--- net/sunrpc/svc_xprt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sunrpc/svc_xprt.c +2 -1
@@ -807,7 +807,8 @@ int svc_send(struct svc_rqst *rqstp)/* Grab mutex to serialize outgoing data. */ mutex_lock (&xprt->xpt_mutex); -if (test_bit (XPT_DEAD , &xprt->xpt_flags)) +if (test_bit (XPT_DEAD , &xprt->xpt_flags) + ||test_bit (XPT_CLOSE , &xprt->xpt_flags)) len = -ENOTCONN ;else len = xprt->xpt_ops->xpo_sendto (rqstp);
Signature · 1 line
1.8.5.2
PATCH 196/213 svcrpc: fix svc_xprt_enqueue/svc_recv busy-looping
In reply to Paul GortmakerFrom: "J. Bruce Fields" <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit d10f27a750312ed5638c876e4bd6aa83664cccd8 upstream.
The rpc server tries to ensure that there will be room to send a reply before it receives a request.
It does this by tracking, in xpt_reserved, an upper bound on the total size of the replies that is has already committed to for the socket.
Currently it is adding in the estimate for a new reply *before* it checks whether there is space available. If it finds that there is not space, it then subtracts the estimate back out.
This may lead the subsequent svc_xprt_enqueue to decide that there is space after all.
The results is a svc_recv() that will repeatedly return -EAGAIN, causing server threads to loop without doing any actual work.
--- net/sunrpc/svc_xprt.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
net/sunrpc/svc_xprt.c +2 -5
@@ -310,7 +310,6 @@ static void svc_thread_dequeue(struct svc_pool *pool, struct svc_rqst *rqstp)*/ void svc_xprt_enqueue (struct svc_xprt *xprt) { -struct svc_serv *serv = xprt->xpt_server;struct svc_pool *pool;struct svc_rqst *rqstp;int cpu;
@@ -384,8 +383,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt) rqstp, rqstp->rq_xprt); rqstp->rq_xprt = xprt;svc_xprt_get (xprt); - rqstp->rq_reserved = serv->sv_max_mesg; -atomic_add (rqstp->rq_reserved, &xprt->xpt_reserved); pool->sp_stats.threads_woken++;BUG_ON (xprt->xpt_pool != pool);wake_up (&rqstp->rq_wait);
@@ -663,8 +660,6 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)if (xprt) { rqstp->rq_xprt = xprt;svc_xprt_get (xprt); - rqstp->rq_reserved = serv->sv_max_mesg; -atomic_add (rqstp->rq_reserved, &xprt->xpt_reserved); }else {/* No data pending. Go to sleep */ svc_thread_enqueue (pool, rqstp);
@@ -754,6 +749,8 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) }else len = xprt->xpt_ops->xpo_recvfrom (rqstp);dprintk ("svc: got len=%d\n" , len); + rqstp->rq_reserved = serv->sv_max_mesg; +atomic_add (rqstp->rq_reserved, &xprt->xpt_reserved); }/* No data, incomplete (TCP) read, or accept() */
Signature · 1 line
1.8.5.2
PATCH 197/213 vfs: missed source of ->f_pos races
In reply to Paul GortmakerFrom: Al Viro <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 0e665d5d1125f9f4ccff56a75e814f10f88861a2 upstream.
compat_sys_{read,write}v() need the same "pass a copy of file->f_pos" thing as sys_{read,write}{,v}().
--- fs/compat.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/compat.c +8 -2
@@ -1231,11 +1231,14 @@ compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec,struct file *file;int fput_needed;ssize_t ret; +loff_t pos; file =fget_light (fd, &fput_needed);if (!file)return -EBADF ; - ret =compat_readv (file, vec, vlen, &file->f_pos); + pos = file->f_pos; + ret =compat_readv (file, vec, vlen, &pos); + file->f_pos = pos;fput_light (file, fput_needed);return ret; }
@@ -1288,11 +1291,14 @@ compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec,struct file *file;int fput_needed;ssize_t ret; +loff_t pos; file =fget_light (fd, &fput_needed);if (!file)return -EBADF ; - ret =compat_writev (file, vec, vlen, &file->f_pos); + pos = file->f_pos; + ret =compat_writev (file, vec, vlen, &pos); + file->f_pos = pos;fput_light (file, fput_needed);return ret; }
Signature · 1 line
1.8.5.2
PATCH 198/213 fuse: verify all ioctl retry iov elements
In reply to Paul GortmakerFrom: Zach Brown <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit fb6ccff667712c46b4501b920ea73a326e49626a upstream.
Commit 7572777eef78ebdee1ecb7c258c0ef94d35bad16 attempted to verify that the total iovec from the client doesn't overflow iov_length() but it only checked the first element. The iovec could still overflow by starting with a small element. The obvious fix is to check all the elements.
The overflow case doesn't look dangerous to the kernel as the copy is limited by the length after the overflow. This fix restores the intention of returning an error instead of successfully copying less than the iovec represented.
I found this by code inspection. I built it but don't have a test case. I'm cc:ing stable because the initial commit did as well.
--- fs/fuse/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/file.c +1 -1
@@ -1664,7 +1664,7 @@ static int fuse_verify_ioctl_iov(struct iovec *iov, size_t count)size_t n;u32 max =FUSE_MAX_PAGES_PER_REQ <<PAGE_SHIFT ; -for (n =0 ; n < count; n++) { +for (n =0 ; n < count; n++, iov++) {if (iov->iov_len > (size_t ) max)return -ENOMEM ; max -= iov->iov_len;
Signature · 1 line
1.8.5.2
PATCH 199/213 pcdp: use early_ioremap/early_iounmap to access pcdp table
In reply to Paul GortmakerFrom: Greg Pearson <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 6c4088ac3a4d82779903433bcd5f048c58fb1aca upstream.
efi_setup_pcdp_console() is called during boot to parse the HCDP/PCDP EFI system table and setup an early console for printk output. The routine uses ioremap/iounmap to setup access to the HCDP/PCDP table information.
The call to ioremap is happening early in the boot process which leads to a panic on x86_64 systems:
panic+0x01ca
do_exit+0x043c
oops_end+0x00a7
no_context+0x0119
__bad_area_nosemaphore+0x0138
bad_area_nosemaphore+0x000e
do_page_fault+0x0321
page_fault+0x0020
reserve_memtype+0x02a1
__ioremap_caller+0x0123
ioremap_nocache+0x0012
efi_setup_pcdp_console+0x002b
setup_arch+0x03a9
start_kernel+0x00d4
x86_64_start_reservations+0x012c
x86_64_start_kernel+0x00feThis replaces the calls to ioremap/iounmap in efi_setup_pcdp_console() with calls to early_ioremap/early_iounmap which can be called during early boot.
This patch was tested on an x86_64 prototype system which uses the HCDP/PCDP table for early console setup.
--- drivers/firmware/pcdp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/pcdp.c +2 -2
@@ -95,7 +95,7 @@ efi_setup_pcdp_console(char *cmdline)if (efi.hcdp ==EFI_INVALID_TABLE_ADDR )return -ENODEV ; - pcdp =ioremap (efi.hcdp,4096 ); + pcdp =early_ioremap (efi.hcdp,4096 );printk (KERN_INFO "PCDP: v%d at 0x%lx\n" , pcdp->rev, efi.hcdp);if (strstr (cmdline,"console=hcdp" )) {
@@ -131,6 +131,6 @@ efi_setup_pcdp_console(char *cmdline) } out: -iounmap (pcdp); +early_iounmap (pcdp,4096 );return rc; }
Signature · 1 line
1.8.5.2
PATCH 200/213 futex: Forbid uaddr == uaddr2 in futex_wait_requeue_pi()
In reply to Paul GortmakerFrom: Darren Hart <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 6f7b0a2a5c0fb03be7c25bd1745baa50582348ef upstream.
If uaddr == uaddr2, then we have broken the rule of only requeueing from a non-pi futex to a pi futex with this call. If we attempt this, as the trinity test suite manages to do, we miss early wakeups as q.key is equal to key2 (because they are the same uaddr). We will then attempt to dereference the pi_mutex (which would exist had the futex_q been properly requeued to a pi futex) and trigger a NULL pointer dereference.
--- kernel/futex.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/futex.c +8 -5
@@ -2204,11 +2204,11 @@ int handle_early_requeue_pi_wakeup(struct futex_hash_bucket *hb,* @uaddr2: the pi futex we will take prior to returning to user-space * * The caller will wait on uaddr and will be requeued by futex_requeue() to -* uaddr2 which must be PI aware. Normal wakeup will wake on uaddr2 and -* complete the acquisition of the rt_mutex prior to returning to userspace. -* This ensures the rt_mutex maintains an owner when it has waiters; without -* one, the pi logic wouldn't know which task to boost/deboost, if there was a -* need to. +* uaddr2 which must be PI aware and unique from uaddr. Normal wakeup will wake +* on uaddr2 and complete the acquisition of the rt_mutex prior to returning to +* userspace. This ensures the rt_mutex maintains an owner when it has waiters; +* without one, the pi logic would not know which task to boost/deboost, if +* there was a need to. * * We call schedule in futex_wait_queue_me() when we enqueue and return there * via the following:
@@ -2245,6 +2245,9 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared,struct futex_q q;int res, ret; +if (uaddr == uaddr2) +return -EINVAL ; +if (!bitset)return -EINVAL ;
Signature · 1 line
1.8.5.2
PATCH 201/213 futex: Fix bug in WARN_ON for NULL q.pi_state
In reply to Paul GortmakerFrom: Darren Hart <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit f27071cb7fe3e1d37a9dbe6c0dfc5395cd40fa43 upstream.
The WARN_ON in futex_wait_requeue_pi() for a NULL q.pi_state was testing the address (&q.pi_state) of the pointer instead of the value (q.pi_state) of the pointer. Correct it accordingly.
--- kernel/futex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/futex.c +1 -1
@@ -2321,7 +2321,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared,* signal. futex_unlock_pi() will not destroy the lock_ptr nor * the pi_state. */ -WARN_ON (!&q.pi_state); +WARN_ON (!q.pi_state); pi_mutex = &q.pi_state->pi_mutex; ret =rt_mutex_finish_proxy_lock (pi_mutex, to, &rt_waiter,1 );debug_rt_mutex_free_waiter (&rt_waiter);
Signature · 1 line
1.8.5.2
PATCH 202/213 futex: Test for pi_mutex on fault in futex_wait_requeue_pi()
In reply to Paul GortmakerFrom: Darren Hart <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit b6070a8d9853eda010a549fa9a09eb8d7269b929 upstream.
If fixup_pi_state_owner() faults, pi_mutex may be NULL. Test for pi_mutex != NULL before testing the owner against current and possibly unlocking it.
--- kernel/futex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/futex.c +1 -1
@@ -2348,7 +2348,7 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared,* fault, unlock the rt_mutex and return the fault to userspace. */ if (ret == -EFAULT ) { -if (rt_mutex_owner (pi_mutex) == current) +if (pi_mutex &&rt_mutex_owner (pi_mutex) == current)rt_mutex_unlock (pi_mutex); }else if (ret == -EINTR ) {/*
Signature · 1 line
1.8.5.2
PATCH 203/213 cipso: don't follow a NULL pointer when setsockopt() is called
In reply to Paul GortmakerFrom: Paul Moore <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit a9d0acf8d157c30374af76d43e7f05b5b108be0c upstream.
[ Upstream commit 89d7ae34cdda4195809a5a987f697a517a2a3177 ]
As reported by Alan Cox, and verified by Lin Ming, when a user attempts to add a CIPSO option to a socket using the CIPSO_V4_TAG_LOCAL tag the kernel dies a terrible death when it attempts to follow a NULL pointer (the skb argument to cipso_v4_validate() is NULL when called via the setsockopt() syscall).
This patch fixes this by first checking to ensure that the skb is non-NULL before using it to find the incoming network interface. In the unlikely case where the skb is NULL and the user attempts to add a CIPSO option with the _TAG_LOCAL tag we return an error as this is not something we want to allow.
A simple reproducer, kindly supplied by Lin Ming, although you must have the CIPSO DOI #3 configure on the system first or you will be caught early in cipso_v4_validate():
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/ip.h>
#include <linux/in.h>
#include <string.h>
struct local_tag {
char type;
char length;
char info[4];
};
struct cipso {
char type;
char length;
char doi[4];
struct local_tag local;
};
int main(int argc, char **argv)
{
int sockfd;
struct cipso cipso = {
.type = IPOPT_CIPSO,
.length = sizeof(struct cipso),
.local = {
.type = 128,
.length = sizeof(struct local_tag),
},
};
memset(cipso.doi, 0, 4);
cipso.doi[3] = 3;
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
#define SOL_IP 0
setsockopt(sockfd, SOL_IP, IP_OPTIONS,
&cipso, sizeof(struct cipso));
return 0;
}--- net/ipv4/cipso_ipv4.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/ipv4/cipso_ipv4.c +4 -2
@@ -1727,8 +1727,10 @@ int cipso_v4_validate(const struct sk_buff *skb, unsigned char **option)case CIPSO_V4_TAG_LOCAL :/* This is a non-standard tag that we only allow for * local connections, so if the incoming interface is -* not the loopback device drop the packet. */ -if (!(skb->dev->flags &IFF_LOOPBACK )) { +* not the loopback device drop the packet. Further, +* there is no legitimate reason for setting this from +* userspace so reject it if skb is NULL. */ +if (skb ==NULL || !(skb->dev->flags &IFF_LOOPBACK )) { err_offset = opt_iter; goto validate_return_locked; }
Signature · 1 line
1.8.5.2
PATCH 204/213 Avoid dangling pointer in scsi_requeue_command()
In reply to Paul GortmakerFrom: Bart Van Assche <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 940f5d47e2f2e1fa00443921a0abf4822335b54d upstream.
When we call scsi_unprep_request() the command associated with the request gets destroyed and therefore drops its reference on the device. If this was the only reference, the device may get released and we end up with a NULL pointer deref when we call blk_requeue_request.
--- drivers/scsi/scsi_lib.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/scsi/scsi_lib.c +11 -0
@@ -484,15 +484,26 @@ static void scsi_run_queue(struct request_queue *q)*/ static void scsi_requeue_command (struct request_queue *q,struct scsi_cmnd *cmd) { +struct scsi_device *sdev = cmd->device;struct request *req = cmd->request;unsigned long flags; +/* +* We need to hold a reference on the device to avoid the queue being +* killed after the unlock and before scsi_run_queue is invoked which +* may happen because scsi_unprep_request() puts the command which +* releases its reference on the device. +*/ +get_device (&sdev->sdev_gendev); +spin_lock_irqsave (q->queue_lock, flags);scsi_unprep_request (req);blk_requeue_request (q, req);spin_unlock_irqrestore (q->queue_lock, flags);scsi_run_queue (q); + +put_device (&sdev->sdev_gendev); }void scsi_next_command (struct scsi_cmnd *cmd)
Signature · 1 line
1.8.5.2
PATCH 205/213 libsas: continue revalidation
In reply to Paul GortmakerFrom: Dan Williams <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 26f2f199ff150d8876b2641c41e60d1c92d2fb81 upstream.
Continue running revalidation until no more broadcast devices are discovered. Fixes cases where re-discovery completes too early in a domain with multiple expanders with pending re-discovery events. Servicing BCNs can get backed up behind error recovery.
--- drivers/scsi/libsas/sas_expander.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/libsas/sas_expander.c +4 -4
@@ -1947,9 +1947,7 @@ int sas_ex_revalidate_domain(struct domain_device *port_dev)struct domain_device *dev =NULL ; res =sas_find_bcast_dev (port_dev, &dev); -if (res) - goto out; -if (dev) { +while (res ==0 && dev) {struct expander_device *ex = &dev->ex_dev;int i =0 , phy_id;
@@ -1961,8 +1959,10 @@ int sas_ex_revalidate_domain(struct domain_device *port_dev) res =sas_rediscover (dev, phy_id); i = phy_id +1 ; }while (i < ex->num_phys); + + dev =NULL ; + res =sas_find_bcast_dev (port_dev, &dev); } -out:return res; }
Signature · 1 line
1.8.5.2
PATCH 206/213 SCSI: libsas: fix sas_discover_devices return code handling
In reply to Paul GortmakerFrom: Dan Williams <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit e69e5d3d25d6b58543f782a515baeda064e2b601 upstream.
commit b17caa174a7e1fd2e17b26e210d4ee91c4c28b37 upstream.
commit 198439e4 [SCSI] libsas: do not set res = 0 in sas_ex_discover_dev() commit 19252de6 [SCSI] libsas: fix wide port hotplug issues
The above commits seem to have confused the return value of sas_ex_discover_dev which is non-zero on failure and sas_ex_join_wide_port which just indicates short circuiting discovery on already established ports. The result is random discovery failures depending on configuration.
Calls to sas_ex_join_wide_port are the source of the trouble as its return value is errantly assigned to 'res'. Convert it to bool and stop returning its result up the stack.
--- drivers/scsi/libsas/sas_expander.c | 39 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 27 deletions(-)
drivers/scsi/libsas/sas_expander.c +12 -27
@@ -755,7 +755,7 @@ static struct domain_device *sas_ex_discover_end_dev( }/* See if this phy is part of a wide port */ -static int sas_ex_join_wide_port (struct domain_device *parent,int phy_id) +static bool sas_ex_join_wide_port (struct domain_device *parent,int phy_id) {struct ex_phy *phy = &parent->ex_dev.ex_phy[phy_id];int i;
@@ -771,11 +771,11 @@ static int sas_ex_join_wide_port(struct domain_device *parent, int phy_id)sas_port_add_phy (ephy->port, phy->phy); phy->port = ephy->port; phy->phy_state =PHY_DEVICE_DISCOVERED ; -return 0 ; +return true; } } -return -ENODEV ; +return false; } static struct domain_device *sas_ex_discover_expander(
@@ -913,8 +913,7 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)return res; } - res =sas_ex_join_wide_port (dev, phy_id); -if (!res) { +if (sas_ex_join_wide_port (dev, phy_id)) {SAS_DPRINTK ("Attaching ex phy%d to wide port %016llx\n" , phy_id,SAS_ADDR (ex_phy->attached_sas_addr));return res;
@@ -959,8 +958,7 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)if (SAS_ADDR (ex->ex_phy[i].attached_sas_addr) ==SAS_ADDR (child->sas_addr)) { ex->ex_phy[i].phy_state=PHY_DEVICE_DISCOVERED ; - res =sas_ex_join_wide_port (dev, i); -if (!res) +if (sas_ex_join_wide_port (dev, i))SAS_DPRINTK ("Attaching ex phy%d to wide port %016llx\n" , i,SAS_ADDR (ex->ex_phy[i].attached_sas_addr));
@@ -1813,32 +1811,20 @@ static int sas_discover_new(struct domain_device *dev, int phy_id) {struct ex_phy *ex_phy = &dev->ex_dev.ex_phy[phy_id];struct domain_device *child; -bool found = false; -int res, i; +int res;SAS_DPRINTK ("ex %016llx phy%d new device attached\n" ,SAS_ADDR (dev->sas_addr), phy_id); res =sas_ex_phy_discover (dev, phy_id);if (res) - goto out; -/* to support the wide port inserted */ -for (i =0 ; i < dev->ex_dev.num_phys; i++) { -struct ex_phy *ex_phy_temp = &dev->ex_dev.ex_phy[i]; -if (i == phy_id) -continue ; -if (SAS_ADDR (ex_phy_temp->attached_sas_addr) == -SAS_ADDR (ex_phy->attached_sas_addr)) { - found = true; -break ; - } - } -if (found) { -sas_ex_join_wide_port (dev, phy_id); +return res; + +if (sas_ex_join_wide_port (dev, phy_id))return 0 ; - } + res =sas_ex_discover_devices (dev, phy_id); -if (!res) - goto out; +if (res) +return res;list_for_each_entry (child, &dev->ex_dev.children, siblings) {if (SAS_ADDR (child->sas_addr) ==SAS_ADDR (ex_phy->attached_sas_addr)) {
@@ -1848,7 +1834,6 @@ static int sas_discover_new(struct domain_device *dev, int phy_id)break ; } } -out:return res; }
Signature · 1 line
1.8.5.2
PATCH 207/213 fix eh wakeup (scsi_schedule_eh vs scsi_restart_operations)
In reply to Paul GortmakerFrom: Dan Williams <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 57fc2e335fd3c2f898ee73570dc81426c28dc7b4 upstream.
Rapid ata hotplug on a libsas controller results in cases where libsas is waiting indefinitely on eh to perform an ata probe.
A race exists between scsi_schedule_eh() and scsi_restart_operations() in the case when scsi_restart_operations() issues i/o to other devices in the sas domain. When this happens the host state transitions from SHOST_RECOVERY (set by scsi_schedule_eh) back to SHOST_RUNNING and ->host_busy is non-zero so we put the eh thread to sleep even though ->host_eh_scheduled is active.
Before putting the error handler to sleep we need to check if the host_state needs to return to SHOST_RECOVERY for another trip through eh. Since i/o that is released by scsi_restart_operations has been blocked for at least one eh cycle, this implementation allows those i/o's to run before another eh cycle starts to discourage hung task timeouts.
--- drivers/scsi/scsi_error.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/scsi/scsi_error.c +14 -0
@@ -1614,6 +1614,20 @@ static void scsi_restart_operations(struct Scsi_Host *shost)* requests are started. */ scsi_run_host_queues (shost); + +/* +* if eh is active and host_eh_scheduled is pending we need to re-run +* recovery. we do this check after scsi_run_host_queues() to allow +* everything pent up since the last eh run a chance to make forward +* progress before we sync again. Either we'll immediately re-run +* recovery or scsi_device_unbusy() will wake us again when these +* pending commands complete. +*/ +spin_lock_irqsave (shost->host_lock, flags); +if (shost->host_eh_scheduled) +if (scsi_host_set_state (shost,SHOST_RECOVERY )) +WARN_ON (scsi_host_set_state (shost,SHOST_CANCEL_RECOVERY )); +spin_unlock_irqrestore (shost->host_lock, flags); }/**
Signature · 1 line
1.8.5.2
PATCH 208/213 eCryptfs: Properly check for O_RDONLY flag before doing privileged open
In reply to Paul GortmakerFrom: Tyler Hicks <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 9fe79d7600497ed8a95c3981cbe5b73ab98222f0 upstream.
If the first attempt at opening the lower file read/write fails, eCryptfs will retry using a privileged kthread. However, the privileged retry should not happen if the lower file's inode is read-only because a read/write open will still be unsuccessful.
The check for determining if the open should be retried was intended to be based on the access mode of the lower file's open flags being O_RDONLY, but the check was incorrectly performed. This would cause the open to be retried by the privileged kthread, resulting in a second failed open of the lower file. This patch corrects the check to determine if the open request should be handled by the privileged kthread.
--- fs/ecryptfs/kthread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ecryptfs/kthread.c +1 -1
@@ -149,7 +149,7 @@ int ecryptfs_privileged_open(struct file **lower_file, (*lower_file) =dentry_open (lower_dentry, lower_mnt, flags, cred);if (!IS_ERR (*lower_file)) goto out; -if (flags &O_RDONLY ) { +if ((flags &O_ACCMODE ) ==O_RDONLY ) { rc =PTR_ERR ((*lower_file)); goto out; }
Signature · 1 line
1.8.5.2
PATCH 209/213 fuse: fix stat call on 32 bit platforms
In reply to Paul GortmakerFrom: Pavel Shilovsky <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 45c72cd73c788dd18c8113d4a404d6b4a01decf1 upstream.
Now we store attr->ino at inode->i_ino, return attr->ino at the first time and then return inode->i_ino if the attribute timeout isn't expired. That's wrong on 32 bit platforms because attr->ino is 64 bit and inode->i_ino is 32 bit in this case.
Fix this by saving 64 bit ino in fuse_inode structure and returning it every time we call getattr. Also squash attr->ino into inode->i_ino explicitly.
--- fs/fuse/dir.c | 1 + fs/fuse/fuse_i.h | 3 +++ fs/fuse/inode.c | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-)
fs/fuse/dir.c +1 -0
@@ -855,6 +855,7 @@ int fuse_update_attributes(struct inode *inode, struct kstat *stat,if (stat) {generic_fillattr (inode, stat); stat->mode = fi->orig_i_mode; + stat->ino = fi->orig_ino; } }
fs/fuse/fuse_i.h +3 -0
@@ -76,6 +76,9 @@ struct fuse_inode {preserve the original mode */ mode_t orig_i_mode; +/** 64 bit inode number */ +u64 orig_ino; +/** Version of last attribute change */ u64 attr_version;
fs/fuse/inode.c +16 -1
@@ -86,6 +86,7 @@ static struct inode *fuse_alloc_inode(struct super_block *sb) fi->nlookup =0 ; fi->attr_version =0 ; fi->writectr =0 ; + fi->orig_ino =0 ;INIT_LIST_HEAD (&fi->write_files);INIT_LIST_HEAD (&fi->queued_writes);INIT_LIST_HEAD (&fi->writepages);
@@ -140,6 +141,18 @@ static int fuse_remount_fs(struct super_block *sb, int *flags, char *data)return 0 ; } +/* +* ino_t is 32-bits on 32-bit arch. We have to squash the 64-bit value down +* so that it will fit. +*/ +static ino_t fuse_squash_ino (u64 ino64) +{ +ino_t ino = (ino_t ) ino64; +if (sizeof (ino_t) <sizeof (u64)) + ino ^= ino64 >> (sizeof (u64) -sizeof (ino_t)) *8 ; +return ino; +} +void fuse_change_attributes_common (struct inode *inode,struct fuse_attr *attr,u64 attr_valid) {
@@ -149,7 +162,7 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr, fi->attr_version = ++fc->attr_version; fi->i_time = attr_valid; - inode->i_ino = attr->ino; + inode->i_ino =fuse_squash_ino (attr->ino); inode->i_mode = (inode->i_mode &S_IFMT ) | (attr->mode &07777 ); inode->i_nlink = attr->nlink; inode->i_uid = attr->uid;
@@ -175,6 +188,8 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr, fi->orig_i_mode = inode->i_mode;if (!(fc->flags &FUSE_DEFAULT_PERMISSIONS )) inode->i_mode &= ~S_ISVTX ; + + fi->orig_ino = attr->ino; } void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
Signature · 1 line
1.8.5.2
PATCH 210/213 phonet: Check input from user before allocating
In reply to Paul GortmakerFrom: Sasha Levin <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit bcf1b70ac6eb0ed8286c66e6bf37cb747cbaa04c upstream.
A phonet packet is limited to USHRT_MAX bytes, this is never checked during tx which means that the user can specify any size he wishes, and the kernel will attempt to allocate that size.
In the good case, it'll lead to the following warning, but it may also cause the kernel to kick in the OOM and kill a random task on the server.
[ 8921.744094] WARNING: at mm/page_alloc.c:2255 __alloc_pages_slowpath+0x65/0x730() [ 8921.749770] Pid: 5081, comm: trinity Tainted: G W 3.4.0-rc1-next-20120402-sasha #46 [ 8921.756672] Call Trace: [ 8921.758185] [<ffffffff810b2ba7>] warn_slowpath_common+0x87/0xb0 [ 8921.762868] [<ffffffff810b2be5>] warn_slowpath_null+0x15/0x20 [ 8921.765399] [<ffffffff8117eae5>] __alloc_pages_slowpath+0x65/0x730 [ 8921.769226] [<ffffffff81179c8a>] ? zone_watermark_ok+0x1a/0x20 [ 8921.771686] [<ffffffff8117d045>] ? get_page_from_freelist+0x625/0x660 [ 8921.773919] [<ffffffff8117f3a8>] __alloc_pages_nodemask+0x1f8/0x240 [ 8921.776248] [<ffffffff811c03e0>] kmalloc_large_node+0x70/0xc0 [ 8921.778294] [<ffffffff811c4bd4>] __kmalloc_node_track_caller+0x34/0x1c0 [ 8921.780847] [<ffffffff821b0e3c>] ? sock_alloc_send_pskb+0xbc/0x260 [ 8921.783179] [<ffffffff821b3c65>] __alloc_skb+0x75/0x170 [ 8921.784971] [<ffffffff821b0e3c>] sock_alloc_send_pskb+0xbc/0x260 [ 8921.787111] [<ffffffff821b002e>] ? release_sock+0x7e/0x90 [ 8921.788973] [<ffffffff821b0ff0>] sock_alloc_send_skb+0x10/0x20 [ 8921.791052] [<ffffffff824cfc20>] pep_sendmsg+0x60/0x380 [ 8921.792931] [<ffffffff824cb4a6>] ? pn_socket_bind+0x156/0x180 [ 8921.794917] [<ffffffff824cb50f>] ? pn_socket_autobind+0x3f/0x90 [ 8921.797053] [<ffffffff824cb63f>] pn_socket_sendmsg+0x4f/0x70 [ 8921.798992] [<ffffffff821ab8e7>] sock_aio_write+0x187/0x1b0 [ 8921.801395] [<ffffffff810e325e>] ? sub_preempt_count+0xae/0xf0 [ 8921.803501] [<ffffffff8111842c>] ? __lock_acquire+0x42c/0x4b0 [ 8921.805505] [<ffffffff821ab760>] ? __sock_recv_ts_and_drops+0x140/0x140 [ 8921.807860] [<ffffffff811e07cc>] do_sync_readv_writev+0xbc/0x110 [ 8921.809986] [<ffffffff811958e7>] ? might_fault+0x97/0xa0 [ 8921.811998] [<ffffffff817bd99e>] ? security_file_permission+0x1e/0x90 [ 8921.814595] [<ffffffff811e17e2>] do_readv_writev+0xe2/0x1e0 [ 8921.816702] [<ffffffff810b8dac>] ? do_setitimer+0x1ac/0x200 [ 8921.818819] [<ffffffff810e2ec1>] ? get_parent_ip+0x11/0x50 [ 8921.820863] [<ffffffff810e325e>] ? sub_preempt_count+0xae/0xf0 [ 8921.823318] [<ffffffff811e1926>] vfs_writev+0x46/0x60 [ 8921.825219] [<ffffffff811e1a3f>] sys_writev+0x4f/0xb0 [ 8921.827127] [<ffffffff82658039>] system_call_fastpath+0x16/0x1b [ 8921.829384] ---[ end trace dffe390f30db9eb7 ]---
--- net/phonet/pep.c | 3 +++ 1 file changed, 3 insertions(+)
net/phonet/pep.c +3 -0
@@ -862,6 +862,9 @@ static int pep_sendmsg(struct kiocb *iocb, struct sock *sk,int flags = msg->msg_flags;int err, done; +if (len >USHORT_MAX ) +return -EMSGSIZE ; +if ((msg->msg_flags & ~(MSG_DONTWAIT |MSG_EOR |MSG_NOSIGNAL |MSG_CMSG_COMPAT )) || !(msg->msg_flags &MSG_EOR ))
Signature · 1 line
1.8.5.2
PATCH 211/213 PCI: Add quirk for still enabled interrupts on Intel Sandy Bridge GPUs
In reply to Paul GortmakerFrom: Thomas Jarosch <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit cdb1f35dc7de42802527140a3613871c394548e1 upstream.
commit f67fd55fa96f7d7295b43ffbc4a97d8f55e473aa upstream.
Some BIOS implementations leave the Intel GPU interrupts enabled, even though no one is handling them (f.e. i915 driver is never loaded). Additionally the interrupt destination is not set up properly and the interrupt ends up -somewhere-.
These spurious interrupts are "sticky" and the kernel disables the (shared) interrupt line after 100.000+ generated interrupts.
Fix it by disabling the still enabled interrupts. This resolves crashes often seen on monitor unplug.
Tested on the following boards:
- Intel DH61CR: Affected
- Intel DH67BL: Affected
- Intel S1200KP server board: Affected
- Asus P8H61-M LE: Affected, but system does not crash. Probably the IRQ ends up somewhere unnoticed.
According to reports on the net, the Intel DH61WW board is also affected.
Many thanks to Jesse Barnes from Intel for helping with the register configuration and to Intel in general for providing public hardware documentation.
--- drivers/pci/quirks.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/pci/quirks.c +34 -0
@@ -2692,6 +2692,40 @@ static void __devinit fixup_ti816x_class(struct pci_dev* dev) }DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_TI ,0xb800 , fixup_ti816x_class); +/* +* Some BIOS implementations leave the Intel GPU interrupts enabled, +* even though no one is handling them (f.e. i915 driver is never loaded). +* Additionally the interrupt destination is not set up properly +* and the interrupt ends up -somewhere-. +* +* These spurious interrupts are "sticky" and the kernel disables +* the (shared) interrupt line after 100.000+ generated interrupts. +* +* Fix it by disabling the still enabled interrupts. +* This resolves crashes often seen on monitor unplug. +*/ +#define I915_DEIER_REG 0x4400c +static void __devinit disable_igfx_irq (struct pci_dev *dev) +{ +void __iomem *regs =pci_iomap (dev,0 ,0 ); +if (regs ==NULL ) { +dev_warn (&dev->dev,"igfx quirk: Can't iomap PCI device\n" ); +return ; + } + +/* Check if any interrupt line is still enabled */ +if (readl (regs +I915_DEIER_REG ) !=0 ) { +dev_warn (&dev->dev,"BIOS left Intel GPU interrupts enabled; " +"disabling\n" ); + +writel (0 , regs +I915_DEIER_REG ); + } + +pci_iounmap (dev, regs); +} +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x0102 , disable_igfx_irq); +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_INTEL ,0x010a , disable_igfx_irq); +static void pci_do_fixups (struct pci_dev *dev,struct pci_fixup *f,struct pci_fixup *end) {
Signature · 1 line
1.8.5.2
PATCH 212/213 crypto: sha512 - Fix byte counter overflow in SHA-512
In reply to Paul GortmakerFrom: Kent Yoder <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit 25c3d30c918207556ae1d6e663150ebdf902186b upstream.
The current code only increments the upper 64 bits of the SHA-512 byte counter when the number of bytes hashed happens to hit 2^64 exactly.
This patch increments the upper 64 bits whenever the lower 64 bits overflows.
--- crypto/sha512_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/sha512_generic.c +1 -1
@@ -177,7 +177,7 @@ sha512_update(struct shash_desc *desc, const u8 *data, unsigned int len) index = sctx->count[0 ] &0x7f ;/* Update number of bytes */ -if (!(sctx->count[0 ] += len)) +if ((sctx->count[0 ] += len) < len) sctx->count[1 ]++; part_len =128 - index;
Signature · 1 line
1.8.5.2
PATCH 213/213 video:uvesafb: Fix oops that uvesafb try to execute NX-protected page
In reply to Paul GortmakerFrom: Wang YanQing <[email protected]>
-------------------
This is a commit scheduled for the next v2.6.34 longterm release.
http://git.kernel.org/?p=linux/kernel/git/paulg/longterm-queue-2.6.34.git
If you see a problem with using this for longterm, please comment.
-------------------commit b78f29ca0516266431688c5eb42d39ce42ec039a upstream.
This patch fix the oops below that catched in my machine
[ 81.560602] uvesafb: NVIDIA Corporation, GT216 Board - 0696a290, Chip Rev , OEM: NVIDIA, VBE v3.0 [ 81.609384] uvesafb: protected mode interface info at c000:d350 [ 81.609388] uvesafb: pmi: set display start = c00cd3b3, set palette = c00cd40e [ 81.609390] uvesafb: pmi: ports = 3b4 3b5 3ba 3c0 3c1 3c4 3c5 3c6 3c7 3c8 3c9 3cc 3ce 3cf 3d0 3d1 3d2 3d3 3d4 3d5 3da [ 81.614558] uvesafb: VBIOS/hardware doesn't support DDC transfers [ 81.614562] uvesafb: no monitor limits have been set, default refresh rate will be used [ 81.614994] uvesafb: scrolling: ypan using protected mode interface, yres_virtual=4915 [ 81.744147] kernel tried to execute NX-protected page - exploit attempt? (uid: 0) [ 81.744153] BUG: unable to handle kernel paging request at c00cd3b3 [ 81.744159] IP: [<c00cd3b3>] 0xc00cd3b2 [ 81.744167] *pdpt = 00000000016d6001 *pde = 0000000001c7b067 *pte = 80000000000cd163 [ 81.744171] Oops: 0011 [#1] SMP [ 81.744174] Modules linked in: uvesafb(+) cfbcopyarea cfbimgblt cfbfillrect [ 81.744178] [ 81.744181] Pid: 3497, comm: modprobe Not tainted 3.3.0-rc4NX+ #71 Acer Aspire 4741 /Aspire 4741 [ 81.744185] EIP: 0060:[<c00cd3b3>] EFLAGS: 00010246 CPU: 0 [ 81.744187] EIP is at 0xc00cd3b3 [ 81.744189] EAX: 00004f07 EBX: 00000000 ECX: 00000000 EDX: 00000000 [ 81.744191] ESI: f763f000 EDI: f763f6e8 EBP: f57f3a0c ESP: f57f3a00 [ 81.744192] DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068 [ 81.744195] Process modprobe (pid: 3497, ti=f57f2000 task=f748c600 task.ti=f57f2000) [ 81.744196] Stack: [ 81.744197] f82512c5 f759341c 00000000 f57f3a30 c124a9bc 00000001 00000001 000001e0 [ 81.744202] f8251280 f763f000 f7593400 00000000 f57f3a40 c12598dd f5c0c000 00000000 [ 81.744206] f57f3b10 c1255efe c125a21a 00000006 f763f09c 00000000 c1c6cb60 f7593400 [ 81.744210] Call Trace: [ 81.744215] [<f82512c5>] ? uvesafb_pan_display+0x45/0x60 [uvesafb] [ 81.744222] [<c124a9bc>] fb_pan_display+0x10c/0x160 [ 81.744226] [<f8251280>] ? uvesafb_vbe_find_mode+0x180/0x180 [uvesafb] [ 81.744230] [<c12598dd>] bit_update_start+0x1d/0x50 [ 81.744232] [<c1255efe>] fbcon_switch+0x39e/0x550 [ 81.744235] [<c125a21a>] ? bit_cursor+0x4ea/0x560 [ 81.744240] [<c129b6cb>] redraw_screen+0x12b/0x220 [ 81.744245] [<c128843b>] ? tty_do_resize+0x3b/0xc0 [ 81.744247] [<c129ef42>] vc_do_resize+0x3d2/0x3e0 [ 81.744250] [<c129efb4>] vc_resize+0x14/0x20 [ 81.744253] [<c12586bd>] fbcon_init+0x29d/0x500 [ 81.744255] [<c12984c4>] ? set_inverse_trans_unicode+0xe4/0x110 [ 81.744258] [<c129b378>] visual_init+0xb8/0x150 [ 81.744261] [<c129c16c>] bind_con_driver+0x16c/0x360 [ 81.744264] [<c129b47e>] ? register_con_driver+0x6e/0x190 [ 81.744267] [<c129c3a1>] take_over_console+0x41/0x50 [ 81.744269] [<c1257b7a>] fbcon_takeover+0x6a/0xd0 [ 81.744272] [<c12594b8>] fbcon_event_notify+0x758/0x790 [ 81.744277] [<c10929e2>] notifier_call_chain+0x42/0xb0 [ 81.744280] [<c1092d30>] __blocking_notifier_call_chain+0x60/0x90 [ 81.744283] [<c1092d7a>] blocking_notifier_call_chain+0x1a/0x20 [ 81.744285] [<c124a5a1>] fb_notifier_call_chain+0x11/0x20 [ 81.744288] [<c124b759>] register_framebuffer+0x1d9/0x2b0 [ 81.744293] [<c1061c73>] ? ioremap_wc+0x33/0x40 [ 81.744298] [<f82537c6>] uvesafb_probe+0xaba/0xc40 [uvesafb] [ 81.744302] [<c12bb81f>] platform_drv_probe+0xf/0x20 [ 81.744306] [<c12ba558>] driver_probe_device+0x68/0x170 [ 81.744309] [<c12ba731>] __device_attach+0x41/0x50 [ 81.744313] [<c12b9088>] bus_for_each_drv+0x48/0x70 [ 81.744316] [<c12ba7f3>] device_attach+0x83/0xa0 [ 81.744319] [<c12ba6f0>] ? __driver_attach+0x90/0x90 [ 81.744321] [<c12b991f>] bus_probe_device+0x6f/0x90 [ 81.744324] [<c12b8a45>] device_add+0x5e5/0x680 [ 81.744329] [<c122a1a3>] ? kvasprintf+0x43/0x60 [ 81.744332] [<c121e6e4>] ? kobject_set_name_vargs+0x64/0x70 [ 81.744335] [<c121e6e4>] ? kobject_set_name_vargs+0x64/0x70 [ 81.744339] [<c12bbe9f>] platform_device_add+0xff/0x1b0 [ 81.744343] [<f8252906>] uvesafb_init+0x50/0x9b [uvesafb] [ 81.744346] [<c100111f>] do_one_initcall+0x2f/0x170 [ 81.744350] [<f82528b6>] ? uvesafb_is_valid_mode+0x66/0x66 [uvesafb] [ 81.744355] [<c10c6994>] sys_init_module+0xf4/0x1410 [ 81.744359] [<c1157fc0>] ? vfsmount_lock_local_unlock_cpu+0x30/0x30 [ 81.744363] [<c144cb10>] sysenter_do_call+0x12/0x36 [ 81.744365] Code: f5 00 00 00 32 f6 66 8b da 66 d1 e3 66 ba d4 03 8a e3 b0 1c 66 ef b0 1e 66 ef 8a e7 b0 1d 66 ef b0 1f 66 ef e8 fa 00 00 00 61 c3 <60> e8 c8 00 00 00 66 8b f3 66 8b da 66 ba d4 03 b0 0c 8a e5 66 [ 81.744388] EIP: [<c00cd3b3>] 0xc00cd3b3 SS:ESP 0068:f57f3a00 [ 81.744391] CR2: 00000000c00cd3b3 [ 81.744393] ---[ end trace 18b2c87c925b54d6 ]---
--- drivers/video/uvesafb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/video/uvesafb.c +9 -2
@@ -815,8 +815,15 @@ static int __devinit uvesafb_vbe_init(struct fb_info *info) par->pmi_setpal = pmi_setpal; par->ypan = ypan; -if (par->pmi_setpal || par->ypan) -uvesafb_vbe_getpmi (task, par); +if (par->pmi_setpal || par->ypan) { +if (__supported_pte_mask & _PAGE_NX) { + par->pmi_setpal = par->ypan =0 ; +printk (KERN_WARNING "uvesafb: NX protection is actively." +"We have better not to use the PMI.\n" ); + }else { +uvesafb_vbe_getpmi (task, par); + } + }#else /* The protected mode interface is not available on non-x86. */ par->pmi_setpal = par->ypan =0 ;
Signature · 1 line
1.8.5.2