~kelsey-steele/ubuntu/+source/linux/+git/xenial-next:master-next

Last commit made on 2020-04-02
Get this branch:
git clone -b master-next https://git.launchpad.net/~kelsey-steele/ubuntu/+source/linux/+git/xenial-next
Only Kelsey Steele can upload to this branch. If you are Kelsey Steele please log in for upload directions.

Branch merges

Branch information

Recent commits

e132a3e... by Cengiz Can

blktrace: fix dereference after null check

There was a recent change in blktrace.c that added a RCU protection to
`q->blk_trace` in order to fix a use-after-free issue during access.

However the change missed an edge case that can lead to dereferencing of
`bt` pointer even when it's NULL:

Coverity static analyzer marked this as a FORWARD_NULL issue with CID
1460458.

```
/kernel/trace/blktrace.c: 1904 in sysfs_blk_trace_attr_store()
1898 ret = 0;
1899 if (bt == NULL)
1900 ret = blk_trace_setup_queue(q, bdev);
1901
1902 if (ret == 0) {
1903 if (attr == &dev_attr_act_mask)
>>> CID 1460458: Null pointer dereferences (FORWARD_NULL)
>>> Dereferencing null pointer "bt".
1904 bt->act_mask = value;
1905 else if (attr == &dev_attr_pid)
1906 bt->pid = value;
1907 else if (attr == &dev_attr_start_lba)
1908 bt->start_lba = value;
1909 else if (attr == &dev_attr_end_lba)
```

Added a reassignment with RCU annotation to fix the issue.

Fixes: c780e86dd48 ("blktrace: Protect q->blk_trace with RCU")
Cc: <email address hidden>
Reviewed-by: Ming Lei <email address hidden>
Reviewed-by: Bob Liu <email address hidden>
Reviewed-by: Steven Rostedt (VMware) <email address hidden>
Signed-off-by: Cengiz Can <email address hidden>
Signed-off-by: Jens Axboe <email address hidden>

CVE-2019-19768
(cherry picked from commit 153031a301bb07194e9c37466cfce8eacb977621)
Signed-off-by: Benjamin M Romer <email address hidden>
Acked-by: Andrea Righi <email address hidden>
Acked-by: Kamal Mostafa <email address hidden>
Signed-off-by: Kelsey Skunberg <email address hidden>

8f0753f... by Jan Kara <email address hidden>

blktrace: Protect q->blk_trace with RCU

KASAN is reporting that __blk_add_trace() has a use-after-free issue
when accessing q->blk_trace. Indeed the switching of block tracing (and
thus eventual freeing of q->blk_trace) is completely unsynchronized with
the currently running tracing and thus it can happen that the blk_trace
structure is being freed just while __blk_add_trace() works on it.
Protect accesses to q->blk_trace by RCU during tracing and make sure we
wait for the end of RCU grace period when shutting down tracing. Luckily
that is rare enough event that we can afford that. Note that postponing
the freeing of blk_trace to an RCU callback should better be avoided as
it could have unexpected user visible side-effects as debugfs files
would be still existing for a short while block tracing has been shut
down.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=205711
CC: <email address hidden>
Reviewed-by: Chaitanya Kulkarni <email address hidden>
Reviewed-by: Ming Lei <email address hidden>
Tested-by: Ming Lei <email address hidden>
Reviewed-by: Bart Van Assche <email address hidden>
Reported-by: Tristan Madani <email address hidden>
Signed-off-by: Jan Kara <email address hidden>
Signed-off-by: Jens Axboe <email address hidden>

CVE-2019-19768
(backported from commit c780e86dd48ef6467a1146cf7d0fe1e05a635039)
[ ben_r: adjusted patch to apply to ubuntu.
  v2 corrects two merge errors. ]
Signed-off-by: Benjamin M Romer <email address hidden>
Acked-by: Andrea Righi <email address hidden>
Acked-by: Kamal Mostafa <email address hidden>
Signed-off-by: Kelsey Skunberg <email address hidden>

c2c3ce8... by Kleber Sacilotto de Souza

test_bpf: flag tests that cannot be jited on s390

BugLink: https://bugs.launchpad.net/bugs/1768452

Flag with FLAG_EXPECTED_FAIL the BPF_MAXINSNS tests that cannot be jited
on s390 because they exceed BPF_SIZE_MAX and fail when
CONFIG_BPF_JIT_ALWAYS_ON is set. Also set .expected_errcode to -ENOTSUPP
so the tests pass in that case.

Signed-off-by: Kleber Sacilotto de Souza <email address hidden>
Acked-by: Song Liu <email address hidden>
Signed-off-by: Daniel Borkmann <email address hidden>
(backported from commit 3203c9010060806ff88c9989aeab4dc8d9a474dc)
[PHLin: context adjustment, drop non-existing part]
Signed-off-by: Po-Hsu Lin <email address hidden>
Acked-by: Andrea Righi <email address hidden>
Acked-by: Sultan Alsawaf <email address hidden>
Signed-off-by: Kelsey Skunberg <email address hidden>

119771d... by Ming Lei <email address hidden>

block: fix bio_will_gap() for first bvec with offset

BugLink: https://bugs.launchpad.net/bugs/1869229

Commit 729204ef49ec("block: relax check on sg gap") allows us to merge
bios, if both are physically contiguous. This change can merge a huge
number of small bios, through mkfs for example, mkfs.ntfs running time
can be decreased to ~1/10.

But if one rq starts with a non-aligned buffer (the 1st bvec's bv_offset
is non-zero) and if we allow the merge, it is quite difficult to respect
sg gap limit, especially the max segment size, or we risk having an
unaligned virtual boundary. This patch tries to avoid the issue by
disallowing a merge, if the req starts with an unaligned buffer.

Also add comments to explain why the merged segment can't end in
unaligned virt boundary.

Fixes: 729204ef49ec ("block: relax check on sg gap")
Tested-by: Johannes Thumshirn <email address hidden>
Reviewed-by: Johannes Thumshirn <email address hidden>
Signed-off-by: Ming Lei <email address hidden>

Rewrote parts of the commit message and comments.

Signed-off-by: Jens Axboe <email address hidden>
(cherry picked from commit 5a8d75a1b8c99bdc926ba69b7b7dbe4fae81a5af)
Signed-off-by: Matthew Ruffell <email address hidden>
Signed-off-by: Heitor Alves de Siqueira <email address hidden>
Acked-by: Sultan Alsawaf <email address hidden>
Acked-by: Marcelo Henrique Cerri <email address hidden>
Signed-off-by: Kelsey Skunberg <email address hidden>

ae1479c... by Greg Kroah-Hartman <email address hidden>

Linux 4.4.217

BugLink: https://bugs.launchpad.net/bugs/1868629

Signed-off-by: Khalid Elmously <email address hidden>
Signed-off-by: Kelsey Skunberg <email address hidden>

d0316aa... by Matteo Croce <email address hidden>

ipv4: ensure rcu_read_lock() in cipso_v4_error()

BugLink: https://bugs.launchpad.net/bugs/1868629

commit 3e72dfdf8227b052393f71d820ec7599909dddc2 upstream.

Similarly to commit c543cb4a5f07 ("ipv4: ensure rcu_read_lock() in
ipv4_link_failure()"), __ip_options_compile() must be called under rcu
protection.

Fixes: 3da1ed7ac398 ("net: avoid use IPCB in cipso_v4_error")
Suggested-by: Guillaume Nault <email address hidden>
Signed-off-by: Matteo Croce <email address hidden>
Acked-by: Paul Moore <email address hidden>
Signed-off-by: David S. Miller <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>

Signed-off-by: Khalid Elmously <email address hidden>
Signed-off-by: Kelsey Skunberg <email address hidden>

2674d79... by Jann Horn (corp account)

mm: slub: add missing TID bump in kmem_cache_alloc_bulk()

BugLink: https://bugs.launchpad.net/bugs/1868629

commit fd4d9c7d0c71866ec0c2825189ebd2ce35bd95b8 upstream.

When kmem_cache_alloc_bulk() attempts to allocate N objects from a percpu
freelist of length M, and N > M > 0, it will first remove the M elements
from the percpu freelist, then call ___slab_alloc() to allocate the next
element and repopulate the percpu freelist. ___slab_alloc() can re-enable
IRQs via allocate_slab(), so the TID must be bumped before ___slab_alloc()
to properly commit the freelist head change.

Fix it by unconditionally bumping c->tid when entering the slowpath.

Cc: <email address hidden>
Fixes: ebe909e0fdb3 ("slub: improve bulk alloc strategy")
Signed-off-by: Jann Horn <email address hidden>
Signed-off-by: Linus Torvalds <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>

Signed-off-by: Khalid Elmously <email address hidden>
Signed-off-by: Kelsey Skunberg <email address hidden>

3842312... by Kees Cook

ARM: 8958/1: rename missed uaccess .fixup section

BugLink: https://bugs.launchpad.net/bugs/1868629

commit f87b1c49bc675da30d8e1e8f4b60b800312c7b90 upstream.

When the uaccess .fixup section was renamed to .text.fixup, one case was
missed. Under ld.bfd, the orphaned section was moved close to .text
(since they share the "ax" bits), so things would work normally on
uaccess faults. Under ld.lld, the orphaned section was placed outside
the .text section, making it unreachable.

Link: https://github.com/ClangBuiltLinux/linux/issues/282
Link: https://bugs.chromium.org/p/chromium/issues/detail?id=1020633#c44
Link: https://<email address hidden>
Link: https://lore.kernel.org/lkml/202002071754.F5F073F1D@keescook/

Fixes: c4a84ae39b4a5 ("ARM: 8322/1: keep .text and .fixup regions closer together")
Cc: <email address hidden>
Signed-off-by: Kees Cook <email address hidden>
Reviewed-by: Ard Biesheuvel <email address hidden>
Reviewed-by: Nick Desaulniers <email address hidden>
Signed-off-by: Russell King <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>

Signed-off-by: Khalid Elmously <email address hidden>
Signed-off-by: Kelsey Skunberg <email address hidden>

d6b0ebf... by Florian Fainelli

ARM: 8957/1: VDSO: Match ARMv8 timer in cntvct_functional()

BugLink: https://bugs.launchpad.net/bugs/1868629

commit 45939ce292b4b11159719faaf60aba7d58d5fe33 upstream.

It is possible for a system with an ARMv8 timer to run a 32-bit kernel.
When this happens we will unconditionally have the vDSO code remove the
__vdso_gettimeofday and __vdso_clock_gettime symbols because
cntvct_functional() returns false since it does not match that
compatibility string.

Fixes: ecf99a439105 ("ARM: 8331/1: VDSO initialization, mapping, and synchronization")
Signed-off-by: Florian Fainelli <email address hidden>
Signed-off-by: Russell King <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>

Signed-off-by: Khalid Elmously <email address hidden>
Signed-off-by: Kelsey Skunberg <email address hidden>

722b477... by Qian Cai <email address hidden>

jbd2: fix data races at struct journal_head

BugLink: https://bugs.launchpad.net/bugs/1868629

[ Upstream commit 6c5d911249290f41f7b50b43344a7520605b1acb ]

journal_head::b_transaction and journal_head::b_next_transaction could
be accessed concurrently as noticed by KCSAN,

 LTP: starting fsync04
 /dev/zero: Can't open blockdev
 EXT4-fs (loop0): mounting ext3 file system using the ext4 subsystem
 EXT4-fs (loop0): mounted filesystem with ordered data mode. Opts: (null)
 ==================================================================
 BUG: KCSAN: data-race in __jbd2_journal_refile_buffer [jbd2] / jbd2_write_access_granted [jbd2]

 write to 0xffff99f9b1bd0e30 of 8 bytes by task 25721 on cpu 70:
  __jbd2_journal_refile_buffer+0xdd/0x210 [jbd2]
  __jbd2_journal_refile_buffer at fs/jbd2/transaction.c:2569
  jbd2_journal_commit_transaction+0x2d15/0x3f20 [jbd2]
  (inlined by) jbd2_journal_commit_transaction at fs/jbd2/commit.c:1034
  kjournald2+0x13b/0x450 [jbd2]
  kthread+0x1cd/0x1f0
  ret_from_fork+0x27/0x50

 read to 0xffff99f9b1bd0e30 of 8 bytes by task 25724 on cpu 68:
  jbd2_write_access_granted+0x1b2/0x250 [jbd2]
  jbd2_write_access_granted at fs/jbd2/transaction.c:1155
  jbd2_journal_get_write_access+0x2c/0x60 [jbd2]
  __ext4_journal_get_write_access+0x50/0x90 [ext4]
  ext4_mb_mark_diskspace_used+0x158/0x620 [ext4]
  ext4_mb_new_blocks+0x54f/0xca0 [ext4]
  ext4_ind_map_blocks+0xc79/0x1b40 [ext4]
  ext4_map_blocks+0x3b4/0x950 [ext4]
  _ext4_get_block+0xfc/0x270 [ext4]
  ext4_get_block+0x3b/0x50 [ext4]
  __block_write_begin_int+0x22e/0xae0
  __block_write_begin+0x39/0x50
  ext4_write_begin+0x388/0xb50 [ext4]
  generic_perform_write+0x15d/0x290
  ext4_buffered_write_iter+0x11f/0x210 [ext4]
  ext4_file_write_iter+0xce/0x9e0 [ext4]
  new_sync_write+0x29c/0x3b0
  __vfs_write+0x92/0xa0
  vfs_write+0x103/0x260
  ksys_write+0x9d/0x130
  __x64_sys_write+0x4c/0x60
  do_syscall_64+0x91/0xb05
  entry_SYSCALL_64_after_hwframe+0x49/0xbe

 5 locks held by fsync04/25724:
  #0: ffff99f9911093f8 (sb_writers#13){.+.+}, at: vfs_write+0x21c/0x260
  #1: ffff99f9db4c0348 (&sb->s_type->i_mutex_key#15){+.+.}, at: ext4_buffered_write_iter+0x65/0x210 [ext4]
  #2: ffff99f5e7dfcf58 (jbd2_handle){++++}, at: start_this_handle+0x1c1/0x9d0 [jbd2]
  #3: ffff99f9db4c0168 (&ei->i_data_sem){++++}, at: ext4_map_blocks+0x176/0x950 [ext4]
  #4: ffffffff99086b40 (rcu_read_lock){....}, at: jbd2_write_access_granted+0x4e/0x250 [jbd2]
 irq event stamp: 1407125
 hardirqs last enabled at (1407125): [<ffffffff980da9b7>] __find_get_block+0x107/0x790
 hardirqs last disabled at (1407124): [<ffffffff980da8f9>] __find_get_block+0x49/0x790
 softirqs last enabled at (1405528): [<ffffffff98a0034c>] __do_softirq+0x34c/0x57c
 softirqs last disabled at (1405521): [<ffffffff97cc67a2>] irq_exit+0xa2/0xc0

 Reported by Kernel Concurrency Sanitizer on:
 CPU: 68 PID: 25724 Comm: fsync04 Tainted: G L 5.6.0-rc2-next-20200221+ #7
 Hardware name: HPE ProLiant DL385 Gen10/ProLiant DL385 Gen10, BIOS A40 07/10/2019

The plain reads are outside of jh->b_state_lock critical section which result
in data races. Fix them by adding pairs of READ|WRITE_ONCE().

Reviewed-by: Jan Kara <email address hidden>
Signed-off-by: Qian Cai <email address hidden>
Link: https://<email address hidden>
Signed-off-by: Theodore Ts'o <email address hidden>
Signed-off-by: Sasha Levin <email address hidden>
Signed-off-by: Khalid Elmously <email address hidden>
Signed-off-by: Kelsey Skunberg <email address hidden>