[PATCH] cpuset: Move node_isset() outside of the rcu_read region
From: Yanfei Xu It's no need to keep node_isset still in rcu_read region, just move it outside of the rcu_read region. Signed-off-by: Yanfei Xu --- kernel/cgroup/cpuset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 642415b8c3c9..51d51ed97deb 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -3443,9 +3443,9 @@ bool __cpuset_node_allowed(int node, gfp_t gfp_mask) rcu_read_lock(); cs = nearest_hardwall_ancestor(task_cs(current)); - allowed = node_isset(node, cs->mems_allowed); rcu_read_unlock(); + allowed = node_isset(node, cs->mems_allowed); spin_unlock_irqrestore(_lock, flags); return allowed; } -- 2.18.2
[PATCH v2] mm/page_alloc.c: __perform_reclaim should return 'unsigned long'
From: Yanfei Xu __perform_reclaim()'s single caller expects it to return 'unsigned long', hence change its return value and a local variable to 'unsigned long'. Signed-off-by: Yanfei Xu Suggested-by: Andrew Morton --- mm/page_alloc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index fab5e97dc9ca..9c985b0c316c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4241,13 +4241,12 @@ EXPORT_SYMBOL_GPL(fs_reclaim_release); #endif /* Perform direct synchronous page reclaim */ -static int +static unsigned long __perform_reclaim(gfp_t gfp_mask, unsigned int order, const struct alloc_context *ac) { - int progress; unsigned int noreclaim_flag; - unsigned long pflags; + unsigned long pflags, progress; cond_resched(); -- 2.18.2
[PATCH] mm/page_alloc.c: variable type of 'progress' should be 'unsigned long'
From: Yanfei Xu try_to_free_pages returns the number of pages reclaimed, and the type of returns is 'unsigned long'. So we should use a matched type for storing it. Signed-off-by: Yanfei Xu --- mm/page_alloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index fab5e97dc9ca..5f1016c70b94 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4245,9 +4245,8 @@ static int __perform_reclaim(gfp_t gfp_mask, unsigned int order, const struct alloc_context *ac) { - int progress; unsigned int noreclaim_flag; - unsigned long pflags; + unsigned long pflags, progress; cond_resched(); -- 2.18.2
[PATCH] mm/page_alloc.c: avoid inheritting current's flags when invoked in interrupt
From: Yanfei Xu alloc_mask shouldn't inherit the current task's flags when __alloc_pages_nodemask is invoked in interrupt. Signed-off-by: Yanfei Xu --- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index fab5e97dc9ca..388b587b35a8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4889,7 +4889,8 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid, * from a particular context which has been marked by * memalloc_no{fs,io}_{save,restore}. */ - alloc_mask = current_gfp_context(gfp_mask); + if (!in_interrupt()) + alloc_mask = current_gfp_context(gfp_mask); ac.spread_dirty_pages = false; /* -- 2.18.2
[PATCH] arm64/numa: Fix a typo in comment of arm64_numa_init
From: Yanfei Xu Fix a typo in comment of arm64_numa_init. 'encomapssing' should be 'encompassing'. Signed-off-by: Yanfei Xu --- arch/arm64/mm/numa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c index 73f8b49d485c..d402da26cdca 100644 --- a/arch/arm64/mm/numa.c +++ b/arch/arm64/mm/numa.c @@ -448,7 +448,7 @@ static int __init dummy_numa_init(void) * arm64_numa_init() - Initialize NUMA * * Try each configured NUMA initialization method until one succeeds. The - * last fallback is dummy single node config encomapssing whole memory. + * last fallback is dummy single node config encompassing whole memory. */ void __init arm64_numa_init(void) { -- 2.18.2
[PATCH] USB: core: limit access to rawdescriptors which were not allocated
From: Yanfei Xu When using systemcall to read the rawdescriptors, make sure we won't access to the rawdescriptors never allocated, which are number exceed the USB_MAXCONFIG. Reported-by: syzbot+256e56ddde8b8957e...@syzkaller.appspotmail.com Signed-off-by: Yanfei Xu --- drivers/usb/core/sysfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index a2ca38e25e0c..1a7a625e5f55 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c @@ -895,7 +895,8 @@ read_descriptors(struct file *filp, struct kobject *kobj, * configurations (config plus subsidiary descriptors). */ for (cfgno = -1; cfgno < udev->descriptor.bNumConfigurations && - nleft > 0; ++cfgno) { + nleft > 0 && + cfgno < USB_MAXCONFIG; ++cfgno) { if (cfgno < 0) { src = >descriptor; srclen = sizeof(struct usb_device_descriptor); -- 2.18.2
[PATCH] USB: integrate macro definitions into include/linux/usb.h
From: Yanfei Xu include/linux/usb.h also contains 'Hard limit' and 'Arbitrary limit' macro definitions in it, hence we can integrate these from config.c into include/linux/usb.h Signed-off-by: Yanfei Xu --- drivers/usb/core/config.c | 3 --- include/linux/usb.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 562a730befda..58c5d946cd86 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -14,9 +14,6 @@ #include "usb.h" -#define USB_MAXALTSETTING 128 /* Hard limit */ - -#define USB_MAXCONFIG 8 /* Arbitrary limit */ static inline const char *plural(int n) diff --git a/include/linux/usb.h b/include/linux/usb.h index 20c555db4621..d0a117cfc6bd 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -275,9 +275,12 @@ void usb_put_intf(struct usb_interface *intf); /* Hard limit */ #define USB_MAXENDPOINTS 30 +#define USB_MAXALTSETTING 128 + /* this maximum is arbitrary */ #define USB_MAXINTERFACES 32 #define USB_MAXIADS(USB_MAXINTERFACES/2) +#define USB_MAXCONFIG 8 /* * USB Resume Timer: Every Host controller driver should drive the resume -- 2.18.2
[PATCH v2] mm/memory: Fix typo in __do_fault() comment
From: Yanfei Xu It's "pte_alloc_one", not "pte_alloc_pne". Let's fix that. Signed-off-by: Yanfei Xu Reviewed-by: David Hildenbrand --- v2: modify the commit message mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index c3a83f4ca851..9cc3d0dc816c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3446,7 +3446,7 @@ static vm_fault_t __do_fault(struct vm_fault *vmf) * unlock_page(A) * lock_page(B) * lock_page(B) -* pte_alloc_pne +* pte_alloc_one * shrink_page_list * wait_on_page_writeback(A) * SetPageWriteback(B) -- 2.18.2
[PATCH] mm/memory.c: Replace vmf->vma with variable vma
From: Yanfei Xu The code has declared a vma_struct named vma which is assigned a value of vmf->vma. Thus, use variable vma directly here. Signed-off-by: Yanfei Xu --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index 9cc3d0dc816c..88f61b4f9638 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3454,7 +3454,7 @@ static vm_fault_t __do_fault(struct vm_fault *vmf) * # flush A, B to clear the writeback */ if (pmd_none(*vmf->pmd) && !vmf->prealloc_pte) { - vmf->prealloc_pte = pte_alloc_one(vmf->vma->vm_mm); + vmf->prealloc_pte = pte_alloc_one(vma->vm_mm); if (!vmf->prealloc_pte) return VM_FAULT_OOM; smp_wmb(); /* See comment in __pte_alloc() */ -- 2.18.2
[PATCH] mm/memory.c: Correct the function name in comment
From: Yanfei Xu Correct the function name which is "pte_alloc_pne" to "pte_alloc_one" Signed-off-by: Yanfei Xu --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index c3a83f4ca851..9cc3d0dc816c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3446,7 +3446,7 @@ static vm_fault_t __do_fault(struct vm_fault *vmf) * unlock_page(A) * lock_page(B) * lock_page(B) -* pte_alloc_pne +* pte_alloc_one * shrink_page_list * wait_on_page_writeback(A) * SetPageWriteback(B) -- 2.18.2
[PATCH] mm/mempolicy: Remove the useless newline in policy_node()
From: Yanfei Xu Remove the useless newline among policy_node parameters, that makes code neater. Signed-off-by: Yanfei Xu --- mm/mempolicy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index afaa09ff9f6c..a345ad50b86f 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1885,8 +1885,7 @@ nodemask_t *policy_nodemask(gfp_t gfp, struct mempolicy *policy) } /* Return the node id preferred by the given mempolicy, or the given id */ -static int policy_node(gfp_t gfp, struct mempolicy *policy, - int nd) +static int policy_node(gfp_t gfp, struct mempolicy *policy, int nd) { if (policy->mode == MPOL_PREFERRED && !(policy->flags & MPOL_F_LOCAL)) nd = policy->v.preferred_node; -- 2.18.2
[PATCH] mempolicy.h: fix typo
From: Yanfei Xu Change "interlave" to "interleave". Signed-off-by: Yanfei Xu --- include/linux/mempolicy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index ea9c15b60a96..4dc41428b095 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h @@ -28,7 +28,7 @@ struct mm_struct; * the process policy is used. Interrupts ignore the memory policy * of the current process. * - * Locking policy for interlave: + * Locking policy for interleave: * In process context there is no locking because only the process accesses * its own state. All vma manipulation is somewhat protected by a down_read on * mmap_lock. -- 2.18.2
[PATCH] userfaultfd: avoid the duplicated release for userfaultfd_ctx
From: Yanfei Xu when get_unused_fd_flags gets failure, userfaultfd_ctx_cachep will be freed by userfaultfd_fops's release function which is the userfaultfd_release. So we could return directly after fput(). userfaultfd_release()->userfaultfd_ctx_put(ctx) Fixes: d08ac70b1e0d (Wire UFFD up to SELinux) Reported-by: syzbot+75867c44841cb6373...@syzkaller.appspotmail.com Signed-off-by: Yanfei Xu --- fs/userfaultfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 3a4d6ac5a81a..e98317c15530 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -2049,7 +2049,7 @@ SYSCALL_DEFINE1(userfaultfd, int, flags) fd = get_unused_fd_flags(O_RDONLY | O_CLOEXEC); if (fd < 0) { fput(file); - goto out; + return fd; } ctx->owner = file_inode(file); -- 2.18.2