ALSA: hda: Use model=lg quirk for LG P1 Express to enable playback and capture
Subsystems (21)
PATCH 1/23 ALSA: hda: Use model=lg quirk for LG P1 Express to enable playback and capture
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Daniel T Chen <[email protected]>
commit 77c4d5cdb81d25a45fbdfb84dd3348121219a072 upstream.
The original reporter states that audible playback from the internal speaker is inaudible despite the hardware being properly detected. To work around this symptom, he uses the model=lg quirk to properly enable both playback, capture, and jack sense. Another user corroborates this workaround on separate hardware. Add this PCI SSID to the quirk table to enable it for further LG P1 Expresses.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -3154,6 +3154,7 @@SND_PCI_QUIRK (0x1734 ,0x10b0 ,"Fujitsu" ,ALC880_FUJITSU ),SND_PCI_QUIRK (0x1854 ,0x0018 ,"LG LW20" ,ALC880_LG_LW ),SND_PCI_QUIRK (0x1854 ,0x003b ,"LG" ,ALC880_LG ), +SND_PCI_QUIRK (0x1854 ,0x005f ,"LG P1 Express" ,ALC880_LG ),SND_PCI_QUIRK (0x1854 ,0x0068 ,"LG w1" ,ALC880_LG ),SND_PCI_QUIRK (0x1854 ,0x0077 ,"LG LW25" ,ALC880_LG_LW ), SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
PATCH 10/23 mv_xor: fix race in tasklet function
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Saeed Bishara <[email protected]>
commit 8333f65ef094e47020cd01452b4637e7daf5a77f upstream.
use mv_xor_slot_cleanup() instead of __mv_xor_slot_cleanup() as the former function aquires the spin lock that needed to protect the drivers data.
--- drivers/dma/mv_xor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/mv_xor.c +1 -1
@@ -449,7 +449,7 @@static void mv_xor_tasklet (unsigned long data) {struct mv_xor_chan *chan = (struct mv_xor_chan *) data; -__mv_xor_slot_cleanup (chan); +mv_xor_slot_cleanup (chan); } static struct mv_xor_desc_slot *
PATCH 21/23 hvc_console: Fix race between hvc_close and hvc_remove
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Amit Shah <[email protected]>
commit e74d098c66543d0731de62eb747ccd5b636a6f4c upstream.
Alan pointed out a race in the code where hvc_remove is invoked. The recent virtio_console work is the first user of hvc_remove().
Alan describes it thus:
The hvc_console assumes that a close and remove call can't occur at the same time.
In addition tty_hangup(tty) is problematic as tty_hangup is asynchronous itself....
So this can happen
hvc_close hvc_remove
hung up ? - no
lock
tty = hp->tty unlock
lock
hp->tty = NULL
unlock
notify del
kref_put the hvc struct
close completes
tty is destroyed
tty_hangup dead tty tty->ops will be NULL NULL->...
This patch adds some tty krefs and also converts to using tty_vhangup().
--- drivers/char/hvc_console.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)
drivers/char/hvc_console.c +20 -9
@@ -312,6 +312,7 @@spin_lock_irqsave (&hp->lock, flags);/* Check and then increment for fast path open. */ if (hp->count++ >0 ) { +tty_kref_get (tty);spin_unlock_irqrestore (&hp->lock, flags);hvc_kick ();return 0 ;
@@ -320,7 +321,7 @@ tty->driver_data = hp; tty->low_latency =1 ;/* Makes flushes to ldisc synchronous. */ - hp->tty = tty; + hp->tty =tty_kref_get (tty);spin_unlock_irqrestore (&hp->lock, flags);
@@ -337,6 +338,7 @@spin_lock_irqsave (&hp->lock, flags); hp->tty =NULL ;spin_unlock_irqrestore (&hp->lock, flags); +tty_kref_put (tty); tty->driver_data =NULL ;kref_put (&hp->kref, destroy_hvc_struct);printk (KERN_ERR "hvc_open: request_irq failed with rc %d.\n" , rc);
@@ -364,13 +366,18 @@return ; hp = tty->driver_data; +spin_lock_irqsave (&hp->lock, flags); +tty_kref_get (tty);if (--hp->count ==0 ) {/* We are done with the tty pointer now. */ hp->tty =NULL ;spin_unlock_irqrestore (&hp->lock, flags); +/* Put the ref obtained in hvc_open() */ +tty_kref_put (tty); +if (hp->ops->notifier_del) hp->ops->notifier_del (hp, hp->data);
@@ -387,6 +394,7 @@spin_unlock_irqrestore (&hp->lock, flags); } +tty_kref_put (tty);kref_put (&hp->kref, destroy_hvc_struct); }
@@ -423,6 +431,7 @@while (temp_open_count) { --temp_open_count; +tty_kref_put (tty);kref_put (&hp->kref, destroy_hvc_struct); } }
@@ -550,7 +559,7 @@ poll_mask |=HVC_POLL_WRITE ;/* No tty attached, just skip */ - tty = hp->tty; + tty =tty_kref_get (hp->tty);if (tty ==NULL ) goto bail;
@@ -627,6 +636,8 @@tty_flip_buffer_push (tty); } +if (tty) +tty_kref_put (tty);return poll_mask; }
@@ -749,7 +760,7 @@struct tty_struct *tty;spin_lock_irqsave (&hp->lock, flags); - tty = hp->tty; + tty =tty_kref_get (hp->tty);if (hp->index <MAX_NR_HVC_CONSOLES ) vtermnos[hp->index] =-1 ;
@@ -761,18 +772,18 @@/* * We 'put' the instance that was grabbed when the kref instance * was initialized using kref_init(). Let the last holder of this -* kref cause it to be removed, which will probably be the tty_hangup +* kref cause it to be removed, which will probably be the tty_vhangup * below. */ kref_put (&hp->kref, destroy_hvc_struct);/* -* This function call will auto chain call hvc_hangup. The tty should -* always be valid at this time unless a simultaneous tty close already -* cleaned up the hvc_struct. +* This function call will auto chain call hvc_hangup. */ -if (tty) -tty_hangup (tty); +if (tty) { +tty_vhangup (tty); +tty_kref_put (tty); + }return 0 ; }
PATCH 2/23 ALSA: hda: Use LPIB for Dell Latitude 131L
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Daniel T Chen <[email protected]>
commit 9919c7619c52d01e89103bca405cc3d4a2b1ac31 upstream.
The OR has verified that position_fix=1 is necessary to work around errors on his machine.
--- sound/pci/hda/hda_intel.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/hda_intel.c +1 -0
@@ -1966,6 +1966,7 @@static struct snd_pci_quirk position_fix_list[]__devinitdata = {SND_PCI_QUIRK (0x1028 ,0x01cc ,"Dell D820" ,POS_FIX_LPIB ),SND_PCI_QUIRK (0x1028 ,0x01de ,"Dell Precision 390" ,POS_FIX_LPIB ), +SND_PCI_QUIRK (0x1028 ,0x01f6 ,"Dell Latitude 131L" ,POS_FIX_LPIB ),SND_PCI_QUIRK (0x1043 ,0x813d ,"ASUS P5AD2" ,POS_FIX_LPIB ), {} };
PATCH 18/23 sunrpc: prevent use-after-free on clearing XPT_BUSY
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: NeilBrown <[email protected]>
commit ed2849d3ecfa339435818eeff28f6c3424300cec upstream.
When an xprt is created, it has a refcount of 1, and XPT_BUSY is set. The refcount is *not* owned by the thread that created the xprt (as is clear from the fact that creators never put the reference). Rather, it is owned by the absence of XPT_DEAD. Once XPT_DEAD is set, (And XPT_BUSY is clear) that initial reference is dropped and the xprt can be freed.
So when a creator clears XPT_BUSY it is dropping its only reference and so must not touch the xprt again.
However svc_recv, after calling ->xpo_accept (and so getting an XPT_BUSY reference on a new xprt), calls svc_xprt_recieved. This clears XPT_BUSY and then svc_xprt_enqueue - this last without owning a reference. This is dangerous and has been seen to leave svc_xprt_enqueue working with an xprt containing garbage.
So we need to hold an extra counted reference over that call to svc_xprt_received.
For safety, any time we clear XPT_BUSY and then use the xprt again, we first get a reference, and the put it again afterwards.
Note that svc_close_all does not need this extra protection as there are no threads running, and the final free can only be called asynchronously from such a thread.
--- net/sunrpc/svc_xprt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
net/sunrpc/svc_xprt.c +8 -1
@@ -172,6 +172,7 @@spin_lock (&svc_xprt_class_lock);list_for_each_entry (xcl, &svc_xprt_class_list, xcl_list) {struct svc_xprt *newxprt; +unsigned short newport;if (strcmp (xprt_name, xcl->xcl_name))continue ;
@@ -192,8 +193,9 @@spin_lock_bh (&serv->sv_lock);list_add (&newxprt->xpt_list, &serv->sv_permsocks);spin_unlock_bh (&serv->sv_lock); + newport =svc_xprt_local_port (newxprt);clear_bit (XPT_BUSY , &newxprt->xpt_flags); -return svc_xprt_local_port (newxprt); +return newport; } err:spin_unlock (&svc_xprt_class_lock);
@@ -386,8 +388,13 @@ {BUG_ON (!test_bit (XPT_BUSY , &xprt->xpt_flags)); xprt->xpt_pool =NULL ; +/* As soon as we clear busy, the xprt could be closed and +* 'put', so we need a reference to call svc_xprt_enqueue with: +*/ +svc_xprt_get (xprt);clear_bit (XPT_BUSY , &xprt->xpt_flags);svc_xprt_enqueue (xprt); +svc_xprt_put (xprt); }EXPORT_SYMBOL_GPL (svc_xprt_received);
PATCH 6/23 HID: hidraw: fix window in hidraw_release
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Jiri Slaby <[email protected]>
commit cb174681a9ececa6702f114b85bdf82144b6a5af upstream.
[ Backport to .32.y by Antonio Ospite <[email protected]> ]
There is a window between hidraw_table check and its dereference. In that window, the device may be unplugged and removed form the system and we will then dereference NULL.
Lock that place properly so that either we get NULL and jump out or we can work with real pointer.
--- drivers/hid/hidraw.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/hid/hidraw.c +8 -3
@@ -196,11 +196,14 @@unsigned int minor =iminor (inode);struct hidraw *dev;struct hidraw_list *list = file->private_data; +int ret; +mutex_lock (&minors_lock);if (!hidraw_table[minor]) {printk (KERN_EMERG "hidraw device with minor %d doesn't exist\n" , minor); -return -ENODEV ; + ret = -ENODEV ; + goto unlock; }list_del (&list->node);
@@ -211,10 +214,12 @@else kfree (list->hidraw); } -kfree (list); + ret =0 ; +unlock: +mutex_unlock (&minors_lock); -return 0 ; +return ret; } static long hidraw_ioctl(struct file *file, unsigned int cmd,
PATCH 20/23 tracing: Fix panic when lseek() called on "trace" opened for writing
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Slava Pestov <[email protected]>
commit 364829b1263b44aa60383824e4c1289d83d78ca7 upstream.
The file_ops struct for the "trace" special file defined llseek as seq_lseek(). However, if the file was opened for writing only, seq_open() was not called, and the seek would dereference a null pointer, file->private_data.
This patch introduces a new wrapper for seq_lseek() which checks if the file descriptor is opened for reading first. If not, it does nothing.
LKML-Reference: <[email protected]>
--- kernel/trace/trace.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
kernel/trace/trace.c +10 -2
@@ -2041,17 +2041,25 @@return ret; } +static loff_t tracing_seek (struct file *file,loff_t offset,int origin) +{ +if (file->f_mode &FMODE_READ ) +return seq_lseek (file, offset, origin); +else +return 0 ; +} +static struct file_operations tracing_fops = { .open = tracing_open, .read = seq_read, - .llseek = seq_lseek, + .llseek = tracing_lseek, .release = tracing_release, };static struct file_operations tracing_lt_fops = { .open = tracing_lt_open, .read = seq_read, - .llseek = seq_lseek, + .llseek = tracing_lseek, .release = tracing_release, };
PATCH 3/23 ALSA: hda: Use LPIB quirk for Dell Inspiron m101z/1120
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Daniel T Chen <[email protected]>
commit e03fa055bc126e536c7f65862e08a9b143138ea9 upstream.
Sjoerd Simons reports that, without using position_fix=1, recording experiences overruns. Work around that by applying the LPIB quirk for his hardware.
--- sound/pci/hda/hda_intel.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/hda_intel.c +1 -0
@@ -1967,6 +1967,7 @@SND_PCI_QUIRK (0x1028 ,0x01cc ,"Dell D820" ,POS_FIX_LPIB ),SND_PCI_QUIRK (0x1028 ,0x01de ,"Dell Precision 390" ,POS_FIX_LPIB ),SND_PCI_QUIRK (0x1028 ,0x01f6 ,"Dell Latitude 131L" ,POS_FIX_LPIB ), +SND_PCI_QUIRK (0x1028 ,0x0470 ,"Dell Inspiron 1120" ,POS_FIX_LPIB ), SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), {} };
PATCH 16/23 sctp: Fix a race between ICMP protocol unreachable and connect()
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Vlad Yasevich <[email protected]>
commit 50b5d6ad63821cea324a5a7a19854d4de1a0a819 upstream.
ICMP protocol unreachable handling completely disregarded the fact that the user may have locked the socket. It proceeded to destroy the association, even though the user may have held the lock and had a ref on the association. This resulted in the following:
Attempt to release alive inet socket f6afcc00
=========================
[ BUG: held lock freed! ]
-------------------------
somenu/2672 is freeing memory f6afcc00-f6afcfff, with a lock still held there!
(sk_lock-AF_INET){+.+.+.}, at: [<c122098a>] sctp_connect+0x13/0x4c
1 lock held by somenu/2672:
#0: (sk_lock-AF_INET){+.+.+.}, at: [<c122098a>] sctp_connect+0x13/0x4c
stack backtrace: Pid: 2672, comm: somenu Not tainted 2.6.32-telco #55 Call Trace: [<c1232266>] ? printk+0xf/0x11 [<c1038553>] debug_check_no_locks_freed+0xce/0xff [<c10620b4>] kmem_cache_free+0x21/0x66 [<c1185f25>] __sk_free+0x9d/0xab [<c1185f9c>] sk_free+0x1c/0x1e [<c1216e38>] sctp_association_put+0x32/0x89 [<c1220865>] __sctp_connect+0x36d/0x3f4 [<c122098a>] ? sctp_connect+0x13/0x4c [<c102d073>] ? autoremove_wake_function+0x0/0x33 [<c12209a8>] sctp_connect+0x31/0x4c [<c11d1e80>] inet_dgram_connect+0x4b/0x55 [<c11834fa>] sys_connect+0x54/0x71 [<c103a3a2>] ? lock_release_non_nested+0x88/0x239 [<c1054026>] ? might_fault+0x42/0x7c [<c1054026>] ? might_fault+0x42/0x7c [<c11847ab>] sys_socketcall+0x6d/0x178 [<c10da994>] ? trace_hardirqs_on_thunk+0xc/0x10 [<c1002959>] syscall_call+0x7/0xb
This was because the sctp_wait_for_connect() would aqcure the socket lock and then proceed to release the last reference count on the association, thus cause the fully destruction path to finish freeing the socket.
The simplest solution is to start a very short timer in case the socket is owned by user. When the timer expires, we can do some verification and be able to do the release properly.
--- include/net/sctp/sm.h | 1 + include/net/sctp/structs.h | 3 +++ net/sctp/input.c | 22 ++++++++++++++++++---- net/sctp/sm_sideeffect.c | 35 +++++++++++++++++++++++++++++++++++ net/sctp/transport.c | 2 ++ 5 files changed, 59 insertions(+), 4 deletions(-)
include/net/sctp/sm.h +1 -0
@@ -277,6 +277,7 @@/* 2nd level prototypes */ void sctp_generate_t3_rtx_event (unsigned long peer);void sctp_generate_heartbeat_event (unsigned long peer); +void sctp_generate_proto_unreach_event (unsigned long peer);void sctp_ootb_pkt_free (struct sctp_packet *);
include/net/sctp/structs.h +3 -0
@@ -998,6 +998,9 @@/* Heartbeat timer is per destination. */ struct timer_list hb_timer; +/* Timer to handle ICMP proto unreachable envets */ +struct timer_list proto_unreach_timer; +/* Since we're using per-destination retransmission timers * (see above), we're also using per-destination "transmitted" * queues. This probably ought to be a private struct
net/sctp/input.c +18 -4
@@ -425,11 +425,25 @@ {SCTP_DEBUG_PRINTK ("%s\n" , __func__); -sctp_do_sm (SCTP_EVENT_T_OTHER , -SCTP_ST_OTHER (SCTP_EVENT_ICMP_PROTO_UNREACH ), - asoc->state, asoc->ep, asoc, t, -GFP_ATOMIC ); +if (sock_owned_by_user (sk)) { +if (timer_pending (&t->proto_unreach_timer)) +return ; +else { +if (!mod_timer (&t->proto_unreach_timer, + jiffies + (HZ /20 ))) +sctp_association_hold (asoc); + } + }else { +if (timer_pending (&t->proto_unreach_timer) && +del_timer (&t->proto_unreach_timer)) +sctp_association_put (asoc); + +sctp_do_sm (SCTP_EVENT_T_OTHER , +SCTP_ST_OTHER (SCTP_EVENT_ICMP_PROTO_UNREACH ), + asoc->state, asoc->ep, asoc, t, +GFP_ATOMIC ); + } }/* Common lookup code for icmp/icmpv6 error handler. */
net/sctp/sm_sideeffect.c +35 -0
@@ -397,6 +397,41 @@sctp_transport_put (transport); } +/* Handle the timeout of the ICMP protocol unreachable timer. Trigger +* the correct state machine transition that will close the association. +*/ +void sctp_generate_proto_unreach_event (unsigned long data) +{ +struct sctp_transport *transport = (struct sctp_transport *) data; +struct sctp_association *asoc = transport->asoc; + +sctp_bh_lock_sock (asoc->base.sk); +if (sock_owned_by_user (asoc->base.sk)) { +SCTP_DEBUG_PRINTK ("%s:Sock is busy.\n" , __func__); + +/* Try again later. */ +if (!mod_timer (&transport->proto_unreach_timer, + jiffies + (HZ /20 ))) +sctp_association_hold (asoc); + goto out_unlock; + } + +/* Is this structure just waiting around for us to actually +* get destroyed? +*/ +if (asoc->base.dead) + goto out_unlock; + +sctp_do_sm (SCTP_EVENT_T_OTHER , +SCTP_ST_OTHER (SCTP_EVENT_ICMP_PROTO_UNREACH ), + asoc->state, asoc->ep, asoc, transport,GFP_ATOMIC ); + +out_unlock: +sctp_bh_unlock_sock (asoc->base.sk); +sctp_association_put (asoc); +} + +/* Inject a SACK Timeout event into the state machine. */ static void sctp_generate_sack_event (unsigned long data) {
net/sctp/transport.c +2 -0
@@ -107,6 +107,8 @@ (unsigned long)peer);setup_timer (&peer->hb_timer, sctp_generate_heartbeat_event, (unsigned long )peer); +setup_timer (&peer->proto_unreach_timer, + sctp_generate_proto_unreach_event, (unsigned long )peer);/* Initialize the 64-bit random nonce sent with heartbeat. */ get_random_bytes (&peer->hb_nonce,sizeof (peer->hb_nonce));
PATCH 12/23 NFS: Fix fcntl F_GETLK not reporting some conflicts
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Sergey Vlasov <[email protected]>
commit 21ac19d484a8ffb66f64487846c8d53afef04d2b upstream.
The commit 129a84de2347002f09721cda3155ccfd19fade40 (locks: fix F_GETLK regression (failure to find conflicts)) fixed the posix_test_lock() function by itself, however, its usage in NFS changed by the commit 9d6a8c5c213e34c475e72b245a8eb709258e968c (locks: give posix_test_lock same interface as ->lock) remained broken - subsequent NFS-specific locking code received F_UNLCK instead of the user-specified lock type. To fix the problem, fl->fl_type needs to be saved before the posix_test_lock() call and restored if no local conflicts were reported.
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=23892
--- fs/nfs/file.c | 2 ++ 1 file changed, 2 insertions(+)
fs/nfs/file.c +2 -0
@@ -552,6 +552,7 @@ {struct inode *inode = filp->f_mapping->host;int status =0 ; +unsigned int saved_type = fl->fl_type;lock_kernel ();/* Try local locking first */
@@ -560,6 +561,7 @@/* found a conflict */ goto out; } + fl->fl_type = saved_type;if (nfs_have_delegation (inode,FMODE_READ )) goto out_noconflict;
PATCH 17/23 sound: Prevent buffer overflow in OSS load_mixer_volumes
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Dan Rosenberg <[email protected]>
commit d81a12bc29ae4038770e05dce4ab7f26fd5880fb upstream.
The load_mixer_volumes() function, which can be triggered by unprivileged users via the SOUND_MIXER_SETLEVELS ioctl, is vulnerable to a buffer overflow. Because the provided "name" argument isn't guaranteed to be NULL terminated at the expected 32 bytes, it's possible to overflow past the end of the last element in the mixer_vols array. Further exploitation can result in an arbitrary kernel write (via subsequent calls to load_mixer_volumes()) leading to privilege escalation, or arbitrary kernel reads via get_mixer_levels(). In addition, the strcmp() may leak bytes beyond the mixer_vols array.
--- sound/oss/soundcard.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/oss/soundcard.c +2 -2
@@ -87,7 +87,7 @@int i, n;for (i =0 ; i < num_mixer_volumes; i++) { -if (strcmp (name, mixer_vols[i].name) ==0 ) { +if (strncmp (name, mixer_vols[i].name,32 ) ==0 ) {if (present) mixer_vols[i].num = i;return mixer_vols[i].levels;
@@ -99,7 +99,7 @@ } n = num_mixer_volumes++; -strcpy (mixer_vols[n].name, name); +strncpy (mixer_vols[n].name, name,32 );if (present) mixer_vols[n].num = n;
PATCH 4/23 USB: usb-storage: unusual_devs entry for the Samsung YP-CP3
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Vitaly Kuznetsov <[email protected]>
commit d73a9b3001f29271c2e9f2a806b05a431c5d9591 upstream.
Add an unusual_devs entry for the Samsung YP-CP3 MP4 player.
User was getting the following errors in dmesg:
usb 2-6: reset high speed USB device using ehci_hcd and address 2 usb 2-6: reset high speed USB device using ehci_hcd and address 2 usb 2-6: reset high speed USB device using ehci_hcd and address 2 usb 2-6: USB disconnect, address 2
sd 3:0:0:0: [sdb] Assuming drive cache: write through sdb:<2>ldm_validate_partition_table(): Disk read failed. Dev sdb: unable to read RDB block 0
unable to read partition table
--- drivers/usb/storage/unusual_devs.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/storage/unusual_devs.h +7 -0
@@ -608,6 +608,13 @@ US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_MAX_SECTORS_64), +/* Reported by Vitaly Kuznetsov <[email protected]> */ +UNUSUAL_DEV (0x04e8 ,0x5122 ,0x0000 ,0x9999 , +"Samsung" , +"YP-CP3" , +US_SC_DEVICE ,US_PR_DEVICE ,NULL , + US_FL_MAX_SECTORS_64 | US_FL_BULK_IGNORE_TAG), +/* Entry and supporting patch by Theodore Kilgore <[email protected]>. * Device uses standards-violating 32-byte Bulk Command Block Wrappers and * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011.
PATCH 13/23 nfsd: Fix possible BUG_ON firing in set_change_info
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Neil Brown <[email protected]>
commit c1ac3ffcd0bc7e9617f62be8c7043d53ab84deac upstream.
If vfs_getattr in fill_post_wcc returns an error, we don't set fh_post_change.
For NFSv4, this can result in set_change_info triggering a BUG_ON. i.e. fh_post_saved being zero isn't really a bug.
So:
- instead of BUGging when fh_post_saved is zero, just clear ->atomic.
- if vfs_getattr fails in fill_post_wcc, take a copy of i_ctime anyway. This will be used i seg_change_info, but not overly trusted.
- While we are there, remove the pointless 'if' statements in set_change_info. There is no harm setting all the values.
--- fs/nfsd/nfs3xdr.c | 6 ++++-- include/linux/nfsd/xdr4.h | 21 ++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-)
fs/nfsd/nfs3xdr.c +4 -2
@@ -272,9 +272,11 @@ err =vfs_getattr (fhp->fh_export->ex_path.mnt, fhp->fh_dentry, &fhp->fh_post_attr); -if (err) +if (err) { fhp->fh_post_saved =0 ; -else +/* Grab the ctime anyway - set_change_info might use it */ + fhp->fh_post_attr.ctime = fhp->fh_dentry->d_inode->i_ctime; + }else fhp->fh_post_saved =1 ; }
include/linux/nfsd/xdr4.h +2 -2
@@ -424,8 +424,8 @@static inline void set_change_info (struct nfsd4_change_info *cinfo,struct svc_fh *fhp) { -BUG_ON (!fhp->fh_pre_saved || !fhp->fh_post_saved); - cinfo->atomic =1 ; +BUG_ON (!fhp->fh_pre_saved); + cinfo->atomic = fhp->fh_post_saved; cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec; cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec; cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec;
PATCH 23/23 install_special_mapping skips security_file_mmap check.
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Tavis Ormandy <[email protected]>
commit 462e635e5b73ba9a4c03913b77138cd57ce4b050 upstream.
The install_special_mapping routine (used, for example, to setup the vdso) skips the security check before insert_vm_struct, allowing a local attacker to bypass the mmap_min_addr security restriction by limiting the available pages for special mappings.
bprm_mm_init() also skips the check, and although I don't think this can be used to bypass any restrictions, I don't see any reason not to have the security check.
$ uname -m
x86_64
$ cat /proc/sys/vm/mmap_min_addr
65536
$ cat install_special_mapping.s
section .bss
resb BSS_SIZE
section .text
global _start
_start:
mov eax, __NR_pause
int 0x80
$ nasm -D__NR_pause=29 -DBSS_SIZE=0xfffed000 -f elf -o install_special_mapping.o install_special_mapping.s
$ ld -m elf_i386 -Ttext=0x10000 -Tbss=0x11000 -o install_special_mapping install_special_mapping.o
$ ./install_special_mapping &
[1] 14303
$ cat /proc/14303/maps
0000f000-00010000 r-xp 00000000 00:00 0 [vdso]
00010000-00011000 r-xp 00001000 00:19 2453665 /home/taviso/install_special_mapping
00011000-ffffe000 rwxp 00000000 00:00 0 [stack]It's worth noting that Red Hat are shipping with mmap_min_addr set to 4096.
--- fs/exec.c | 5 +++++ mm/mmap.c | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-)
fs/exec.c +5 -0
@@ -257,6 +257,11 @@ vma->vm_flags =VM_STACK_FLAGS ; vma->vm_page_prot =vm_get_page_prot (vma->vm_flags); + + err =security_file_mmap (NULL ,0 ,0 ,0 , vma->vm_start,1 ); +if (err) + goto err; + err =insert_vm_struct (mm, vma);if (err) {up_write (&mm->mmap_sem);
mm/mmap.c +12 -4
@@ -2253,6 +2253,7 @@ unsigned long addr, unsigned long len, unsigned long vm_flags, struct page **pages) { + int ret;struct vm_area_struct *vma; vma =kmem_cache_zalloc (vm_area_cachep,GFP_KERNEL );
@@ -2269,14 +2270,21 @@ vma->vm_ops = &special_mapping_vmops; vma->vm_private_data = pages; -if (unlikely (insert_vm_struct (mm, vma))) { -kmem_cache_free (vm_area_cachep, vma); -return -ENOMEM ; - } + ret =security_file_mmap (NULL ,0 ,0 ,0 , vma->vm_start,1 ); +if (ret) + goto out; + + ret =insert_vm_struct (mm, vma); +if (ret) + goto out; mm->total_vm += len >>PAGE_SHIFT ;return 0 ; + +out: +kmem_cache_free (vm_area_cachep, vma); +return ret; }static DEFINE_MUTEX (mm_all_locks_mutex);
PATCH 14/23 PM / Hibernate: Fix PM_POST_* notification with user-space suspend
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Takashi Iwai <[email protected]>
commit 1497dd1d29c6a53fcd3c80f7ac8d0e0239e7389e upstream.
The user-space hibernation sends a wrong notification after the image restoration because of thinko for the file flag check. RDONLY corresponds to hibernation and WRONLY to restoration, confusingly.
--- kernel/power/user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/user.c +1 -1
@@ -129,7 +129,7 @@free_all_swap_pages (data->swap);if (data->frozen)thaw_processes (); -pm_notifier_call_chain (data->mode ==O_WRONLY ? +pm_notifier_call_chain (data->mode ==O_RDONLY ?PM_POST_HIBERNATION :PM_POST_RESTORE );atomic_inc (&snapshot_device_available);
PATCH 11/23 md: fix bug with re-adding of partially recovered device.
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: NeilBrown <[email protected]>
commit 1a855a0606653d2d82506281e2c686bacb4b2f45 upstream.
With v0.90 metadata, a hot-spare does not become a full member of the array until recovery is complete. So if we re-add such a device to the array, we know that all of it is as up-to-date as the event count would suggest, and so it a bitmap-based recovery is possible.
However with v1.x metadata, the hot-spare immediately becomes a full member of the array, but it record how much of the device has been recovered. If the array is stopped and re-assembled recovery starts from this point.
When such a device is hot-added to an array we currently lose the 'how much is recovered' information and incorrectly included it as a full in-sync member (after bitmap-based fixup).
This is wrong and unsafe and could corrupt data.
So be more careful about setting saved_raid_disk - which is what guides the re-adding of devices back into an array. The new code matches the code in slot_store which does a similar thing, which is encouraging.
This is suitable for any -stable kernel.
--- drivers/md/md.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/md/md.c +5 -2
@@ -4300,7 +4300,7 @@ PTR_ERR(rdev));return PTR_ERR (rdev); } -/* set save_raid_disk if appropriate */ +/* set saved_raid_disk if appropriate */ if (!mddev->persistent) {if (info->state & (1 <<MD_DISK_SYNC ) && info->raid_disk < mddev->raid_disks)
@@ -4310,7 +4310,10 @@ }else super_types[mddev->major_version].validate_super (mddev, rdev); - rdev->saved_raid_disk = rdev->raid_disk; +if (test_bit (In_sync, &rdev->flags)) + rdev->saved_raid_disk = rdev->raid_disk; +else + rdev->saved_raid_disk =-1 ;clear_bit (In_sync, &rdev->flags);/* just to be sure */ if (info->state & (1 <<MD_DISK_WRITEMOSTLY ))
PATCH 5/23 USB: misc: uss720.c: add another vendor/product ID
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Thomas Sailer <[email protected]>
commit ecc1624a2fff45780959efbcb73ace18fdb3c58d upstream.
Fabio Battaglia report that he has another cable that works with this driver, so this patch adds its vendor/product ID.
--- drivers/usb/misc/uss720.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/misc/uss720.c +3 -1
@@ -3,7 +3,7 @@/* * uss720.c -- USS720 USB Parport Cable. * -* Copyright (C) 1999, 2005 +* Copyright (C) 1999, 2005, 2010 * Thomas Sailer ([email protected]) * * This program is free software; you can redistribute it and/or modify
@@ -774,6 +774,8 @@ { USB_DEVICE(0x0557, 0x2001) }, { USB_DEVICE(0x0729, 0x1284) }, { USB_DEVICE(0x1293, 0x0002) }, + { USB_DEVICE(0x1293, 0x0002) }, + { USB_DEVICE(0x050d, 0x0002) }, { } /* Terminating entry */ };
PATCH 22/23 hvc_console: Fix race between hvc_close and hvc_remove, again
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Anton Blanchard <[email protected]>
commit 320718ee074acce5ffced6506cb51af1388942aa upstream.
I don't claim to understand the tty layer, but it seems like hvc_open and hvc_close should be balanced in their kref reference counting.
Right now we get a kref every call to hvc_open:
if (hp->count++ > 0) {
tty_kref_get(tty); <----- here
spin_unlock_irqrestore(&hp->lock, flags);
hvc_kick();
return 0;
} /* else count == 0 */
tty->driver_data = hp;
hp->tty = tty_kref_get(tty); <------ or here if hp->count was 0But hvc_close has:
tty_kref_get(tty);
if (--hp->count == 0) {
...
/* Put the ref obtained in hvc_open() */
tty_kref_put(tty);
...
}
tty_kref_put(tty);Since the outside kref get/put balance we only do a single kref_put when count reaches 0.
The patch below changes things to call tty_kref_put once for every hvc_close call, and with that my machine boots fine.
--- drivers/char/hvc_console.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/char/hvc_console.c +0 -4
@@ -368,16 +368,12 @@ hp = tty->driver_data;spin_lock_irqsave (&hp->lock, flags); -tty_kref_get (tty);if (--hp->count ==0 ) {/* We are done with the tty pointer now. */ hp->tty =NULL ;spin_unlock_irqrestore (&hp->lock, flags); -/* Put the ref obtained in hvc_open() */ -tty_kref_put (tty); -if (hp->ops->notifier_del) hp->ops->notifier_del (hp, hp->data);
PATCH 19/23 x86, gcc-4.6: Use gcc -m options when building vdso
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: H. Peter Anvin <[email protected]>
commit de2a8cf98ecdde25231d6c5e7901e2cffaf32af9 upstream.
The vdso Makefile passes linker-style -m options not to the linker but to gcc. This happens to work with earlier gcc, but fails with gcc 4.6. Pass gcc-style -m options, instead.
Note: all currently supported versions of gcc supports -m32, so there is no reason to conditionalize it any more.
LKML-Reference: <tip-*@git.kernel.org>
arch/x86/vdso/Makefile +2 -2
@@ -25,7 +25,7 @@ export CPPFLAGS_vdso.lds += -P -C -VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -Wl,-soname=linux-vdso.so.1 \ +VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \ -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 $(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
@@ -69,7 +69,7 @@ vdso32-images = $(vdso32.so-y:%=vdso32-%.so) CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds) -VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -Wl,-soname=linux-gate.so.1 +VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-soname=linux-gate.so.1 # This makes sure the $(obj) subdirectory exists even though vdso32/ # is not a kbuild sub-make subdirectory.
PATCH 15/23 posix-cpu-timers: workaround to suppress the problems with mt exec
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Oleg Nesterov <[email protected]>
commit e0a70217107e6f9844628120412cb27bb4cea194 upstream.
posix-cpu-timers.c correctly assumes that the dying process does posix_cpu_timers_exit_group() and removes all !CPUCLOCK_PERTHREAD timers from signal->cpu_timers list.
But, it also assumes that timer->it.cpu.task is always the group leader, and thus the dead ->task means the dead thread group.
This is obviously not true after de_thread() changes the leader. After that almost every posix_cpu_timer_ method has problems.
It is not simple to fix this bug correctly. First of all, I think that timer->it.cpu should use struct pid instead of task_struct. Also, the locking should be reworked completely. In particular, tasklist_lock should not be used at all. This all needs a lot of nontrivial and hard-to-test changes.
Change __exit_signal() to do posix_cpu_timers_exit_group() when the old leader dies during exec. This is not the fix, just the temporary hack to hide the problem for 2.6.37 and stable. IOW, this is obviously wrong but this is what we currently have anyway:
cpu timers do not work after mt exec.
In theory this change adds another race. The exiting leader can detach the timers which were attached to the new leader. However, the window between de_thread() and release_task() is small, we can pretend that sys_timer_create() was called before de_thread().
--- kernel/exit.c | 8 ++++++++ 1 file changed, 8 insertions(+)
kernel/exit.c +8 -0
@@ -94,6 +94,14 @@posix_cpu_timers_exit_group (tsk); else {/* +* This can only happen if the caller is de_thread(). +* FIXME: this is the temporary hack, we should teach +* posix-cpu-timers to handle this case correctly. +*/ +if (unlikely (has_group_leader_pid (tsk))) +posix_cpu_timers_exit_group (tsk); + +/* * If there is any task waiting for the group exit * then notify it: */
PATCH 9/23 IB/uverbs: Handle large number of entries in poll CQ
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Dan Carpenter <[email protected]>
commit 7182afea8d1afd432a17c18162cc3fd441d0da93 upstream.
In ib_uverbs_poll_cq() code there is a potential integer overflow if userspace passes in a large cmd.ne. The calls to kmalloc() would allocate smaller buffers than intended, leading to memory corruption. There iss also an information leak if resp wasn't all used. Unprivileged userspace may call this function, although only if an RDMA device that uses this function is present.
Fix this by copying CQ entries one at a time, which avoids the allocation entirely, and also by moving this copying into a function that makes sure to initialize all memory copied to userspace.
Special thanks to Jason Gunthorpe <[email protected]> for his help and advice.
[ Monkey around with things a bit to avoid bad code generation by gcc
when designated initializers are used. - Roland ]
--- drivers/infiniband/core/uverbs_cmd.c | 101 +++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 44 deletions(-)
drivers/infiniband/core/uverbs_cmd.c +56 -43
@@ -875,68 +875,81 @@return ret ? ret : in_len; } +static int copy_wc_to_user (void __user *dest,struct ib_wc *wc) +{ +struct ib_uverbs_wc tmp; + + tmp.wr_id = wc->wr_id; + tmp.status = wc->status; + tmp.opcode = wc->opcode; + tmp.vendor_err = wc->vendor_err; + tmp.byte_len = wc->byte_len; + tmp.ex.imm_data = (__u32 __force ) wc->ex.imm_data; + tmp.qp_num = wc->qp->qp_num; + tmp.src_qp = wc->src_qp; + tmp.wc_flags = wc->wc_flags; + tmp.pkey_index = wc->pkey_index; + tmp.slid = wc->slid; + tmp.sl = wc->sl; + tmp.dlid_path_bits = wc->dlid_path_bits; + tmp.port_num = wc->port_num; + tmp.reserved =0 ; + +if (copy_to_user (dest, &tmp,sizeof tmp)) +return -EFAULT ; + +return 0 ; +} +ssize_t ib_uverbs_poll_cq (struct ib_uverbs_file *file,const char __user *buf,int in_len,int out_len) {struct ib_uverbs_poll_cq cmd; -struct ib_uverbs_poll_cq_resp *resp; +struct ib_uverbs_poll_cq_resp resp; +u8 __user *header_ptr; +u8 __user *data_ptr;struct ib_cq *cq; -struct ib_wc *wc; -int ret =0 ; -int i; -int rsize; +struct ib_wc wc; +int ret;if (copy_from_user (&cmd, buf,sizeof cmd))return -EFAULT ; - wc =kmalloc (cmd.ne *sizeof *wc,GFP_KERNEL ); -if (!wc) -return -ENOMEM ; - - rsize =sizeof *resp + cmd.ne *sizeof (struct ib_uverbs_wc ); - resp =kmalloc (rsize,GFP_KERNEL ); -if (!resp) { - ret = -ENOMEM ; - goto out_wc; - } - cq =idr_read_cq (cmd.cq_handle, file->ucontext,0 ); -if (!cq) { - ret = -EINVAL ; - goto out; - } +if (!cq) +return -EINVAL ; - resp->count =ib_poll_cq (cq, cmd.ne, wc); +/* we copy a struct ib_uverbs_poll_cq_resp to user space */ + header_ptr = (void __user *)(unsigned long ) cmd.response; + data_ptr = header_ptr +sizeof resp; -put_cq_read (cq); +memset (&resp,0 ,sizeof resp); +while (resp.count < cmd.ne) { + ret =ib_poll_cq (cq,1 , &wc); +if (ret <0 ) + goto out_put; +if (!ret) +break ; + + ret =copy_wc_to_user (data_ptr, &wc); +if (ret) + goto out_put; -for (i =0 ; i < resp->count; i++) { - resp->wc[i].wr_id = wc[i].wr_id; - resp->wc[i].status = wc[i].status; - resp->wc[i].opcode = wc[i].opcode; - resp->wc[i].vendor_err = wc[i].vendor_err; - resp->wc[i].byte_len = wc[i].byte_len; - resp->wc[i].ex.imm_data = (__u32 __force ) wc[i].ex.imm_data; - resp->wc[i].qp_num = wc[i].qp->qp_num; - resp->wc[i].src_qp = wc[i].src_qp; - resp->wc[i].wc_flags = wc[i].wc_flags; - resp->wc[i].pkey_index = wc[i].pkey_index; - resp->wc[i].slid = wc[i].slid; - resp->wc[i].sl = wc[i].sl; - resp->wc[i].dlid_path_bits = wc[i].dlid_path_bits; - resp->wc[i].port_num = wc[i].port_num; + data_ptr +=sizeof (struct ib_uverbs_wc ); + ++resp.count; } -if (copy_to_user ((void __user *) (unsigned long ) cmd.response, resp, rsize)) +if (copy_to_user (header_ptr, &resp,sizeof resp)) { ret = -EFAULT ; + goto out_put; + } -out: -kfree (resp); + ret = in_len; -out_wc: -kfree (wc); -return ret ? ret : in_len; +out_put: +put_cq_read (cq); +return ret; } ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file,
PATCH 7/23 hwmon: (adm1026) Allow 1 as a valid divider value
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Gabriele Gorla <[email protected]>
commit 8b0f1840a46449e1946fc88860ef3ec8d6b1c2c7 upstream.
Allow 1 as a valid div value as specified in the ADM1026 datasheet.
--- drivers/hwmon/adm1026.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/hwmon/adm1026.c +1 -3
@@ -926,9 +926,7 @@ val =simple_strtol (buf,NULL ,10 ); new_div =DIV_TO_REG (val); -if (new_div ==0 ) { -return -EINVAL ; - } +mutex_lock (&data->update_lock); orig_div = data->fan_div[nr]; data->fan_div[nr] =DIV_FROM_REG (new_div);
PATCH 8/23 hwmon: (adm1026) Fix setting fan_div
In reply to a message not in the archive2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Gabriele Gorla <[email protected]>
commit 52bc9802ce849d0d287cc5fe76d06b0daa3986ca upstream.
Prevent setting fan_div from stomping on other fans that share the same I2C register.
--- drivers/hwmon/adm1026.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/hwmon/adm1026.c +9 -7
@@ -922,7 +922,7 @@int nr = sensor_attr->index;struct i2c_client *client =to_i2c_client (dev);struct adm1026_data *data =i2c_get_clientdata (client); -int val, orig_div, new_div, shift; +int val, orig_div, new_div; val =simple_strtol (buf,NULL ,10 ); new_div =DIV_TO_REG (val);
@@ -932,15 +932,17 @@ data->fan_div[nr] =DIV_FROM_REG (new_div);if (nr <4 ) {/* 0 <= nr < 4 */ - shift =2 * nr;adm1026_write_value (client,ADM1026_REG_FAN_DIV_0_3 , - ((DIV_TO_REG (orig_div) & (~(0x03 << shift))) | - (new_div << shift))); + (DIV_TO_REG (data->fan_div[0 ]) <<0 ) | + (DIV_TO_REG (data->fan_div[1 ]) <<2 ) | + (DIV_TO_REG (data->fan_div[2 ]) <<4 ) | + (DIV_TO_REG (data->fan_div[3 ]) <<6 )); }else {/* 3 < nr < 8 */ - shift =2 * (nr -4 );adm1026_write_value (client,ADM1026_REG_FAN_DIV_4_7 , - ((DIV_TO_REG (orig_div) & (~(0x03 << (2 * shift)))) | - (new_div << shift))); + (DIV_TO_REG (data->fan_div[4 ]) <<0 ) | + (DIV_TO_REG (data->fan_div[5 ]) <<2 ) | + (DIV_TO_REG (data->fan_div[6 ]) <<4 ) | + (DIV_TO_REG (data->fan_div[7 ]) <<6 )); }if (data->fan_div[nr] != orig_div) {
Re: [PATCH 21/23] hvc_console: Fix race between hvc_close and hvc_remove
In reply to Willy TarreauHi,
Quoted 6 lines
From: Amit Shah <[email protected]>
commit
e74d098c66543d0731de62eb747ccd5b636a6f4cupstream.Alan pointed out a race in the code where
hvc_removeis invoked. The recentvirtio_consolework is the first user ofhvc_remove().
I faintly remember this bug caused boot issues and the following patch must be applied to fix it.
Anton
--
commit 320718ee074acce5ffced6506cb51af1388942aa
Author: Anton Blanchard <[email protected]> Date: Tue Apr 6 21:42:38 2010 +1000
hvc_console: Fix race between hvc_close and hvc_remove
I don't claim to understand the tty layer, but it seems like hvc_open and
hvc_close should be balanced in their kref reference counting.
Right now we get a kref every call to hvc_open:
if (hp->count++ > 0) {
tty_kref_get(tty); <----- here
spin_unlock_irqrestore(&hp->lock, flags);
hvc_kick();
return 0;
} /* else count == 0 */
tty->driver_data = hp;
hp->tty = tty_kref_get(tty); <------ or here if hp->count was 0
But hvc_close has:
tty_kref_get(tty);
if (--hp->count == 0) {
...
/* Put the ref obtained in hvc_open() */
tty_kref_put(tty);
...
}
tty_kref_put(tty);
Since the outside kref get/put balance we only do a single kref_put when
count reaches 0.
The patch below changes things to call tty_kref_put once for every
hvc_close call, and with that my machine boots fine.
Signed-off-by: Anton Blanchard <[email protected]>
Acked-by: Amit Shah <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>drivers/char/hvc_console.c +0 -4
@@ -368,16 +368,12 @@ static void hvc_close(struct tty_struct *tty, struct file * filp) hp = tty->driver_data;spin_lock_irqsave (&hp->lock, flags); -tty_kref_get (tty);if (--hp->count ==0 ) {/* We are done with the tty pointer now. */ hp->tty =NULL ;spin_unlock_irqrestore (&hp->lock, flags); -/* Put the ref obtained in hvc_open() */ -tty_kref_put (tty); -if (hp->ops->notifier_del) hp->ops->notifier_del (hp, hp->data);
Re: [PATCH 21/23] hvc_console: Fix race between hvc_close and hvc_remove
Hi Anton,
Quoted 5 lines · Anton Blanchard
Hi,
Quoted 2 lines
From: Amit Shah <[email protected]>
Quoted 7 lines
Quoted 4 lines
commit
e74d098c66543d0731de62eb747ccd5b636a6f4cupstream.Alan pointed out a race in the code where
hvc_removeis invoked. The recentvirtio_consolework is the first user ofhvc_remove().I faintly remember this bug caused boot issues and the following patch must be applied to fix it.
The patch you pointed was indeed merged just after this one so we should be OK. Thanks very much for the double check !
Willy
Re: [Stable-review] [PATCH 20/23] tracing: Fix panic when lseek() called on "trace" opened for writing
In reply to Willy TarreauQuoted 14 lines · Willy Tarreau
2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Slava Pestov <[email protected]>
commit
364829b1263b44aa60383824e4c1289d83d78ca7upstream.The
file_opsstruct for the "trace" special file defined llseek asseq_lseek(). However, if the file was opened for writing only,seq_open()was not called, and the seek would dereference a null pointer,file->private_data.This patch introduces a new wrapper for
seq_lseek()which checks if the file descriptor is opened for reading first. If not, it does nothing.
[...]
Quoted 7 lines
kernel/trace/trace.c +1
-0@@ -2041,17 +2041,25 @@return ret; } +static loff_t tracing_seek (struct file *file,loff_t offset,int origin)
[...]
Quoted 1 line
kernel/trace/trace.c +1
-0+ .llseek = tracing_lseek,
[...]
kernel/trace/trace.c
Quoted 1 line
kernel/trace/trace.c +1
-0+ .llseek = tracing_lseek,
[...]
These names don't agree!
Ben.
Signature · 2 lines
Ben Hutchings Once a job is fouled up, anything done to improve it makes it worse.
Steven Rostedt
maintainerRe: [Stable-review] [PATCH 20/23] tracing: Fix panic when lseek() called on "trace" opened for writing
Quoted 22 lines · Ben Hutchings
Quoted 14 lines · Willy Tarreau
2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Slava Pestov <[email protected]>
commit
364829b1263b44aa60383824e4c1289d83d78ca7upstream.The
file_opsstruct for the "trace" special file defined llseek asseq_lseek(). However, if the file was opened for writing only,seq_open()was not called, and the seek would dereference a null pointer,file->private_data.This patch introduces a new wrapper for
seq_lseek()which checks if the file descriptor is opened for reading first. If not, it does nothing.[...]
Quoted 6 lines
kernel/trace/trace.c +0
-0@@ -2041,17 +2041,25 @@return ret; }
Quoted 8 lines
Quoted 1 line
kernel/trace/trace.c +1
-0+static loff_t tracing_seek (struct file *file,loff_t offset,int origin)[...]
Quoted 1 line
kernel/trace/trace.c +1
-0+ .llseek = tracing_lseek,[...]
kernel/trace/trace.c
Quoted 1 line
kernel/trace/trace.c +1
-0+ .llseek = tracing_lseek,[...]
These names don't agree!
What don't they agree on?
-- Steve
Re: [Stable-review] [PATCH 20/23] tracing: Fix panic when lseek() called on "trace" opened for writing
Quoted 25 lines · Steven Rostedt
Quoted 24 lines · Ben Hutchings
Quoted 14 lines · Willy Tarreau
2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Slava Pestov <[email protected]>
commit
364829b1263b44aa60383824e4c1289d83d78ca7upstream.The
file_opsstruct for the "trace" special file defined llseek asseq_lseek(). However, if the file was opened for writing only,seq_open()was not called, and the seek would dereference a null pointer,file->private_data.This patch introduces a new wrapper for
seq_lseek()which checks if the file descriptor is opened for reading first. If not, it does nothing.[...]
Quoted 7 lines
kernel/trace/trace.c +1
-0@@ -2041,17 +2041,25 @@return ret; } +static loff_t tracing_seek (struct file *file,loff_t offset,int origin)[...]
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
kernel/trace/trace.c +1
-0+ .llseek = tracing_lseek,[...]
kernel/trace/trace.c
Quoted 1 line
kernel/trace/trace.c +1
-0+ .llseek = tracing_lseek,[...]
These names don't agree!
What don't they agree on?
Whether seek is spelt with an 'l'...
Ben.
Signature · 2 lines
Ben Hutchings Once a job is fouled up, anything done to improve it makes it worse.
Steven Rostedt
maintainerRe: [Stable-review] [PATCH 20/23] tracing: Fix panic when lseek() called on "trace" opened for writing
Quoted 28 lines · Ben Hutchings
Quoted 27 lines · Steven Rostedt
Quoted 26 lines · Ben Hutchings
Quoted 14 lines · Willy Tarreau
2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Slava Pestov <[email protected]>
commit
364829b1263b44aa60383824e4c1289d83d78ca7upstream.The
file_opsstruct for the "trace" special file defined llseek asseq_lseek(). However, if the file was opened for writing only,seq_open()was not called, and the seek would dereference a null pointer,file->private_data.This patch introduces a new wrapper for
seq_lseek()which checks if the file descriptor is opened for reading first. If not, it does nothing.[...]
Quoted 7 lines
kernel/trace/trace.c +1
-0@@ -2041,17 +2041,25 @@return ret; } +static loff_t tracing_seek (struct file *file,loff_t offset,int origin)[...]
Quoted 1 line
kernel/trace/trace.c +1
-0+ .llseek = tracing_lseek,[...]
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
kernel/trace/trace.c
Quoted 1 line
kernel/trace/trace.c +1
-0+ .llseek = tracing_lseek,[...]
These names don't agree!
What don't they agree on?
Whether seek is spelt with an 'l'...
Ah, I was looking at the two .llseek lines ;)
Yeah, in mainline it's just tracing_seek.
-- Steve
Re: [Stable-review] [PATCH 20/23] tracing: Fix panic when lseek() called on "trace" opened for writing
In reply to Ben HutchingsHi Ben,
Quoted 22 lines · Ben Hutchings
Quoted 14 lines · Willy Tarreau
2.6.27.58-stable review patch. If anyone has any objections, please let us know.
------------------
From: Slava Pestov <[email protected]>
commit
364829b1263b44aa60383824e4c1289d83d78ca7upstream.The
file_opsstruct for the "trace" special file defined llseek asseq_lseek(). However, if the file was opened for writing only,seq_open()was not called, and the seek would dereference a null pointer,file->private_data.This patch introduces a new wrapper for
seq_lseek()which checks if the file descriptor is opened for reading first. If not, it does nothing.[...]
Quoted 6 lines
kernel/trace/trace.c +0
-0@@ -2041,17 +2041,25 @@return ret; }
Quoted 8 lines
Quoted 1 line
kernel/trace/trace.c +1
-0+static loff_t tracing_seek (struct file *file,loff_t offset,int origin)[...]
Quoted 1 line
kernel/trace/trace.c +1
-0+ .llseek = tracing_lseek,[...]
kernel/trace/trace.c
Quoted 1 line
kernel/trace/trace.c +1
-0+ .llseek = tracing_lseek,[...]
These names don't agree!
Indeed, it's been fixed before releasing.
Thanks for the review anyway !
Willy