Skip to content

Commit

Permalink
Merge branch 'akpm' (patches from Andrew)
Browse files Browse the repository at this point in the history
Mergr misc fixes from Andrew Morton:
 "28 fixes"

* emailed patches from Andrew Morton <[email protected]>: (28 commits)
  fs/hugetlbfs/inode.c: change put_page/unlock_page order in hugetlbfs_fallocate()
  mm/hugetlb: fix NULL-pointer dereference on 5-level paging machine
  autofs: revert "autofs: fix AT_NO_AUTOMOUNT not being honored"
  autofs: revert "autofs: take more care to not update last_used on path walk"
  fs/fat/inode.c: fix sb_rdonly() change
  mm, memcg: fix mem_cgroup_swapout() for THPs
  mm: migrate: fix an incorrect call of prep_transhuge_page()
  kmemleak: add scheduling point to kmemleak_scan()
  scripts/bloat-o-meter: don't fail with division by 0
  fs/mbcache.c: make count_objects() more robust
  Revert "mm/page-writeback.c: print a warning if the vm dirtiness settings are illogical"
  mm/madvise.c: fix madvise() infinite loop under special circumstances
  exec: avoid RLIMIT_STACK races with prlimit()
  IB/core: disable memory registration of filesystem-dax vmas
  v4l2: disable filesystem-dax mapping support
  mm: fail get_vaddr_frames() for filesystem-dax mappings
  mm: introduce get_user_pages_longterm
  device-dax: implement ->split() to catch invalid munmap attempts
  mm, hugetlbfs: introduce ->split() to vm_operations_struct
  scripts/faddr2line: extend usage on generic arch
  ...
  • Loading branch information
torvalds committed Nov 30, 2017
2 parents b915176 + 72639e6 commit a0908a1
Show file tree
Hide file tree
Showing 40 changed files with 238 additions and 101 deletions.
7 changes: 0 additions & 7 deletions Documentation/sysctl/vm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ Note: the minimum value allowed for dirty_bytes is two pages (in bytes); any
value lower than this limit will be ignored and the old configuration will be
retained.

Note: the value of dirty_bytes also must be set greater than
dirty_background_bytes or the amount of memory corresponding to
dirty_background_ratio.

==============================================================

dirty_expire_centisecs
Expand All @@ -181,9 +177,6 @@ generating disk writes will itself start writing out dirty data.

The total available memory is not equal to total system memory.

Note: dirty_ratio must be set greater than dirty_background_ratio or
ratio corresponding to dirty_background_bytes.

==============================================================

dirty_writeback_centisecs
Expand Down
1 change: 0 additions & 1 deletion arch/arm/include/asm/pgtable-3level.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ static inline pte_t pte_mkspecial(pte_t pte)
}
#define __HAVE_ARCH_PTE_SPECIAL

#define __HAVE_ARCH_PMD_WRITE
#define pmd_write(pmd) (pmd_isclear((pmd), L_PMD_SECT_RDONLY))
#define pmd_dirty(pmd) (pmd_isset((pmd), L_PMD_SECT_DIRTY))
#define pud_page(pud) pmd_page(__pmd(pud_val(pud)))
Expand Down
1 change: 0 additions & 1 deletion arch/arm64/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ static inline int pmd_protnone(pmd_t pmd)

#define pmd_thp_or_huge(pmd) (pmd_huge(pmd) || pmd_trans_huge(pmd))

#define __HAVE_ARCH_PMD_WRITE
#define pmd_write(pmd) pte_write(pmd_pte(pmd))

#define pmd_mkhuge(pmd) (__pmd(pmd_val(pmd) & ~PMD_TABLE_BIT))
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ static inline pmd_t pmd_mkhuge(pmd_t pmd)
extern void set_pmd_at(struct mm_struct *mm, unsigned long addr,
pmd_t *pmdp, pmd_t pmd);

#define __HAVE_ARCH_PMD_WRITE
#define pmd_write pmd_write
static inline int pmd_write(pmd_t pmd)
{
return !!(pmd_val(pmd) & _PAGE_WRITE);
Expand Down
1 change: 0 additions & 1 deletion arch/powerpc/include/asm/book3s/64/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,6 @@ static inline int pmd_protnone(pmd_t pmd)
}
#endif /* CONFIG_NUMA_BALANCING */

#define __HAVE_ARCH_PMD_WRITE
#define pmd_write(pmd) pte_write(pmd_pte(pmd))
#define __pmd_write(pmd) __pte_write(pmd_pte(pmd))
#define pmd_savedwrite(pmd) pte_savedwrite(pmd_pte(pmd))
Expand Down
8 changes: 7 additions & 1 deletion arch/s390/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ static inline unsigned long pmd_pfn(pmd_t pmd)
return (pmd_val(pmd) & origin_mask) >> PAGE_SHIFT;
}

#define __HAVE_ARCH_PMD_WRITE
#define pmd_write pmd_write
static inline int pmd_write(pmd_t pmd)
{
return (pmd_val(pmd) & _SEGMENT_ENTRY_WRITE) != 0;
Expand Down Expand Up @@ -1264,6 +1264,12 @@ static inline pud_t pud_mkwrite(pud_t pud)
return pud;
}

#define pud_write pud_write
static inline int pud_write(pud_t pud)
{
return (pud_val(pud) & _REGION3_ENTRY_WRITE) != 0;
}

static inline pud_t pud_mkclean(pud_t pud)
{
if (pud_large(pud)) {
Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/include/asm/pgtable_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ static inline unsigned long pmd_pfn(pmd_t pmd)
return pte_pfn(pte);
}

#define __HAVE_ARCH_PMD_WRITE
#define pmd_write pmd_write
static inline unsigned long pmd_write(pmd_t pmd)
{
pte_t pte = __pte(pmd_val(pmd));
Expand Down
4 changes: 2 additions & 2 deletions arch/sparc/mm/gup.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static int gup_huge_pmd(pmd_t *pmdp, pmd_t pmd, unsigned long addr,
if (!(pmd_val(pmd) & _PAGE_VALID))
return 0;

if (write && !pmd_write(pmd))
if (!pmd_access_permitted(pmd, write))
return 0;

refs = 0;
Expand Down Expand Up @@ -114,7 +114,7 @@ static int gup_huge_pud(pud_t *pudp, pud_t pud, unsigned long addr,
if (!(pud_val(pud) & _PAGE_VALID))
return 0;

if (write && !pud_write(pud))
if (!pud_access_permitted(pud, write))
return 0;

refs = 0;
Expand Down
1 change: 0 additions & 1 deletion arch/tile/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ static inline void pmd_clear(pmd_t *pmdp)
#define pmd_mkdirty(pmd) pte_pmd(pte_mkdirty(pmd_pte(pmd)))
#define pmd_huge_page(pmd) pte_huge(pmd_pte(pmd))
#define pmd_mkhuge(pmd) pte_pmd(pte_mkhuge(pmd_pte(pmd)))
#define __HAVE_ARCH_PMD_WRITE

#define pfn_pmd(pfn, pgprot) pte_pmd(pfn_pte((pfn), (pgprot)))
#define pmd_pfn(pmd) pte_pfn(pmd_pte(pmd))
Expand Down
8 changes: 7 additions & 1 deletion arch/x86/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ extern int pmdp_clear_flush_young(struct vm_area_struct *vma,
unsigned long address, pmd_t *pmdp);


#define __HAVE_ARCH_PMD_WRITE
#define pmd_write pmd_write
static inline int pmd_write(pmd_t pmd)
{
return pmd_flags(pmd) & _PAGE_RW;
Expand All @@ -1088,6 +1088,12 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
clear_bit(_PAGE_BIT_RW, (unsigned long *)pmdp);
}

#define pud_write pud_write
static inline int pud_write(pud_t pud)
{
return pud_flags(pud) & _PAGE_RW;
}

/*
* clone_pgd_range(pgd_t *dst, pgd_t *src, int count);
*
Expand Down
12 changes: 12 additions & 0 deletions drivers/dax/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,21 @@ static int dev_dax_fault(struct vm_fault *vmf)
return dev_dax_huge_fault(vmf, PE_SIZE_PTE);
}

static int dev_dax_split(struct vm_area_struct *vma, unsigned long addr)
{
struct file *filp = vma->vm_file;
struct dev_dax *dev_dax = filp->private_data;
struct dax_region *dax_region = dev_dax->region;

if (!IS_ALIGNED(addr, dax_region->align))
return -EINVAL;
return 0;
}

static const struct vm_operations_struct dax_vm_ops = {
.fault = dev_dax_fault,
.huge_fault = dev_dax_huge_fault,
.split = dev_dax_split,
};

static int dax_mmap(struct file *filp, struct vm_area_struct *vma)
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/core/umem.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
sg_list_start = umem->sg_head.sgl;

while (npages) {
ret = get_user_pages(cur_base,
ret = get_user_pages_longterm(cur_base,
min_t(unsigned long, npages,
PAGE_SIZE / sizeof (struct page *)),
gup_flags, page_list, vma_list);
Expand Down
5 changes: 3 additions & 2 deletions drivers/media/v4l2-core/videobuf-dma-sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,13 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma,
dprintk(1, "init user [0x%lx+0x%lx => %d pages]\n",
data, size, dma->nr_pages);

err = get_user_pages(data & PAGE_MASK, dma->nr_pages,
err = get_user_pages_longterm(data & PAGE_MASK, dma->nr_pages,
flags, dma->pages, NULL);

if (err != dma->nr_pages) {
dma->nr_pages = (err >= 0) ? err : 0;
dprintk(1, "get_user_pages: err=%d [%d]\n", err, dma->nr_pages);
dprintk(1, "get_user_pages_longterm: err=%d [%d]\n", err,
dma->nr_pages);
return err < 0 ? err : -EINVAL;
}
return 0;
Expand Down
17 changes: 6 additions & 11 deletions fs/autofs4/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ static int autofs4_mount_wait(const struct path *path, bool rcu_walk)
pr_debug("waiting for mount name=%pd\n", path->dentry);
status = autofs4_wait(sbi, path, NFY_MOUNT);
pr_debug("mount wait done status=%d\n", status);
ino->last_used = jiffies;
}
ino->last_used = jiffies;
return status;
}

Expand Down Expand Up @@ -321,21 +321,16 @@ static struct dentry *autofs4_mountpoint_changed(struct path *path)
*/
if (autofs_type_indirect(sbi->type) && d_unhashed(dentry)) {
struct dentry *parent = dentry->d_parent;
struct autofs_info *ino;
struct dentry *new;

new = d_lookup(parent, &dentry->d_name);
if (!new)
return NULL;
if (new == dentry)
dput(new);
else {
struct autofs_info *ino;

ino = autofs4_dentry_ino(new);
ino->last_used = jiffies;
dput(path->dentry);
path->dentry = new;
}
ino = autofs4_dentry_ino(new);
ino->last_used = jiffies;
dput(path->dentry);
path->dentry = new;
}
return path->dentry;
}
Expand Down
3 changes: 2 additions & 1 deletion fs/dax.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,8 @@ static void dax_mapping_entry_mkclean(struct address_space *mapping,

if (pfn != pmd_pfn(*pmdp))
goto unlock_pmd;
if (!pmd_dirty(*pmdp) && !pmd_write(*pmdp))
if (!pmd_dirty(*pmdp)
&& !pmd_access_permitted(*pmdp, WRITE))
goto unlock_pmd;

flush_cache_page(vma, address, pfn);
Expand Down
7 changes: 6 additions & 1 deletion fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1340,10 +1340,15 @@ void setup_new_exec(struct linux_binprm * bprm)
* avoid bad behavior from the prior rlimits. This has to
* happen before arch_pick_mmap_layout(), which examines
* RLIMIT_STACK, but after the point of no return to avoid
* needing to clean up the change on failure.
* races from other threads changing the limits. This also
* must be protected from races with prlimit() calls.
*/
task_lock(current->group_leader);
if (current->signal->rlim[RLIMIT_STACK].rlim_cur > _STK_LIM)
current->signal->rlim[RLIMIT_STACK].rlim_cur = _STK_LIM;
if (current->signal->rlim[RLIMIT_STACK].rlim_max > _STK_LIM)
current->signal->rlim[RLIMIT_STACK].rlim_max = _STK_LIM;
task_unlock(current->group_leader);
}

arch_pick_mmap_layout(current->mm);
Expand Down
2 changes: 1 addition & 1 deletion fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ static void __exit fat_destroy_inodecache(void)

static int fat_remount(struct super_block *sb, int *flags, char *data)
{
int new_rdonly;
bool new_rdonly;
struct msdos_sb_info *sbi = MSDOS_SB(sb);
*flags |= SB_NODIRATIME | (sbi->options.isvfat ? 0 : SB_NOATIME);

Expand Down
4 changes: 2 additions & 2 deletions fs/hugetlbfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,11 +639,11 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
mutex_unlock(&hugetlb_fault_mutex_table[hash]);

/*
* page_put due to reference from alloc_huge_page()
* unlock_page because locked by add_to_page_cache()
* page_put due to reference from alloc_huge_page()
*/
put_page(page);
unlock_page(page);
put_page(page);
}

if (!(mode & FALLOC_FL_KEEP_SIZE) && offset + len > inode->i_size)
Expand Down
3 changes: 3 additions & 0 deletions fs/mbcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ static unsigned long mb_cache_count(struct shrinker *shrink,
struct mb_cache *cache = container_of(shrink, struct mb_cache,
c_shrink);

/* Unlikely, but not impossible */
if (unlikely(cache->c_entry_count < 0))
return 0;
return cache->c_entry_count;
}

Expand Down
15 changes: 3 additions & 12 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,18 +1129,9 @@ static int follow_automount(struct path *path, struct nameidata *nd,
* of the daemon to instantiate them before they can be used.
*/
if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY |
LOOKUP_OPEN | LOOKUP_CREATE |
LOOKUP_AUTOMOUNT))) {
/* Positive dentry that isn't meant to trigger an
* automount, EISDIR will allow it to be used,
* otherwise there's no mount here "now" so return
* ENOENT.
*/
if (path->dentry->d_inode)
return -EISDIR;
else
return -ENOENT;
}
LOOKUP_OPEN | LOOKUP_CREATE | LOOKUP_AUTOMOUNT)) &&
path->dentry->d_inode)
return -EISDIR;

if (path->dentry->d_sb->s_user_ns != &init_user_ns)
return -EACCES;
Expand Down
12 changes: 10 additions & 2 deletions include/asm-generic/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -805,15 +805,23 @@ static inline int pmd_trans_huge(pmd_t pmd)
{
return 0;
}
#ifndef __HAVE_ARCH_PMD_WRITE
#ifndef pmd_write
static inline int pmd_write(pmd_t pmd)
{
BUG();
return 0;
}
#endif /* __HAVE_ARCH_PMD_WRITE */
#endif /* pmd_write */
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */

#ifndef pud_write
static inline int pud_write(pud_t pud)
{
BUG();
return 0;
}
#endif /* pud_write */

#if !defined(CONFIG_TRANSPARENT_HUGEPAGE) || \
(defined(CONFIG_TRANSPARENT_HUGEPAGE) && \
!defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD))
Expand Down
17 changes: 16 additions & 1 deletion include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3088,7 +3088,8 @@ static inline int vfs_lstat(const char __user *name, struct kstat *stat)
static inline int vfs_fstatat(int dfd, const char __user *filename,
struct kstat *stat, int flags)
{
return vfs_statx(dfd, filename, flags, stat, STATX_BASIC_STATS);
return vfs_statx(dfd, filename, flags | AT_NO_AUTOMOUNT,
stat, STATX_BASIC_STATS);
}
static inline int vfs_fstat(int fd, struct kstat *stat)
{
Expand Down Expand Up @@ -3194,6 +3195,20 @@ static inline bool vma_is_dax(struct vm_area_struct *vma)
return vma->vm_file && IS_DAX(vma->vm_file->f_mapping->host);
}

static inline bool vma_is_fsdax(struct vm_area_struct *vma)
{
struct inode *inode;

if (!vma->vm_file)
return false;
if (!vma_is_dax(vma))
return false;
inode = file_inode(vma->vm_file);
if (inode->i_mode == S_IFCHR)
return false; /* device-dax */
return true;
}

static inline int iocb_flags(struct file *file)
{
int res = 0;
Expand Down
8 changes: 0 additions & 8 deletions include/linux/hugetlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,6 @@ static inline int pgd_write(pgd_t pgd)
}
#endif

#ifndef pud_write
static inline int pud_write(pud_t pud)
{
BUG();
return 0;
}
#endif

#define HUGETLB_ANON_FILE "anon_hugepage"

enum {
Expand Down
2 changes: 1 addition & 1 deletion include/linux/migrate.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static inline struct page *new_page_nodemask(struct page *page,
new_page = __alloc_pages_nodemask(gfp_mask, order,
preferred_nid, nodemask);

if (new_page && PageTransHuge(page))
if (new_page && PageTransHuge(new_page))
prep_transhuge_page(new_page);

return new_page;
Expand Down
Loading

0 comments on commit a0908a1

Please sign in to comment.