4.4.59-stable review
Greg Kroah-Hartman
maintainerPATCH 3/14 xfrm_user: validate XFRM_MSG_NEWAE incoming ESN size harder
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Whitcroft <[email protected]>
commit f843ee6dd019bcece3e74e76ad9df0155655d0df upstream.
Kees Cook has pointed out that xfrm_replay_state_esn_len() is subject to wrapping issues. To ensure we are correctly ensuring that the two ESN structures are the same size compare both the overall size as reported by xfrm_replay_state_esn_len() and the internal length are the same.
CVE-2017-7184
--- net/xfrm/xfrm_user.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/xfrm/xfrm_user.c +5 -1
@@ -412,7 +412,11 @@ static inline int xfrm_replay_verify_len up =nla_data (rp); ulen =xfrm_replay_state_esn_len (up); -if (nla_len (rp) < ulen ||xfrm_replay_state_esn_len (replay_esn) != ulen) +/* Check the overall length and the internal bitmap length to avoid +* potential overflow. */ +if (nla_len (rp) < ulen || +xfrm_replay_state_esn_len (replay_esn) != ulen || + replay_esn->bmp_len != up->bmp_len)return -EINVAL ;if (up->replay_window > up->bmp_len *sizeof (__u32) *8 )
Greg Kroah-Hartman
maintainerPATCH 5/14 pinctrl: qcom: Dont clear status bit on irq_unmask
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Andersson <[email protected]>
commit a6566710adaa4a7dd5e0d99820ff9c9c30ee5951 upstream.
Clearing the status bit on irq_unmask will discard any pending interrupt that did arrive after the irq_ack, i.e. while the IRQ handler function was executing.
--- drivers/pinctrl/qcom/pinctrl-msm.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/pinctrl/qcom/pinctrl-msm.c +0 -4
@@ -597,10 +597,6 @@ static void msm_gpio_irq_unmask(struct ispin_lock_irqsave (&pctrl->lock, flags); - val =readl (pctrl->regs + g->intr_status_reg); - val &= ~BIT (g->intr_status_bit); -writel (val, pctrl->regs + g->intr_status_reg); - val =readl (pctrl->regs + g->intr_cfg_reg); val |=BIT (g->intr_enable_bit);writel (val, pctrl->regs + g->intr_cfg_reg);
Greg Kroah-Hartman
maintainerPATCH 6/14 c6x/ptrace: Remove useless PTRACE_SETREGSET implementation
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit fb411b837b587a32046dc4f369acb93a10b1def8 upstream.
gpr_set won't work correctly and can never have been tested, and the correct behaviour is not clear due to the endianness-dependent task layout.
So, just remove it. The core code will now return -EOPNOTSUPPORT when trying to set NT_PRSTATUS on this architecture until/unless a correct implementation is supplied.
--- arch/c6x/kernel/ptrace.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-)
arch/c6x/kernel/ptrace.c +0 -41
@@ -69,46 +69,6 @@ static int gpr_get(struct task_struct *t 0, sizeof(*regs)); } -static int gpr_set (struct task_struct *target, -const struct user_regset *regset, -unsigned int pos,unsigned int count, -const void *kbuf,const void __user *ubuf) -{ -int ret; -struct pt_regs *regs =task_pt_regs (target); - -/* Don't copyin TSR or CSR */ - ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, - ®s, -0 ,PT_TSR *sizeof (long )); -if (ret) -return ret; - - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, -PT_TSR *sizeof (long ), - (PT_TSR +1 ) *sizeof (long )); -if (ret) -return ret; - - ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, - ®s, - (PT_TSR +1 ) *sizeof (long ), -PT_CSR *sizeof (long )); -if (ret) -return ret; - - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, -PT_CSR *sizeof (long ), - (PT_CSR +1 ) *sizeof (long )); -if (ret) -return ret; - - ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, - ®s, - (PT_CSR +1 ) *sizeof (long ),-1 ); -return ret; -} -enum c6x_regset {REGSET_GPR , };
@@ -120,7 +80,6 @@ static const struct user_regset c6x_regs .size = sizeof(u32), .align = sizeof(u32), .get = gpr_get, - .set = gpr_set }, };
Greg Kroah-Hartman
maintainerPATCH 7/14 h8300/ptrace: Fix incorrect register transfer count
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit 502585c7555083d4a949c08350306b9ec196779e upstream.
regs_set() and regs_get() are vulnerable to an off-by-1 buffer overrun if CONFIG_CPU_H8S is set, since this adds an extra entry to register_offset[] but not to user_regs_struct.
So, iterate over user_regs_struct based on its actual size, not based on the length of register_offset[].
--- arch/h8300/kernel/ptrace.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/h8300/kernel/ptrace.c +5 -3
@@ -95,7 +95,8 @@ static int regs_get(struct task_struct *long *reg = (long *)®s;/* build user regs in buffer */ -for (r =0 ; r <ARRAY_SIZE (register_offset); r++) +BUILD_BUG_ON (sizeof (regs) %sizeof (long ) !=0 ); +for (r =0 ; r <sizeof (regs) /sizeof (long ); r++) *reg++ =h8300_get_reg (target, r); return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
@@ -113,7 +114,8 @@ static int regs_set(struct task_struct *long *reg;/* build user regs in buffer */ -for (reg = (long *)®s, r =0 ; r <ARRAY_SIZE (register_offset); r++) +BUILD_BUG_ON (sizeof (regs) %sizeof (long ) !=0 ); +for (reg = (long *)®s, r =0 ; r <sizeof (regs) /sizeof (long ); r++) *reg++ =h8300_get_reg (target, r); ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
@@ -122,7 +124,7 @@ static int regs_set(struct task_struct *return ret;/* write back to pt_regs */ -for (reg = (long *)®s, r =0 ; r <ARRAY_SIZE (register_offset); r++) +for (reg = (long *)®s, r =0 ; r <sizeof (regs) /sizeof (long ); r++)h8300_put_reg (target, r, *reg++);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 9/14 sparc/ptrace: Preserve previous registers for short regset write
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit d3805c546b275c8cc7d40f759d029ae92c7175f2 upstream.
Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET to fill all the registers, the thread's old registers are preserved.
--- arch/sparc/kernel/ptrace_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/ptrace_64.c +1 -1
@@ -311,7 +311,7 @@ static int genregs64_set(struct task_str }if (!ret) { -unsigned long y; +unsigned long y = regs->y; ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &y,
Greg Kroah-Hartman
maintainerPATCH 10/14 metag/ptrace: Preserve previous registers for short regset write
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit a78ce80d2c9178351b34d78fec805140c29c193e upstream.
Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET to fill all the registers, the thread's old registers are preserved.
--- arch/metag/kernel/ptrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/metag/kernel/ptrace.c +1 -1
@@ -303,7 +303,7 @@ static int metag_tls_set(struct task_str const void *kbuf, const void __user *ubuf) { int ret; -void __user *tls; +void __user *tls = target->thread.tls_ptr; ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, &tls,0 ,-1 );if (ret)
Greg Kroah-Hartman
maintainerPATCH 12/14 metag/ptrace: Reject partial NT_METAG_RPIPE writes
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit 7195ee3120d878259e8d94a5d9f808116f34d5ea upstream.
It's not clear what behaviour is sensible when doing partial write of NT_METAG_RPIPE, so just don't bother.
This patch assumes that userspace will never rely on a partial SETREGSET in this case, since it's not clear what should happen anyway.
--- arch/metag/kernel/ptrace.c | 2 ++ 1 file changed, 2 insertions(+)
arch/metag/kernel/ptrace.c +2 -0
@@ -253,6 +253,8 @@ int metag_rp_state_copyin(struct pt_regsunsigned long long *ptr;int ret, i; +if (count <4 *13 ) +return -EINVAL ;/* Read the entire pipeline before making any changes */ ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, &rp,0 ,4 *13 );
Greg Kroah-Hartman
maintainerPATCH 14/14 sched/rt: Add a missing rescheduling point
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
commit 619bd4a71874a8fd78eb6ccf9f272c5e98bcc7b7 upstream.
Since the change in commit:
fd7a4bed1835 ("sched, rt: Convert switched_{from, to}_rt() / prio_changed_rt() to balance callbacks")
... we don't reschedule a task under certain circumstances:
Lets say task-A, SCHED_OTHER, is running on CPU0 (and it may run only on CPU0) and holds a PI lock. This task is removed from the CPU because it used up its time slice and another SCHED_OTHER task is running. Task-B on CPU1 runs at RT priority and asks for the lock owned by task-A. This results in a priority boost for task-A. Task-B goes to sleep until the lock has been made available. Task-A is already runnable (but not active), so it receives no wake up.
The reality now is that task-A gets on the CPU once the scheduler decides to remove the current task despite the fact that a high priority task is enqueued and waiting. This may take a long time.
The desired behaviour is that CPU0 immediately reschedules after the priority boost which made task-A the task with the lowest priority.
--- kernel/sched/deadline.c | 3 +-- kernel/sched/rt.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
kernel/sched/deadline.c +1 -2
@@ -1771,12 +1771,11 @@ static void switched_to_dl(struct rq *rq#ifdef CONFIG_SMP if (p->nr_cpus_allowed >1 && rq->dl.overloaded)queue_push_tasks (rq); -#else +#endif if (dl_task (rq->curr))check_preempt_curr_dl (rq, p,0 );else resched_curr (rq); -#endif } }
kernel/sched/rt.c +1 -2
@@ -2136,10 +2136,9 @@ static void switched_to_rt(struct rq *rq#ifdef CONFIG_SMP if (p->nr_cpus_allowed >1 && rq->rt.overloaded)queue_push_tasks (rq); -#else +#endif /* CONFIG_SMP */ if (p->prio < rq->curr->prio)resched_curr (rq); -#endif /* CONFIG_SMP */ } }
Greg Kroah-Hartman
maintainercover 4.4.59-stable review
This is the start of the stable review cycle for the 4.4.59 release. There are 14 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat Apr 1 09:49:26 UTC 2017. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.59-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.4.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.4.59-rc1
Sebastian Andrzej Siewior <[email protected]>
sched/rt: Add a missing rescheduling point
Eric Biggers <[email protected]>
fscrypt: remove broken support for detecting keyring key revocation
Dave Martin <[email protected]>
metag/ptrace: Reject partial NT_METAG_RPIPE writes
Dave Martin <[email protected]>
metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS
Dave Martin <[email protected]>
metag/ptrace: Preserve previous registers for short regset write
Dave Martin <[email protected]>
sparc/ptrace: Preserve previous registers for short regset write
Dave Martin <[email protected]>
mips/ptrace: Preserve previous registers for short regset write
Dave Martin <[email protected]>
h8300/ptrace: Fix incorrect register transfer count
Dave Martin <[email protected]>
c6x/ptrace: Remove useless PTRACE_SETREGSET implementation
Bjorn Andersson <[email protected]>
pinctrl: qcom: Don't clear status bit on irq_unmask
Ladi Prosek <[email protected]>
virtio_balloon: init 1st buffer in stats vq
Andy Whitcroft <[email protected]>
xfrm_user: validate XFRM_MSG_NEWAE incoming ESN size harder
Andy Whitcroft <[email protected]>
xfrm_user: validate XFRM_MSG_NEWAE XFRMA_REPLAY_ESN_VAL replay_window
Florian Westphal <[email protected]>
xfrm: policy: init locks early
-------------
Diffstat:
Makefile | 4 ++-- arch/c6x/kernel/ptrace.c | 41 -------------------------------------- arch/h8300/kernel/ptrace.c | 8 +++++--- arch/metag/kernel/ptrace.c | 19 ++++++++++++++---- arch/mips/kernel/ptrace.c | 3 ++- arch/sparc/kernel/ptrace_64.c | 2 +- drivers/pinctrl/qcom/pinctrl-msm.c | 4 ---- drivers/virtio/virtio_balloon.c | 2 ++ fs/ext4/crypto_key.c | 28 +++++++------------------- fs/ext4/ext4.h | 14 +------------ fs/ext4/ext4_crypto.h | 1 - fs/f2fs/crypto_key.c | 28 +++++++------------------- fs/f2fs/f2fs.h | 14 +------------ fs/f2fs/f2fs_crypto.h | 1 - kernel/sched/deadline.c | 3 +-- kernel/sched/rt.c | 3 +-- net/xfrm/xfrm_policy.c | 10 +++++----- net/xfrm/xfrm_user.c | 9 ++++++++- 18 files changed, 58 insertions(+), 136 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/14 xfrm: policy: init locks early
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit c282222a45cb9503cbfbebfdb60491f06ae84b49 upstream.
Dmitry reports following splat:
INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.
CPU: 0 PID: 13059 Comm: syz-executor1 Not tainted 4.10.0-rc7-next-20170207 #1 [..] spin_lock_bh include/linux/spinlock.h:304 [inline] xfrm_policy_flush+0x32/0x470 net/xfrm/xfrm_policy.c:963 xfrm_policy_fini+0xbf/0x560 net/xfrm/xfrm_policy.c:3041 xfrm_net_init+0x79f/0x9e0 net/xfrm/xfrm_policy.c:3091 ops_init+0x10a/0x530 net/core/net_namespace.c:115 setup_net+0x2ed/0x690 net/core/net_namespace.c:291 copy_net_ns+0x26c/0x530 net/core/net_namespace.c:396 create_new_namespaces+0x409/0x860 kernel/nsproxy.c:106 unshare_nsproxy_namespaces+0xae/0x1e0 kernel/nsproxy.c:205 SYSC_unshare kernel/fork.c:2281 [inline]
Problem is that when we get error during xfrm_net_init we will call xfrm_policy_fini which will acquire xfrm_policy_lock before it was initialized. Just move it around so locks get set up first.
--- net/xfrm/xfrm_policy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/xfrm/xfrm_policy.c +5 -5
@@ -3030,6 +3030,11 @@ static int __net_init xfrm_net_init(stru {int rv; +/* Initialize the per-net locks here */ +spin_lock_init (&net->xfrm.xfrm_state_lock); +rwlock_init (&net->xfrm.xfrm_policy_lock); +mutex_init (&net->xfrm.xfrm_cfg_mutex); + rv =xfrm_statistics_init (net);if (rv <0 ) goto out_statistics;
@@ -3046,11 +3051,6 @@ static int __net_init xfrm_net_init(struif (rv <0 ) goto out; -/* Initialize the per-net locks here */ -spin_lock_init (&net->xfrm.xfrm_state_lock); -rwlock_init (&net->xfrm.xfrm_policy_lock); -mutex_init (&net->xfrm.xfrm_cfg_mutex); -return 0 ; out:
Greg Kroah-Hartman
maintainerPATCH 2/14 xfrm_user: validate XFRM_MSG_NEWAE XFRMA_REPLAY_ESN_VAL replay_window
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Whitcroft <[email protected]>
commit 677e806da4d916052585301785d847c3b3e6186a upstream.
When a new xfrm state is created during an XFRM_MSG_NEWSA call we validate the user supplied replay_esn to ensure that the size is valid and to ensure that the replay_window size is within the allocated buffer. However later it is possible to update this replay_esn via a XFRM_MSG_NEWAE call. There we again validate the size of the supplied buffer matches the existing state and if so inject the contents. We do not at this point check that the replay_window is within the allocated memory. This leads to out-of-bounds reads and writes triggered by netlink packets. This leads to memory corruption and the potential for priviledge escalation.
We already attempt to validate the incoming replay information in xfrm_new_ae() via xfrm_replay_verify_len(). This confirms that the user is not trying to change the size of the replay state buffer which includes the replay_esn. It however does not check the replay_window remains within that buffer. Add validation of the contained replay_window.
CVE-2017-7184
--- net/xfrm/xfrm_user.c | 3 +++ 1 file changed, 3 insertions(+)
net/xfrm/xfrm_user.c +3 -0
@@ -415,6 +415,9 @@ static inline int xfrm_replay_verify_lenif (nla_len (rp) < ulen ||xfrm_replay_state_esn_len (replay_esn) != ulen)return -EINVAL ; +if (up->replay_window > up->bmp_len *sizeof (__u32) *8 ) +return -EINVAL ; +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 4/14 virtio_balloon: init 1st buffer in stats vq
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ladi Prosek <[email protected]>
commit fc8653228c8588a120f6b5dad6983b7b61ff669e upstream.
When init_vqs runs, virtio_balloon.stats is either uninitialized or contains stale values. The host updates its state with garbage data because it has no way of knowing that this is just a marker buffer used for signaling.
This patch updates the stats before pushing the initial buffer.
Alternative fixes:
* Push an empty buffer in init_vqs. Not easily done with the current virtio implementation and violates the spec "Driver MUST supply the same subset of statistics in all buffers submitted to the statsq".
* Push a buffer with invalid tags in init_vqs. Violates the same spec clause, plus "invalid tag" is not really defined.
Note: the spec says:
When using the legacy interface, the device SHOULD ignore all values in the first buffer in the statsq supplied by the driver after device initialization. Note: Historically, drivers supplied an uninitialized buffer in the first buffer.
Unfortunately QEMU does not seem to implement the recommendation even for the legacy interface.
--- drivers/virtio/virtio_balloon.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/virtio/virtio_balloon.c +2 -0
@@ -416,6 +416,8 @@ static int init_vqs(struct virtio_balloo* Prime this virtqueue with one buffer so the hypervisor can * use it to signal us later (it can't be broken yet!). */ +update_balloon_stats (vb); +sg_init_one (&sg, vb->stats,sizeof vb->stats);if (virtqueue_add_outbuf (vb->stats_vq, &sg,1 , vb,GFP_KERNEL ) <0 )
Greg Kroah-Hartman
maintainerPATCH 8/14 mips/ptrace: Preserve previous registers for short regset write
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit d614fd58a2834cfe4efa472c33c8f3ce2338b09b upstream.
Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET to fill all the registers, the thread's old registers are preserved.
--- arch/mips/kernel/ptrace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/kernel/ptrace.c +2 -1
@@ -485,7 +485,8 @@ static int fpr_set(struct task_struct *t &target->thread.fpu, 0, sizeof(elf_fpregset_t)); -for (i =0 ; i <NUM_FPU_REGS ; i++) { +BUILD_BUG_ON (sizeof (fpr_val) !=sizeof (elf_fpreg_t)); +for (i =0 ; i <NUM_FPU_REGS && count >=sizeof (elf_fpreg_t); i++) { err =user_regset_copyin (&pos, &count, &kbuf, &ubuf, &fpr_val, i *sizeof (elf_fpreg_t), (i +1 ) *sizeof (elf_fpreg_t));
Greg Kroah-Hartman
maintainerPATCH 13/14 fscrypt: remove broken support for detecting keyring key revocation
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 1b53cf9815bb4744958d41f3795d5d5a1d365e2d upstream.
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.
--- fs/ext4/crypto_key.c | 28 +++++++--------------------- fs/ext4/ext4.h | 14 +------------- fs/ext4/ext4_crypto.h | 1 - fs/f2fs/crypto_key.c | 28 +++++++--------------------- fs/f2fs/f2fs.h | 14 +------------- fs/f2fs/f2fs_crypto.h | 1 - 6 files changed, 16 insertions(+), 70 deletions(-)
fs/ext4/crypto_key.c +7 -21
@@ -88,8 +88,6 @@ void ext4_free_crypt_info(struct ext4_crif (!ci)return ; -if (ci->ci_keyring_key) -key_put (ci->ci_keyring_key);crypto_free_ablkcipher (ci->ci_ctfm);kmem_cache_free (ext4_crypt_info_cachep, ci); }
@@ -111,7 +109,7 @@ void ext4_free_encryption_info(struct inext4_free_crypt_info (ci); } -int _ext4_get_encryption_info (struct inode *inode) +int ext4_get_encryption_info (struct inode *inode) {struct ext4_inode_info *ei =EXT4_I (inode);struct ext4_crypt_info *crypt_info;
@@ -128,22 +126,15 @@ int _ext4_get_encryption_info(struct inochar mode;int res; +if (ei->i_crypt_info) +return 0 ; +if (!ext4_read_workqueue) { res =ext4_init_crypto ();if (res)return res; } -retry: - crypt_info =ACCESS_ONCE (ei->i_crypt_info); -if (crypt_info) { -if (!crypt_info->ci_keyring_key || -key_validate (crypt_info->ci_keyring_key) ==0 ) -return 0 ; -ext4_free_encryption_info (inode, crypt_info); - goto retry; - } - res =ext4_xattr_get (inode,EXT4_XATTR_INDEX_ENCRYPTION ,EXT4_XATTR_NAME_ENCRYPTION_CONTEXT , &ctx,sizeof (ctx));
@@ -166,7 +157,6 @@ retry: crypt_info->ci_data_mode = ctx.contents_encryption_mode; crypt_info->ci_filename_mode = ctx.filenames_encryption_mode; crypt_info->ci_ctfm =NULL ; - crypt_info->ci_keyring_key =NULL ;memcpy (crypt_info->ci_master_key, ctx.master_key_descriptor,sizeof (crypt_info->ci_master_key));if (S_ISREG (inode->i_mode))
@@ -206,7 +196,6 @@ retry: keyring_key =NULL ; goto out; } - crypt_info->ci_keyring_key = keyring_key;if (keyring_key->type != &key_type_logon) {printk_once (KERN_WARNING "ext4: key type must be logon\n" );
@@ -253,16 +242,13 @@ got_key: ext4_encryption_key_size(mode));if (res) goto out; -memzero_explicit (raw_key,sizeof (raw_key)); -if (cmpxchg (&ei->i_crypt_info,NULL , crypt_info) !=NULL ) { -ext4_free_crypt_info (crypt_info); - goto retry; - } -return 0 ; +if (cmpxchg (&ei->i_crypt_info,NULL , crypt_info) ==NULL ) + crypt_info =NULL ; out:if (res == -ENOKEY ) res =0 ; +key_put (keyring_key);ext4_free_crypt_info (crypt_info);memzero_explicit (raw_key,sizeof (raw_key));return res;
fs/ext4/ext4.h +1 -13
@@ -2330,23 +2330,11 @@ static inline void ext4_fname_free_filen/* crypto_key.c */ void ext4_free_crypt_info (struct ext4_crypt_info *ci);void ext4_free_encryption_info (struct inode *inode,struct ext4_crypt_info *ci); -int _ext4_get_encryption_info (struct inode *inode);#ifdef CONFIG_EXT4_FS_ENCRYPTION int ext4_has_encryption_key (struct inode *inode); -static inline int ext4_get_encryption_info (struct inode *inode) -{ -struct ext4_crypt_info *ci =EXT4_I (inode)->i_crypt_info; - -if (!ci || - (ci->ci_keyring_key && - (ci->ci_keyring_key->flags & ((1 <<KEY_FLAG_INVALIDATED ) | - (1 <<KEY_FLAG_REVOKED ) | - (1 <<KEY_FLAG_DEAD ))))) -return _ext4_get_encryption_info (inode); -return 0 ; -} +int ext4_get_encryption_info (struct inode *inode);static inline struct ext4_crypt_info *ext4_encryption_info (struct inode *inode) {
fs/ext4/ext4_crypto.h +0 -1
@@ -78,7 +78,6 @@ struct ext4_crypt_info {char ci_filename_mode;char ci_flags;struct crypto_ablkcipher *ci_ctfm; -struct key *ci_keyring_key;char ci_master_key[EXT4_KEY_DESCRIPTOR_SIZE ]; };
fs/f2fs/crypto_key.c +7 -21
@@ -92,7 +92,6 @@ static void f2fs_free_crypt_info(structif (!ci)return ; -key_put (ci->ci_keyring_key);crypto_free_ablkcipher (ci->ci_ctfm);kmem_cache_free (f2fs_crypt_info_cachep, ci); }
@@ -113,7 +112,7 @@ void f2fs_free_encryption_info(struct inf2fs_free_crypt_info (ci); } -int _f2fs_get_encryption_info (struct inode *inode) +int f2fs_get_encryption_info (struct inode *inode) {struct f2fs_inode_info *fi =F2FS_I (inode);struct f2fs_crypt_info *crypt_info;
@@ -129,18 +128,12 @@ int _f2fs_get_encryption_info(struct inochar mode;int res; +if (fi->i_crypt_info) +return 0 ; + res =f2fs_crypto_initialize ();if (res)return res; -retry: - crypt_info =ACCESS_ONCE (fi->i_crypt_info); -if (crypt_info) { -if (!crypt_info->ci_keyring_key || -key_validate (crypt_info->ci_keyring_key) ==0 ) -return 0 ; -f2fs_free_encryption_info (inode, crypt_info); - goto retry; - } res = f2fs_getxattr(inode, F2FS_XATTR_INDEX_ENCRYPTION, F2FS_XATTR_NAME_ENCRYPTION_CONTEXT,
@@ -159,7 +152,6 @@ retry: crypt_info->ci_data_mode = ctx.contents_encryption_mode; crypt_info->ci_filename_mode = ctx.filenames_encryption_mode; crypt_info->ci_ctfm =NULL ; - crypt_info->ci_keyring_key =NULL ;memcpy (crypt_info->ci_master_key, ctx.master_key_descriptor,sizeof (crypt_info->ci_master_key));if (S_ISREG (inode->i_mode))
@@ -197,7 +189,6 @@ retry: keyring_key =NULL ; goto out; } - crypt_info->ci_keyring_key = keyring_key;BUG_ON (keyring_key->type != &key_type_logon); ukp =user_key_payload (keyring_key);if (ukp->datalen !=sizeof (struct f2fs_encryption_key )) {
@@ -230,17 +221,12 @@ retry:if (res) goto out; -memzero_explicit (raw_key,sizeof (raw_key)); -if (cmpxchg (&fi->i_crypt_info,NULL , crypt_info) !=NULL ) { -f2fs_free_crypt_info (crypt_info); - goto retry; - } -return 0 ; - +if (cmpxchg (&fi->i_crypt_info,NULL , crypt_info) ==NULL ) + crypt_info =NULL ; out:if (res == -ENOKEY && !S_ISREG (inode->i_mode)) res =0 ; - +key_put (keyring_key);f2fs_free_crypt_info (crypt_info);memzero_explicit (raw_key,sizeof (raw_key));return res;
fs/f2fs/f2fs.h +1 -13
@@ -2149,7 +2149,6 @@ void f2fs_end_io_crypto_work(struct f2fs/* crypto_key.c */ void f2fs_free_encryption_info (struct inode *,struct f2fs_crypt_info *); -int _f2fs_get_encryption_info (struct inode *inode);/* crypto_fname.c */ bool f2fs_valid_filenames_enc_mode (uint32_t );
@@ -2170,18 +2169,7 @@ void f2fs_exit_crypto(void);int f2fs_has_encryption_key (struct inode *); -static inline int f2fs_get_encryption_info (struct inode *inode) -{ -struct f2fs_crypt_info *ci =F2FS_I (inode)->i_crypt_info; - -if (!ci || - (ci->ci_keyring_key && - (ci->ci_keyring_key->flags & ((1 <<KEY_FLAG_INVALIDATED ) | - (1 <<KEY_FLAG_REVOKED ) | - (1 <<KEY_FLAG_DEAD ))))) -return _f2fs_get_encryption_info (inode); -return 0 ; -} +int f2fs_get_encryption_info (struct inode *inode);void f2fs_fname_crypto_free_buffer (struct f2fs_str *); int f2fs_fname_setup_filename(struct inode *, const struct qstr *,
fs/f2fs/f2fs_crypto.h +0 -1
@@ -79,7 +79,6 @@ struct f2fs_crypt_info {char ci_filename_mode;char ci_flags;struct crypto_ablkcipher *ci_ctfm; -struct key *ci_keyring_key;char ci_master_key[F2FS_KEY_DESCRIPTOR_SIZE ]; };
Greg Kroah-Hartman
maintainerPATCH 11/14 metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS
In reply to Greg Kroah-Hartman4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit 5fe81fe98123ce41265c65e95d34418d30d005d1 upstream.
Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET to fill TXSTATUS, a well-defined default value is used, based on the task's current value.
--- arch/metag/kernel/ptrace.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
arch/metag/kernel/ptrace.c +12 -3
@@ -24,6 +24,16 @@* user_regset definitions. */ +static unsigned long user_txstatus (const struct pt_regs *regs) +{ +unsigned long data = (unsigned long )regs->ctx.Flags; + +if (regs->ctx.SaveMask &TBICTX_CBUF_BIT ) + data |=USER_GP_REGS_STATUS_CATCH_BIT ; + +return data; +} +int metag_gp_regs_copyout (const struct pt_regs *regs,unsigned int pos,unsigned int count,void *kbuf,void __user *ubuf)
@@ -62,9 +72,7 @@ int metag_gp_regs_copyout(const struct pif (ret) goto out;/* TXSTATUS */ - data = (unsigned long )regs->ctx.Flags; -if (regs->ctx.SaveMask &TBICTX_CBUF_BIT ) - data |=USER_GP_REGS_STATUS_CATCH_BIT ; + data =user_txstatus (regs); ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, &data,4 *25 ,4 *26 );if (ret)
@@ -119,6 +127,7 @@ int metag_gp_regs_copyin(struct pt_regsif (ret) goto out;/* TXSTATUS */ + data =user_txstatus (regs); ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, &data,4 *25 ,4 *26 );if (ret)
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.59 release. There are 14 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat Apr 1 09:49:26 UTC 2017. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.59-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.4.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.4.59 release. There are 14 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat Apr 1 09:49:26 UTC 2017. Anything received after that time might be too late.
Build results:
total: 149 pass: 149 fail: 0 Qemu test results: total: 115 pass: 115 fail: 0
Details are available at http://kerneltests.org/builders.
Guenter