Commit Graph

446944 Commits

Author SHA1 Message Date
Eric Dumazet b01a8531d0 netns: provide pure entropy for net_hash_mix()
[ Upstream commit 355b98553789b646ed97ad801a619ff898471b92 ]

net_hash_mix() currently uses kernel address of a struct net,
and is used in many places that could be used to reveal this
address to a patient attacker, thus defeating KASLR, for
the typical case (initial net namespace, &init_net is
not dynamically allocated)

I believe the original implementation tried to avoid spending
too many cycles in this function, but security comes first.

Also provide entropy regardless of CONFIG_NET_NS.

Fixes: 0b4419162a ("netns: introduce the net_hash_mix "salt" for hashes")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Amit Klein <aksecurity@gmail.com>
Reported-by: Benny Pinkas <benny@pinkas.net>
Cc: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-27 22:10:05 +02:00
Linus Torvalds 9879b43b8b binfmt_elf: switch to new creds when switching to new mm
commit 9f834ec18defc369d73ccf9e87a2790bfa05bf46 upstream.

We used to delay switching to the new credentials until after we had
mapped the executable (and possible elf interpreter).  That was kind of
odd to begin with, since the new executable will actually then _run_
with the new creds, but whatever.

The bigger problem was that we also want to make sure that we turn off
prof events and tracing before we start mapping the new executable
state.  So while this is a cleanup, it's also a fix for a possible
information leak.

Reported-by: Robert Święcki <robert@swiecki.net>
Tested-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: David Howells <dhowells@redhat.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Andy Lutomirski <luto@amacapital.net>
Acked-by: Eric W. Biederman <ebiederm@xmission.com>
Cc: Willy Tarreau <w@1wt.eu>
Cc: Kees Cook <keescook@chromium.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Federico Manuel Bento <up201407890@fc.up.pt>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-27 22:10:05 +02:00
Manfred Schlaegl 32f32907a8 fbdev: fbmem: fix memory access if logo is bigger than the screen
[ Upstream commit a5399db139cb3ad9b8502d8b1bd02da9ce0b9df0 ]

There is no clipping on the x or y axis for logos larger that the framebuffer
size. Therefore: a logo bigger than screen size leads to invalid memory access:

[    1.254664] Backtrace:
[    1.254728] [<c02714e0>] (cfb_imageblit) from [<c026184c>] (fb_show_logo+0x620/0x684)
[    1.254763]  r10:00000003 r9:00027fd8 r8:c6a40000 r7:c6a36e50 r6:00000000 r5:c06b81e4
[    1.254774]  r4:c6a3e800
[    1.254810] [<c026122c>] (fb_show_logo) from [<c026c1e4>] (fbcon_switch+0x3fc/0x46c)
[    1.254842]  r10:c6a3e824 r9:c6a3e800 r8:00000000 r7:c6a0c000 r6:c070b014 r5:c6a3e800
[    1.254852]  r4:c6808c00
[    1.254889] [<c026bde8>] (fbcon_switch) from [<c029c8f8>] (redraw_screen+0xf0/0x1e8)
[    1.254918]  r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:c070d5a0 r5:00000080
[    1.254928]  r4:c6808c00
[    1.254961] [<c029c808>] (redraw_screen) from [<c029d264>] (do_bind_con_driver+0x194/0x2e4)
[    1.254991]  r9:00000000 r8:00000000 r7:00000014 r6:c070d5a0 r5:c070d5a0 r4:c070d5a0

So prevent displaying a logo bigger than screen size and avoid invalid
memory access.

Signed-off-by: Manfred Schlaegl <manfred.schlaegl@ginzinger.com>
Signed-off-by: Martin Kepplinger <martin.kepplinger@ginzinger.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-07-27 22:10:04 +02:00
Ranjani Sridharan f6a1ce7a15 ALSA: PCM: check if ops are defined before suspending PCM
[ Upstream commit d9c0b2afe820fa3b3f8258a659daee2cc71ca3ef ]

BE dai links only have internal PCM's and their substream ops may
not be set. Suspending these PCM's will result in their
 ops->trigger() being invoked and cause a kernel oops.
So skip suspending PCM's if their ops are NULL.

[ NOTE: this change is required now for following the recent PCM core
  change to get rid of snd_pcm_suspend() call.  Since DPCM BE takes
  the runtime carried from FE while keeping NULL ops, it can hit this
  bug.  See details at:
     https://github.com/thesofproject/linux/pull/582
  -- tiwai ]

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-07-27 22:10:04 +02:00
Sebastian Andrzej Siewior c03ca5f3a8 ARM: 8840/1: use a raw_spinlock_t in unwind
[ Upstream commit 74ffe79ae538283bbf7c155e62339f1e5c87b55a ]

Mostly unwind is done with irqs enabled however SLUB may call it with
irqs disabled while creating a new SLUB cache.

I had system freeze while loading a module which called
kmem_cache_create() on init. That means SLUB's __slab_alloc() disabled
interrupts and then

->new_slab_objects()
 ->new_slab()
  ->setup_object()
   ->setup_object_debug()
    ->init_tracking()
     ->set_track()
      ->save_stack_trace()
       ->save_stack_trace_tsk()
        ->walk_stackframe()
         ->unwind_frame()
          ->unwind_find_idx()
           =>spin_lock_irqsave(&unwind_lock);

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-07-27 22:10:04 +02:00
Benjamin Block f9cc1ae00b scsi: core: replace GFP_ATOMIC with GFP_KERNEL in scsi_scan.c
[ Upstream commit 1749ef00f7312679f76d5e9104c5d1e22a829038 ]

We had a test-report where, under memory pressure, adding LUNs to the
systems would fail (the tests add LUNs strictly in sequence):

[ 5525.853432] scsi 0:0:1:1088045124: Direct-Access     IBM      2107900          .148 PQ: 0 ANSI: 5
[ 5525.853826] scsi 0:0:1:1088045124: alua: supports implicit TPGS
[ 5525.853830] scsi 0:0:1:1088045124: alua: device naa.6005076303ffd32700000000000044da port group 0 rel port 43
[ 5525.853931] sd 0:0:1:1088045124: Attached scsi generic sg10 type 0
[ 5525.854075] sd 0:0:1:1088045124: [sdk] Disabling DIF Type 1 protection
[ 5525.855495] sd 0:0:1:1088045124: [sdk] 2097152 512-byte logical blocks: (1.07 GB/1.00 GiB)
[ 5525.855606] sd 0:0:1:1088045124: [sdk] Write Protect is off
[ 5525.855609] sd 0:0:1:1088045124: [sdk] Mode Sense: ed 00 00 08
[ 5525.855795] sd 0:0:1:1088045124: [sdk] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 5525.857838]  sdk: sdk1
[ 5525.859468] sd 0:0:1:1088045124: [sdk] Attached SCSI disk
[ 5525.865073] sd 0:0:1:1088045124: alua: transition timeout set to 60 seconds
[ 5525.865078] sd 0:0:1:1088045124: alua: port group 00 state A preferred supports tolusnA
[ 5526.015070] sd 0:0:1:1088045124: alua: port group 00 state A preferred supports tolusnA
[ 5526.015213] sd 0:0:1:1088045124: alua: port group 00 state A preferred supports tolusnA
[ 5526.587439] scsi_alloc_sdev: Allocation failure during SCSI scanning, some SCSI devices might not be configured
[ 5526.588562] scsi_alloc_sdev: Allocation failure during SCSI scanning, some SCSI devices might not be configured

Looking at the code of scsi_alloc_sdev(), and all the calling contexts,
there seems to be no reason to use GFP_ATMOIC here. All the different
call-contexts use a mutex at some point, and nothing in between that
requires no sleeping, as far as I could see. Additionally, the code that
later allocates the block queue for the device (scsi_mq_alloc_queue())
already uses GFP_KERNEL.

There are similar allocations in two other functions:
scsi_probe_and_add_lun(), and scsi_add_lun(),; that can also be done with
GFP_KERNEL.

Here is the contexts for the three functions so far:

    scsi_alloc_sdev()
        scsi_probe_and_add_lun()
            scsi_sequential_lun_scan()
                __scsi_scan_target()
                    scsi_scan_target()
                        mutex_lock()
                    scsi_scan_channel()
                        scsi_scan_host_selected()
                            mutex_lock()
            scsi_report_lun_scan()
                __scsi_scan_target()
    	            ...
            __scsi_add_device()
                mutex_lock()
            __scsi_scan_target()
                ...
        scsi_report_lun_scan()
            ...
        scsi_get_host_dev()
            mutex_lock()

    scsi_probe_and_add_lun()
        ...

    scsi_add_lun()
        scsi_probe_and_add_lun()
            ...

So replace all these, and give them a bit of a better chance to succeed,
with more chances of reclaim.

Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-07-27 22:10:03 +02:00
Tony Jones 1738483f68 tools lib traceevent: Fix buffer overflow in arg_eval
[ Upstream commit 7c5b019e3a638a5a290b0ec020f6ca83d2ec2aaa ]

Fix buffer overflow observed when running perf test.

The overflow is when trying to evaluate "1ULL << (64 - 1)" which is
resulting in -9223372036854775808 which overflows the 20 character
buffer.

If is possible this bug has been reported before but I still don't see
any fix checked in:

See: https://www.spinics.net/lists/linux-perf-users/msg07714.html

Reported-by: Michael Sartain <mikesart@fastmail.com>
Reported-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Tony Jones <tonyj@suse.de>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Fixes: f7d82350e5 ("tools/events: Add files to create libtraceevent.a")
Link: http://lkml.kernel.org/r/20190228015532.8941-1-tonyj@suse.de
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-07-27 22:10:03 +02:00
Uladzislau Rezki (Sony) a6c2f4f94b mm/vmalloc.c: fix kernel BUG at mm/vmalloc.c:512!
[ Upstream commit afd07389d3f4933c7f7817a92fb5e053d59a3182 ]

One of the vmalloc stress test case triggers the kernel BUG():

  <snip>
  [60.562151] ------------[ cut here ]------------
  [60.562154] kernel BUG at mm/vmalloc.c:512!
  [60.562206] invalid opcode: 0000 [#1] PREEMPT SMP PTI
  [60.562247] CPU: 0 PID: 430 Comm: vmalloc_test/0 Not tainted 4.20.0+ #161
  [60.562293] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
  [60.562351] RIP: 0010:alloc_vmap_area+0x36f/0x390
  <snip>

it can happen due to big align request resulting in overflowing of
calculated address, i.e.  it becomes 0 after ALIGN()'s fixup.

Fix it by checking if calculated address is within vstart/vend range.

Link: http://lkml.kernel.org/r/20190124115648.9433-2-urezki@gmail.com
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Joel Fernandes <joelaf@google.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-07-27 22:10:02 +02:00
Christian Brauner 40a828a92e sysctl: handle overflow for file-max
[ Upstream commit 32a5ad9c22852e6bd9e74bdec5934ef9d1480bc5 ]

Currently, when writing

  echo 18446744073709551616 > /proc/sys/fs/file-max

/proc/sys/fs/file-max will overflow and be set to 0.  That quickly
crashes the system.

This commit sets the max and min value for file-max.  The max value is
set to long int.  Any higher value cannot currently be used as the
percpu counters are long ints and not unsigned integers.

Note that the file-max value is ultimately parsed via
__do_proc_doulongvec_minmax().  This function does not report error when
min or max are exceeded.  Which means if a value largen that long int is
written userspace will not receive an error instead the old value will be
kept.  There is an argument to be made that this should be changed and
__do_proc_doulongvec_minmax() should return an error when a dedicated min
or max value are exceeded.  However this has the potential to break
userspace so let's defer this to an RFC patch.

Link: http://lkml.kernel.org/r/20190107222700.15954-3-christian@brauner.io
Signed-off-by: Christian Brauner <christian@brauner.io>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Joe Lawrence <joe.lawrence@redhat.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Waiman Long <longman@redhat.com>
[christian@brauner.io: v4]
  Link: http://lkml.kernel.org/r/20190210203943.8227-3-christian@brauner.io
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-07-27 22:10:02 +02:00
Douglas Anderson 9b4dadbfa9 tracing: kdb: Fix ftdump to not sleep
[ Upstream commit 31b265b3baaf55f209229888b7ffea523ddab366 ]

As reported back in 2016-11 [1], the "ftdump" kdb command triggers a
BUG for "sleeping function called from invalid context".

kdb's "ftdump" command wants to call ring_buffer_read_prepare() in
atomic context.  A very simple solution for this is to add allocation
flags to ring_buffer_read_prepare() so kdb can call it without
triggering the allocation error.  This patch does that.

Note that in the original email thread about this, it was suggested
that perhaps the solution for kdb was to either preallocate the buffer
ahead of time or create our own iterator.  I'm hoping that this
alternative of adding allocation flags to ring_buffer_read_prepare()
can be considered since it means I don't need to duplicate more of the
core trace code into "trace_kdb.c" (for either creating my own
iterator or re-preparing a ring allocator whose memory was already
allocated).

NOTE: another option for kdb is to actually figure out how to make it
reuse the existing ftrace_dump() function and totally eliminate the
duplication.  This sounds very appealing and actually works (the "sr
z" command can be seen to properly dump the ftrace buffer).  The
downside here is that ftrace_dump() fully consumes the trace buffer.
Unless that is changed I'd rather not use it because it means "ftdump
| grep xyz" won't be very useful to search the ftrace buffer since it
will throw away the whole trace on the first grep.  A future patch to
dump only the last few lines of the buffer will also be hard to
implement.

[1] https://lkml.kernel.org/r/20161117191605.GA21459@google.com

Link: http://lkml.kernel.org/r/20190308193205.213659-1-dianders@chromium.org

Reported-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-07-27 22:10:01 +02:00
Corinna Vinschen a1ad82df8f qcacld-2.0: wlan_hdd_restart_driver: no WCNSS, so call VOS_BUG(0) instead
This kind of fixes "qcacld-2.0: Add scenario based BUG report"

1. #include <linux/wcnss_wlan.h> is missing in wlan_hdd_main.c, so
   HAVE_WCNSS_RESET_INTR is never defined, so wcnss_reset_intr() is
   never called from wlan_hdd_restart_driver().  This is still the
   case in upstream branches.

2. Even *if* we add this #include, wcnss_reset_intr() will be unavailable
   because the Samsung apq8084 kernel is built without CONFIG_WCNSS_CORE.

3. And even *if* we try to enable CONFIG_WCNSS_CORE and *if* WCNSS
   actually builds, we have no idea if wcnss_reset_intr() is actually doing
   the right thing for our ROME chip since there are only branches for
   PRONTO and RIVA.  ROME is very certainly not PRONTO, but is it RIVA?

4. In comparison, on bullhead the situation is the same as above, plus
   wcnss_reset_intr() is a no-op in the RIVA branch.  Same on Samsung
   msm8976, except wcnss_reset_intr() doesn't even exist.

5. Ultimately this makes vos_wlanRestart() a no-op which just logs stuff.
   It's a complete mystery how this call was supposed to replace the old
   VOS_BUG(0) call.

6. Conclusion: The code change in "qcacld-2.0: Add scenario based BUG report"
   does never reset the WLAN driver, nor does it restart the device in case
   of error.  If that was really intended, why call vos_wlanRestart() at all?

7. For now we change wlan_hdd_restart_driver() to call VOS_BUG(0).  That
   will restart the device every time qcacld-2.0 deems an error as fatal,
   just like before.  Except, we now may have better logging.  Either the
   crash never occurs again, or we may have a chance to debug and fix the
   original problem.  Either way, we probably can revert this patch at one
   point.

Change-Id: I339cb339d3919a47ce781918544391622bda4c94
Signed-off-by: Corinna Vinschen <xda@vinschen.de>
2019-07-27 22:10:01 +02:00
Ratnam Rachuri 8de7dd14a2 qcacld-2.0: Pass the peer mac address during deauth notification
prima to qcacld-2.0 propagation

Currently only session id and reason code are posted to SME
during disassoc notification. SAP callback in HDD will deregister the
station based on the station ID which is determined using the peer
mac address and since peer mac address is not passed, it fails to
deregister the station.
To address this, pass the peer mac address while posting disassoc
notification from PE to SME.

CRs-Fixed: 957855
Change-Id: I2976bb5e441f4658ad46ce0d64e0420eae240ac8
2019-07-27 22:10:01 +02:00
Nick Desaulniers 78ef5ad5fb msm: thermal: validate userspace args to prevent buffer overflow.
Prevent a userspace ioctl variable from accessing an array out of
bounds.

BUG: 27243728
Change-Id: I43690364273ace4a22e214bab88c76f0749c6d4f
2019-07-27 22:10:00 +02:00
Siqi Lin 26348f7fa6 msm_thermal: send OFF/ONLINE uevent in hotplug cases
Send the correct uevent after setting a CPU core online or offline.
This allows ueventd to set correct SELinux labels for newly created
sysfs CPU device nodes.

Bug: 28887345
Change-Id: If31b8529b31de9544914e27514aca571039abb60
Signed-off-by: Siqi Lin <siqilin@google.com>
Signed-off-by: Thierry Strudel <tstrudel@google.com>
2019-07-27 22:10:00 +02:00
Srinivas Girigowda d15df584eb qcacld-2.0: Delete SSR timer after isLogpInProgress is reset
In hdd_wlan_re_init(), SSR timer is deleted and isLogpInProgress is set to FALSE
but between these two there are NL socket related calls which can sleep
under low memory conditions (or etc) because of which timer is deleted but
isLogpInProgress is not reset to FALSE. This can potentially fail the
south-bound requests for a brief amount of time.

Hence it is always better to delete the SSR timer only after
isLogpInProgress is reset to FALSE.

Change-Id: I699438ff3e0c2f7b81e0bbf81be6f514841e194b
CRs-Fixed: 1017011
2019-07-27 22:09:59 +02:00
Varun Reddy Yeturu 7bc8ecac33 qcacld-2.0: Fix incorrect logic to disable hi_rssi feature
Fix incorrect logic to disable hi_rssi feature.
Both hi_rssi_scan_rssi_delta and neighborLookupThreshold are
positive values. Ideally it should be checked if the current
AP is better than the HI_RSSI threshold and then disable
the feature. The HI_RSSI threshold is the difference
between the lookup threshold and the hi_rssi delta.

CRs-Fixed: 1014859
Change-Id: I6980927b25c34b9b4d8ac13c22e93abc4ec500ec
2019-07-27 22:09:59 +02:00
Gupta, Kapil 1b8f8f1775 qcacld-2.0: Ignore BMISS indication in case previous one is not processed
prima to qcacld-2.0 propagation

If SME has active cmd, continuous BMiss in BMPS state will
exhaust sme command pool.
To avoid this, Ignore BMiss indication in case previous one is
not processed.
CRs-Fixed: 979109
Change-Id: I87f6d5437f181abb92772ad142b2101547d76657
2019-07-27 22:09:58 +02:00
Padma, Santhosh Kumar ef1abb3e96 qcacld-2.0: Dump stack only once
Add changes to dump stack only once. Also, change thread stuck
timer to 10 seconds from 5 seconds (THREAD_STUCK_TIMER_VAL) and
probe thread only when thread stuck counter is zero to avoid
out of wrapper messages. Remove unnecessary error logs also.

Change-Id: I6c2ab331256b190fd0ce67f8fb95ed4d7cb5e61a
CRs-Fixed: 1032098
2019-07-27 22:09:58 +02:00
Mahesh Kumar Kalikot Veetil 5e02959d02 qcacld-2.0: Fix a deadlock in proto trace
There is a potential deadlock scenario with a spin lock between
a tasklet and a thread context. Fix it by using spin_lock_bh
because that will disable bottom halves on that CPU and thus
prevent a dead lock that could otherwise occur if the process
context code took the lock and then a software IRQ was run which
attempt to acquire the same lock.

Change-Id: I5f83cb7cecd7227e0ea9c9db001bb0420bf09c94
CRs-Fixed: 1014766
2019-07-27 22:09:58 +02:00
Gupta, Kapil 8a255f5b11 qcacld-2.0: Add scenario based BUG report
prima to qcacld-2.0 propagation

Change to initiate BUG report in case of fatal event
Add INI support to Enable/Disable it.

The fatal event handled are as below:
 - Roaming failed after successfull preauth.
 - MC thread is Stucked for 15 sec.
 - Sme command timeout.
 - PE defer queue is full.
 - VOS run out of message wrapper.
 - Management tx timeout.
 - HDD level wait for event timeout.

CRs-Fixed: 912560
Change-Id: I64dff8b7d0836340ce3bec5f5985d1919b600c23
2019-07-27 22:09:57 +02:00
Padma, Santhosh Kumar 6b78aa9d53 qcacld-2.0: Dump stack information during thread stuck
prima to qcacld-2.0 propagation

When MC thread is stuck, currently there is no way to
get the call stack. So, add this support to dump the
call stack of MC thread that got stuck

Change-Id: I2e4f445c8e4d65905bc7f00bca215d000f61b1db
CRs-Fixed: 979886
2019-07-27 22:09:57 +02:00
Srinivas Girigowda 313f6c17a9 cnss: Expose dump stack functionality
Add changes to expose dump stack functionality which can be used
by driver to dump stack information when it requires.

CRs-Fixed: 979886
Change-Id: Ib929ad0a510b996ac54d17afd2957ea487c62851
Signed-off-by: Abhishek Singh <absingh@codeaurora.org>
Signed-off-by: Srinivas Girigowda <sgirigow@codeaurora.org>
2019-07-27 22:09:56 +02:00
Oleg Nesterov 9517972d5c wait/ptrace: assume __WALL if the child is traced
commit bf959931ddb88c4e4366e96dd22e68fa0db9527c upstream.

The following program (simplified version of generated by syzkaller)

	#include <pthread.h>
	#include <unistd.h>
	#include <sys/ptrace.h>
	#include <stdio.h>
	#include <signal.h>

	void *thread_func(void *arg)
	{
		ptrace(PTRACE_TRACEME, 0,0,0);
		return 0;
	}

	int main(void)
	{
		pthread_t thread;

		if (fork())
			return 0;

		while (getppid() != 1)
			;

		pthread_create(&thread, NULL, thread_func, NULL);
		pthread_join(thread, NULL);
		return 0;
	}

creates an unreapable zombie if /sbin/init doesn't use __WALL.

This is not a kernel bug, at least in a sense that everything works as
expected: debugger should reap a traced sub-thread before it can reap the
leader, but without __WALL/__WCLONE do_wait() ignores sub-threads.

Unfortunately, it seems that /sbin/init in most (all?) distributions
doesn't use it and we have to change the kernel to avoid the problem.
Note also that most init's use sys_waitid() which doesn't allow __WALL, so
the necessary user-space fix is not that trivial.

This patch just adds the "ptrace" check into eligible_child().  To some
degree this matches the "tsk->ptrace" in exit_notify(), ->exit_signal is
mostly ignored when the tracee reports to debugger.  Or WSTOPPED, the
tracer doesn't need to set this flag to wait for the stopped tracee.

This obviously means the user-visible change: __WCLONE and __WALL no
longer have any meaning for debugger.  And I can only hope that this won't
break something, but at least strace/gdb won't suffer.

We could make a more conservative change.  Say, we can take __WCLONE into
account, or !thread_group_leader().  But it would be nice to not
complicate these historical/confusing checks.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Cc: Pedro Alves <palves@redhat.com>
Cc: Roland McGrath <roland@hack.frob.com>
Cc: <syzkaller@googlegroups.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-07-27 22:09:56 +02:00
Oleg Nesterov a8822b0e86 ptrace: revert "Prepare to fix racy accesses on task breakpoints"
This reverts commit bf26c01849 ("Prepare to fix racy accesses on task
breakpoints").

The patch was fine but we can no longer race with SIGKILL after commit
9899d11f65 ("ptrace: ensure arch_ptrace/ptrace_request can never race
with SIGKILL"), the __TASK_TRACED tracee can't be woken up and
->ptrace_bps[] can't go away.

Now that ptrace_get_breakpoints/ptrace_put_breakpoints have no callers,
we can kill them and remove task->ptrace_bp_refcnt.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Michael Neuling <mikey@neuling.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Prasad <prasad@linux.vnet.ibm.com>
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-07-27 22:09:55 +02:00
Oleg Nesterov 3d5d221acc ptrace/arm: revert "hw_breakpoints: Fix racy access to ptrace breakpoints"
This reverts commit bf0b8f4b55 ("hw_breakpoints: Fix racy access to
ptrace breakpoints").

The patch was fine but we can no longer race with SIGKILL after commit
9899d11f65 ("ptrace: ensure arch_ptrace/ptrace_request can never race
with SIGKILL"), the __TASK_TRACED tracee can't be woken up and
->ptrace_bps[] can't go away.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Michael Neuling <mikey@neuling.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Prasad <prasad@linux.vnet.ibm.com>
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-07-27 22:09:55 +02:00
Srinivas Girigowda 95c8db83ed qcacld-2.0: Fix warning while stopping pmfcomeback timer for roam session
In case of PMF connection pmfcomeback timer is initialized
for the old session and not for new FT session and thus
gives warning while stopping the timer when FT session is
deleted.

Fix this issue by initializing PMF timer for FT session.

Change-Id: I7ef1db436c39a824aeb199e51d28a011d527f7bd
CRs-Fixed: 1050380
Bug: 31358630
Signed-off-by: Srinivas Girigowda <sgirigow@codeaurora.org>
2019-07-27 22:09:54 +02:00
Srinivas Girigowda 6346c30c8e qcacld-2.0: Validate multicast filter count
Before configuring to firmware, validate multicast
filter count does not exceed the max allowed value.

Change-Id: I1bcb1c820a5154109565a8c283bf5131a3b90855
CRs-Fixed: 1059974
Bug: 31037507
Signed-off-by: Srinivas Girigowda <sgirigow@codeaurora.org>
2019-07-27 22:09:54 +02:00
Sreelakshmi Konamki 3b53416709 qcacld-2.0: Flush driver and firmware logs only for driver ring id
Currently driver flushes driver and firmware logs irrespective of ring id.
Host should flush the logs only for driver ring id.
Add changes to fix the same issue.

Change-Id: I50cfde1baaf18c1a3992f956182b49044ccc4b1d
CRs-Fixed: 1053219
2019-07-27 22:09:53 +02:00
Srinivas Girigowda 0962320b3c qcacld-2.0: Do not probe MC thread when its suspended
Do not probe MC thread when its suspended during cfg80211
suspend and increase thread stuck detection threshold to
avoid reporting false alarm.

Change-Id: Ia93289eaf89538818a8e1264dfcf3306d682bd9b
CRs-Fixed: 1047257
Bug: 30407099
Signed-off-by: Srinivas Girigowda <sgirigow@codeaurora.org>
2019-07-27 22:09:53 +02:00
Srinivas Girigowda cc7d39f1ce qcacld-2.0: Fix buffer over read in iwpriv WE_UNIT_TEST_CMD command
In current driver, WE_UNIT_TEST_CMD has below problem.
- apps_arg[1] can have zero value and can lead to
  buffer overead

Change the code to handle the number of args if user has
given zero.

CRs-Fixed: 1029540
Change-Id: Idc8e1d77d9623daeb98d0c4b7ad8a8d6cfa9c2d2
Bug: 29941999
Bug: 29944562
Signed-off-by: Srinivas Girigowda <sgirigow@codeaurora.org>
2019-07-27 22:09:53 +02:00
Srinivas Girigowda dd5d4a6592 qcacld-2.0: Don't Tag Non-WoW packets as Runtime PM packets after wow suspend
Some WMI Commands can be send in Runtime PM context and MC thread context.
Packets coming via MC Thread Context can be tagged as Runtime PM packets
when runtime pm in progress.

Packets should be tagged in the same caller context to avoid any race
condition. Being stability issue, addressing this issue by not tagging
any non-wow commands as runtime pm after wow suspend. This will ensure
all the non-wow packets coming after wow_suspend flag is set as non
runtime pm packets and will trigger a runtime resume.

CRs-Fixed: 1037430
Change-Id: I03528a395e1d88ca2c5aaeca27fa505c3426f778
Bug: 31438853
Signed-off-by: Srinivas Girigowda <sgirigow@codeaurora.org>
2019-07-27 22:09:52 +02:00
Srinivas Girigowda 78d5c4bb0f qcacld-2.0: Block interface down until pending scan request is aborted
prima to qcacld-2.0 propagation

From Kernel-3.18 onwards pending scan request is handled
as part of NETDEV_DOWN event, by invoking the cfg80211_scan_done
callback which frees the scan request structure. To support this,
driver will not invoke scan_done_callback if interface is down.

In case, if interface down and up are called back to back there
is a chance that kernel frees scan request as part of NETDEV_DOWN
and after which before driver triggers scan_done_callback if
interface is made up, driver scan_done_callback is through its
execution and accesses the freed scan request results in kernel
panic.

To mitigate this, don't return from hdd_stop until scan request
is aborted. Though this fix is to avoid kernel panic due to 3.18
kernel specific changes, it is acceptable across all the kernel
versions.

Change-Id: Iba8bd7a32fac33e8a0c3eea293aad682a1105397
CRs-Fixed: 977264
Bug: 31438853
Signed-off-by: Srinivas Girigowda <sgirigow@codeaurora.org>
2019-07-27 22:09:52 +02:00
Srinivas Girigowda bfcf26a0c1 qcacld-2.0: Avoid kernel warnings due to improper work queue initialization
Kernel throws warnings on the invocation of schedule_work() before the
work is initialized.

To mitigate this issue, initialize the work before it is scheduled.

Change-Id: Ia73f3fb186ba0818162d8263a72187a71c2f4a07
CRs-Fixed: 1010964
Bug: 28405264
Signed-off-by: Srinivas Girigowda <sgirigow@codeaurora.org>
2019-07-27 22:09:51 +02:00
Srinivas Girigowda 31a9cac27f qcacld-2.0: Fix type mismatch and bitwise operation on different size
1.Fix argument type mismatch with format specifier in sscanf used by
hdd_hex_string_to_u16_array.
2.Fix bitwise operation on different size by typecasting.

Change-Id: Iccec386d8d88d69ccc4eacd2031d5664ed948acc
CRs-Fixed: 1018489
Bug: 31438853
Signed-off-by: Srinivas Girigowda <sgirigow@codeaurora.org>
2019-07-27 22:09:51 +02:00
Srinivas Girigowda b990418021 qcacld-2.0: Set htc tx tag when call set vdev suspend dtim
It doesn't set tag HTC_TX_PACKET_TAG_AUTO_PM when attempt to suspend
and set vdev suspend dtim, which cause host wake up frequently.

Change-Id: Iba32c715694e64ce7d941f198990b25b9c87240d
CRs-Fixed: 1003313
Bug: 31438853
Signed-off-by: Srinivas Girigowda <sgirigow@codeaurora.org>
2019-07-27 22:09:50 +02:00
syphyr d132d6387f ANDROID: Remove conflicting Samsung options for upstream changes
In order to bring lowmemorykiller in sync with Google sources,
the following Samsung specific changes have been removed:

SEC_TIMEOUT_LOW_MEMORY_KILLER
SEC_DEBUG_LMK_MEMINFO
SEC_DEBUG_LMK_COUNT_INFO

These options are not used upstream and conflict.
2019-07-27 22:09:50 +02:00
Tim Murray 9697139d52 lowmemorykiller: account for unevictable pages
lowmemorykiller was not taking into account unevictable pages when
deciding what level to kill. If significant amounts of memory were
pinned, this caused lowmemorykiller to effectively stop at a much higher
level than it should.

bug 31255977

Change-Id: I763ecbfef8c56d65bb8f6147ae810692bd81b6e2
2019-07-27 22:09:50 +02:00
Vinayak Menon 862f4f71e0 staging: android: lowmemorykiller: neglect swap cached pages in other_file
With ZRAM enabled it is observed that lowmemory killer
doesn't trigger properly. swap cached pages are
accounted in NR_FILE, and lowmemorykiller considers
this as reclaimable and adds to other_file. But these
pages can't be reclaimed unless lowmemorykiller triggers.
So subtract swap pages from other_file.

Signed-off-by: Vinayak Menon <vinayakm.list@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 058dbde928597e7a8bd04e28e77e5cfc4270591d)

Change-Id: I217e831bbe1db830e6d61c7943e442a32a7548a1
2019-07-27 22:09:49 +02:00
Thierry Strudel 8a04cc5c75 Revert "android/lowmemorykiller: Check all tasks for death pending"
This reverts commit 7ec0cf6d3f.
2019-07-27 22:09:49 +02:00
Thierry Strudel 919a123cc9 Revert "android/lowmemorykiller: Wait for memory to be freed"
This reverts commit 25f87e504b.

Change-Id: If8709a45b36fb73bee4e9c3e4e99937a8a952651
2019-07-27 22:09:48 +02:00
Thierry Strudel 6f6c955aa5 Revert "android/lowmemorykiller: Ignore tasks with freed mm"
This reverts commit 05d5ad4d0a.

Change-Id: Ib5770b5b38f123116322507646ae9bce6c3c186a
2019-07-27 22:09:48 +02:00
Thierry Strudel 44ba2354e3 Revert "android: lowmemorykiller: add lmk parameters tunning code."
This reverts commit f92471abb9.
2019-07-27 22:09:48 +02:00
Thierry Strudel 6b1475d492 Revert "android/lowmemorykiller: Selectively count free CMA pages"
This reverts commit 06e8520b10.
2019-07-27 22:09:47 +02:00
Thierry Strudel 0675816e5b Revert "lowmemorykiller: Account for highmem during kswapd reclaim"
This reverts commit e137b1a41f.
2019-07-27 22:09:47 +02:00
Thierry Strudel 70bbc4c513 Revert "lowmemorykiller: enhance debug information"
This reverts commit ba79232663.

Change-Id: I6a1b524ccdcd7c963cd0c380061b1b05c9a3fe3e
2019-07-27 22:09:46 +02:00
Thierry Strudel 6b8d46ce77 Revert "lowmemorykiller: Dump out slab state information"
This reverts commit ed1aff26c1.
2019-07-27 22:09:46 +02:00
Thierry Strudel 5cfdb9221d Revert "lowmemorykiller: Run the lowmemory notifier when killing"
This reverts commit f49905e2be.
2019-07-27 22:09:45 +02:00
Thierry Strudel da8ab3ac0e Revert "lowmemorykiller: use for_each_thread instead of buggy while_each_thread"
This reverts commit 4e352bff294dc89bbd9fc74646d9fe01cbfd6e02.
2019-07-27 22:09:45 +02:00
Thierry Strudel 200ed15225 Revert "lowmemorykiller: Don't count swap cache pages twice"
This reverts commit 52acbe414c1643066b299c1e9cdae7f4f188d419.
2019-07-27 22:09:45 +02:00
Thierry Strudel 9174c4f83f Revert "lowmemorykiller: Do proper NULL checks"
This reverts commit a7d54d72883cf7cb31c059e31125695babbf2b8d.
2019-07-27 22:09:44 +02:00