Commit graph android_kernel_sony_sdm845/kernel
Message SHA1
Merge "Merge remote-tracking branch '4.9/tmp-82ab074' into 4.9" into msm-4.9
Channagoud Kadabi   authored and   Gerrit - the friendly Code Review server   commited 2017-03-28 10:59:22 -07:00
577379aa74
Merge "sched/core_ctl: Fix state_lock spinlock contention" into msm-4.9
Kyle Yan   authored and   Gerrit - the friendly Code Review server   commited 2017-03-28 04:00:23 -07:00
20e0464bf0
Merge remote-tracking branch '4.9/tmp-82ab074' into 4.9
* 4.9/tmp-82ab074:
  Linux 4.9.17
  crypto: powerpc - Fix initialisation of crc32c context
  locking/rwsem: Fix down_write_killable() for CONFIG_RWSEM_GENERIC_SPINLOCK=y
  futex: Add missing error handling to FUTEX_REQUEUE_PI
  futex: Fix potential use-after-free in FUTEX_REQUEUE_PI
  x86/perf: Fix CR4.PCE propagation to use active_mm instead of mm
  x86/kasan: Fix boot with KASAN=y and PROFILE_ANNOTATED_BRANCHES=y
  x86/tsc: Fix ART for TSC_KNOWN_FREQ
  irqchip/gicv3-its: Add workaround for QDF2400 ITS erratum 0065
  arm64: KVM: VHE: Clear HCR_TGE when invalidating guest TLBs
  drm/vc4: Fix ->clock_select setting for the VEC encoder
  drm/vc4: Fix race between page flip completion event and clean-up
  clk: bcm2835: Fix ->fixed_divider of pllh_aux
  powerpc/mm: Fix build break when CMA=n && SPAPR_TCE_IOMMU=y
  usb: gadget: udc: atmel: remove memory leak
  serial: 8250_pci: Detach low-level driver during PCI error recovery
  ACPI / blacklist: Make Dell Latitude 3350 ethernet work
  ACPI / blacklist: add _REV quirks for Dell Precision 5520 and 3520
  slub: move synchronize_sched out of slab_mutex on shrink
  uvcvideo: uvc_scan_fallback() for webcams with broken chain
  s390/zcrypt: Introduce CEX6 toleration
  block: allow WRITE_SAME commands with the SG_IO ioctl
  drm/nouveau/disp/nv50-: specify ctrl/user separately when constructing classes
  drm/nouveau/disp/nv50-: split chid into chid.ctrl and chid.user
  drm/nouveau/disp/gp102: fix cursor/overlay immediate channel indices
  vfio/spapr: Postpone default window creation
  vfio/spapr: Add a helper to create default DMA window
  powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown
  vfio/spapr: Reference mm in tce_container
  powerpc/iommu: Stop using @current in mm_iommu_xxx
  powerpc/iommu: Pass mm_struct to init/cleanup helpers
  vfio/spapr: Postpone allocation of userspace version of TCE table
  Drivers: hv: ring_buffer: count on wrap around mappings in get_next_pkt_raw() (v2)
  ibmveth: calculate gso_segs for large packets
  PCI: Do any VF BAR updates before enabling the BARs
  PCI: Ignore BAR updates on virtual functions
  PCI: Update BARs using property bits appropriate for type
  PCI: Don't update VF BARs while VF memory space is enabled
  PCI: Decouple IORESOURCE_ROM_ENABLE and PCI_ROM_ADDRESS_ENABLE
  PCI: Add comments about ROM BAR updating
  PCI: Remove pci_resource_bar() and pci_iov_resource_bar()
  PCI: Separate VF BAR updates from standard BAR updates
  x86/hyperv: Handle unknown NMIs on one CPU when unknown_nmi_panic
  scsi: ibmvscsis: Synchronize cmds at remove time
  scsi: ibmvscsis: Synchronize cmds at tpg_enable_store time
  scsi: ibmvscsis: Rearrange functions for future patches
  scsi: ibmvscsis: Clean up properly if target_submit_cmd/tmr fails
  scsi: ibmvscsis: Return correct partition name/# to client
  scsi: ibmvscsis: Issues from Dan Carpenter/Smatch
  igb: add i211 to i210 PHY workaround
  igb: Workaround for igb i210 firmware issue
  xen: do not re-use pirq number cached in pci device msi msg data
  dmaengine: iota: ioat_alloc_chan_resources should not perform sleeping allocations.
  bpf: fix mark_reg_unknown_value for spilled regs on map value marking
  bpf: fix regression on verifier pruning wrt map lookups
  bpf: fix state equivalence
  bpf: Detect identical PTR_TO_MAP_VALUE_OR_NULL registers
  dccp: fix memory leak during tear-down of unsuccessful connection request
  tun: fix premature POLLOUT notification on tun devices
  dccp/tcp: fix routing redirect race
  bridge: drop netfilter fake rtable unconditionally
  ipv6: avoid write to a possibly cloned skb
  ipv6: make ECMP route replacement less greedy
  mpls: Do not decrement alive counter for unregister events
  mpls: Send route delete notifications when router module is unloaded
  act_connmark: avoid crashing on malformed nlattrs with null parms
  uapi: fix linux/packet_diag.h userspace compilation error
  net/tunnel: set inner protocol in network gro hooks
  vrf: Fix use-after-free in vrf_xmit
  dccp: fix use-after-free in dccp_feat_activate_values
  net/sched: act_skbmod: remove unneeded rcu_read_unlock in tcf_skbmod_dump
  net: fix socket refcounting in skb_complete_tx_timestamp()
  net: fix socket refcounting in skb_complete_wifi_ack()
  tcp: fix various issues for sockets morphing to listen state
  strparser: destroy workqueue on module exit
  dccp: Unlock sock before calling sk_free()
  ipv6: orphan skbs in reassembly unit
  net: net_enable_timestamp() can be called from irq contexts
  net: don't call strlen() on the user buffer in packet_bind_spkt()
  net: bridge: allow IPv6 when multicast flood is disabled
  tcp/dccp: block BH for SYN processing
  mlxsw: spectrum_router: Avoid potential packets loss
  geneve: lock RCU on TX path
  vxlan: lock RCU on TX path
  net: phy: Avoid deadlock during phy_error()
  l2tp: avoid use-after-free caused by l2tp_ip_backlog_recv
  net sched actions: decrement module reference count after table flush.
  ipv4: mask tos for input route
  vxlan: don't allow overwrite of config src addr
  vti6: return GRE_KEY for vti6
  vxlan: correctly validate VXLAN ID against VXLAN_N_VID
  net/mlx5e: Fix wrong CQE decompression
  net/mlx5e: Do not reduce LRO WQE size when not using build_skb
  net/mlx5e: Register/unregister vport representors on interface attach/detach
  ANDROID: mmc: core: export emmc revision
  ANDROID: sdcardfs: Fix gid issue
  ANDROID: sdcardfs: Remove uninformative prints
  ANDROID: sdcardfs: move path_put outside of spinlock
  ANDROID: sdcardfs: Use case insensitive hash function
  ANDROID: sdcardfs: declare MODULE_ALIAS_FS
  ANDROID: sdcardfs: Get the blocksize from the lower fs
  ANDROID: sdcardfs: Use d_invalidate instead of drop_recurisve
  ANDROID: sdcardfs: Switch to internal case insensitive compare
  ANDROID: sdcardfs: Use spin_lock_nested
  ANDROID: sdcardfs: Replace get/put with d_lock
  ANDROID: sdcardfs: rate limit warning print
  ANDROID: sdcardfs: Fix case insensitive lookup
  ANDROID: sdcardfs: support direct-IO (DIO) operations
  ANDROID: sdcardfs: implement vm_ops->page_mkwrite
  ANDROID: sdcardfs: Don't bother deleting freelist
  ANDROID: sdcardfs: Add missing path_put
  ANDROID: sdcardfs: Fix incorrect hash
  ANDROID: export security_path_chown
  ANDROID: sdcardfs: Switch strcasecmp for internal call
  ANDROID: sdcardfs: switch to full_name_hash and qstr
  ANDROID: sdcardfs: Add GID Derivation to sdcardfs
  ANDROID: sdcardfs: Remove redundant operation
  ANDROID: sdcardfs: add support for user permission isolation
  ANDROID: sdcardfs: Refactor configfs interface
  ANDROID: sdcardfs: Allow non-owners to touch
  ANDROID: binder: add padding to binder_fd_array_object.
  ANDROID: binder: use group leader instead of open thread
  BACKPORT: mmc: core: Export device lifetime information through sysfs
  ANDROID: android-verity: do not compile as independent module

Change-Id: I7d409ec3e84eaa7f499c951d38f4cba2614415f7
Signed-off-by: Kyle Yan <kyan@codeaurora.org>

Kyle Yan   commited 2017-03-27 13:25:25 -07:00
110cce4ad4
core_ctl: Bail out early from the boost API when core_ctl is disabled
core_ctl can be completely disabled from a kernel parameter now.
Add a check to bail out early from the boost API.

Change-Id: Ib825500b0cb2c06af2cfcb82e5d79f91e9dd7b3b
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Pavankumar Kondeti   commited 2017-03-27 09:59:11 +05:30
d198dde643
core_ctl: Add a kernel parameter to disable core_ctl
Add a kernel parameter called "core_ctl_disable_cpumask" to
specify the CPUs for which core_ctl is not needed. As
core_ctl operates on a cluster basis, all of the CPUs in a
given cluster must be specified to disable core_ctl on that
cluster.

Change-Id: Idfdc5b3aa9f54bafe20489e5ded9d96da6eff21c
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Pavankumar Kondeti   commited 2017-03-27 09:59:04 +05:30
1e951a7ff0
sched/core_ctl: Fix state_lock spinlock contention
There is no need to call core_ctl_check() from scheduler tick path
on all CPUs. This results in core_ctl's state_lock spin lock
contention. Assign this job to the CPU which is responsible
for updating the ticks.

Change-Id: I9664037cc25c204d532bdd0f006c7e27ef143497
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Pavankumar Kondeti   commited 2017-03-27 09:54:18 +05:30
e9afb1aa77
Merge "sched: Call sched_exit() when a task is exiting" into msm-4.9
Kyle Yan   authored and   Gerrit - the friendly Code Review server   commited 2017-03-25 04:00:34 -07:00
9767aee57b
Merge "trace: cpu_freq_switch: Add profiler for CPU frequency switch times" into msm-4.9
Kyle Yan   authored and   Gerrit - the friendly Code Review server   commited 2017-03-25 04:00:22 -07:00
239ad2dcc2
sched: Call sched_exit() when a task is exiting
The scheduler needs to do some book-keeping when a task exits.
Call the scheduler hook sched_exit() that takes care of all of
that necessary book-keeping.

Change-Id: I551aead70248b06f9d918e6d032075d6ecaa7fed
Signed-off-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org>

Syed Rameez Mustafa   commited 2017-03-24 15:57:31 -07:00
d5b9f97f3c
sched: don't assume higher capacity means higher power in tick migration
When an upmigrate ineligible task running on the maximum capacity CPU,
we check if it can be migrated to a lower capacity CPU in tick path.
Add a power cost based check there to prevent the task migration
from a power efficient CPU.

Change-Id: I291c62d7dbf169d5123faba5f5246ad44a7a40dd
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Pavankumar Kondeti   authored and   Gerrit - the friendly Code Review server   commited 2017-03-24 10:55:25 -07:00
4fed24d120
sched: optimize cpumask operations during task placement
Compute the CPU search mask once by taking task affinity,
cpu_active_mask and cpu_isolated_mask into account and cache
it in cpu_selection_env. This prevents doing the same cpumask
operations multiple times.

Change-Id: I78f35c59e6ee9437b3a522ac7ad856c0251f81ec
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Pavankumar Kondeti   authored and   Gerrit - the friendly Code Review server   commited 2017-03-24 10:55:16 -07:00
52296641a3
sched: don't select an inactive/isolated CPU in sbc()
In select_best_cpu(), if no CPU is selected from the candidate
cluster, the search is expanded to the backup cluster. The
current code may select an inactive/isolated CPU in the
backup cluster. Fix this.

Change-Id: Id1e8a2b2f84ea274cdeda408957490ca05ef5fdb
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Pavankumar Kondeti   authored and   Gerrit - the friendly Code Review server   commited 2017-03-24 10:55:10 -07:00
068743c10e
sched: Fix load tracking bug to avoid adding phantom task demand
When update_task_ravg() is called with the TASK_UPDATE event on a task
that is not on the runqueue, task demand accounting incorrectly treats
the time delta as execution time. This can happen when a sleeping
task is moved to/from colocation groups. This phantom execution time can
cause unpredictable changes to demand that in turn can result in
incorrect task placement. Fix the issue by adding special handling of
TASK_UPDATE in task demand accounting. CPU busy time accounting already
has all the necessary checks.

Change-Id: Ibb42d83ac353bf2e849055fa3cb5c22e7acd56de
Signed-off-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org>

Syed Rameez Mustafa   authored and   Gerrit - the friendly Code Review server   commited 2017-03-24 10:54:02 -07:00
b1bfa78b62
Merge "sched: fix bug in auto adjustment of group upmigrate/downmigrate" into msm-4.9
Kyle Yan   authored and   Gerrit - the friendly Code Review server   commited 2017-03-24 10:42:45 -07:00
82175be6ea
Merge "sched: remove sched_new_task_windows tunable" into msm-4.9
Kyle Yan   authored and   Gerrit - the friendly Code Review server   commited 2017-03-23 10:20:05 -07:00
aff73b63fc
Merge "core_ctl: remove "cpus" sysfs file that prints CPU online status" into msm-4.9
Kyle Yan   authored and   Gerrit - the friendly Code Review server   commited 2017-03-23 10:20:04 -07:00
2444a62475
Merge "core_ctl: use pr_fmt" into msm-4.9
Kyle Yan   authored and   Gerrit - the friendly Code Review server   commited 2017-03-23 10:20:03 -07:00
3b0d26c513
Merge "core_ctl: kill maintenance of online state" into msm-4.9
Kyle Yan   authored and   Gerrit - the friendly Code Review server   commited 2017-03-23 10:20:03 -07:00
66e7c96a10
Merge "core_ctl: fix bug in assignment of not_preferred tunable values" into msm-4.9
Kyle Yan   authored and   Gerrit - the friendly Code Review server   commited 2017-03-23 10:20:02 -07:00
5d467eb3cd
Merge "core_ctl: redo offline_delay_ms tunable implementation" into msm-4.9
Kyle Yan   authored and   Gerrit - the friendly Code Review server   commited 2017-03-23 10:20:01 -07:00
4076c838fd
drivers: Fix more compiler warnings
Fix uninitialized variable warnings that were not previously caught by
old compiler.

Change-Id: I5014a235da41d32a3a1ae234286270ec9af875fc
Signed-off-by: Kyle Yan <kyan@codeaurora.org>

Kyle Yan   commited 2017-03-22 19:20:23 -07:00
74fdd73187
locking/rwsem: Fix down_write_killable() for CONFIG_RWSEM_GENERIC_SPINLOCK=y
am: c406096522

Change-Id: I2ac74fa5f03a3dff0b45e91d8be4e80c9c70da98

Niklas Cassel   authored and   android-build-merger   commited 2017-03-22 12:09:25 +00:00
7298964b46
futex: Add missing error handling to FUTEX_REQUEUE_PI
am: 1522181f4b

Change-Id: I74d73e5550ccb3a8d846f636b4f7940b124d261c

Peter Zijlstra   authored and   android-build-merger   commited 2017-03-22 12:09:16 +00:00
7135bd3da3
futex: Fix potential use-after-free in FUTEX_REQUEUE_PI
am: 6244ffc5a1

Change-Id: I973ed47c736e8deeebcea67e885abfb557fc1469

Peter Zijlstra   authored and   android-build-merger   commited 2017-03-22 12:09:06 +00:00
11a359f58e
bpf: fix mark_reg_unknown_value for spilled regs on map value marking
am: 0e0f1d6fdb

Change-Id: I3990cdd8bc095423723df1771ec87158dc8cb63a

Daniel Borkmann   authored and   android-build-merger   commited 2017-03-22 12:01:48 +00:00
82af7abe04
bpf: fix regression on verifier pruning wrt map lookups
am: 1889d6d9b5

Change-Id: I528df00bc5cd00aec10f56ad53907f6ca8044973

Daniel Borkmann   authored and   android-build-merger   commited 2017-03-22 12:01:38 +00:00
01db8bf2c4
bpf: fix state equivalence
am: b7f5aa1ca0

Change-Id: I1d61f752ac33e41ebb748eba7d3f48003ee29c19

Alexei Starovoitov   authored and   android-build-merger   commited 2017-03-22 12:01:29 +00:00
67684a346c
bpf: Detect identical PTR_TO_MAP_VALUE_OR_NULL registers
am: 1411707acb

Change-Id: I02e316379d5a19258ea601e75b9f4cece6450acd

Thomas Graf   authored and   android-build-merger   commited 2017-03-22 12:01:20 +00:00
199e71c26a
locking/rwsem: Fix down_write_killable() for CONFIG_RWSEM_GENERIC_SPINLOCK=y
commit 17fcbd590d0c3e35bd9646e2215f86586378bc42 upstream.

We hang if SIGKILL has been sent, but the task is stuck in down_read()
(after do_exit()), even though no task is doing down_write() on the
rwsem in question:

  INFO: task libupnp:21868 blocked for more than 120 seconds.
  libupnp         D    0 21868      1 0x08100008
  ...
  Call Trace:
  __schedule()
  schedule()
  __down_read()
  do_exit()
  do_group_exit()
  __wake_up_parent()

This bug has already been fixed for CONFIG_RWSEM_XCHGADD_ALGORITHM=y in
the following commit:

 04cafed7fc ("locking/rwsem: Fix down_write_killable()")

... however, this bug also exists for CONFIG_RWSEM_GENERIC_SPINLOCK=y.

Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: <mhocko@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Niklas Cassel <niklass@axis.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: d47996082f ("locking/rwsem: Introduce basis for down_write_killable()")
Link: http://lkml.kernel.org/r/1487981873-12649-1-git-send-email-niklass@axis.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Niklas Cassel   authored and   Greg Kroah-Hartman   commited 2017-03-22 12:43:40 +01:00
c406096522
futex: Add missing error handling to FUTEX_REQUEUE_PI
commit 9bbb25afeb182502ca4f2c4f3f88af0681b34cae upstream.

Thomas spotted that fixup_pi_state_owner() can return errors and we
fail to unlock the rt_mutex in that case.

Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Cc: juri.lelli@arm.com
Cc: bigeasy@linutronix.de
Cc: xlpang@redhat.com
Cc: rostedt@goodmis.org
Cc: mathieu.desnoyers@efficios.com
Cc: jdesfossez@efficios.com
Cc: dvhart@infradead.org
Cc: bristot@redhat.com
Link: http://lkml.kernel.org/r/20170304093558.867401760@infradead.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Peter Zijlstra   authored and   Greg Kroah-Hartman   commited 2017-03-22 12:43:40 +01:00
1522181f4b
futex: Fix potential use-after-free in FUTEX_REQUEUE_PI
commit c236c8e95a3d395b0494e7108f0d41cf36ec107c upstream.

While working on the futex code, I stumbled over this potential
use-after-free scenario. Dmitry triggered it later with syzkaller.

pi_mutex is a pointer into pi_state, which we drop the reference on in
unqueue_me_pi(). So any access to that pointer after that is bad.

Since other sites already do rt_mutex_unlock() with hb->lock held, see
for example futex_lock_pi(), simply move the unlock before
unqueue_me_pi().

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Cc: juri.lelli@arm.com
Cc: bigeasy@linutronix.de
Cc: xlpang@redhat.com
Cc: rostedt@goodmis.org
Cc: mathieu.desnoyers@efficios.com
Cc: jdesfossez@efficios.com
Cc: dvhart@infradead.org
Cc: bristot@redhat.com
Link: http://lkml.kernel.org/r/20170304093558.801744246@infradead.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Peter Zijlstra   authored and   Greg Kroah-Hartman   commited 2017-03-22 12:43:40 +01:00
6244ffc5a1
bpf: fix mark_reg_unknown_value for spilled regs on map value marking
[ Upstream commit 6760bf2ddde8ad64f8205a651223a93de3a35494 ]

Martin reported a verifier issue that hit the BUG_ON() for his
test case in the mark_reg_unknown_value() function:

  [  202.861380] kernel BUG at kernel/bpf/verifier.c:467!
  [...]
  [  203.291109] Call Trace:
  [  203.296501]  [<ffffffff811364d5>] mark_map_reg+0x45/0x50
  [  203.308225]  [<ffffffff81136558>] mark_map_regs+0x78/0x90
  [  203.320140]  [<ffffffff8113938d>] do_check+0x226d/0x2c90
  [  203.331865]  [<ffffffff8113a6ab>] bpf_check+0x48b/0x780
  [  203.343403]  [<ffffffff81134c8e>] bpf_prog_load+0x27e/0x440
  [  203.355705]  [<ffffffff8118a38f>] ? handle_mm_fault+0x11af/0x1230
  [  203.369158]  [<ffffffff812d8188>] ? security_capable+0x48/0x60
  [  203.382035]  [<ffffffff811351a4>] SyS_bpf+0x124/0x960
  [  203.393185]  [<ffffffff810515f6>] ? __do_page_fault+0x276/0x490
  [  203.406258]  [<ffffffff816db320>] entry_SYSCALL_64_fastpath+0x13/0x94

This issue got uncovered after the fix in a08dd0da5307 ("bpf: fix
regression on verifier pruning wrt map lookups"). The reason why it
wasn't noticed before was, because as mentioned in a08dd0da5307,
mark_map_regs() was doing the id matching incorrectly based on the
uncached regs[regno].id. So, in the first loop, we walked all regs
and as soon as we found regno == i, then this reg's id was cleared
when calling mark_reg_unknown_value() thus that every subsequent
register was probed against id of 0 (which, in combination with the
PTR_TO_MAP_VALUE_OR_NULL type is an invalid condition that no other
register state can hold), and therefore wasn't type transitioned such
as in the spilled register case for the second loop.

Now since that got fixed, it turned out that 57a09bf0a416 ("bpf:
Detect identical PTR_TO_MAP_VALUE_OR_NULL registers") used
mark_reg_unknown_value() incorrectly for the spilled regs, and thus
hitting the BUG_ON() in some cases due to regno >= MAX_BPF_REG.

Although spilled regs have the same type as the non-spilled regs
for the verifier state, that is, struct bpf_reg_state, they are
semantically different from the non-spilled regs. In other words,
there can be up to 64 (MAX_BPF_STACK / BPF_REG_SIZE) spilled regs
in the stack, for example, register R<x> could have been spilled by
the program to stack location X, Y, Z, and in mark_map_regs() we
need to scan these stack slots of type STACK_SPILL for potential
registers that we have to transition from PTR_TO_MAP_VALUE_OR_NULL.
Therefore, depending on the location, the spilled_regs regno can
be a lot higher than just MAX_BPF_REG's value since we operate on
stack instead. The reset in mark_reg_unknown_value() itself is
just fine, only that the BUG_ON() was inappropriate for this. Fix
it by making a __mark_reg_unknown_value() version that can be
called from mark_map_reg() generically; we know for the non-spilled
case that the regno is always < MAX_BPF_REG anyway.

Fixes: 57a09bf0a416 ("bpf: Detect identical PTR_TO_MAP_VALUE_OR_NULL registers")
Reported-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Daniel Borkmann   authored and   Greg Kroah-Hartman   commited 2017-03-22 12:43:35 +01:00
0e0f1d6fdb
bpf: fix regression on verifier pruning wrt map lookups
[ Upstream commit a08dd0da5307ba01295c8383923e51e7997c3576 ]

Commit 57a09bf0a416 ("bpf: Detect identical PTR_TO_MAP_VALUE_OR_NULL
registers") introduced a regression where existing programs stopped
loading due to reaching the verifier's maximum complexity limit,
whereas prior to this commit they were loading just fine; the affected
program has roughly 2k instructions.

What was found is that state pruning couldn't be performed effectively
anymore due to mismatches of the verifier's register state, in particular
in the id tracking. It doesn't mean that 57a09bf0a416 is incorrect per
se, but rather that verifier needs to perform a lot more work for the
same program with regards to involved map lookups.

Since commit 57a09bf0a416 is only about tracking registers with type
PTR_TO_MAP_VALUE_OR_NULL, the id is only needed to follow registers
until they are promoted through pattern matching with a NULL check to
either PTR_TO_MAP_VALUE or UNKNOWN_VALUE type. After that point, the
id becomes irrelevant for the transitioned types.

For UNKNOWN_VALUE, id is already reset to 0 via mark_reg_unknown_value(),
but not so for PTR_TO_MAP_VALUE where id is becoming stale. It's even
transferred further into other types that don't make use of it. Among
others, one example is where UNKNOWN_VALUE is set on function call
return with RET_INTEGER return type.

states_equal() will then fall through the memcmp() on register state;
note that the second memcmp() uses offsetofend(), so the id is part of
that since d2a4dd37f6b4 ("bpf: fix state equivalence"). But the bisect
pointed already to 57a09bf0a416, where we really reach beyond complexity
limit. What I found was that states_equal() often failed in this
case due to id mismatches in spilled regs with registers in type
PTR_TO_MAP_VALUE. Unlike non-spilled regs, spilled regs just perform
a memcmp() on their reg state and don't have any other optimizations
in place, therefore also id was relevant in this case for making a
pruning decision.

We can safely reset id to 0 as well when converting to PTR_TO_MAP_VALUE.
For the affected program, it resulted in a ~17 fold reduction of
complexity and let the program load fine again. Selftest suite also
runs fine. The only other place where env->id_gen is used currently is
through direct packet access, but for these cases id is long living, thus
a different scenario.

Also, the current logic in mark_map_regs() is not fully correct when
marking NULL branch with UNKNOWN_VALUE. We need to cache the destination
reg's id in any case. Otherwise, once we marked that reg as UNKNOWN_VALUE,
it's id is reset and any subsequent registers that hold the original id
and are of type PTR_TO_MAP_VALUE_OR_NULL won't be marked UNKNOWN_VALUE
anymore, since mark_map_reg() reuses the uncached regs[regno].id that
was just overridden. Note, we don't need to cache it outside of
mark_map_regs(), since it's called once on this_branch and the other
time on other_branch, which are both two independent verifier states.
A test case for this is added here, too.

Fixes: 57a09bf0a416 ("bpf: Detect identical PTR_TO_MAP_VALUE_OR_NULL registers")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Daniel Borkmann   authored and   Greg Kroah-Hartman   commited 2017-03-22 12:43:35 +01:00
1889d6d9b5
bpf: fix state equivalence
[ Upstream commit d2a4dd37f6b41fbcad76efbf63124eb3126c66fe ]

Commmits 57a09bf0a416 ("bpf: Detect identical PTR_TO_MAP_VALUE_OR_NULL registers")
and 484611357c ("bpf: allow access into map value arrays") by themselves
are correct, but in combination they make state equivalence ignore 'id' field
of the register state which can lead to accepting invalid program.

Fixes: 57a09bf0a416 ("bpf: Detect identical PTR_TO_MAP_VALUE_OR_NULL registers")
Fixes: 484611357c ("bpf: allow access into map value arrays")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Alexei Starovoitov   authored and   Greg Kroah-Hartman   commited 2017-03-22 12:43:35 +01:00
b7f5aa1ca0
bpf: Detect identical PTR_TO_MAP_VALUE_OR_NULL registers
[ Upstream commit 57a09bf0a416700676e77102c28f9cfcb48267e0 ]

A BPF program is required to check the return register of a
map_elem_lookup() call before accessing memory. The verifier keeps
track of this by converting the type of the result register from
PTR_TO_MAP_VALUE_OR_NULL to PTR_TO_MAP_VALUE after a conditional
jump ensures safety. This check is currently exclusively performed
for the result register 0.

In the event the compiler reorders instructions, BPF_MOV64_REG
instructions may be moved before the conditional jump which causes
them to keep their type PTR_TO_MAP_VALUE_OR_NULL to which the
verifier objects when the register is accessed:

0: (b7) r1 = 10
1: (7b) *(u64 *)(r10 -8) = r1
2: (bf) r2 = r10
3: (07) r2 += -8
4: (18) r1 = 0x59c00000
6: (85) call 1
7: (bf) r4 = r0
8: (15) if r0 == 0x0 goto pc+1
 R0=map_value(ks=8,vs=8) R4=map_value_or_null(ks=8,vs=8) R10=fp
9: (7a) *(u64 *)(r4 +0) = 0
R4 invalid mem access 'map_value_or_null'

This commit extends the verifier to keep track of all identical
PTR_TO_MAP_VALUE_OR_NULL registers after a map_elem_lookup() by
assigning them an ID and then marking them all when the conditional
jump is observed.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Thomas Graf   authored and   Greg Kroah-Hartman   commited 2017-03-22 12:43:35 +01:00
1411707acb
sched: fix bug in auto adjustment of group upmigrate/downmigrate
sched_group_upmigrate tunable can accept values greater than
100%. Don't limit it to 100% while doing the auto adjustment.

Change-Id: I3d1c1e84f2f4dec688235feb1536b9261a3e808b
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Pavankumar Kondeti   commited 2017-03-22 11:48:32 +05:30
80f5fbf66b
sched: remove sched_new_task_windows tunable
The sched_new_task_windows tunable is set to 5 in the scheduler
and it is not changed from user space. Remove this unused tunable.

Change-Id: I771e12b44876efe75ce87a90e4e9d69c22168b64
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Pavankumar Kondeti   commited 2017-03-22 11:48:25 +05:30
41b41665fa
core_ctl: remove "cpus" sysfs file that prints CPU online status
core_ctl module no longer hotplug the CPUs. Hence remove the
/sys/devices/system/cpu/cpuX/core_ctl/cpus file interface which
pints the online/offline state of all CPUs in the cluster.

The global_state file interface can still be used to know all
the state information about all CPUs. Replace "Active" with
"Isolated" string in this file output. Otherwise we see that
an offline CPU as active.

Change-Id: Id6ffb1c3ddfe85cf34ab670ceea8b53e5b2f60e2
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Pavankumar Kondeti   commited 2017-03-22 11:44:31 +05:30
fbfa7b3562
core_ctl: use pr_fmt
We use pr_* to print info/warn/error messages. Use pr_fmt so
that the messages are prefixed by "core_ctl:" string.

Change-Id: Icc84db30ebf0855599431366d090a2b1c94da6d0
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Pavankumar Kondeti   commited 2017-03-22 11:44:27 +05:30
088f334c4f
core_ctl: kill maintenance of online state
The online state is cached in CPU hotplug callbacks. This is
used in determining the potential candidates for isolation or
unisolation. The current code has checks in hotplug notifier
callback to correct the online state if it is out of sync
with the actualy CPU state. All this maintenance can be
avoided by directly using cpu_online().

This patch fixes an incorrect warning message emitted from
CPU_UP_CANCELED event callback.

Change-Id: I9681ce6c5bc701507427d60db397ca4966fbdb58
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Pavankumar Kondeti   commited 2017-03-22 11:44:23 +05:30
85dfbfa7bf
core_ctl: fix bug in assignment of not_preferred tunable values
Cluster's lru list is iterated while storing the not_preferred
tunable values. The position of a CPU in this list gets changed
when it is isolated. This results in an incorrect assignment of
user input. Fix this by iterating the CPUs serially in a cluster.

Change-Id: I7235ca981b0fd82488034ab8d1880bb7498c9a72
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Pavankumar Kondeti   commited 2017-03-22 11:44:18 +05:30
63877bc1e4
core_ctl: redo offline_delay_ms tunable implementation
The offline_delay_ms tunable is supposed to give hysteresis
effect by delaying the CPU isolation. The current implementation
is not enforcing this correctly due to which we see a CPU is
getting isolated immediately in the next evaluation cycle.

Allow isolating a CPU only if offline_delay_ms is passed
after since the last time we isolated/unisolated/evaluated
without changing the need CPUs.

Change-Id: I9681a11dea1ffa07b2fda6cc9a40af9b453bf553
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>

Pavankumar Kondeti   commited 2017-03-22 11:44:13 +05:30
83236e3e89
Merge remote-tracking branch '4.9/tmp-23b839a' into msm-4.9
* 4.9/tmp-23b839a:
  Linux 4.9.16
  IB/mlx5: Verify that Q counters are supported
  rc: raw decoder for keymap protocol is not loaded on register
  dm: flush queued bios when process blocks to avoid deadlock
  KVM: arm/arm64: Let vcpu thread modify its own active state
  KVM: s390: Fix guest migration for huge guests resulting in panic
  ext4: don't BUG when truncating encrypted inodes on the orphan list
  serial: samsung: Continue to work if DMA request fails
  USB: serial: io_ti: fix information leak in completion handler
  USB: serial: io_ti: fix NULL-deref in interrupt callback
  USB: iowarrior: fix NULL-deref in write
  USB: iowarrior: fix NULL-deref at probe
  USB: serial: omninet: fix reference leaks at open
  USB: serial: safe_serial: fix information leak in completion handler
  usb: host: xhci-plat: Fix timeout on removal of hot pluggable xhci controllers
  usb: host: xhci-dbg: HCIVERSION should be a binary number
  Revert "usb: gadget: uvc: Add missing call for additional setup data"
  usb: gadget: function: f_fs: pass companion descriptor along
  usb: ohci-at91: Do not drop unhandled USB suspend control requests
  usb: dwc3-omap: Fix missing break in dwc3_omap_set_mailbox()
  usb: dwc3: gadget: make Set Endpoint Configuration macros safe
  usb: gadget: dummy_hcd: clear usb_gadget region before registration
  PCI: Prevent VPD access for QLogic ISP2722
  powerpc/xics: Work around limitations of OPAL XICS priority handling
  powerpc: Emulation support for load/store instructions on LE
  i2c: add missing of_node_put in i2c_mux_del_adapters
  dw2102: don't do DMA on stack
  efi/arm: Fix boot crash with CONFIG_CPUMASK_OFFSTACK=y
  ucount: Remove the atomicity from ucount->count
  tracing: Add #undef to fix compile error
  cpmac: remove hopeless #warning
  bcm63xx_enet: avoid uninitialized variable warning
  MIPS: ralink: Remove unused rt*_wdt_reset functions
  MIPS: ralink: Remove unused timer functions
  MIPS: ralink: Cosmetic change to prom_init().
  mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy
  MIPS: Update lemote2f_defconfig for CPU_FREQ_STAT change
  MIPS: ip22: Fix ip28 build for modern gcc
  MIPS: Update ip27_defconfig for SCSI_DH change
  MIPS: ip27: Disable qlge driver in defconfig
  MIPS: VDSO: avoid duplicate CAC_BASE definition
  MIPS: Update defconfigs for NF_CT_PROTO_DCCP/UDPLITE change
  crypto: improve gcc optimization flags for serpent and wp512
  USB: serial: digi_acceleport: fix OOB-event processing
  USB: serial: digi_acceleport: fix OOB data sanity check
  ANDROID: sched: fix duplicate sched_group_energy const specifiers
  ANDROID: power: align wakeup_sources format
  ANDROID: dm: android-verity: allow disable dm-verity for Treble VTS

Conflicts:
	drivers/usb/gadget/function/f_fs.c
	drivers/usb/host/xhci-plat.c

Change-Id: Ie97f041c7512b888ecdedcf79981aed53a4da7dc
Signed-off-by: Kyle Yan <kyan@codeaurora.org>

Kyle Yan   commited 2017-03-20 13:54:01 -07:00
deb64a7f1e
trace: cpu_freq_switch: Add profiler for CPU frequency switch times
It is sometimes useful to profile how long CPU frequency switches
take, and traces have already been added for this purpose. Make
use of these and the trace_stat framework to generate statistical
histograms of frequency switch times in the following format:

 # cat /sys/kernel/debug/tracing/trace_stat/cpu_freq_switch
  CPU START_KHZ  END_KHZ COUNT AVG_US MIN_US MAX_US
    |         |        |     |      |      |      |
    0    384000  1512000     3   2787   1648   3418
    0    486000   384000     1   1129   1129   1129
    0   1458000   384000     1   3174   3174   3174
    0   1512000   384000     1   3265   3265   3265
    0   1512000   486000     1   3235   3235   3235
    0   1512000  1458000     1    213    213    213
    0   1512000  1512000     1      0      0      0

Profiling is disabled by default (since it does incur some
overhead). It can be enabled or re-disabled echoing 1 or 0
to /sys/kernel/debug/tracing/cpu_freq_switch_profile_enabled

Change-Id: I3ef7f9d681b7bd13bcaa031003b10312afe1aefe
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

Matt Wagantall   authored and   Stephen Boyd   commited 2017-03-20 12:16:04 -07:00
c481c78661
ucount: Remove the atomicity from ucount->count
am: ee6f7ee1e4

Change-Id: I222bf26458f918b2481e0c14ce2b0bf5fd3c85d8

Eric W. Biederman   authored and   android-build-merger   commited 2017-03-18 11:33:08 +00:00
4ee06d54ee
ucount: Remove the atomicity from ucount->count
commit 040757f738e13caaa9c5078bca79aa97e11dde88 upstream.

Always increment/decrement ucount->count under the ucounts_lock.  The
increments are there already and moving the decrements there means the
locking logic of the code is simpler.  This simplification in the
locking logic fixes a race between put_ucounts and get_ucounts that
could result in a use-after-free because the count could go zero then
be found by get_ucounts and then be freed by put_ucounts.

A bug presumably this one was found by a combination of syzkaller and
KASAN.  JongWhan Kim reported the syzkaller failure and Dmitry Vyukov
spotted the race in the code.

Fixes: f6b2db1a3e ("userns: Make the count of user namespaces per user")
Reported-by: JongHwan Kim <zzoru007@gmail.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Andrei Vagin <avagin@gmail.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Eric W. Biederman   authored and   Greg Kroah-Hartman   commited 2017-03-18 19:14:29 +08:00
ee6f7ee1e4
ANDROID: sched: fix duplicate sched_group_energy const specifiers
EAS uses "const struct sched_group_energy * const" fairly consistently.
But a couple of places swap the "*" and second "const", making the
pointer mutable.

In the case of struct sched_group, "* const" would have been an error,
since init_sched_energy() writes to sd->groups->sge.

Change-Id: Ic6a8fcf99e65c0f25d9cc55c32625ef3ca5c9aca
Signed-off-by: Greg Hackmann <ghackmann@google.com>

Greg Hackmann   commited 2017-03-17 09:48:24 -07:00
2a3c6e6396
Merge "Merge remote-tracking branch '4.9/tmp-47c0adf' into 4.9" into msm-4.9
Kyle Yan   authored and   Gerrit - the friendly Code Review server   commited 2017-03-16 17:27:31 -07:00
0795fffe5c
Merge remote-tracking branch '4.9/tmp-47c0adf' into 4.9
* 4.9/tmp-47c0adf:
  Linux 4.9.15
  drivers: hv: Turn off write permission on the hypercall page
  fat: fix using uninitialized fields of fat_inode/fsinfo_inode
  mm: do not call mem_cgroup_free() from within mem_cgroup_alloc()
  thp: fix another corner case of munlock() vs. THPs
  x86/tlb: Fix tlb flushing when lguest clears PGE
  x86, mm: fix gup_pte_range() vs DAX mappings
  libceph: use BUG() instead of BUG_ON(1)
  drm/i915: Fix not finding the VBT when it overlaps with OPREGION_ASLE_EXT
  drm/i915: Avoid spurious WARNs about the wrong pipe in the PPS code
  drm: Cancel drm_fb_helper_resume_work on unload
  drm: Cancel drm_fb_helper_dirty_work on unload
  drm/i915/gvt: Disable access to stolen memory as a guest
  drm/atomic: fix an error code in mode_fixup()
  drm/imx: imx-tve: Do not set the regulator voltage
  dmaengine: imx-sdma - correct the dma transfer residue calculation
  drm/vmwgfx: Work around drm removal of control nodes
  drm/ttm: Make sure BOs being swapped out are cacheable
  drm/edid: Add EDID_QUIRK_FORCE_8BPC quirk for Rotel RSX-1058
  drm/ast: Fix AST2400 POST failure without BMC FW or VBIOS
  drm/ast: Call open_key before enable_mmio in POST code
  drm/ast: Fix test for VGA enabled
  drm/amdgpu: add more cases to DCE11 possible crtc mask setup
  mac80211: use driver-indicated transmitter STA only for data frames
  mac80211: don't handle filtered frames within a BA session
  mac80211: don't reorder frames with SN smaller than SSN
  mac80211: flush delayed work when entering suspend
  nfit, libnvdimm: fix interleave set cookie calculation
  xtensa: move parse_tag_fdt out of #ifdef CONFIG_BLK_DEV_INITRD
  pwm: pca9685: Fix period change with same duty cycle
  nlm: Ensure callback code also checks that the files match
  drivers/pci/hotplug: Fix initial state for empty slot
  drivers/pci/hotplug: Handle presence detection change properly
  target: Fix NULL dereference during LUN lookup + active I/O shutdown
  pci/hotplug/pnv-php: Disable surprise hotplug capability on conflicts
  pci/hotplug/pnv-php: Remove WARN_ON() in pnv_php_put_slot()
  ceph: remove req from unsafe list when unregistering it
  ktest: Fix child exit code processing
  memory/atmel-ebi: Fix ns <-> cycles conversions
  orangefs: Use RCU for destroy_inode
  fs: Better permission checking for submounts
  IB/srp: Fix race conditions related to task management
  IB/srp: Avoid that duplicate responses trigger a kernel bug
  IB/SRP: Avoid using IB_MR_TYPE_SG_GAPS
  IB/mlx5: Fix out-of-bound access
  IB/IPoIB: Add destination address when re-queue packet
  IB/ipoib: Fix deadlock between rmmod and set_mode
  mnt: Tuck mounts under others instead of creating shadow/side mounts.
  brcmfmac: fix incorrect event channel deduction
  cxl: fix nested locking hang during EEH hotplug
  cxl: Prevent read/write to AFU config space while AFU not configured
  net: mvpp2: fix DMA address calculation in mvpp2_txq_inc_put()
  s390: use correct input data address for setup_randomness
  s390: make setup_randomness work
  s390: TASK_SIZE for kernel threads
  s390/chsc: Add exception handler for CHSC instruction
  s390/kdump: Use "LINUX" ELF note name instead of "CORE"
  s390/dcssblk: fix device size calculation in dcssblk_direct_access()
  s390/qdio: clear DSCI prior to scanning multiple input queues
  Bluetooth: Add another AR3012 04ca:3018 device
  KVM: VMX: use correct vmcs_read/write for guest segment selector/base
  KVM: s390: Disable dirty log retrieval for UCONTROL guests
  serial: 8250_pci: Add MKS Tenta SCOM-0800 and SCOM-0801 cards
  tty: n_hdlc: get rid of racy n_hdlc.tbuf
  uid_sys_stats: change to use rt_mutex
  ANDROID: uid_sys_stats: account for fsync syscalls
  ANDROID: sched: add a counter to track fsync
  ANDROID: uid_sys_stats: fix negative write bytes.
  ANDROID: uid_sys_stats: allow writing same state
  ANDROID: uid_sys_stats: rename uid_cputime.c to uid_sys_stats.c
  ANDROID: uid_cputime: add per-uid IO usage accounting
  ANDROID: sched/walt: Fix missing locking in WALT port
  UPSTREAM: arm64: Allow hw watchpoint of length 3,5,6 and 7
  UPSTREAM: arm64: hw_breakpoint: Handle inexact watchpoint addresses
  UPSTREAM: arm64: Allow hw watchpoint at varied offset from base address
  UPSTREAM: hw_breakpoint: Allow watchpoint of length 3,5,6 and 7
  ANDROID: usb: gadget: f_accessory: Fix for UsbAccessory clean unbind.
  ANDROID: nf: IDLETIMER: Use fullsock when querying uid
  ANDROID: Replace spaces by '_' for some android filesystem tracepoints.

Conflicts:
	kernel/sched/core.c
	kernel/sched/fair.c

Change-Id: I31ee14ac15765dbb5fe53800d2c39224131287b0
Signed-off-by: Kyle Yan <kyan@codeaurora.org>

Kyle Yan   commited 2017-03-15 13:38:21 -07:00
90ed47f1fa
kernel: rcu: Panic on RCU stall
Enable panic on RCU stalls if the RCU_PANIC_ON_STALL is enabled. This
helps collecting the cpu context for debugging.

Change-Id: Ibc95799df995bf31053152ab9b3894710fcd9f43
Signed-off-by: Channagoud Kadabi <ckadabi@codeaurora.org>

Channagoud Kadabi   commited 2017-03-15 11:49:57 -07:00
2eada80751