Merge 4.9.48 into android-4.9

Changes in 4.9.48
	irqchip: mips-gic: SYNC after enabling GIC region
	i2c: ismt: Don't duplicate the receive length for block reads
	i2c: ismt: Return EMSGSIZE for block reads with bogus length
	crypto: algif_skcipher - only call put_page on referenced and used pages
	mm, uprobes: fix multiple free of ->uprobes_state.xol_area
	mm, madvise: ensure poisoned pages are removed from per-cpu lists
	ceph: fix readpage from fscache
	cpumask: fix spurious cpumask_of_node() on non-NUMA multi-node configs
	cpuset: Fix incorrect memory_pressure control file mapping
	alpha: uapi: Add support for __SANE_USERSPACE_TYPES__
	CIFS: Fix maximum SMB2 header size
	CIFS: remove endian related sparse warning
	wl1251: add a missing spin_lock_init()
	lib/mpi: kunmap after finishing accessing buffer
	xfrm: policy: check policy direction value
	drm/ttm: Fix accounting error when fail to get pages for pool
	kvm: arm/arm64: Force reading uncached stage2 PGD
	epoll: fix race between ep_poll_callback(POLLFREE) and ep_free()/ep_remove()
	Linux 4.9.48

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2017-09-07 10:32:23 +02:00
21 changed files with 108 additions and 51 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
VERSION = 4 VERSION = 4
PATCHLEVEL = 9 PATCHLEVEL = 9
SUBLEVEL = 47 SUBLEVEL = 48
EXTRAVERSION = EXTRAVERSION =
NAME = Roaring Lionus NAME = Roaring Lionus
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef _ALPHA_TYPES_H #ifndef _ALPHA_TYPES_H
#define _ALPHA_TYPES_H #define _ALPHA_TYPES_H
#include <asm-generic/int-ll64.h> #include <uapi/asm/types.h>
#endif /* _ALPHA_TYPES_H */ #endif /* _ALPHA_TYPES_H */
+11 -1
View File
@@ -9,8 +9,18 @@
* need to be careful to avoid a name clashes. * need to be careful to avoid a name clashes.
*/ */
#ifndef __KERNEL__ /*
* This is here because we used to use l64 for alpha
* and we don't want to impact user mode with our change to ll64
* in the kernel.
*
* However, some user programs are fine with this. They can
* flag __SANE_USERSPACE_TYPES__ to get int-ll64.h here.
*/
#if !defined(__SANE_USERSPACE_TYPES__) && !defined(__KERNEL__)
#include <asm-generic/int-l64.h> #include <asm-generic/int-l64.h>
#else
#include <asm-generic/int-ll64.h>
#endif #endif
#endif /* _UAPI_ALPHA_TYPES_H */ #endif /* _UAPI_ALPHA_TYPES_H */
+1 -1
View File
@@ -837,7 +837,7 @@ void kvm_free_stage2_pgd(struct kvm *kvm)
spin_lock(&kvm->mmu_lock); spin_lock(&kvm->mmu_lock);
if (kvm->arch.pgd) { if (kvm->arch.pgd) {
unmap_stage2_range(kvm, 0, KVM_PHYS_SIZE); unmap_stage2_range(kvm, 0, KVM_PHYS_SIZE);
pgd = kvm->arch.pgd; pgd = READ_ONCE(kvm->arch.pgd);
kvm->arch.pgd = NULL; kvm->arch.pgd = NULL;
} }
spin_unlock(&kvm->mmu_lock); spin_unlock(&kvm->mmu_lock);
+7 -2
View File
@@ -86,8 +86,13 @@ static void skcipher_free_async_sgls(struct skcipher_async_req *sreq)
} }
sgl = sreq->tsg; sgl = sreq->tsg;
n = sg_nents(sgl); n = sg_nents(sgl);
for_each_sg(sgl, sg, n, i) for_each_sg(sgl, sg, n, i) {
put_page(sg_page(sg)); struct page *page = sg_page(sg);
/* some SGs may not have a page mapped */
if (page && page_ref_count(page))
put_page(page);
}
kfree(sreq->tsg); kfree(sreq->tsg);
} }
+1 -1
View File
@@ -612,7 +612,7 @@ static void ttm_page_pool_fill_locked(struct ttm_page_pool *pool,
} else { } else {
pr_err("Failed to fill pool (%p)\n", pool); pr_err("Failed to fill pool (%p)\n", pool);
/* If we have any pages left put them to the pool. */ /* If we have any pages left put them to the pool. */
list_for_each_entry(p, &pool->list, lru) { list_for_each_entry(p, &new_pages, lru) {
++cpages; ++cpages;
} }
list_splice(&new_pages, &pool->list); list_splice(&new_pages, &pool->list);
+4 -2
View File
@@ -341,8 +341,10 @@ static int ismt_process_desc(const struct ismt_desc *desc,
break; break;
case I2C_SMBUS_BLOCK_DATA: case I2C_SMBUS_BLOCK_DATA:
case I2C_SMBUS_I2C_BLOCK_DATA: case I2C_SMBUS_I2C_BLOCK_DATA:
memcpy(&data->block[1], dma_buffer, desc->rxbytes); if (desc->rxbytes != dma_buffer[0] + 1)
data->block[0] = desc->rxbytes; return -EMSGSIZE;
memcpy(data->block, dma_buffer, desc->rxbytes);
break; break;
} }
return 0; return 0;
+4 -1
View File
@@ -1115,8 +1115,11 @@ static int __init gic_of_init(struct device_node *node,
gic_len = resource_size(&res); gic_len = resource_size(&res);
} }
if (mips_cm_present()) if (mips_cm_present()) {
write_gcr_gic_base(gic_base | CM_GCR_GIC_BASE_GICEN_MSK); write_gcr_gic_base(gic_base | CM_GCR_GIC_BASE_GICEN_MSK);
/* Ensure GIC region is enabled before trying to access it */
__sync();
}
gic_present = true; gic_present = true;
__gic_init(gic_base, gic_len, cpu_vec, 0, node); __gic_init(gic_base, gic_len, cpu_vec, 0, node);
+1
View File
@@ -1571,6 +1571,7 @@ struct ieee80211_hw *wl1251_alloc_hw(void)
wl->state = WL1251_STATE_OFF; wl->state = WL1251_STATE_OFF;
mutex_init(&wl->mutex); mutex_init(&wl->mutex);
spin_lock_init(&wl->wl_lock);
wl->tx_mgmt_frm_rate = DEFAULT_HW_GEN_TX_RATE; wl->tx_mgmt_frm_rate = DEFAULT_HW_GEN_TX_RATE;
wl->tx_mgmt_frm_mod = DEFAULT_HW_GEN_MODULATION_TYPE; wl->tx_mgmt_frm_mod = DEFAULT_HW_GEN_MODULATION_TYPE;
+15 -9
View File
@@ -188,7 +188,7 @@ static int ceph_releasepage(struct page *page, gfp_t g)
/* /*
* read a single page, without unlocking it. * read a single page, without unlocking it.
*/ */
static int readpage_nounlock(struct file *filp, struct page *page) static int ceph_do_readpage(struct file *filp, struct page *page)
{ {
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(filp);
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
@@ -218,7 +218,7 @@ static int readpage_nounlock(struct file *filp, struct page *page)
err = ceph_readpage_from_fscache(inode, page); err = ceph_readpage_from_fscache(inode, page);
if (err == 0) if (err == 0)
goto out; return -EINPROGRESS;
dout("readpage inode %p file %p page %p index %lu\n", dout("readpage inode %p file %p page %p index %lu\n",
inode, filp, page, page->index); inode, filp, page, page->index);
@@ -248,8 +248,11 @@ out:
static int ceph_readpage(struct file *filp, struct page *page) static int ceph_readpage(struct file *filp, struct page *page)
{ {
int r = readpage_nounlock(filp, page); int r = ceph_do_readpage(filp, page);
unlock_page(page); if (r != -EINPROGRESS)
unlock_page(page);
else
r = 0;
return r; return r;
} }
@@ -1235,7 +1238,7 @@ retry_locked:
goto retry_locked; goto retry_locked;
r = writepage_nounlock(page, NULL); r = writepage_nounlock(page, NULL);
if (r < 0) if (r < 0)
goto fail_nosnap; goto fail_unlock;
goto retry_locked; goto retry_locked;
} }
@@ -1263,11 +1266,14 @@ retry_locked:
} }
/* we need to read it. */ /* we need to read it. */
r = readpage_nounlock(file, page); r = ceph_do_readpage(file, page);
if (r < 0) if (r < 0) {
goto fail_nosnap; if (r == -EINPROGRESS)
return -EAGAIN;
goto fail_unlock;
}
goto retry_locked; goto retry_locked;
fail_nosnap: fail_unlock:
unlock_page(page); unlock_page(page);
return r; return r;
} }
+3 -9
View File
@@ -240,13 +240,7 @@ void ceph_fscache_file_set_cookie(struct inode *inode, struct file *filp)
} }
} }
static void ceph_vfs_readpage_complete(struct page *page, void *data, int error) static void ceph_readpage_from_fscache_complete(struct page *page, void *data, int error)
{
if (!error)
SetPageUptodate(page);
}
static void ceph_vfs_readpage_complete_unlock(struct page *page, void *data, int error)
{ {
if (!error) if (!error)
SetPageUptodate(page); SetPageUptodate(page);
@@ -274,7 +268,7 @@ int ceph_readpage_from_fscache(struct inode *inode, struct page *page)
return -ENOBUFS; return -ENOBUFS;
ret = fscache_read_or_alloc_page(ci->fscache, page, ret = fscache_read_or_alloc_page(ci->fscache, page,
ceph_vfs_readpage_complete, NULL, ceph_readpage_from_fscache_complete, NULL,
GFP_KERNEL); GFP_KERNEL);
switch (ret) { switch (ret) {
@@ -303,7 +297,7 @@ int ceph_readpages_from_fscache(struct inode *inode,
return -ENOBUFS; return -ENOBUFS;
ret = fscache_read_or_alloc_pages(ci->fscache, mapping, pages, nr_pages, ret = fscache_read_or_alloc_pages(ci->fscache, mapping, pages, nr_pages,
ceph_vfs_readpage_complete_unlock, ceph_readpage_from_fscache_complete,
NULL, mapping_gfp_mask(mapping)); NULL, mapping_gfp_mask(mapping));
switch (ret) { switch (ret) {
+1 -1
View File
@@ -194,7 +194,7 @@ check_name(struct dentry *direntry, struct cifs_tcon *tcon)
int i; int i;
if (unlikely(direntry->d_name.len > if (unlikely(direntry->d_name.len >
tcon->fsAttrInfo.MaxPathNameComponentLength)) le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength)))
return -ENAMETOOLONG; return -ENAMETOOLONG;
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)) { if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)) {
+2 -2
View File
@@ -84,8 +84,8 @@
#define NUMBER_OF_SMB2_COMMANDS 0x0013 #define NUMBER_OF_SMB2_COMMANDS 0x0013
/* BB FIXME - analyze following length BB */ /* 4 len + 52 transform hdr + 64 hdr + 56 create rsp */
#define MAX_SMB2_HDR_SIZE 0x78 /* 4 len + 64 hdr + (2*24 wct) + 2 bct + 2 pad */ #define MAX_SMB2_HDR_SIZE 0x00b0
#define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe) #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe)
#define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd) #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd)
+26 -16
View File
@@ -524,8 +524,13 @@ static void ep_remove_wait_queue(struct eppoll_entry *pwq)
wait_queue_head_t *whead; wait_queue_head_t *whead;
rcu_read_lock(); rcu_read_lock();
/* If it is cleared by POLLFREE, it should be rcu-safe */ /*
whead = rcu_dereference(pwq->whead); * If it is cleared by POLLFREE, it should be rcu-safe.
* If we read NULL we need a barrier paired with
* smp_store_release() in ep_poll_callback(), otherwise
* we rely on whead->lock.
*/
whead = smp_load_acquire(&pwq->whead);
if (whead) if (whead)
remove_wait_queue(whead, &pwq->wait); remove_wait_queue(whead, &pwq->wait);
rcu_read_unlock(); rcu_read_unlock();
@@ -1010,17 +1015,6 @@ static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *k
struct eventpoll *ep = epi->ep; struct eventpoll *ep = epi->ep;
int ewake = 0; int ewake = 0;
if ((unsigned long)key & POLLFREE) {
ep_pwq_from_wait(wait)->whead = NULL;
/*
* whead = NULL above can race with ep_remove_wait_queue()
* which can do another remove_wait_queue() after us, so we
* can't use __remove_wait_queue(). whead->lock is held by
* the caller.
*/
list_del_init(&wait->task_list);
}
spin_lock_irqsave(&ep->lock, flags); spin_lock_irqsave(&ep->lock, flags);
/* /*
@@ -1102,10 +1096,26 @@ out_unlock:
if (pwake) if (pwake)
ep_poll_safewake(&ep->poll_wait); ep_poll_safewake(&ep->poll_wait);
if (epi->event.events & EPOLLEXCLUSIVE) if (!(epi->event.events & EPOLLEXCLUSIVE))
return ewake; ewake = 1;
return 1; if ((unsigned long)key & POLLFREE) {
/*
* If we race with ep_remove_wait_queue() it can miss
* ->whead = NULL and do another remove_wait_queue() after
* us, so we can't use __remove_wait_queue().
*/
list_del_init(&wait->task_list);
/*
* ->whead != NULL protects us from the race with ep_free()
* or ep_remove(), ep_remove_wait_queue() takes whead->lock
* held by the caller. Once we nullify it, nothing protects
* ep/epi or even wait.
*/
smp_store_release(&ep_pwq_from_wait(wait)->whead, NULL);
}
return ewake;
} }
/* /*
+5 -1
View File
@@ -48,7 +48,11 @@
#define parent_node(node) ((void)(node),0) #define parent_node(node) ((void)(node),0)
#endif #endif
#ifndef cpumask_of_node #ifndef cpumask_of_node
#define cpumask_of_node(node) ((void)node, cpu_online_mask) #ifdef CONFIG_NEED_MULTIPLE_NODES
#define cpumask_of_node(node) ((node) == 0 ? cpu_online_mask : cpu_none_mask)
#else
#define cpumask_of_node(node) ((void)node, cpu_online_mask)
#endif
#endif #endif
#ifndef pcibus_to_node #ifndef pcibus_to_node
#define pcibus_to_node(bus) ((void)(bus), -1) #define pcibus_to_node(bus) ((void)(bus), -1)
+1
View File
@@ -1908,6 +1908,7 @@ static struct cftype files[] = {
{ {
.name = "memory_pressure", .name = "memory_pressure",
.read_u64 = cpuset_read_u64, .read_u64 = cpuset_read_u64,
.private = FILE_MEMORY_PRESSURE,
}, },
{ {
-2
View File
@@ -1254,8 +1254,6 @@ void uprobe_end_dup_mmap(void)
void uprobe_dup_mmap(struct mm_struct *oldmm, struct mm_struct *newmm) void uprobe_dup_mmap(struct mm_struct *oldmm, struct mm_struct *newmm)
{ {
newmm->uprobes_state.xol_area = NULL;
if (test_bit(MMF_HAS_UPROBES, &oldmm->flags)) { if (test_bit(MMF_HAS_UPROBES, &oldmm->flags)) {
set_bit(MMF_HAS_UPROBES, &newmm->flags); set_bit(MMF_HAS_UPROBES, &newmm->flags);
/* unconditionally, dup_mmap() skips VM_DONTCOPY vmas */ /* unconditionally, dup_mmap() skips VM_DONTCOPY vmas */
+8
View File
@@ -745,6 +745,13 @@ static void mm_init_owner(struct mm_struct *mm, struct task_struct *p)
#endif #endif
} }
static void mm_init_uprobes_state(struct mm_struct *mm)
{
#ifdef CONFIG_UPROBES
mm->uprobes_state.xol_area = NULL;
#endif
}
static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p, static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
struct user_namespace *user_ns) struct user_namespace *user_ns)
{ {
@@ -772,6 +779,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS
mm->pmd_huge_pte = NULL; mm->pmd_huge_pte = NULL;
#endif #endif
mm_init_uprobes_state(mm);
if (current->mm) { if (current->mm) {
mm->flags = current->mm->flags & MMF_INIT_MASK; mm->flags = current->mm->flags & MMF_INIT_MASK;
+3 -1
View File
@@ -364,11 +364,11 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int nbytes)
} }
miter.consumed = lzeros; miter.consumed = lzeros;
sg_miter_stop(&miter);
nbytes -= lzeros; nbytes -= lzeros;
nbits = nbytes * 8; nbits = nbytes * 8;
if (nbits > MAX_EXTERN_MPI_BITS) { if (nbits > MAX_EXTERN_MPI_BITS) {
sg_miter_stop(&miter);
pr_info("MPI: mpi too large (%u bits)\n", nbits); pr_info("MPI: mpi too large (%u bits)\n", nbits);
return NULL; return NULL;
} }
@@ -376,6 +376,8 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int nbytes)
if (nbytes > 0) if (nbytes > 0)
nbits -= count_leading_zeros(*buff) - (BITS_PER_LONG - 8); nbits -= count_leading_zeros(*buff) - (BITS_PER_LONG - 8);
sg_miter_stop(&miter);
nlimbs = DIV_ROUND_UP(nbytes, BYTES_PER_MPI_LIMB); nlimbs = DIV_ROUND_UP(nbytes, BYTES_PER_MPI_LIMB);
val = mpi_alloc(nlimbs); val = mpi_alloc(nlimbs);
if (!val) if (!val)
+7
View File
@@ -533,6 +533,8 @@ static long madvise_remove(struct vm_area_struct *vma,
static int madvise_hwpoison(int bhv, unsigned long start, unsigned long end) static int madvise_hwpoison(int bhv, unsigned long start, unsigned long end)
{ {
struct page *p; struct page *p;
struct zone *zone;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
for (; start < end; start += PAGE_SIZE << for (; start < end; start += PAGE_SIZE <<
@@ -561,6 +563,11 @@ static int madvise_hwpoison(int bhv, unsigned long start, unsigned long end)
if (ret) if (ret)
return ret; return ret;
} }
/* Ensure that all poisoned pages are removed from per-cpu lists */
for_each_populated_zone(zone)
drain_all_pages(zone);
return 0; return 0;
} }
#endif #endif
+6
View File
@@ -3308,9 +3308,15 @@ int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
struct xfrm_state *x_new[XFRM_MAX_DEPTH]; struct xfrm_state *x_new[XFRM_MAX_DEPTH];
struct xfrm_migrate *mp; struct xfrm_migrate *mp;
/* Stage 0 - sanity checks */
if ((err = xfrm_migrate_check(m, num_migrate)) < 0) if ((err = xfrm_migrate_check(m, num_migrate)) < 0)
goto out; goto out;
if (dir >= XFRM_POLICY_MAX) {
err = -EINVAL;
goto out;
}
/* Stage 1 - find policy */ /* Stage 1 - find policy */
if ((pol = xfrm_migrate_policy_find(sel, dir, type, net)) == NULL) { if ((pol = xfrm_migrate_policy_find(sel, dir, type, net)) == NULL) {
err = -ENOENT; err = -ENOENT;