1. 07 Oct, 2012 40 commits
    • Dan Carpenter's avatar
      USB: kaweth.c: use GFP_ATOMIC under spin_lock · c8be4f3d
      Dan Carpenter authored
      [ Upstream commit e4c7f259 ]
      
      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.
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      c8be4f3d
    • Alan Cox's avatar
      wanmain: comparing array with NULL · 1e7991ce
      Alan Cox authored
      [ Upstream commit 8b72ff64 ]
      
      gcc really should warn about these !
      Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      1e7991ce
    • Paul Moore's avatar
      cipso: don't follow a NULL pointer when setsockopt() is called · a9d0acf8
      Paul Moore authored
      [ Upstream commit 89d7ae34 ]
      
      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;
      	}
      
      CC: Lin Ming <mlin@ss.pku.edu.cn>
      Reported-by: default avatarAlan Cox <alan@lxorguk.ukuu.org.uk>
      Signed-off-by: default avatarPaul Moore <pmoore@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      a9d0acf8
    • Neil Horman's avatar
      sctp: Fix list corruption resulting from freeing an association on a list · 4c356cbc
      Neil Horman authored
      [ Upstream commit 2eebc1e1 ]
      
      A few days ago Dave Jones reported this oops:
      
      [22766.294255] general protection fault: 0000 [#1] PREEMPT SMP
      [22766.295376] CPU 0
      [22766.295384] Modules linked in:
      [22766.387137]  ffffffffa169f292 6b6b6b6b6b6b6b6b ffff880147c03a90
      ffff880147c03a74
      [22766.387135] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 00000000000
      [22766.387136] Process trinity-watchdo (pid: 10896, threadinfo ffff88013e7d2000,
      [22766.387137] Stack:
      [22766.387140]  ffff880147c03a10
      [22766.387140]  ffffffffa169f2b6
      [22766.387140]  ffff88013ed95728
      [22766.387143]  0000000000000002
      [22766.387143]  0000000000000000
      [22766.387143]  ffff880003fad062
      [22766.387144]  ffff88013c120000
      [22766.387144]
      [22766.387145] Call Trace:
      [22766.387145]  <IRQ>
      [22766.387150]  [<ffffffffa169f292>] ? __sctp_lookup_association+0x62/0xd0
      [sctp]
      [22766.387154]  [<ffffffffa169f2b6>] __sctp_lookup_association+0x86/0xd0 [sctp]
      [22766.387157]  [<ffffffffa169f597>] sctp_rcv+0x207/0xbb0 [sctp]
      [22766.387161]  [<ffffffff810d4da8>] ? trace_hardirqs_off_caller+0x28/0xd0
      [22766.387163]  [<ffffffff815827e3>] ? nf_hook_slow+0x133/0x210
      [22766.387166]  [<ffffffff815902fc>] ? ip_local_deliver_finish+0x4c/0x4c0
      [22766.387168]  [<ffffffff8159043d>] ip_local_deliver_finish+0x18d/0x4c0
      [22766.387169]  [<ffffffff815902fc>] ? ip_local_deliver_finish+0x4c/0x4c0
      [22766.387171]  [<ffffffff81590a07>] ip_local_deliver+0x47/0x80
      [22766.387172]  [<ffffffff8158fd80>] ip_rcv_finish+0x150/0x680
      [22766.387174]  [<ffffffff81590c54>] ip_rcv+0x214/0x320
      [22766.387176]  [<ffffffff81558c07>] __netif_receive_skb+0x7b7/0x910
      [22766.387178]  [<ffffffff8155856c>] ? __netif_receive_skb+0x11c/0x910
      [22766.387180]  [<ffffffff810d423e>] ? put_lock_stats.isra.25+0xe/0x40
      [22766.387182]  [<ffffffff81558f83>] netif_receive_skb+0x23/0x1f0
      [22766.387183]  [<ffffffff815596a9>] ? dev_gro_receive+0x139/0x440
      [22766.387185]  [<ffffffff81559280>] napi_skb_finish+0x70/0xa0
      [22766.387187]  [<ffffffff81559cb5>] napi_gro_receive+0xf5/0x130
      [22766.387218]  [<ffffffffa01c4679>] e1000_receive_skb+0x59/0x70 [e1000e]
      [22766.387242]  [<ffffffffa01c5aab>] e1000_clean_rx_irq+0x28b/0x460 [e1000e]
      [22766.387266]  [<ffffffffa01c9c18>] e1000e_poll+0x78/0x430 [e1000e]
      [22766.387268]  [<ffffffff81559fea>] net_rx_action+0x1aa/0x3d0
      [22766.387270]  [<ffffffff810a495f>] ? account_system_vtime+0x10f/0x130
      [22766.387273]  [<ffffffff810734d0>] __do_softirq+0xe0/0x420
      [22766.387275]  [<ffffffff8169826c>] call_softirq+0x1c/0x30
      [22766.387278]  [<ffffffff8101db15>] do_softirq+0xd5/0x110
      [22766.387279]  [<ffffffff81073bc5>] irq_exit+0xd5/0xe0
      [22766.387281]  [<ffffffff81698b03>] do_IRQ+0x63/0xd0
      [22766.387283]  [<ffffffff8168ee2f>] common_interrupt+0x6f/0x6f
      [22766.387283]  <EOI>
      [22766.387284]
      [22766.387285]  [<ffffffff8168eed9>] ? retint_swapgs+0x13/0x1b
      [22766.387285] Code: c0 90 5d c3 66 0f 1f 44 00 00 4c 89 c8 5d c3 0f 1f 00 55 48
      89 e5 48 83
      ec 20 48 89 5d e8 4c 89 65 f0 4c 89 6d f8 66 66 66 66 90 <0f> b7 87 98 00 00 00
      48 89 fb
      49 89 f5 66 c1 c0 08 66 39 46 02
      [22766.387307]
      [22766.387307] RIP
      [22766.387311]  [<ffffffffa168a2c9>] sctp_assoc_is_match+0x19/0x90 [sctp]
      [22766.387311]  RSP <ffff880147c039b0>
      [22766.387142]  ffffffffa16ab120
      [22766.599537] ---[ end trace 3f6dae82e37b17f5 ]---
      [22766.601221] Kernel panic - not syncing: Fatal exception in interrupt
      
      It appears from his analysis and some staring at the code that this is likely
      occuring because an association is getting freed while still on the
      sctp_assoc_hashtable.  As a result, we get a gpf when traversing the hashtable
      while a freed node corrupts part of the list.
      
      Nominally I would think that an mibalanced refcount was responsible for this,
      but I can't seem to find any obvious imbalance.  What I did note however was
      that the two places where we create an association using
      sctp_primitive_ASSOCIATE (__sctp_connect and sctp_sendmsg), have failure paths
      which free a newly created association after calling sctp_primitive_ASSOCIATE.
      sctp_primitive_ASSOCIATE brings us into the sctp_sf_do_prm_asoc path, which
      issues a SCTP_CMD_NEW_ASOC side effect, which in turn adds a new association to
      the aforementioned hash table.  the sctp command interpreter that process side
      effects has not way to unwind previously processed commands, so freeing the
      association from the __sctp_connect or sctp_sendmsg error path would lead to a
      freed association remaining on this hash table.
      
      I've fixed this but modifying sctp_[un]hash_established to use hlist_del_init,
      which allows us to proerly use hlist_unhashed to check if the node is on a
      hashlist safely during a delete.  That in turn alows us to safely call
      sctp_unhash_established in the __sctp_connect and sctp_sendmsg error paths
      before freeing them, regardles of what the associations state is on the hash
      list.
      
      I noted, while I was doing this, that the __sctp_unhash_endpoint was using
      hlist_unhsashed in a simmilar fashion, but never nullified any removed nodes
      pointers to make that function work properly, so I fixed that up in a simmilar
      fashion.
      
      I attempted to test this using a virtual guest running the SCTP_RR test from
      netperf in a loop while running the trinity fuzzer, both in a loop.  I wasn't
      able to recreate the problem prior to this fix, nor was I able to trigger the
      failure after (neither of which I suppose is suprising).  Given the trace above
      however, I think its likely that this is what we hit.
      Signed-off-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      Reported-by: davej@redhat.com
      CC: davej@redhat.com
      CC: "David S. Miller" <davem@davemloft.net>
      CC: Vlad Yasevich <vyasevich@gmail.com>
      CC: Sridhar Samudrala <sri@us.ibm.com>
      CC: linux-sctp@vger.kernel.org
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      4c356cbc
    • Brian Foster's avatar
      ext4: don't let i_reserved_meta_blocks go negative · 8927e0c6
      Brian Foster authored
      commit 97795d2a 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.
      Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      8927e0c6
    • J. Bruce Fields's avatar
      nfsd4: our filesystems are normally case sensitive · 2302a060
      J. Bruce Fields authored
      commit 2930d381 upstream.
      
      Actually, xfs and jfs can optionally be case insensitive; we'll handle
      that case in later patches.
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      2302a060
    • Chris Mason's avatar
      Btrfs: call the ordered free operation without any locks held · 7665fb0c
      Chris Mason authored
      commit e9fbcb42 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.
      Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      7665fb0c
    • Lan Tianyu's avatar
      ACPI/AC: prevent OOPS on some boxes due to missing check power_supply_register() return value check · d4e89205
      Lan Tianyu authored
      commit f197ac13 upstream.
      
      In the ac.c, power_supply_register()'s return value is not checked.
      
      As a result, the driver's add() ops may return success
      even though the device failed to initialize.
      
      For example, some BIOS may describe two ACADs in the same DSDT.
      The second ACAD device will fail to register,
      but ACPI driver's add() ops returns sucessfully.
      The ACPI device will receive ACPI notification and cause OOPS.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=772730Signed-off-by: default avatarLan Tianyu <tianyu.lan@intel.com>
      Signed-off-by: default avatarLen Brown <len.brown@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      d4e89205
    • J. Bruce Fields's avatar
      locks: fix checking of fcntl_setlease argument · e59164b8
      J. Bruce Fields authored
      commit 0ec4f431 upstream.
      
      The only checks of the long argument passed to fcntl(fd,F_SETLEASE,.)
      are done after converting the long to an int.  Thus some illegal values
      may be let through and cause problems in later code.
      
      [ They actually *don't* cause problems in mainline, as of Dave Jones's
        commit 8d657eb3 "Remove easily user-triggerable BUG from
        generic_setlease", but we should fix this anyway.  And this patch will
        be necessary to fix real bugs on earlier kernels. ]
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      e59164b8
    • Hans de Goede's avatar
      usbdevfs: Correct amount of data copied to user in processcompl_compat · 105ef39b
      Hans de Goede authored
      commit 2102e06a 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.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      105ef39b
    • Bart Van Assche's avatar
      SCSI: Avoid dangling pointer in scsi_requeue_command() · b41f1574
      Bart Van Assche authored
      commit 940f5d47 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.
      Reported-by: default avatarMike Christie <michaelc@cs.wisc.edu>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Reviewed-by: default avatarMike Christie <michaelc@cs.wisc.edu>
      Reviewed-by: default avatarTejun Heo <tj@kernel.org>
      [jejb: enhance commend and add commit log for stable]
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      b41f1574
    • Dan Williams's avatar
      SCSI: fix eh wakeup (scsi_schedule_eh vs scsi_restart_operations) · 3abcd813
      Dan Williams authored
      commit 57fc2e33 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.
      Reported-by: default avatarTom Jackson <thomas.p.jackson@intel.com>
      Tested-by: default avatarTom Jackson <thomas.p.jackson@intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      3abcd813
    • Dan Williams's avatar
      SCSI: libsas: fix sas_discover_devices return code handling · e69e5d3d
      Dan Williams authored
      commit b17caa17 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.
      Tested-by: default avatarDan Melnic <dan.melnic@amd.com>
      Reported-by: default avatarDan Melnic <dan.melnic@amd.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Reviewed-by: default avatarJack Wang <jack_wang@usish.com>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      e69e5d3d
    • Dan Williams's avatar
      SCSI: libsas: continue revalidation · 4b6a4ff5
      Dan Williams authored
      commit 26f2f199 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.
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      4b6a4ff5
    • Tiejun Chen's avatar
      powerpc: Add "memory" attribute for mfmsr() · 74b9a48f
      Tiejun Chen authored
      commit b416c9a1 upstream.
      
      Add "memory" attribute in inline assembly language as a compiler
      barrier to make sure 4.6.x GCC don't reorder mfmsr().
      Signed-off-by: default avatarTiejun Chen <tiejun.chen@windriver.com>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      74b9a48f
    • roger blofeld's avatar
      powerpc/ftrace: Fix assembly trampoline register usage · ca9005b3
      roger blofeld authored
      commit fd5a4298 upstream.
      
      Just like the module loader, ftrace needs to be updated to use r12
      instead of r11 with newer gcc's.
      Signed-off-by: default avatarRoger Blofeld <blofeldus@yahoo.com>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      ca9005b3
    • David Daney's avatar
      MIPS: Properly align the .data..init_task section. · 21e6f143
      David Daney authored
      commit 7b1c0d26 upstream.
      
      Improper alignment can lead to unbootable systems and/or random
      crashes.
      
      [ralf@linux-mips.org: This is a lond standing bug since
      6eb10bc9 (kernel.org) rsp.
      c422a10917f75fd19fa7fe070aaaa23e384dae6f (lmo) [MIPS: Clean up linker script
      using new linker script macros.] so dates back to 2.6.32.]
      Signed-off-by: default avatarDavid Daney <david.daney@cavium.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/3881/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      21e6f143
    • John Stultz's avatar
      ntp: Fix STA_INS/DEL clearing bug · c96f4bff
      John Stultz authored
      commit 6b1859db upstream.
      
      In commit 6b43ae8a, I
      introduced a bug that kept the STA_INS or STA_DEL bit
      from being cleared from time_status via adjtimex()
      without forcing STA_PLL first.
      
      Usually once the STA_INS is set, it isn't cleared
      until the leap second is applied, so its unlikely this
      affected anyone. However during testing I noticed it
      took some effort to cancel a leap second once STA_INS
      was set.
      Signed-off-by: default avatarJohn Stultz <johnstul@us.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Link: http://lkml.kernel.org/r/1342156917-25092-2-git-send-email-john.stultz@linaro.orgSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      c96f4bff
    • Andy Lutomirski's avatar
      mm: Hold a file reference in madvise_remove · c9c9fee8
      Andy Lutomirski authored
      commit 9ab4233d upstream.
      
      Otherwise the code races with munmap (causing a use-after-free
      of the vma) or with close (causing a use-after-free of the struct
      file).
      
      The bug was introduced by commit 90ed52eb ("[PATCH] holepunch: fix
      mmap_sem i_mutex deadlock")
      
      [bwh: Backported to 3.2:
       - Adjust context
       - madvise_remove() calls vmtruncate_range(), not do_fallocate()]
      [luto: Backported to 3.0: Adjust context]
      
      Cc: Hugh Dickins <hugh@veritas.com>
      Cc: Miklos Szeredi <mszeredi@suse.cz>
      Cc: Badari Pulavarty <pbadari@us.ibm.com>
      Cc: Nick Piggin <npiggin@suse.de>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarAndy Lutomirski <luto@amacapital.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      c9c9fee8
    • Bjrn Mork's avatar
      USB: cdc-wdm: fix lockup on error in wdm_read · 1d568736
      Bjrn Mork authored
      commit b086b6b1 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.
      Signed-off-by: default avatarBjrn Mork <bjorn@mork.no>
      Acked-by: default avatarOliver Neukum <oneukum@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      1d568736
    • Tyler Hicks's avatar
      eCryptfs: Properly check for O_RDONLY flag before doing privileged open · 9fff5f61
      Tyler Hicks authored
      commit 9fe79d76 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.
      Signed-off-by: default avatarTyler Hicks <tyhicks@canonical.com>
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      9fff5f61
    • Mel Gorman's avatar
      stable: Allow merging of backports for serious user-visible performance issues · 0f03f497
      Mel Gorman authored
      commit eb3979f6 upstream.
      
      Distribution kernel maintainers routinely backport fixes for users that
      were deemed important but not "something critical" as defined by the
      rules. To users of these kernels they are very serious and failing to fix
      them reduces the value of -stable.
      
      The problem is that the patches fixing these issues are often subtle and
      prone to regressions in other ways and need greater care and attention.
      To combat this, these "serious" backports should have a higher barrier
      to entry.
      
      This patch relaxes the rules to allow a distribution maintainer to merge
      to -stable a backported patch or small series that fixes a "serious"
      user-visible performance issue. They should include additional information on
      the user-visible bug affected and a link to the bugzilla entry if available.
      The same rules about the patch being already in mainline still apply.
      Signed-off-by: default avatarMel Gorman <mgorman@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      0f03f497
    • Jan Kara's avatar
      udf: Improve table length check to avoid possible overflow · 6b804000
      Jan Kara authored
      commit 57b9655d upstream.
      
      When a partition table length is corrupted to be close to 1 << 32, the
      check for its length may overflow on 32-bit systems and we will think
      the length is valid. Later on the kernel can crash trying to read beyond
      end of buffer. Fix the check to avoid possible overflow.
      
      CC: stable@vger.kernel.org
      Reported-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      6b804000
    • Jan Kara's avatar
      udf: Avoid run away loop when partition table length is corrupted · 65ff664e
      Jan Kara authored
      commit adee11b2 upstream.
      
      Check provided length of partition table so that (possibly maliciously)
      corrupted partition table cannot cause accessing data beyond current buffer.
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      65ff664e
    • Pavel Shilovsky's avatar
      fuse: fix stat call on 32 bit platforms · db8a784a
      Pavel Shilovsky authored
      commit 45c72cd7 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.
      Signed-off-by: default avatarPavel Shilovsky <piastry@etersoft.ru>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      db8a784a
    • Steffen Rumler's avatar
      powerpc: Fix kernel panic during kernel module load · dcd92275
      Steffen Rumler authored
      commit 3c752965 upstream.
      
      This fixes a problem which can causes kernel oopses while loading
      a kernel module.
      
      According to the PowerPC EABI specification, GPR r11 is assigned
      the dedicated function to point to the previous stack frame.
      In the powerpc-specific kernel module loader, do_plt_call()
      (in arch/powerpc/kernel/module_32.c), GPR r11 is also used
      to generate trampoline code.
      
      This combination crashes the kernel, in the case where the compiler
      chooses to use a helper function for saving GPRs on entry, and the
      module loader has placed the .init.text section far away from the
      .text section, meaning that it has to generate a trampoline for
      functions in the .init.text section to call the GPR save helper.
      Because the trampoline trashes r11, references to the stack frame
      using r11 can cause an oops.
      
      The fix just uses GPR r12 instead of GPR r11 for generating the
      trampoline code.  According to the statements from Freescale, this is
      safe from an EABI perspective.
      
      I've tested the fix for kernel 2.6.33 on MPC8541.
      Signed-off-by: default avatarSteffen Rumler <steffen.rumler.ext@nsn.com>
      [paulus@samba.org: reworded the description]
      Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      dcd92275
    • James Bottomley's avatar
      SCSI: fix scsi_wait_scan · 24f65f8b
      James Bottomley authored
      commit 1ff2f403 upstream.
      
      Commit  c7510859
      Author: Rafael J. Wysocki <rjw@sisk.pl>
      Date:   Sun Apr 12 20:06:56 2009 +0200
      
          PM/Hibernate: Wait for SCSI devices scan to complete during resume
      
      Broke the scsi_wait_scan module in 2.6.30.  Apparently debian still uses it so
      fix it and backport to stable before removing it in 3.6.
      
      The breakage is caused because the function template in
      include/scsi/scsi_scan.h is defined to be a nop unless SCSI is built in.
      That means that in the modular case (which is every distro), the
      scsi_wait_scan module does a simple async_synchronize_full() instead of
      waiting for scans.
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      24f65f8b
    • Sarah Sharp's avatar
      xhci: Reset reserved command ring TRBs on cleanup. · 6dd99cb6
      Sarah Sharp authored
      commit 33b2831a upstream.
      
      When the xHCI driver needs to clean up memory (perhaps due to a failed
      register restore on resume from S3 or resume from S4), it needs to reset
      the number of reserved TRBs on the command ring to zero.  Otherwise,
      several resume cycles (about 30) with a UAS device attached will
      continually increment the number of reserved TRBs, until all command
      submissions fail because there isn't enough room on the command ring.
      
      This patch should be backported to kernels as old as 2.6.32,
      that contain the commit 913a8a34
      "USB: xhci: Change how xHCI commands are handled."
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      6dd99cb6
    • Jan Kara's avatar
      ext4: fix error handling on inode bitmap corruption · 1f2e3234
      Jan Kara authored
      commit acd6ad83 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().
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      1f2e3234
    • Jan Kara's avatar
      ext3: Fix error handling on inode bitmap corruption · ba57e38b
      Jan Kara authored
      commit 1415dd87 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().
      Reviewed-by: default avatarEric Sandeen <sandeen@redhat.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      ba57e38b
    • Jonathan Nieder's avatar
      NFSv4: Revalidate uid/gid after open · 5816579f
      Jonathan Nieder authored
      This is a shorter (and more appropriate for stable kernels) analog to
      the following upstream commit:
      
      commit 6926afd1
      Author: Trond Myklebust <Trond.Myklebust@netapp.com>
      Date:   Sat Jan 7 13:22:46 2012 -0500
      
          NFSv4: Save the owner/group name string when doing open
      
          ...so that we can do the uid/gid mapping outside the asynchronous RPC
          context.
          This fixes a bug in the current NFSv4 atomic open code where the client
          isn't able to determine what the true uid/gid fields of the file are,
          (because the asynchronous nature of the OPEN call denies it the ability
          to do an upcall) and so fills them with default values, marking the
          inode as needing revalidation.
          Unfortunately, in some cases, the VFS will do some additional sanity
          checks on the file, and may override the server's decision to allow
          the open because it sees the wrong owner/group fields.
      Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
      
      Without this patch, logging into two different machines with home
      directories mounted over NFS4 and then running "vim" and typing ":q"
      in each reliably produces the following error on the second machine:
      
      	E137: Viminfo file is not writable: /users/system/rtheys/.viminfo
      
      This regression was introduced by 80e52ace ("NFSv4: Don't do
      idmapper upcalls for asynchronous RPC calls", merged during the 2.6.32
      cycle) --- after the OPEN call, .viminfo has the default values for
      st_uid and st_gid (0xfffffffe) cached because we do not want to let
      rpciod wait for an idmapper upcall to fill them in.
      
      The fix used in mainline is to save the owner and group as strings and
      perform the upcall in _nfs4_proc_open outside the rpciod context,
      which takes about 600 lines.  For stable, we can do something similar
      with a one-liner: make open check for the stale fields and make a
      (synchronous) GETATTR call to fill them when needed.
      
      Trond dictated the patch, I typed it in, and Rik tested it.
      
      Addresses http://bugs.debian.org/659111 and
                https://bugzilla.redhat.com/789298Reported-by: default avatarRik Theys <Rik.Theys@esat.kuleuven.be>
      Explained-by: default avatarDavid Flyn <davidf@rd.bbc.co.uk>
      Signed-off-by: default avatarJonathan Nieder <jrnieder@gmail.com>
      Tested-by: default avatarRik Theys <Rik.Theys@esat.kuleuven.be>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      5816579f
    • Mark Hills's avatar
      ALSA: echoaudio: Remove incorrect part of assertion · 826b464b
      Mark Hills authored
      commit c914f55f upstream.
      
      This assertion seems to imply that chip->dsp_code_to_load is a pointer.
      It's actually an integer handle on the actual firmware, and 0 has no
      special meaning.
      
      The assertion prevents initialisation of a Darla20 card, but would also
      affect other models. It seems it was introduced in commit dd7b254d.
      
      ALSA sound/pci/echoaudio/echoaudio.c:2061 Echoaudio driver starting...
      ALSA sound/pci/echoaudio/echoaudio.c:1969 chip=ebe4e000
      ALSA sound/pci/echoaudio/echoaudio.c:2007 pci=ed568000 irq=19 subdev=0010 Init hardware...
      ALSA sound/pci/echoaudio/darla20_dsp.c:36 init_hw() - Darla20
      ------------[ cut here ]------------
      WARNING: at sound/pci/echoaudio/echoaudio_dsp.c:478 init_hw+0x1d1/0x86c [snd_darla20]()
      Hardware name: Dell DM051
      BUG? (!chip->dsp_code_to_load || !chip->comm_page)
      Signed-off-by: default avatarMark Hills <mark@pogo.org.uk>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      826b464b
    • Eric Dumazet's avatar
      netem: fix possible skb leak · 88a3ee1a
      Eric Dumazet authored
      [ Upstream commit 116a0fc3 ]
      
      skb_checksum_help(skb) can return an error, we must free skb in this
      case. qdisc_drop(skb, sch) can also be feeded with a NULL skb (if
      skb_unshare() failed), so lets use this generic helper.
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Stephen Hemminger <shemminger@osdl.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      88a3ee1a
    • Tim Bird's avatar
      ARM: 7410/1: Add extra clobber registers for assembly in kernel_execve · 25849872
      Tim Bird authored
      commit e787ec13 upstream.
      
      The inline assembly in kernel_execve() uses r8 and r9.  Since this
      code sequence does not return, it usually doesn't matter if the
      register clobber list is accurate.  However, I saw a case where a
      particular version of gcc used r8 as an intermediate for the value
      eventually passed to r9.  Because r8 is used in the inline
      assembly, and not mentioned in the clobber list, r9 was set
      to an incorrect value.
      
      This resulted in a kernel panic on execution of the first user-space
      program in the system.  r9 is used in ret_to_user as the thread_info
      pointer, and if it's wrong, bad things happen.
      Signed-off-by: default avatarTim Bird <tim.bird@am.sony.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      25849872
    • David Ward's avatar
      net_sched: gred: Fix oops in gred_dump() in WRED mode · 31ff79fb
      David Ward authored
      [ Upstream commit 244b65db ]
      
      A parameter set exists for WRED mode, called wred_set, to hold the same
      values for qavg and qidlestart across all VQs. The WRED mode values had
      been previously held in the VQ for the default DP. After these values
      were moved to wred_set, the VQ for the default DP was no longer created
      automatically (so that it could be omitted on purpose, to have packets
      in the default DP enqueued directly to the device without using RED).
      
      However, gred_dump() was overlooked during that change; in WRED mode it
      still reads qavg/qidlestart from the VQ for the default DP, which might
      not even exist. As a result, this command sequence will cause an oops:
      
      tc qdisc add dev $DEV handle $HANDLE parent $PARENT gred setup \
          DPs 3 default 2 grio
      tc qdisc change dev $DEV handle $HANDLE gred DP 0 prio 8 $RED_OPTIONS
      tc qdisc change dev $DEV handle $HANDLE gred DP 1 prio 8 $RED_OPTIONS
      
      This fixes gred_dump() in WRED mode to use the values held in wred_set.
      Signed-off-by: default avatarDavid Ward <david.ward@ll.mit.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      31ff79fb
    • Davide Ciminaghi's avatar
      net/ethernet: ks8851_mll fix rx frame buffer overflow · 28188e3a
      Davide Ciminaghi authored
      [ Upstream commit 8a9a0ea6 ]
      
      At the beginning of ks_rcv(), a for loop retrieves the
      header information relevant to all the frames stored
      in the mac's internal buffers. The number of pending
      frames is stored as an 8 bits field in KS_RXFCTR.
      If interrupts are disabled long enough to allow for more than
      32 frames to accumulate in the MAC's internal buffers, a buffer
      overflow occurs.
      This patch fixes the problem by making the
      driver's frame_head_info buffer big enough.
      Well actually, since the chip appears to have 12K of
      internal rx buffers and the shortest ethernet frame should
      be 64 bytes long, maybe the limit could be set to
      12*1024/64 = 192 frames, but 255 should be safer.
      Signed-off-by: default avatarDavide Ciminaghi <ciminaghi@gnudd.com>
      Signed-off-by: default avatarRaffaele Recalcati <raffaele.recalcati@bticino.it>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      28188e3a
    • Tony Zelenoff's avatar
      atl1: fix kernel panic in case of DMA errors · cf4f7218
      Tony Zelenoff authored
      [ Upstream commit 03662e41 ]
      
      Problem:
      There was two separate work_struct structures which share one
      handler. Unfortunately getting atl1_adapter structure from
      work_struct in case of DMA error was done from incorrect
      offset which cause kernel panics.
      
      Solution:
      The useless work_struct for DMA error removed and
      handler name changed to more generic one.
      Signed-off-by: default avatarTony Zelenoff <antonz@parallels.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      cf4f7218
    • Eric Dumazet's avatar
      net: fix a race in sock_queue_err_skb() · 237b6148
      Eric Dumazet authored
      [ Upstream commit 110c4330 ]
      
      As soon as an skb is queued into socket error queue, another thread
      can consume it, so we are not allowed to reference skb anymore, or risk
      use after free.
      Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      237b6148
    • Eric Dumazet's avatar
      netlink: fix races after skb queueing · e0547758
      Eric Dumazet authored
      [ Upstream commit 4a7e7c2a ]
      
      As soon as an skb is queued into socket receive_queue, another thread
      can consume it, so we are not allowed to reference skb anymore, or risk
      use after free.
      Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      e0547758
    • Sasha Levin's avatar
      phonet: Check input from user before allocating · e61eb0d0
      Sasha Levin authored
      [ Upstream commit bcf1b70a ]
      
      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 ]---
      Signed-off-by: default avatarSasha Levin <levinsasha928@gmail.com>
      Acked-by: default avatarRmi Denis-Courmont <remi.denis-courmont@nokia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      e61eb0d0