Commit graph

306972 commits

Author SHA1 Message Date
D.S. Ljungmark
ba0d2ae061 ipv6: Don't reduce hop limit for an interface
A local route may have a lower hop_limit set than global routes do.

RFC 3756, Section 4.2.7, "Parameter Spoofing"

>   1.  The attacker includes a Current Hop Limit of one or another small
>       number which the attacker knows will cause legitimate packets to
>       be dropped before they reach their destination.

>   As an example, one possible approach to mitigate this threat is to
>   ignore very small hop limits.  The nodes could implement a
>   configurable minimum hop limit, and ignore attempts to set it below
>   said limit.

Change-Id: I51ee1778e3d2d5fa1aefbdf1ad8869e4e8dc28b2
Signed-off-by: D.S. Ljungmark <ljungmark@modio.se>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-29 23:12:10 +08:00
Andrey Vagin
be41f71342 netfilter: nf_conntrack: reserve two bytes for nf_ct_ext->len
"len" contains sizeof(nf_ct_ext) and size of extensions. In a worst
case it can contain all extensions. Bellow you can find sizes for all
types of extensions. Their sum is definitely bigger than 256.

nf_ct_ext_types[0]->len = 24
nf_ct_ext_types[1]->len = 32
nf_ct_ext_types[2]->len = 24
nf_ct_ext_types[3]->len = 32
nf_ct_ext_types[4]->len = 152
nf_ct_ext_types[5]->len = 2
nf_ct_ext_types[6]->len = 16
nf_ct_ext_types[7]->len = 8

I have seen "len" up to 280 and my host has crashes w/o this patch.

The right way to fix this problem is reducing the size of the ecache
extension (4) and Florian is going to do this, but these changes will
be quite large to be appropriate for a stable tree.

Change-Id: If9efaf2b103cf304bbfa583e354cfad3faa77ac2
Fixes: 5b423f6a40 (netfilter: nf_conntrack: fix racy timer handling with reliable)
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2016-10-29 23:12:10 +08:00
Sasha Levin
1fea326d57 net: llc: use correct size for sysctl timeout entries
The timeout entries are sizeof(int) rather than sizeof(long), which
means that when they were getting read we'd also leak kernel memory
to userspace along with the timeout values.

Change-Id: I328d1186720a6f70f555eeeb62c83ee69814868d
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-29 23:12:10 +08:00
Jann Horn
871eac221e fs: take i_mutex during prepare_binprm for set[ug]id executables
This prevents a race between chown() and execve(), where chowning a
setuid-user binary to root would momentarily make the binary setuid
root.

This patch was mostly written by Linus Torvalds.

Signed-off-by: Jann Horn <jann@thejh.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Change-Id: Iecebf23d07e299689e4ba4fd74ea8821ef96e72b
2016-10-29 23:12:10 +08:00
Eric Dumazet
cc354dd458 udp: fix behavior of wrong checksums
We have two problems in UDP stack related to bogus checksums :

1) We return -EAGAIN to application even if receive queue is not empty.
   This breaks applications using edge trigger epoll()

2) Under UDP flood, we can loop forever without yielding to other
   processes, potentially hanging the host, especially on non SMP.

This patch is an attempt to make things better.

We might in the future add extra support for rt applications
wanting to better control time spent doing a recv() in a hostile
environment. For example we could validate checksums before queuing
packets in socket receive queue.

Change-Id: I9355321ac7ee564d56c342fa7738b918052bf308
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-29 23:12:10 +08:00
Michael Halcrow
83ee380d4b eCryptfs: Remove buggy and unnecessary write in file name decode routine
Dmitry Chernenkov used KASAN to discover that eCryptfs writes past the
end of the allocated buffer during encrypted filename decoding. This
fix corrects the issue by getting rid of the unnecessary 0 write when
the current bit offset is 2.

Change-Id: I2e139f816b9ce0ad6d207c6f454d6f25061383ee
Signed-off-by: Michael Halcrow <mhalcrow@google.com>
Reported-by: Dmitry Chernenkov <dmitryc@google.com>
Suggested-by: Kees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org # v2.6.29+: 51ca58d eCryptfs: Filename Encryption: Encoding and encryption functions
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2016-10-29 23:12:10 +08:00
Florian Westphal
91c6941897 netfilter: conntrack: disable generic tracking for known protocols
Given following iptables ruleset:

-P FORWARD DROP
-A FORWARD -m sctp --dport 9 -j ACCEPT
-A FORWARD -p tcp --dport 80 -j ACCEPT
-A FORWARD -p tcp -m conntrack -m state ESTABLISHED,RELATED -j ACCEPT

One would assume that this allows SCTP on port 9 and TCP on port 80.
Unfortunately, if the SCTP conntrack module is not loaded, this allows
*all* SCTP communication, to pass though, i.e. -p sctp -j ACCEPT,
which we think is a security issue.

This is because on the first SCTP packet on port 9, we create a dummy
"generic l4" conntrack entry without any port information (since
conntrack doesn't know how to extract this information).

All subsequent packets that are unknown will then be in established
state since they will fallback to proto_generic and will match the
'generic' entry.

Our originally proposed version [1] completely disabled generic protocol
tracking, but Jozsef suggests to not track protocols for which a more
suitable helper is available, hence we now mitigate the issue for in
tree known ct protocol helpers only, so that at least NAT and direction
information will still be preserved for others.

 [1] http://www.spinics.net/lists/netfilter-devel/msg33430.html

Joint work with Daniel Borkmann.

Change-Id: I7fff74303d98876efd3e7834555cbf95d0319359
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Acked-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2016-10-29 23:12:10 +08:00
Hannes Frederic Sowa
ef06d64826 ipv4: try to cache dst_entries which would cause a redirect
Not caching dst_entries which cause redirects could be exploited by hosts
on the same subnet, causing a severe DoS attack. This effect aggravated
since commit f886497212 ("ipv4: fix dst race in sk_dst_get()").

Lookups causing redirects will be allocated with DST_NOCACHE set which
will force dst_release to free them via RCU.  Unfortunately waiting for
RCU grace period just takes too long, we can end up with >1M dst_entries
waiting to be released and the system will run OOM. rcuos threads cannot
catch up under high softirq load.

Attaching the flag to emit a redirect later on to the specific skb allows
us to cache those dst_entries thus reducing the pressure on allocation
and deallocation.

This issue was discovered by Marcelo Leitner.

Cc: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Marcelo Leitner <mleitner@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: David S. Miller <davem@davemloft.net>

Change-Id: I53e4b500a4db2f5fece937a42a3bd810b2640c44
2016-10-29 23:12:10 +08:00
Sasha Levin
c030f48a9d KEYS: close race between key lookup and freeing
When a key is being garbage collected, it's key->user would get put before
the ->destroy() callback is called, where the key is removed from it's
respective tracking structures.

This leaves a key hanging in a semi-invalid state which leaves a window open
for a different task to try an access key->user. An example is
find_keyring_by_name() which would dereference key->user for a key that is
in the process of being garbage collected (where key->user was freed but
->destroy() wasn't called yet - so it's still present in the linked list).

This would cause either a panic, or corrupt memory.

Change-Id: Ic74246dc2dcc593f04f71063e3301e7356d588b7
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
2016-10-29 23:12:10 +08:00
FrozenCow
ea3043f8c4 usb: gadget: mass_storage: added sysfs entry for cdrom to LUNs
This patch adds a "cdrom" sysfs entry for each mass_storage LUN, just
like "ro" sysfs entry. This allows switching between USB and CD-ROM
emulation without reinserting the module or recompiling the kernel.

Change-Id: Idf83c74815b1ad370428ab9d3e5503d5f7bcd3b6
2016-10-29 23:12:10 +08:00
Zhao Wei Liew
c0f0ba5bad flo: Enable cpufreq limit driver
Used by PowerHAL for low power mode.

Change-Id: Id1766d78d67567832a18f47cdf8569f517247abf
Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
2016-10-29 23:12:10 +08:00
Zhao Wei Liew
feb154ed0e cpufreq: Add cpufreq limit driver
This allows userspace to specify a min/max limit to the CPU
frequency, working around the standard scaling_[max|min]_freq
sysfs interfaces.

Initially based on Paul's cpufreq_limit driver.

Change-Id: I87dd8a0f67aadce0ca0f5cb668d7ee16c616deb0
Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
2016-10-29 23:12:10 +08:00
Steve Kondik
cf659a312c video: msm: Don't send CABC commands with power off
* Current code is blindly sending commands to the hardware when
   it's powered down. This causes a DMA timeout and wedges the panel
   until rebooted. Add a check for the power state.

Change-Id: I33a508f22c2a1a046a50782912802784928d47f6
[zhaoweiliew: Check against the proper variable]
Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
2016-10-29 23:12:10 +08:00
Zhao Wei Liew
6bf0344b15 msm_fb: Fix ACO bounds check
This was causing auto contrast optimisation to not be set
when the file is written to.

Change-Id: I7e88a6afbf4692b5bc01d7337455f15aa5640d72
Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
2016-10-29 23:12:09 +08:00
Zhao Wei Liew
01e340d26c msm_fb: Print new line when getting ACO and SRE vals
Much neater when getting the value of the file.

Change-Id: Ie5cc4e83323b034b6ae330fe799a6482a0b240bd
Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
2016-10-29 23:12:09 +08:00
Zhao Wei Liew
201c6611ea video: msm: Add more JDI display features
* Add auto contrast optimization.
 * Add 3 intensity levels for SRE.
 * Combine all the CABC commands.
 * Slight clean up.

Change-Id: I6eef9cd79024bf0e13f48faba8dcfce1765f42d1
Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
2016-10-29 23:12:09 +08:00
Steve Kondik
644ca5d77b video: msm: Add support for CABC and SRE for JDI display
Change-Id: Id6b5f3c65a56b310a15ce5dd0484b99001c9a562
2016-10-29 23:12:09 +08:00
Zhao Wei Liew
928892ffef flo: Speed up boot and improve post-boot UX
* Boot with NOOP to speed up boot animation.
 * Enable BFQ scheduler for better UX after boot.

Change-Id: I1300e15b4435f0f51ba6eb974de1f9a7ca0e1032
Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
2016-10-29 23:12:09 +08:00
Mauro Andreolini
eb30968621 block, bfq: add Early Queue Merge (EQM) to BFQ-v7r8 for 3.4.0
A set of processes may happen  to  perform interleaved reads, i.e.,requests
whose union would give rise to a  sequential read  pattern.  There are two
typical  cases: in the first  case,   processes  read  fixed-size chunks of
data at a fixed distance from each other, while in the second case processes
may read variable-size chunks at  variable distances. The latter case occurs
for  example with  QEMU, which  splits the  I/O generated  by the  guest into
multiple chunks,  and lets these chunks  be served by a  pool of cooperating
processes,  iteratively  assigning  the  next  chunk of  I/O  to  the first
available  process. CFQ  uses actual  queue merging  for the  first type of
rocesses, whereas it  uses preemption to get a sequential  read pattern out
of the read requests  performed by the second type of  processes. In the end
it uses  two different  mechanisms to  achieve the  same goal: boosting the
throughput with interleaved I/O.

This patch introduces  Early Queue Merge (EQM), a unified mechanism to get a
sequential  read pattern  with both  types of  processes. The  main idea is
checking newly arrived requests against the next request of the active queue
both in case of actual request insert and in case of request merge. By doing
so, both the types of processes can be handled by just merging their queues.
EQM is  then simpler and  more compact than the  pair of mechanisms used in
CFQ.

Finally, EQM  also preserves the  typical low-latency properties of BFQ, by
properly restoring the weight-raising state of  a queue when it gets back to
a non-merged state.

Change-Id: I6e8e59d479c13669126ccaa7f8c2f9d54dab876f
Signed-off-by: Mauro Andreolini <mauro.andreolini@unimore.it>
Signed-off-by: Arianna Avanzini <avanzini.arianna@gmail.com>
Signed-off-by: Paolo Valente <paolo.valente@unimore.it>
2016-10-29 23:12:09 +08:00
Paolo Valente
0320934b46 block: introduce the BFQ-v7r8 I/O sched for 3.4
Add the BFQ-v7r8 I/O scheduler to 3.4.
The general structure is borrowed from CFQ, as much of the code for
handling I/O contexts. Over time, several useful features have been
ported from CFQ as well (details in the changelog in README.BFQ). A
(bfq_)queue is associated to each task doing I/O on a device, and each
time a scheduling decision has to be made a queue is selected and served
until it expires.

    - Slices are given in the service domain: tasks are assigned
      budgets, measured in number of sectors. Once got the disk, a task
      must however consume its assigned budget within a configurable
      maximum time (by default, the maximum possible value of the
      budgets is automatically computed to comply with this timeout).
      This allows the desired latency vs "throughput boosting" tradeoff
      to be set.

    - Budgets are scheduled according to a variant of WF2Q+, implemented
      using an augmented rb-tree to take eligibility into account while
      preserving an O(log N) overall complexity.

    - A low-latency tunable is provided; if enabled, both interactive
      and soft real-time applications are guaranteed a very low latency.

    - Latency guarantees are preserved also in the presence of NCQ.

    - Also with flash-based devices, a high throughput is achieved
      while still preserving latency guarantees.

    - BFQ features Early Queue Merge (EQM), a sort of fusion of the
      cooperating-queue-merging and the preemption mechanisms present
      in CFQ. EQM is in fact a unified mechanism that tries to get a
      sequential read pattern, and hence a high throughput, with any
      set of processes performing interleaved I/O over a contiguous
      sequence of sectors.

    - BFQ supports full hierarchical scheduling, exporting a cgroups
      interface.  Since each node has a full scheduler, each group can
      be assigned its own weight.

    - If the cgroups interface is not used, only I/O priorities can be
      assigned to processes, with ioprio values mapped to weights
      with the relation weight = IOPRIO_BE_NR - ioprio.

    - ioprio classes are served in strict priority order, i.e., lower
      priority queues are not served as long as there are higher
      priority queues.  Among queues in the same class the bandwidth is
      distributed in proportion to the weight of each queue. A very
      thin extra bandwidth is however guaranteed to the Idle class, to
      prevent it from starving.

Change-Id: I62eb1769f7d6b4e542a10a9c7751a454d31c04de
Signed-off-by: Paolo Valente <paolo.valente@unimore.it>
Signed-off-by: Arianna Avanzini <avanzini.arianna@gmail.com>
2016-10-29 23:12:09 +08:00
Arianna Avanzini
4e5072593a block: cgroups, kconfig, build bits for BFQ-v7r8-3.4
Update Kconfig.iosched and do the related Makefile changes to include
kernel configuration options for BFQ. Also add the bfqio controller
to the cgroups subsystem.

Change-Id: I540ea28658b44c16b998f36eb9c97205f4f288f3
Signed-off-by: Paolo Valente <paolo.valente@unimore.it>
Signed-off-by: Arianna Avanzini <avanzini.arianna@gmail.com>
2016-10-29 23:12:09 +08:00
Zhao Wei Liew
e8e41c8550 sunrpc: Fix possibly uninitialized variable warnings
These warnings are encountered when building with GCC 4.9.

Change-Id: I58b0c4f8c2d1724e42bb8037104ef93337c46f3d
Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
2016-10-29 23:12:09 +08:00
Ricardo Cerqueira
db79ac147f REVERT THIS BEFORE UPDATE ion: Rename heap_mask when used in userspace
The L userspace expects this field to have a different name :/
2016-10-29 23:12:09 +08:00
Steve Kondik
f28f477d40 Fix header list when building with Android
Change-Id: Ib0088b428bd2d8138ca4273e11ec494aeef06b3c
2016-10-29 23:12:09 +08:00
Zhao Wei Liew
d09ee43b19 flo: Add CyanogenMod config
Generated straight from flo_defconfig and added CM localversion.

Change-Id: I666e01bc84447c41970dee677127623e86b8821e
Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
2016-10-29 23:12:09 +08:00
Naveen Kaje
3c47983e8c fs: Add TTY PM IOCTLs to compat table
Augment the compat ioctl table with entries for
PM control of TTY devices. These compat entries
were not present since other TTY/serial core drivers
were not using them.

Backported from msm-3.18.

Change-Id: I96a0e54c001d780a2a427380655f1fbb0091aef7
Signed-off-by: Naveen Kaje <nkaje@codeaurora.org>
2016-10-29 23:08:34 +08:00
Nick Desaulniers
ad29d11ee3 qseecom: initialize data->type on device open
Bug: 28747998
Bug: 29821509
Bug: 29872309
Change-Id: I7ac85fa7aa2904d7975a70f3b68a2288656a2aff
2016-07-01 16:18:10 -07:00
Linus Torvalds
dc18eac80c UPSTREAM: vfs: make AIO use the proper rw_verify_area() area helpers
We had for some reason overlooked the AIO interface, and it didn't use
the proper rw_verify_area() helper function that checks (for example)
mandatory locking on the file, and that the size of the access doesn't
cause us to overflow the provided offset limits etc.

Instead, AIO did just the security_file_permission() thing (that
rw_verify_area() also does) directly.

This fixes it to do all the proper helper functions, which not only
means that now mandatory file locking works with AIO too, we can
actually remove lines of code.

Bug: 28939037
Reported-by: Manish Honap <manish_honap_vit@yahoo.co.in>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit a70b52ec1a)

Change-Id: I2e182e973b44ba97c45c80d52d8a0b7c32a72750
2016-06-20 19:00:55 +00:00
Mekala Natarajan
a63a290f4e flo_defconfig: enable SECURITY_PERF_EVENTS_RESTRICT
Bug: 29119870
Change-Id: Ib9d25b69486bb34ea5749e1342453f3f7f3a2920
Signed-off-by: Mekala Natarajan <mnatarajan@google.com>
2016-06-20 19:00:48 +00:00
Jeff Vander Stoep
91d62042a8 ANDROID: restrict access to perf events
Add:
CONFIG_SECURITY_PERF_EVENTS_RESTRICT=y

to android-base.cfg

The kernel.perf_event_paranoid sysctl is set to 3 by default.
No unprivileged use of the perf_event_open syscall will be
permitted unless it is changed.

Bug: 29054680
Change-Id: Ie7512259150e146d8e382dc64d40e8faaa438917
2016-06-20 19:00:39 +00:00
Jeff Vander Stoep
6301d0d07c FROMLIST: security,perf: Allow further restriction of perf_event_open
When kernel.perf_event_open is set to 3 (or greater), disallow all
access to performance events by users without CAP_SYS_ADMIN.
Add a Kconfig symbol CONFIG_SECURITY_PERF_EVENTS_RESTRICT that
makes this value the default.

This is based on a similar feature in grsecurity
(CONFIG_GRKERNSEC_PERF_HARDEN).  This version doesn't include making
the variable read-only.  It also allows enabling further restriction
at run-time regardless of whether the default is changed.

https://lkml.org/lkml/2016/1/11/587

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

Bug: 29054680
Change-Id: Iff5bff4fc1042e85866df9faa01bce8d04335ab8
2016-06-20 19:00:29 +00:00
Ben Hutchings
c38786a0e5 BACKPORT: perf tools: Document the perf sysctls
perf_event_paranoid was only documented in source code and a perf error
message.  Copy the documentation from the error message to
Documentation/sysctl/kernel.txt.

BACKPORT notes:
The error printing from upstream does not exist in the 3.4 kernel.
Only backporting the documentation update from this commit.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-doc@vger.kernel.org
Link: http://lkml.kernel.org/r/20160119213515.GG2637@decadent.org.uk
[ Remove reference to external Documentation file, provide info inline, as before ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Bug: 29054680
Change-Id: I13e73cfb2ad761c94762d0c8196df7725abdf5c5
2016-06-20 18:45:46 +00:00
Kangjie Lu
96981f7736 UPSTREAM: ALSA: timer: Fix leak in events via snd_timer_user_ccallback
The stack object “r1” has a total size of 32 bytes. Its field
“event” and “val” both contain 4 bytes padding. These 8 bytes
padding bytes are sent to user without being initialized.

Bug: 28980217
Change-Id: Iff69ca708e0022ce9301efae798798b9bfcf9e25
Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Siqi Lin <siqilin@google.com>
(cherry picked from commit 9a47e9cff994f37f7f0dbd9ae23740d0f64f9fe6)
2016-06-20 17:07:50 +00:00
Kangjie Lu
4cb76bd7b2 UPSTREAM: ALSA: timer: Fix leak in events via snd_timer_user_tinterrupt
The stack object “r1” has a total size of 32 bytes. Its field
“event” and “val” both contain 4 bytes padding. These 8 bytes
padding bytes are sent to user without being initialized.

Bug: 28980217
Change-Id: I2bef279bbaa1f20ea831d364b3a4a09a27f07025
Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Siqi Lin <siqilin@google.com>
(cherry picked from commit e4ec8cc8039a7063e24204299b462bd1383184a5)
2016-06-20 17:07:36 +00:00
Kangjie Lu
4bf9389bcf UPSTREAM: ALSA: timer: Fix leak in SNDRV_TIMER_IOCTL_PARAMS
The stack object “tread” has a total size of 32 bytes. Its field
“event” and “val” both contain 4 bytes padding. These 8 bytes
padding bytes are sent to user without being initialized.

Bug: 28980557
Change-Id: Ib66cfcc1e36025255d7f518f3df2c39a21858886
Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Siqi Lin <siqilin@google.com>
(cherry picked from commit cec8f96e49d9be372fdb0c3836dcf31ec71e457e)
2016-06-20 17:06:02 +00:00
Takashi Iwai
fdc6183ddd UPSTREAM: ALSA: timer: Fix race among timer ioctls
ALSA timer ioctls have an open race and this may lead to a
use-after-free of timer instance object.  A simplistic fix is to make
each ioctl exclusive.  We have already tread_sem for controlling the
tread, and extend this as a global mutex to be applied to each ioctl.

The downside is, of course, the worse concurrency.  But these ioctls
aren't to be parallel accessible, in anyway, so it should be fine to
serialize there.

Bug: 28694392
Change-Id: I1ac52f1cba5e7408fd88c8fc1c30ca2e83967ebb
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Tested-by: Dmitry Vyukov <dvyukov@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Siqi Lin <siqilin@google.com>
(cherry picked from commit af368027a49a751d6ff4ee9e3f9961f35bb4fede)
2016-06-20 16:44:15 +00:00
Eric Dumazet
d5127daf88 ipv6: add complete rcu protection around np->opt
[ Upstream commit 45f6fad84cc305103b28d73482b344d7f5b76f39 ]

This patch addresses multiple problems :

UDP/RAW sendmsg() need to get a stable struct ipv6_txoptions
while socket is not locked : Other threads can change np->opt
concurrently. Dmitry posted a syzkaller
(http://github.com/google/syzkaller) program desmonstrating
use-after-free.

Starting with TCP/DCCP lockless listeners, tcp_v6_syn_recv_sock()
and dccp_v6_request_recv_sock() also need to use RCU protection
to dereference np->opt once (before calling ipv6_dup_options())

This patch adds full RCU protection to np->opt

BUG: 28746669

Change-Id: I207da29ac48bb6dd7c40d65f9e27c4e3ff508da0
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Pierre Imai <imaipi@google.com>
2016-06-17 02:54:32 +00:00
Oliver Neukum
f426a67d6a BACKPORT: usbnet: cleanup after bind() in probe()
Bug: 28744625

In case bind() works, but a later error forces bailing
in probe() in error cases work and a timer may be scheduled.
They must be killed. This fixes an error case related to
the double free reported in
http://www.spinics.net/lists/netdev/msg367669.html
and needs to go on top of Linus' fix to cdc-ncm.

(cherry picked from commit 1666984c8625b3db19a9abc298931d35ab7bc64b)

Change-Id: Id1708db3833ade7f1406b941f0bc20671c9c3b3b
Signed-off-by: Oliver Neukum <ONeukum@suse.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-15 10:29:17 -07:00
Thierry Strudel
cd169f77b4 flo_defconfig: disable CONFIG_OABI_COMPAT
Bug: 28522518
Change-Id: I11ec8e02bdb330c10f06e923c1c3d45a145ced15
Signed-off-by: Thierry Strudel <tstrudel@google.com>
2016-06-15 06:30:01 +00:00
Al Viro
b1d288e247 net: validate the range we feed to iov_iter_init() in sys_sendto/sys_recvfrom
Bug: 28759139
Change-Id: I561a14b514d714838ef539a94275b117d7f475f4
Cc: stable@vger.kernel.org # v3.19
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-15 06:22:38 +00:00
kangjie
beeda1afc1 fix infoleak in rtnetlink
the stack object “map” has a total size of 32 bytes. Its last 4
bytes are padding generated by compiler. These padding bytes are
not initialized and sent out via “nla_put”

Bug: 28620102

Change-Id: I13da380c6fe8abca49e3cf9f05293c02b44d2e5e
Signed-off-by: kangjie <kangjielu@gmail.com>
2016-06-15 06:22:23 +00:00
Kangjie Lu
17b1ccf822 USB: usbfs: fix potential infoleak in devio
The stack object “ci” has a total size of 8 bytes. Its last 3 bytes
are padding bytes which are not initialized and leaked to userland
via “copy_to_user”.

Bug: 28619695
Change-Id: I170754d659d0891c075f85211b5e3970b114f097
Signed-off-by: Kangjie Lu <kjlu@gatech.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-15 06:10:35 +00:00
Sunil Khatri
93c8c4ae98 msm: kgsl: Defer adding the mem entry to a process
If we add the mem entry pointer in the process idr and rb tree
too early, other threads can do operations on the entry by
guessing the ID or GPU address before the object gets returned
by the creating operation.

Allocate an ID for the object but don't assign the pointer until
right before the creating function returns ensuring that another
operation can't access it until it is ready.

Bug: 28026365
CRs-Fixed: 1002974
Change-Id: Ic0dedbadc0dd2125bd2a7bcc152972c0555e07f8
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Sunil Khatri <sunilkh@codeaurora.org>
Signed-off-by: Santhosh Punugu <spunug@codeaurora.org>
2016-06-13 15:49:37 -07:00
Patrick Tjin
ea1be87b37 Merge branch 'android-msm-flo-3.4-mnc-mr1-security-next' into android-msm-flo-3.4-mnc-mr1
Merge security-next into mnc-mr1 @ 75dfdc8 for August 2016.1
2016-06-09 14:50:21 -07:00
Mohamad Ayyash
1fc765b172 Don't show empty tag stats for unprivileged uids
BUG: 27577101
BUG: 27532522
Change-Id: I890831a72e5ad4485fdf30e51a146712b18052ed
Signed-off-by: Mohamad Ayyash <mkayyash@google.com
Signed-off-by: Patrick Tjin <pattjin@google.com>
2016-06-08 11:29:32 -07:00
Gilad Avidov
75dfdc8ac1 Subject: qseecom: Add checks for user space buffer pointers
Validate pointers send from user space and pointers
embedded within the mesasge sent from user space.

Bug: 28769920
Change-Id: I1be54924ef3d301908af6e8d4e6506f2aa7f6428
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
Signed-off-by: Gilad Avidov <giladavidov@google.com>
2016-06-06 14:59:58 -07:00
Nick Desaulniers
eee0509259 qseecom: Add checks for API called in IOCTL
Validate the caller is the right type for the IOCTL being
issued and inputs are valid.

Bug: 28747998
Change-Id: Iad71f0f5ed4d53c5d011bd55cdf74ec053d09af5
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
2016-06-06 14:57:34 -07:00
Mona Hossain
b0fe0cfc75 qseecom: Validate inputs from user space
Validate send_cmd, send_modfd_cmd and send_mdfd_resp
input parameters: cmd and response pointers and buffer
lengths and offsets  issued to modify data.

Bug: 28748271
Change-Id: I381836d08aaa48357486fbdc6a122eb5b42bfa0b
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
2016-06-03 12:05:08 -07:00
Zhen Kong
4d12c149cd qseecom: Validate pointer offset in qseecom_send_modfd_cmd
Validate cmd_req_buf pointer offset in qseecom_send_modfy_cmd, and
make sure cmd buffer address to be within shared bufffer.

Bug: 28804057
Change-Id: I431511a92ab2cccbc2daebc0cf76cc3872689a97
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
2016-06-03 12:00:27 -07:00
Mohammad Johny Shaik
24147c05f0 Asoc:msm:Added Buffer overflow check
The overflow check is required to ensure that user space data
in kernel may not go beyond buffer boundary.

Bug: 28751152
Change-Id: I79b7e5f875fadcaeceb05f9163ae3666d4b6b7e1
CRs-Fixed: 563086
Signed-off-by: Mohammad Johny Shaik <mjshai@codeaurora.org>
2016-06-03 11:59:22 -07:00