Commit Graph
344995 Commits
Author SHA1 Message Date
Francescodario Cuzzocrea 4e9a31c7ec drivers: sensors: alps: switch to alarmtimer interface 2019-08-07 16:14:06 +02:00
Kevin F. Haggerty 401ec69a27 sensorhub: Migrate to alarmtimer interface
Change-Id: I19f468933bd5c3b0a4a80a59eec86647b0661609
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:33:25 +02:00
Dave Daynard 596fa615e0 battery: sec_battery: Migrate to alarmtimer interface
Change-Id: If211b431adb97a496c13d824a6d3da2898ad6d5c
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:33:17 +02:00
Francescodario Cuzzocrea 945451f25e sensors: upgrade dependency to alarmtimer interface 2019-08-06 12:32:03 +02:00
leonardo meitz 3fdd9a3455 add hrtimer support to qpnp-sec-charger.c and msm_thermal.c (not fully) 2019-08-06 12:31:35 +02:00
John Stultz 3f26a2eb2f staging: alarm-dev: Implement compat_ioctl support
Implement compat_ioctl support for the alarm-dev ioctl.

Change-Id: Ib33c67f9d25fd4d6401388b9c7dc012a8f3a9bd6
Cc: Serban Constantinescu <serban.constantinescu@arm.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Colin Cross <ccross@google.com>
Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:34 +02:00
Todd Poynor dfb1eb8bcf timerfd: add alarm timers
Add support for clocks CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM.

Change-Id: Iafc8445d3d7ffb35110c860f1607bf03f1edb895
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:34 +02:00
Al Viro d051f7de4f switch timerfd_[sg]ettime(2) to fget_light()
Change-Id: I515d2596cb322ca1945c31209eb03a6d98f5fcc4
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:33 +02:00
Josh Cartwright b6b2e3f885 rtc: pm8xxx: move device_init_wakeup() before rtc_register
Setup wakeup capability before rtc_register to ensure the rtc class core
properly sets up our 'wakealarm' sysfs attribute.

Change-Id: I87e09a6f9f3a593ddf2b9bf9fedfaeb1711d79b3
Signed-off-by: Josh Cartwright <joshc@codeaurora.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:33 +02:00
Xiaocheng Li 21202fcff2 alarmtimer: add rtc irq support for alarm
Add the rtc irq support for alarmtimer to wakeup the
alarm during system suspend.

Change-Id: I41b774ed4e788359321e1c6a564551cc9cd40c8e
Signed-off-by: Xiaocheng Li <lix@codeaurora.org>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:33 +02:00
John Stultz 4f287e192e alarmtimer: Rename alarmtimer_remove to alarmtimer_dequeue
Now that alarmtimer_remove has been simplified, change
its name to _dequeue to better match its paired _enqueue
function.

Change-Id: I234362798c5eb8a1f357758e40cbc794b77e2061
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Colin Cross <ccross@android.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:32 +02:00
Dan Carpenter 5c47f2c80c staging: alarm-dev: information leak in alarm_ioctl()
Smatch complains that if we pass an invalid clock type then "ts" is
never set.  We need to check for errors earlier, otherwise we end up
passing uninitialized stack data to userspace.

Change-Id: Ia09058462fc9815f4cf8ff577884d02bc71f7721
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:32 +02:00
John Stultz 964bc3b0ae staging: alarm-dev: Refactor alarm-dev ioctl code in prep for compat_ioctl
Cleanup the Android alarm-dev driver's ioctl code to refactor it
in preparation for compat_ioctl support.

Change-Id: Ib2a49394d5cb943721e86fc06033a82dec3db913
Cc: Serban Constantinescu <serban.constantinescu@arm.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Colin Cross <ccross@google.com>
Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:31 +02:00
John Stultz 656c70a4d5 staging: alarm-dev: Drop pre Android 1.0 _OLD ioctls
Per Colin's comment:
"The "support old userspace code" comment for those two ioctls has
been there since pre-Android 1.0.  Those apis are not exposed to
Android apps, I don't see any problem deleting them."

Thus this patch removes the ANDROID_ALARM_SET_OLD and
ANDROID_ALARM_SET_AND_WAIT_OLD ioctl compatability
logic.

Change-Id: Ifb7d2e8dee0fe52d4cd6148f5014c4b607d8813e
Cc: Serban Constantinescu <serban.constantinescu@arm.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Colin Cross <ccross@google.com>
Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:31 +02:00
Dae S. Kim ad2834a026 Staging: android: Alarm driver cleanups
Little cleanups. Enum value ANDROID_ALARM_TYPE_COUNT was treated as
an alarm type within a switch statement. That condition was unreachable
though.

Change-Id: I6d66d0155dc44c0e7b01fe44adfc2f39f78176fc
Signed-off-by: Dae S. Kim <dae@velatum.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:30 +02:00
Devendra Naga 77e0fb2cac staging: android: alarm: remove unnecessary goto statement
Change-Id: Ia23997e6ef049ce4cb7b2f1ae63839bc92111b13
Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:30 +02:00
Sachin Kamat 45d283e647 staging: Android: Fix NULL pointer related warning in alarm-dev.c file
Fixes the following sparse warning:
drivers/staging/android/alarm-dev.c:259:35: warning: Using plain integer as NULL pointer

Change-Id: Ie4eca65f820ee67d695030a885eb45438d7b279e
Cc: Brian Swetland <swetland@google.com>
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:29 +02:00
Joe Perches be2d06b53d Staging: android: alarm: Rename pr_alarm to alarm_dbg
Rename a macro to make it explicit it's for debugging.

Use %s: __func__ instead of embedding function names.
Coalesce formats, align arguments.

Change-Id: I583efa9ea4aeb4405dc0499b00995a049de52506
Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:29 +02:00
John Stultz 55620d12c1 staging: android-alarm: Switch from wakelocks to wakeup sources
In their current AOSP tree, the Android in-kernel wakelock
infrastructure has been reimplemented in terms of wakeup
sources:
http://git.linaro.org/gitweb?p=people/jstultz/android.git;a=commitdiff;h=e9911f4efdc55af703b8b3bb8c839e6f5dd173bb

The Android alarm driver currently has stubbed out calls
to wakelock functionality. So this patch simply converts
the stubbed out wakelock calls to wakeup source calls, and
removes the empty wakelock macros

Greg, would you mind queuing this in staging-next?

Change-Id: I3b2eaa66c8648540834c8e55412afaec7e42ee50
CC: Colin Cross <ccross@android.com>
CC: Arve Hjønnevåg <arve@android.com>
CC: Greg KH <gregkh@linuxfoundation.org>
CC: Android Kernel Team <kernel-team@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:28 +02:00
Kevin F. Haggerty bd918577da Revert "rtc: alarm: init power_on_alarm_lock mutex in alarmtimer_rtc_timer_init"
This reverts commit 057d23aac7.

Change-Id: Ic12a33ed76fc1c101f5f28aa4cbf6b6414f84067
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:28 +02:00
Kevin F. Haggerty 97db5ca698 rtc: Remove alarm driver/interface
This is a whole or partial revert of:
49740364548 misc: Import SM-G900F kernel source code
9c66e26930 rtc: alarm: set power_on_alarm again when calling alarm_resume
446d682932 alarm : Fix the race conditions in alarm-dev.c
eeb31ff78d rtc:alarm: remove alarm_shutdown hook in alarm driver
aaf95a368d rtc: alarm: update power_on alarm setting logic
aec339ee1f kernel: alarm: setup the RTC immediately for poweroff alarm
6a5881bcb1 rtc: alarm: Proper handling of spinlock
c83a382633 kernel: alarm: Do not call rtc_alarm_irq_enable in IRQ Disabled context
091c9afe14 kernel: alarm: add dedicated alarm type for poweroff alarm
1b2c1c64aa kernel: alarm: :fix the BUG that device automatically powers on
7289fdd2e0 rtc: alarm: Set power-on alarm 120 sec before actual alarm time
c1b2e47058 rtc: alarm: Add power-on alarm feature
f132c6cf77 Merge commit 'AU_LINUX_ANDROID_ICS.04.00.04.00.126' into msm-3.4
d074fa2796 Merge remote-tracking branch 'common/android-3.0' into msm-3.0
3f2bc4d6eb Initial Contribution
692e468137 rtc alarm: fix bad index when canceling alarms[]
2cd24680f6 rtc: alarm: Update hrtimer if alarm at the head of the queue is reprogrammed
b2a4ab2aa0 rtc: alarm: Don't use save_time_delta.
fa56540eb5 rtc: alarm: Add in-kernel alarm interface
b54b33d0b9 rtc: Add android alarm driver.

Change-Id: Iadf132deb9be432910badffb222177a253de81f5
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:27 +02:00
Kevin F. Haggerty 2ad12bf9a5 Revert "HACK: time: Disable alarmtimer"
This reverts commit abbb445f65.

Change-Id: I03df52855d5d8db780c479e6bd7e3b8f88fde288
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:27 +02:00
Kevin F. Haggerty 89a5cbd8ec Revert "staging: Remove logger and alarm-dev from android Makefile"
This reverts commit 69e80b0b102c0eadf7a5ea8984e5f3dd9109fe43.

Change-Id: Ieddfd00f9e0448590a4e096ef933bc219d8efadc
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:26 +02:00
Kevin F. Haggerty 205f040cad Revert "staging: Remove the Android alarm-dev driver"
This reverts commit e2f192e02955efcac46f0853eadaaa52ae642a93.

Change-Id: I7216659b94d8621265896930ad99f233ddcf1f75
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:26 +02:00
Kevin F. Haggerty c8255adb5e kernel/sys.c: ifndef out PR_SET_TIMERSLACK_PID case for H-projects
* The comment says this case isn't supposed to be here for H-projects,
  variables it depends on are ifndef-ed out for H-projects, just get rid
  of it.

Change-Id: Ic67a1e97c4429dd5cf4df9e2f45fb63d13e4054f
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:26 +02:00
Insun Song 25394d0e37 net: wireless: bcmdhd: fix buffer overrun in wl_cfg80211_add_iw_ie
added boundary check not to override allocated buffer.

Signed-off-by: Insun Song <insun.song@broadcom.com>
Change-Id: I76211db7ef595fc41cf5d5d58de79cedfe80e521
Bug: 32125310
CVE-2017-0567
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:25 +02:00
Sudhir Kohalli 757452e7e9 net: wireless: bcmdhd: Heap overflow in wl_run_escan.
1) The default_chan_list buffer overflow is avoided by checking
n_nodfs index does not exceed num_chans, which is the length
of default_chan_list buffer.
2) The SSID length check 32(max limit) is done and then the SSID
name copied in extra buffer is null terminated. The extra buffer
is allocated a length of of 33 in wl_iw_ioctl.c.
3) Issue of chances of cumulative results->pkt_count length
exceeding allocated memory length of results->total_count is
avoided in this fix. change_array is the destination array
whose length is allocated to results->total_count.

Signed-off-by: Sudhir Kohalli <sudhir.kohalli@broadcom.com>

Bug: 34197514
Bug: 34199963
Bug: 34198729

Change-Id: I0cd268ab696daac938a99f451607a3f4b2cfaed3
[haggertk]: Partial patch - dhd_handle_swc_evt() changes not relevant,
this bcmdhd version does not contain that function
CVE-2017-0568
CVE-2017-0569
CVE-2017-0570
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:25 +02:00
Insun Song e8d16288fe net: wireless: bcmdhd: fix overrun in wl_run_escan
prevent buffer overrun case where WLC_GET_VALID_CHANNELS IOCTL
 overriden by attacker and its return manipulated.

Signed-off-by: Insun Song <insun.song@broadcom.com>
Change-Id: Ifbbaa3c2bdfd9bea7533d605303f18e17c8d85cc
Bug: 34197514
CVE-2017-0568
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:24 +02:00
Insun Song 1dda9b345c net: wireless: bcmdhd: fix buffer overrun in wlfc reordering
added boundary check not to override allocated buffer

Signed-off-by: Insun Song <insun.song@broadcom.com>
Change-Id: Iad44141ba4e4cd224eda292c05ffe525bf74227d
Bug: 34203305
CVE-2017-0571
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:24 +02:00
Insun Song 7b72d74a8c net: wireless: bcmdhd: fix buffer overrun in wl_android_set_roampref
added boundary check not to override allocated buffer.
Specially when user input corrupted or manipulated.

Signed-off-by: Insun Song <insun.song@broadcom.com>
Change-Id: Id6196da10111517696eda5f186b1e2dd19f66085
Bug: 34469904
CVE-2017-0573
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:23 +02:00
Kevin F. Haggerty 8daa9d04d1 msm8974_sec_defconfig: Enable QCOM Crypto Engine Devices
Change-Id: I00fa87fabd3870424c1336f1166b1f9702869c6a
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:23 +02:00
myfluxi 71cb223816 crypto: msm: qcrypto: Remove duplicate definition of list_next_entry()
Change-Id: Ia9008e2f71926f3c3d4fa12fd8c72b3ed2ee76f6
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:22 +02:00
Alex Elder d6aef39f05 kernel.h: define u8, s8, u32, etc. limits
Create constants that define the maximum and minimum values
representable by the kernel types u8, s8, u16, s16, and so on.

Signed-off-by: Alex Elder <elder@linaro.org>
Cc: Sage Weil <sage@inktank.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:22 +02:00
Jin Qian 13ff11b318 BACKPORT: f2fs: sanity check checkpoint segno and blkoff
Make sure segno and blkoff read from raw image are valid.

Fixed conflicts due to missing commit 1e968fdfe69e
("f2fs: introduce f2fs_cp_error for readability") and commit 6bacf52fb58a
("f2fs: add unlikely() macro for compiler more aggressively").

(url https://sourceforge.net/p/linux-f2fs/mailman/message/35835945)

Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Siqi Lin <siqilin@google.com>
Bug: 36588520
Change-Id: Iba66ab97d3d0870ea48b5ef192d9075f225a934a
CVE-2017-10663
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:21 +02:00
Jin Qian 1c09283d21 UPSTREAM: f2fs: sanity check segment count
commit b9dd46188edc2f0d1f37328637860bb65a771124 upstream.

F2FS uses 4 bytes to represent block address. As a result, supported
size of disk is 16 TB and it equals to 16 * 1024 * 1024 / 2 segments.

Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 36815012
Change-Id: I30ea36df066bc07e32e767336b7cae12063fe415
CVE-2017-10662
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:31:21 +02:00
Jin Qian 3aa040ac74 BACKPORT: f2fs: sanity check log_blocks_per_seg
f2fs currently only supports 4KB block size and 2MB segment size.
Sanity check log_blocks_per_seg == 9, i.e. 2MB/4KB = (1 << 9)

Partially
(cherry-picked from commit 9a59b62fd88196844cee5fff851bee2cfd7afb6e)

f2fs: do more integrity verification for superblock

Do more sanity check for superblock during ->mount.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Bug: 36817013
Change-Id: I0be52e54fba82083068337ceb9f7ad985a87319f
Signed-off-by: Jin Qian <jinqian@google.com>
CVE-2017-0750
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:29:56 +02:00
Utkarsh Saxena 79667afde6 msm: ipa: Fix for missing int overflow check in the refcount library
Overflow of reference counter can lead to memory leak.

Before incrementing the reference count, check with
U32_MAX and return for error check.

Bug: 35467471
Change-Id: Ib96d36574ee086ec73c9836110cb2c98e8ae3d66
Acked-by: Mohammed Javid <mjavid@qti.qualcomm.com>
Signed-off-by: Utkarsh Saxena <usaxena@codeaurora.org>
CVE-2017-0746
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:29:55 +02:00
Andrea Arcangeli 92d0f6e8be msm: camera: Fix various small issues in cci driver: fix retvals
This reports an error to the caller after adding the bound checks,
otherwise potentially undefined/unexpected behaviour may result.

Change-Id: Id2897aa5ce4587762b5eda89f7481788d689d0a8
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:28:59 +02:00
Craig Gallek 60319ecfce ipv6: Prevent overrun when parsing v6 header options
commit 2423496af35d94a87156b063ea5cedffc10a70a1 upstream.

The KASAN warning repoted below was discovered with a syzkaller
program.  The reproducer is basically:
  int s = socket(AF_INET6, SOCK_RAW, NEXTHDR_HOP);
  send(s, &one_byte_of_data, 1, MSG_MORE);
  send(s, &more_than_mtu_bytes_data, 2000, 0);

The socket() call sets the nexthdr field of the v6 header to
NEXTHDR_HOP, the first send call primes the payload with a non zero
byte of data, and the second send call triggers the fragmentation path.

The fragmentation code tries to parse the header options in order
to figure out where to insert the fragment option.  Since nexthdr points
to an invalid option, the calculation of the size of the network header
can made to be much larger than the linear section of the skb and data
is read outside of it.

This fix makes ip6_find_1stfrag return an error if it detects
running out-of-bounds.

[   42.361487] ==================================================================
[   42.364412] BUG: KASAN: slab-out-of-bounds in ip6_fragment+0x11c8/0x3730
[   42.365471] Read of size 840 at addr ffff88000969e798 by task ip6_fragment-oo/3789
[   42.366469]
[   42.366696] CPU: 1 PID: 3789 Comm: ip6_fragment-oo Not tainted 4.11.0+ #41
[   42.367628] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-1ubuntu1 04/01/2014
[   42.368824] Call Trace:
[   42.369183]  dump_stack+0xb3/0x10b
[   42.369664]  print_address_description+0x73/0x290
[   42.370325]  kasan_report+0x252/0x370
[   42.370839]  ? ip6_fragment+0x11c8/0x3730
[   42.371396]  check_memory_region+0x13c/0x1a0
[   42.371978]  memcpy+0x23/0x50
[   42.372395]  ip6_fragment+0x11c8/0x3730
[   42.372920]  ? nf_ct_expect_unregister_notifier+0x110/0x110
[   42.373681]  ? ip6_copy_metadata+0x7f0/0x7f0
[   42.374263]  ? ip6_forward+0x2e30/0x2e30
[   42.374803]  ip6_finish_output+0x584/0x990
[   42.375350]  ip6_output+0x1b7/0x690
[   42.375836]  ? ip6_finish_output+0x990/0x990
[   42.376411]  ? ip6_fragment+0x3730/0x3730
[   42.376968]  ip6_local_out+0x95/0x160
[   42.377471]  ip6_send_skb+0xa1/0x330
[   42.377969]  ip6_push_pending_frames+0xb3/0xe0
[   42.378589]  rawv6_sendmsg+0x2051/0x2db0
[   42.379129]  ? rawv6_bind+0x8b0/0x8b0
[   42.379633]  ? _copy_from_user+0x84/0xe0
[   42.380193]  ? debug_check_no_locks_freed+0x290/0x290
[   42.380878]  ? ___sys_sendmsg+0x162/0x930
[   42.381427]  ? rcu_read_lock_sched_held+0xa3/0x120
[   42.382074]  ? sock_has_perm+0x1f6/0x290
[   42.382614]  ? ___sys_sendmsg+0x167/0x930
[   42.383173]  ? lock_downgrade+0x660/0x660
[   42.383727]  inet_sendmsg+0x123/0x500
[   42.384226]  ? inet_sendmsg+0x123/0x500
[   42.384748]  ? inet_recvmsg+0x540/0x540
[   42.385263]  sock_sendmsg+0xca/0x110
[   42.385758]  SYSC_sendto+0x217/0x380
[   42.386249]  ? SYSC_connect+0x310/0x310
[   42.386783]  ? __might_fault+0x110/0x1d0
[   42.387324]  ? lock_downgrade+0x660/0x660
[   42.387880]  ? __fget_light+0xa1/0x1f0
[   42.388403]  ? __fdget+0x18/0x20
[   42.388851]  ? sock_common_setsockopt+0x95/0xd0
[   42.389472]  ? SyS_setsockopt+0x17f/0x260
[   42.390021]  ? entry_SYSCALL_64_fastpath+0x5/0xbe
[   42.390650]  SyS_sendto+0x40/0x50
[   42.391103]  entry_SYSCALL_64_fastpath+0x1f/0xbe
[   42.391731] RIP: 0033:0x7fbbb711e383
[   42.392217] RSP: 002b:00007ffff4d34f28 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
[   42.393235] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fbbb711e383
[   42.394195] RDX: 0000000000001000 RSI: 00007ffff4d34f60 RDI: 0000000000000003
[   42.395145] RBP: 0000000000000046 R08: 00007ffff4d34f40 R09: 0000000000000018
[   42.396056] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000400aad
[   42.396598] R13: 0000000000000066 R14: 00007ffff4d34ee0 R15: 00007fbbb717af00
[   42.397257]
[   42.397411] Allocated by task 3789:
[   42.397702]  save_stack_trace+0x16/0x20
[   42.398005]  save_stack+0x46/0xd0
[   42.398267]  kasan_kmalloc+0xad/0xe0
[   42.398548]  kasan_slab_alloc+0x12/0x20
[   42.398848]  __kmalloc_node_track_caller+0xcb/0x380
[   42.399224]  __kmalloc_reserve.isra.32+0x41/0xe0
[   42.399654]  __alloc_skb+0xf8/0x580
[   42.400003]  sock_wmalloc+0xab/0xf0
[   42.400346]  __ip6_append_data.isra.41+0x2472/0x33d0
[   42.400813]  ip6_append_data+0x1a8/0x2f0
[   42.401122]  rawv6_sendmsg+0x11ee/0x2db0
[   42.401505]  inet_sendmsg+0x123/0x500
[   42.401860]  sock_sendmsg+0xca/0x110
[   42.402209]  ___sys_sendmsg+0x7cb/0x930
[   42.402582]  __sys_sendmsg+0xd9/0x190
[   42.402941]  SyS_sendmsg+0x2d/0x50
[   42.403273]  entry_SYSCALL_64_fastpath+0x1f/0xbe
[   42.403718]
[   42.403871] Freed by task 1794:
[   42.404146]  save_stack_trace+0x16/0x20
[   42.404515]  save_stack+0x46/0xd0
[   42.404827]  kasan_slab_free+0x72/0xc0
[   42.405167]  kfree+0xe8/0x2b0
[   42.405462]  skb_free_head+0x74/0xb0
[   42.405806]  skb_release_data+0x30e/0x3a0
[   42.406198]  skb_release_all+0x4a/0x60
[   42.406563]  consume_skb+0x113/0x2e0
[   42.406910]  skb_free_datagram+0x1a/0xe0
[   42.407288]  netlink_recvmsg+0x60d/0xe40
[   42.407667]  sock_recvmsg+0xd7/0x110
[   42.408022]  ___sys_recvmsg+0x25c/0x580
[   42.408395]  __sys_recvmsg+0xd6/0x190
[   42.408753]  SyS_recvmsg+0x2d/0x50
[   42.409086]  entry_SYSCALL_64_fastpath+0x1f/0xbe
[   42.409513]
[   42.409665] The buggy address belongs to the object at ffff88000969e780
[   42.409665]  which belongs to the cache kmalloc-512 of size 512
[   42.410846] The buggy address is located 24 bytes inside of
[   42.410846]  512-byte region [ffff88000969e780, ffff88000969e980)
[   42.411941] The buggy address belongs to the page:
[   42.412405] page:ffffea000025a780 count:1 mapcount:0 mapping:          (null) index:0x0 compound_mapcount: 0
[   42.413298] flags: 0x100000000008100(slab|head)
[   42.413729] raw: 0100000000008100 0000000000000000 0000000000000000 00000001800c000c
[   42.414387] raw: ffffea00002a9500 0000000900000007 ffff88000c401280 0000000000000000
[   42.415074] page dumped because: kasan: bad access detected
[   42.415604]
[   42.415757] Memory state around the buggy address:
[   42.416222]  ffff88000969e880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[   42.416904]  ffff88000969e900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[   42.417591] >ffff88000969e980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[   42.418273]                    ^
[   42.418588]  ffff88000969ea00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[   42.419273]  ffff88000969ea80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[   42.419882] ==================================================================

Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Craig Gallek <kraig@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.2: adjust filenames, context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
CVE-2017-9074
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>

Change-Id: I0786e1488cd444d809aad79aa8d682f0d1eb0e7f
2019-08-06 12:26:43 +02:00
Eric Dumazet a47e224411 dccp/tcp: do not inherit mc_list from parent
syzkaller found a way to trigger double frees from ip_mc_drop_socket()

It turns out that leave a copy of parent mc_list at accept() time,
which is very bad.

Very similar to commit 8b485ce69876 ("tcp: do not inherit
fastopen_req from parent")

Initial report from Pray3r, completed by Andrey one.
Thanks a lot to them !

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Pray3r <pray3r.z@gmail.com>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
CVE-2017-8890

Change-Id: I5880939b0ad2c19dcb013149dcbc7c479083dad6
2019-08-06 12:26:42 +02:00
Nick Desaulniers 62856dafc3 BACKPORT: msm: camera: Add regulator enable and disable independent of CSID
Regulator enable and disable of CSIPHY depends on the CSID module.
Make the enable and disable of clk regulator independent of CSIPHY.

Bug: 33299365
CRs-Fixed: 1107702
Change-Id: Iabb5eb28d63b34a4c3201c53be17054a1907f4fe
Signed-off-by: Ravi Kishore Tanuku <rktanuku@codeaurora.org>
Signed-off-by: VijayaKumar T M <vtmuni@codeaurora.org>
Signed-off-by: Dennis Cagle <d-cagle@codeaurora.org>
(cherry picked from commit b1bb44c9cca61e48ec6158abad6e7969a8e58abf)
CVE-2017-8264
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:26:42 +02:00
Dennis Cagle 375d3f2b86 msm: kgsl: Fix kgsl memory allocation and free race condition
When allocating userspace memory keep reference to memory
allocation till it is completely initialized and info is send back
to userspace

Bug: 32938443
CRs-Fixed: 2029113
Change-Id: Id72c82bf98c094ecbd4722813c732a998dcbb188
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Sunil Khatri <sunilkh@codeaurora.org>
Signed-off-by: Dennis Cagle <d-cagle@codeaurora.org>
CVE-2017-8262
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:26:41 +02:00
Gaoxiang Chen e0ec196e6d msm: camera: don't cut to 8bits for validating enum variable
In msm_ispif_is_intf_valid(),
we convert a enum variable msm_ispif_vfe_intf,
to uint8_t type for validating.

This could cause potential issue,
if the value is crafted in such a way that lower 8bits pass the validation.

Don't use uint8_t as input parm to avoid such vulnerability.

CRs-Fixed: 2008469
Change-Id: I4ee400ac0edd830decfbe5712966d968976a268a
Signed-off-by: Gaoxiang Chen <gaochen@codeaurora.org>
CVE-2017-8260
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:26:41 +02:00
Abdulla Anam 01d705b8dd msm: vidc: Protect debug_buffer access in core_info_read with lock.
Serialize core_info_read with lock so that multiple concurrent
threads do not cause the write to overflow. Also have the bound
check to avoid overflow in write_str function.

CRs-Fixed: 2013361
CAF-Change-Id: Ia18a4b94cafd69af1d367861f2499fc202f18e9f
Signed-off-by: Abdulla Anam <abdullahanam@codeaurora.org>
Signed-off-by: Sanjay Singh <sisanj@codeaurora.org>
CVE-2017-8244
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>

Change-Id: I8d21d662534f1679594042f3a5b6bcfb4884e11f
2019-08-06 12:26:40 +02:00
Skylar Chang 0d98a476c7 msm: IPA: add the check on intf query
The ipa_ioc_query_intf_rx_props structure comes
from the ioctl handler, and it is verified that
the size of rx buffer does not exceed the
IPA_NUM_PROPS_MAX elements. It is also verified
that the "entry->rx" buffer does not exceed
IPA_NUM_PROPS_MAX when "entry" is allocated.
However, the sizes of the buffer "rx->rx" and
the buffer "entry->rx" are not guaranteed to
be the same and will lead memory corruption
issue. The fix is to add the check before
memcpy.

CAF-Change-Id: Idf5c2d32f47c1a1cffeaa5607193855188893ddb
Signed-off-by: Skylar Chang <chiaweic@codeaurora.org>
[haggertk]: Backport to 3.4/msm8974
CVE-2017-8236
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>

Change-Id: Ib0d0fb7b9564f9484f141df9866d121b2dd2b293
2019-08-06 12:26:40 +02:00
Kees Cook 2216293b25 mm: Tighten x86 /dev/mem with zeroing reads
Under CONFIG_STRICT_DEVMEM, reading System RAM through /dev/mem is
disallowed. However, on x86, the first 1MB was always allowed for BIOS
and similar things, regardless of it actually being System RAM. It was
possible for heap to end up getting allocated in low 1MB RAM, and then
read by things like x86info or dd, which would trip hardened usercopy:

usercopy: kernel memory exposure attempt detected from ffff880000090000 (dma-kmalloc-256) (4096 bytes)

This changes the x86 exception for the low 1MB by reading back zeros for
System RAM areas instead of blindly allowing them. More work is needed to
extend this to mmap, but currently mmap doesn't go through usercopy, so
hardened usercopy won't Oops the kernel.

Change-Id: I6732f317b537c96046427bdcf805803dc138129a
Reported-by: Tommi Rantala <tommi.t.rantala@nokia.com>
Tested-by: Tommi Rantala <tommi.t.rantala@nokia.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
CVE-2017-7889
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:26:39 +02:00
Herbert Xu d14134999c crypto: ahash - Fix EINPROGRESS notification callback
commit ef0579b64e93188710d48667cb5e014926af9f1b upstream.

The ahash API modifies the request's callback function in order
to clean up after itself in some corner cases (unaligned final
and missing finup).

When the request is complete ahash will restore the original
callback and everything is fine.  However, when the request gets
an EBUSY on a full queue, an EINPROGRESS callback is made while
the request is still ongoing.

In this case the ahash API will incorrectly call its own callback.

This patch fixes the problem by creating a temporary request
object on the stack which is used to relay EINPROGRESS back to
the original completion function.

This patch also adds code to preserve the original flags value.

Fixes: ab6bf4e5e5e4 ("crypto: hash - Fix the pointer voodoo in...")
Reported-by: Sabrina Dubroca <sd@queasysnail.net>
Tested-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CVE-2017-7618
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>

Change-Id: Id60b454614430baa609a1d597b051c594ec0a3af
2019-08-06 12:26:39 +02:00
Marek Vasut 19398f087e crypto: hash - Simplify the ahash_finup implementation
The ahash_def_finup() can make use of the request save/restore functions,
thus make it so. This simplifies the code a little and unifies the code
paths.

Note that the same remark about free()ing the req->priv applies here, the
req->priv can only be free()'d after the original request was restored.

Finally, squash a bug in the invocation of completion in the ASYNC path.
In both ahash_def_finup_done{1,2}, the function areq->base.complete(X, err);
was called with X=areq->base.data . This is incorrect , as X=&areq->base
is the correct value. By analysis of the data structures, we see the areq is
of type 'struct ahash_request' , areq->base is of type 'struct crypto_async_request'
and areq->base.completion is of type crypto_completion_t, which is defined in
include/linux/crypto.h as:

  typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err);

This is one lead that the X should be &areq->base . Next up, we can inspect
other code which calls the completion callback to give us kind-of statistical
idea of how this callback is used. We can try:

  $ git grep base\.complete\( drivers/crypto/

Finally, by inspecting ahash_request_set_callback() implementation defined
in include/crypto/hash.h , we observe that the .data entry of 'struct
crypto_async_request' is intended for arbitrary data, not for completion
argument.

Change-Id: I8e7841ed8a70b361c47091e2e121ca273d37b9d2
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: David S. Miller <davem@davemloft.net>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:26:39 +02:00
Marek Vasut f2b594b7fd crypto: hash - Pull out the functions to save/restore request
The functions to save original request within a newly adjusted request
and it's counterpart to restore the original request can be re-used by
more code in the crypto/ahash.c file. Pull these functions out from the
code so they're available.

Change-Id: I665d64be2a1b3cb8144f212fafe7b772db1c977d
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: David S. Miller <davem@davemloft.net>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
2019-08-06 12:26:38 +02:00
Eric Biggers d02517c58a fscrypt: remove broken support for detecting keyring key revocation
Filesystem encryption ostensibly supported revoking a keyring key that
had been used to "unlock" encrypted files, causing those files to become
"locked" again.  This was, however, buggy for several reasons, the most
severe of which was that when key revocation happened to be detected for
an inode, its fscrypt_info was immediately freed, even while other
threads could be using it for encryption or decryption concurrently.
This could be exploited to crash the kernel or worse.

This patch fixes the use-after-free by removing the code which detects
the keyring key having been revoked, invalidated, or expired.  Instead,
an encrypted inode that is "unlocked" now simply remains unlocked until
it is evicted from memory.  Note that this is no worse than the case for
block device-level encryption, e.g. dm-crypt, and it still remains
possible for a privileged user to evict unused pages, inodes, and
dentries by running 'sync; echo 3 > /proc/sys/vm/drop_caches', or by
simply unmounting the filesystem.  In fact, one of those actions was
already needed anyway for key revocation to work even somewhat sanely.
This change is not expected to break any applications.

In the future I'd like to implement a real API for fscrypt key
revocation that interacts sanely with ongoing filesystem operations ---
waiting for existing operations to complete and blocking new operations,
and invalidating and sanitizing key material and plaintext from the VFS
caches.  But this is a hard problem, and for now this bug must be fixed.

This bug affected almost all versions of ext4, f2fs, and ubifs
encryption, and it was potentially reachable in any kernel configured
with encryption support (CONFIG_EXT4_ENCRYPTION=y,
CONFIG_EXT4_FS_ENCRYPTION=y, CONFIG_F2FS_FS_ENCRYPTION=y, or
CONFIG_UBIFS_FS_ENCRYPTION=y).  Note that older kernels did not use the
shared fs/crypto/ code, but due to the potential security implications
of this bug, it may still be worthwhile to backport this fix to them.

Fixes: b7236e21d55f ("ext4 crypto: reorganize how we store keys in the inode")
Cc: stable@vger.kernel.org # v4.2+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Acked-by: Michael Halcrow <mhalcrow@google.com>
[haggertk]: Backport to 3.4/msm8974
CVE-2017-7374
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>

Change-Id: I2204233b893960f4e0e33c58f6135920724e84b1
2019-08-06 12:26:38 +02:00