~cascardo/ubuntu/+source/linux/+git/xenial:stable

Last commit made on 2017-11-01
Get this branch:
git clone -b stable https://git.launchpad.net/~cascardo/ubuntu/+source/linux/+git/xenial
Only Thadeu Lima de Souza Cascardo can upload to this branch. If you are Thadeu Lima de Souza Cascardo please log in for upload directions.

Branch merges

Branch information

Recent commits

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

Linux 4.4.95

BugLink: http://bugs.launchpad.net/bugs/1729107

02ff9cd... by Eric Biggers <email address hidden>

FS-Cache: fix dereference of NULL user_key_payload

BugLink: http://bugs.launchpad.net/bugs/1729107

commit d124b2c53c7bee6569d2a2d0b18b4a1afde00134 upstream.

When the file /proc/fs/fscache/objects (available with
CONFIG_FSCACHE_OBJECT_LIST=y) is opened, we request a user key with
description "fscache:objlist", then access its payload. However, a
revoked key has a NULL payload, and we failed to check for this.
request_key() *does* skip revoked keys, but there is still a window
where the key can be revoked before we access its payload.

Fix it by checking for a NULL payload, treating it like a key which was
already revoked at the time it was requested.

Fixes: 4fbf4291aa15 ("FS-Cache: Allow the current state of all objects to be dumped")
Reviewed-by: James Morris <email address hidden>
Signed-off-by: Eric Biggers <email address hidden>
Signed-off-by: David Howells <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>

1d90431... by Eric Biggers <email address hidden>

fscrypto: require write access to mount to set encryption policy

BugLink: http://bugs.launchpad.net/bugs/1729107

commit ba63f23d69a3a10e7e527a02702023da68ef8a6d upstream.

[Please apply to 4.4-stable. Note: this was already backported, but
only to ext4; it was missed that it should go to f2fs as well. This is
needed to make xfstest generic/395 pass on f2fs.]

Since setting an encryption policy requires writing metadata to the
filesystem, it should be guarded by mnt_want_write/mnt_drop_write.
Otherwise, a user could cause a write to a frozen or readonly
filesystem. This was handled correctly by f2fs but not by ext4. Make
fscrypt_process_policy() handle it rather than relying on the filesystem
to get it right.

Signed-off-by: Eric Biggers <email address hidden>
Signed-off-by: Theodore Ts'o <email address hidden>
Acked-by: Jaegeuk Kim <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>

2fd0ed1... by David Howells

KEYS: Fix race between updating and finding a negative key

BugLink: http://bugs.launchpad.net/bugs/1729107

commit 363b02dab09b3226f3bd1420dad9c72b79a42a76 upstream.

Consolidate KEY_FLAG_INSTANTIATED, KEY_FLAG_NEGATIVE and the rejection
error into one field such that:

 (1) The instantiation state can be modified/read atomically.

 (2) The error can be accessed atomically with the state.

 (3) The error isn't stored unioned with the payload pointers.

This deals with the problem that the state is spread over three different
objects (two bits and a separate variable) and reading or updating them
atomically isn't practical, given that not only can uninstantiated keys
change into instantiated or rejected keys, but rejected keys can also turn
into instantiated keys - and someone accessing the key might not be using
any locking.

The main side effect of this problem is that what was held in the payload
may change, depending on the state. For instance, you might observe the
key to be in the rejected state. You then read the cached error, but if
the key semaphore wasn't locked, the key might've become instantiated
between the two reads - and you might now have something in hand that isn't
actually an error code.

The state is now KEY_IS_UNINSTANTIATED, KEY_IS_POSITIVE or a negative error
code if the key is negatively instantiated. The key_is_instantiated()
function is replaced with key_is_positive() to avoid confusion as negative
keys are also 'instantiated'.

Additionally, barriering is included:

 (1) Order payload-set before state-set during instantiation.

 (2) Order state-read before payload-read when using the key.

Further separate barriering is necessary if RCU is being used to access the
payload content after reading the payload pointers.

Fixes: 146aa8b1453b ("KEYS: Merge the type-specific data with the payload data")
Reported-by: Eric Biggers <email address hidden>
Signed-off-by: David Howells <email address hidden>
Reviewed-by: Eric Biggers <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>

9e55b63... by Eric Biggers <email address hidden>

fscrypt: fix dereference of NULL user_key_payload

BugLink: http://bugs.launchpad.net/bugs/1729107

commit d60b5b7854c3d135b869f74fb93eaf63cbb1991a upstream.

When an fscrypt-encrypted file is opened, we request the file's master
key from the keyrings service as a logon key, then access its payload.
However, a revoked key has a NULL payload, and we failed to check for
this. request_key() *does* skip revoked keys, but there is still a
window where the key can be revoked before we acquire its semaphore.

Fix it by checking for a NULL payload, treating it like a key which was
already revoked at the time it was requested.

Fixes: 88bd6ccdcdd6 ("ext4 crypto: add encryption key management facilities")
Reviewed-by: James Morris <email address hidden>
Cc: <email address hidden> [v4.1+]
Signed-off-by: Eric Biggers <email address hidden>
Signed-off-by: David Howells <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>

0e831c5... by Jaegeuk Kim <email address hidden>

f2fs crypto: add missing locking for keyring_key access

BugLink: http://bugs.launchpad.net/bugs/1729107

commit 745e8490b1e960ad79859dd8ba6a0b5a8d3d994e upstream.

This patch adopts:
 ext4 crypto: add missing locking for keyring_key access

Signed-off-by: Theodore Ts'o <email address hidden>
Signed-off-by: Jaegeuk Kim <email address hidden>
Signed-off-by: Eric Biggers <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>

86ef943... by Jaegeuk Kim <email address hidden>

f2fs crypto: replace some BUG_ON()'s with error checks

BugLink: http://bugs.launchpad.net/bugs/1729107

commit 66aa3e1274fcf887e9d6501a68163270fc7718e7 upstream.

This patch adopts:
 ext4 crypto: replace some BUG_ON()'s with error checks

Signed-off-by: Theodore Ts'o <email address hidden>
Signed-off-by: Jaegeuk Kim <email address hidden>
Signed-off-by: Eric Biggers <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>

a018c44... by Oleg Nesterov <email address hidden>

sched/autogroup: Fix autogroup_move_group() to never skip sched_move_task()

BugLink: http://bugs.launchpad.net/bugs/1729107

commit 18f649ef344127ef6de23a5a4272dbe2fdb73dde upstream.

The PF_EXITING check in task_wants_autogroup() is no longer needed. Remove
it, but see the next patch.

However the comment is correct in that autogroup_move_group() must always
change task_group() for every thread so the sysctl_ check is very wrong;
we can race with cgroups and even sys_setsid() is not safe because a task
running with task_group() == ag->tg must participate in refcounting:

 int main(void)
 {
  int sctl = open("/proc/sys/kernel/sched_autogroup_enabled", O_WRONLY);

  assert(sctl > 0);
  if (fork()) {
   wait(NULL); // destroy the child's ag/tg
   pause();
  }

  assert(pwrite(sctl, "1\n", 2, 0) == 2);
  assert(setsid() > 0);
  if (fork())
   pause();

  kill(getppid(), SIGKILL);
  sleep(1);

  // The child has gone, the grandchild runs with kref == 1
  assert(pwrite(sctl, "0\n", 2, 0) == 2);
  assert(setsid() > 0);

  // runs with the freed ag/tg
  for (;;)
   sleep(1);

  return 0;
 }

crashes the kernel. It doesn't really need sleep(1), it doesn't matter if
autogroup_move_group() actually frees the task_group or this happens later.

Reported-by: Vern Lovejoy <email address hidden>
Signed-off-by: Oleg Nesterov <email address hidden>
Signed-off-by: Peter Zijlstra (Intel) <email address hidden>
Cc: Linus Torvalds <email address hidden>
Cc: Mike Galbraith <email address hidden>
Cc: Peter Zijlstra <email address hidden>
Cc: Thomas Gleixner <email address hidden>
Cc: <email address hidden>
Cc: <email address hidden>
Link: http://<email address hidden>
Signed-off-by: Ingo Molnar <email address hidden>
Signed-off-by: Sumit Semwal <email address hidden>
 [sumits: submit to 4.4 LTS, post testing on Hikey]
Signed-off-by: Greg Kroah-Hartman <email address hidden>

4ee7dc6... by John David Anglin

parisc: Fix double-word compare and exchange in LWS code on 32-bit kernels

BugLink: http://bugs.launchpad.net/bugs/1729107

commit 374b3bf8e8b519f61eb9775888074c6e46b3bf0c upstream.

As discussed on the debian-hppa list, double-wordcompare and exchange
operations fail on 32-bit kernels. Looking at the code, I realized that
the ",ma" completer does the wrong thing in the "ldw,ma 4(%r26), %r29"
instruction. This increments %r26 and causes the following store to
write to the wrong location.

Note by Helge Deller:
The patch applies cleanly to stable kernel series if this upstream
commit is merged in advance:
f4125cfdb300 ("parisc: Avoid trashing sr2 and sr3 in LWS code").

Signed-off-by: John David Anglin <email address hidden>
Tested-by: Christoph Biedl <email address hidden>
Fixes: 89206491201c ("parisc: Implement new LWS CAS supporting 64 bit operations.")
Signed-off-by: Helge Deller <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>

76b692a... by John David Anglin

parisc: Avoid trashing sr2 and sr3 in LWS code

BugLink: http://bugs.launchpad.net/bugs/1729107

commit f4125cfdb3008363137f744c101e5d76ead760ba upstream.

There is no need to trash sr2 and sr3 in the Light-weight syscall (LWS). sr2
already points to kernel space (it's zero in userspace, otherwise syscalls
wouldn't work), and since the LWS code is executed in userspace, we can simply
ignore to preload sr3.

Signed-off-by: John David Anglin <email address hidden>
Signed-off-by: Helge Deller <email address hidden>
Signed-off-by: Greg Kroah-Hartman <email address hidden>