Skip to content

Commit

Permalink
Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/viro/vfs

Pull misc vfs updates from Al Viro:
 "All kinds of stuff.  That probably should've been 5 or 6 separate
  branches, but by the time I'd realized how large and mixed that bag
  had become it had been too close to -final to play with rebasing.

  Some fs/namei.c cleanups there, memdup_user_nul() introduction and
  switching open-coded instances, burying long-dead code, whack-a-mole
  of various kinds, several new helpers for ->llseek(), assorted
  cleanups and fixes from various people, etc.

  One piece probably deserves special mention - Neil's
  lookup_one_len_unlocked().  Similar to lookup_one_len(), but gets
  called without ->i_mutex and tries to avoid ever taking it.  That, of
  course, means that it's not useful for any directory modifications,
  but things like getting inode attributes in nfds readdirplus are fine
  with that.  I really should've asked for moratorium on lookup-related
  changes this cycle, but since I hadn't done that early enough...  I
  *am* asking for that for the coming cycle, though - I'm going to try
  and get conversion of i_mutex to rwsem with ->lookup() done under lock
  taken shared.

  There will be a patch closer to the end of the window, along the lines
  of the one Linus had posted last May - mechanical conversion of
  ->i_mutex accesses to inode_lock()/inode_unlock()/inode_trylock()/
  inode_is_locked()/inode_lock_nested().  To quote Linus back then:

    -----
    |    This is an automated patch using
    |
    |        sed 's/mutex_lock(&\(.*\)->i_mutex)/inode_lock(\1)/'
    |        sed 's/mutex_unlock(&\(.*\)->i_mutex)/inode_unlock(\1)/'
    |        sed 's/mutex_lock_nested(&\(.*\)->i_mutex,[     ]*I_MUTEX_\([A-Z0-9_]*\))/inode_lock_nested(\1, I_MUTEX_\2)/'
    |        sed 's/mutex_is_locked(&\(.*\)->i_mutex)/inode_is_locked(\1)/'
    |        sed 's/mutex_trylock(&\(.*\)->i_mutex)/inode_trylock(\1)/'
    |
    |    with a very few manual fixups
    -----

  I'm going to send that once the ->i_mutex-affecting stuff in -next
  gets mostly merged (or when Linus says he's about to stop taking
  merges)"

* 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (63 commits)
  nfsd: don't hold i_mutex over userspace upcalls
  fs:affs:Replace time_t with time64_t
  fs/9p: use fscache mutex rather than spinlock
  proc: add a reschedule point in proc_readfd_common()
  logfs: constify logfs_block_ops structures
  fcntl: allow to set O_DIRECT flag on pipe
  fs: __generic_file_splice_read retry lookup on AOP_TRUNCATED_PAGE
  fs: xattr: Use kvfree()
  [s390] page_to_phys() always returns a multiple of PAGE_SIZE
  nbd: use ->compat_ioctl()
  fs: use block_device name vsprintf helper
  lib/vsprintf: add %*pg format specifier
  fs: use gendisk->disk_name where possible
  poll: plug an unused argument to do_poll
  amdkfd: don't open-code memdup_user()
  cdrom: don't open-code memdup_user()
  rsxx: don't open-code memdup_user()
  mtip32xx: don't open-code memdup_user()
  [um] mconsole: don't open-code memdup_user_nul()
  [um] hostaudio: don't open-code memdup_user()
  ...
  • Loading branch information
torvalds committed Jan 13, 2016
2 parents ca9706a + bbddca8 commit 33caf82
Show file tree
Hide file tree
Showing 125 changed files with 792 additions and 1,478 deletions.
6 changes: 6 additions & 0 deletions Documentation/printk-formats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ dentry names:

Passed by reference.

block_device names:

%pg sda, sda1 or loop0p1

For printing name of block_device pointers.

struct va_format:

%pV
Expand Down
6 changes: 0 additions & 6 deletions arch/blackfin/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,6 @@ static inline int bad_user_access_length(void)
#define __copy_to_user_inatomic __copy_to_user
#define __copy_from_user_inatomic __copy_from_user

#define copy_to_user_ret(to, from, n, retval) ({ if (copy_to_user(to, from, n))\
return retval; })

#define copy_from_user_ret(to, from, n, retval) ({ if (copy_from_user(to, from, n))\
return retval; })

static inline unsigned long __must_check
copy_from_user(void *to, const void __user *from, unsigned long n)
{
Expand Down
4 changes: 0 additions & 4 deletions arch/m68k/include/asm/uaccess_no.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ extern int __get_user_bad(void);
#define __copy_to_user_inatomic __copy_to_user
#define __copy_from_user_inatomic __copy_from_user

#define copy_to_user_ret(to,from,n,retval) ({ if (copy_to_user(to,from,n)) return retval; })

#define copy_from_user_ret(to,from,n,retval) ({ if (copy_from_user(to,from,n)) return retval; })

/*
* Copy a null terminated string from userspace.
*/
Expand Down
18 changes: 6 additions & 12 deletions arch/mips/lasat/picvue_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
static DEFINE_MUTEX(pvc_mutex);
static char pvc_lines[PVC_NLINES][PVC_LINELEN+1];
static int pvc_linedata[PVC_NLINES];
static struct proc_dir_entry *pvc_display_dir;
static char *pvc_linename[PVC_NLINES] = {"line1", "line2"};
#define DISPLAY_DIR_NAME "display"
static int scroll_dir, scroll_interval;
Expand Down Expand Up @@ -169,35 +168,30 @@ void pvc_proc_timerfunc(unsigned long data)

static void pvc_proc_cleanup(void)
{
int i;
for (i = 0; i < PVC_NLINES; i++)
remove_proc_entry(pvc_linename[i], pvc_display_dir);
remove_proc_entry("scroll", pvc_display_dir);
remove_proc_entry(DISPLAY_DIR_NAME, NULL);

remove_proc_subtree(DISPLAY_DIR_NAME, NULL);
del_timer_sync(&timer);
}

static int __init pvc_proc_init(void)
{
struct proc_dir_entry *proc_entry;
struct proc_dir_entry *dir, *proc_entry;
int i;

pvc_display_dir = proc_mkdir(DISPLAY_DIR_NAME, NULL);
if (pvc_display_dir == NULL)
dir = proc_mkdir(DISPLAY_DIR_NAME, NULL);
if (dir == NULL)
goto error;

for (i = 0; i < PVC_NLINES; i++) {
strcpy(pvc_lines[i], "");
pvc_linedata[i] = i;
}
for (i = 0; i < PVC_NLINES; i++) {
proc_entry = proc_create_data(pvc_linename[i], 0644, pvc_display_dir,
proc_entry = proc_create_data(pvc_linename[i], 0644, dir,
&pvc_line_proc_fops, &pvc_linedata[i]);
if (proc_entry == NULL)
goto error;
}
proc_entry = proc_create("scroll", 0644, pvc_display_dir,
proc_entry = proc_create("scroll", 0644, dir,
&pvc_scroll_proc_fops);
if (proc_entry == NULL)
goto error;
Expand Down
15 changes: 0 additions & 15 deletions arch/mn10300/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,6 @@ extern int fixup_exception(struct pt_regs *regs);
#define __put_user(x, ptr) __put_user_nocheck((x), (ptr), sizeof(*(ptr)))
#define __get_user(x, ptr) __get_user_nocheck((x), (ptr), sizeof(*(ptr)))

/*
* The "xxx_ret" versions return constant specified in third argument, if
* something bad happens. These macros can be optimized for the
* case of just returning from the function xxx_ret is used.
*/

#define put_user_ret(x, ptr, ret) \
({ if (put_user((x), (ptr))) return (ret); })
#define get_user_ret(x, ptr, ret) \
({ if (get_user((x), (ptr))) return (ret); })
#define __put_user_ret(x, ptr, ret) \
({ if (__put_user((x), (ptr))) return (ret); })
#define __get_user_ret(x, ptr, ret) \
({ if (__get_user((x), (ptr))) return (ret); })

struct __large_struct { unsigned long buf[100]; };
#define __m(x) (*(struct __large_struct *)(x))

Expand Down
15 changes: 0 additions & 15 deletions arch/powerpc/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,21 +274,6 @@ do { \
__gu_err; \
})

#ifndef __powerpc64__
#define __get_user64_nocheck(x, ptr, size) \
({ \
long __gu_err; \
long long __gu_val; \
__typeof__(*(ptr)) __user *__gu_addr = (ptr); \
__chk_user_ptr(ptr); \
if (!is_kernel_addr((unsigned long)__gu_addr)) \
might_fault(); \
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
(x) = (__force __typeof__(*(ptr)))__gu_val; \
__gu_err; \
})
#endif /* __powerpc64__ */

#define __get_user_check(x, ptr, size) \
({ \
long __gu_err = -EFAULT; \
Expand Down
19 changes: 3 additions & 16 deletions arch/powerpc/kernel/nvram_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/kmsg_dump.h>
#include <linux/pagemap.h>
#include <linux/pstore.h>
#include <linux/zlib.h>
#include <asm/uaccess.h>
Expand Down Expand Up @@ -733,24 +734,10 @@ static void oops_to_nvram(struct kmsg_dumper *dumper,

static loff_t dev_nvram_llseek(struct file *file, loff_t offset, int origin)
{
int size;

if (ppc_md.nvram_size == NULL)
return -ENODEV;
size = ppc_md.nvram_size();

switch (origin) {
case 1:
offset += file->f_pos;
break;
case 2:
offset += size;
break;
}
if (offset < 0)
return -EINVAL;
file->f_pos = offset;
return file->f_pos;
return generic_file_llseek_size(file, offset, origin, MAX_LFS_FILESIZE,
ppc_md.nvram_size());
}


Expand Down
3 changes: 1 addition & 2 deletions arch/s390/pci/pci_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ static void *s390_dma_alloc(struct device *dev, size_t size,
pa = page_to_phys(page);
memset((void *) pa, 0, size);

map = s390_dma_map_pages(dev, page, pa % PAGE_SIZE,
size, DMA_BIDIRECTIONAL, NULL);
map = s390_dma_map_pages(dev, page, 0, size, DMA_BIDIRECTIONAL, NULL);
if (dma_mapping_error(dev, map)) {
free_pages(pa, get_order(size));
return NULL;
Expand Down
65 changes: 0 additions & 65 deletions arch/sparc/include/asm/uaccess_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,31 +205,6 @@ int __put_user_bad(void);
__gu_ret; \
})

#define __get_user_check_ret(x, addr, size, type, retval) ({ \
register unsigned long __gu_val __asm__ ("l1"); \
if (__access_ok(addr, size)) { \
switch (size) { \
case 1: \
__get_user_asm_ret(__gu_val, ub, addr, retval); \
break; \
case 2: \
__get_user_asm_ret(__gu_val, uh, addr, retval); \
break; \
case 4: \
__get_user_asm_ret(__gu_val, , addr, retval); \
break; \
case 8: \
__get_user_asm_ret(__gu_val, d, addr, retval); \
break; \
default: \
if (__get_user_bad()) \
return retval; \
} \
x = (__force type) __gu_val; \
} else \
return retval; \
})

#define __get_user_nocheck(x, addr, size, type) ({ \
register int __gu_ret; \
register unsigned long __gu_val; \
Expand All @@ -247,20 +222,6 @@ int __put_user_bad(void);
__gu_ret; \
})

#define __get_user_nocheck_ret(x, addr, size, type, retval) ({ \
register unsigned long __gu_val __asm__ ("l1"); \
switch (size) { \
case 1: __get_user_asm_ret(__gu_val, ub, addr, retval); break; \
case 2: __get_user_asm_ret(__gu_val, uh, addr, retval); break; \
case 4: __get_user_asm_ret(__gu_val, , addr, retval); break; \
case 8: __get_user_asm_ret(__gu_val, d, addr, retval); break; \
default: \
if (__get_user_bad()) \
return retval; \
} \
x = (__force type) __gu_val; \
})

#define __get_user_asm(x, size, addr, ret) \
__asm__ __volatile__( \
"/* Get user asm, inline. */\n" \
Expand All @@ -281,32 +242,6 @@ __asm__ __volatile__( \
: "=&r" (ret), "=&r" (x) : "m" (*__m(addr)), \
"i" (-EFAULT))

#define __get_user_asm_ret(x, size, addr, retval) \
if (__builtin_constant_p(retval) && retval == -EFAULT) \
__asm__ __volatile__( \
"/* Get user asm ret, inline. */\n" \
"1:\t" "ld"#size " %1, %0\n\n\t" \
".section __ex_table,#alloc\n\t" \
".align 4\n\t" \
".word 1b,__ret_efault\n\n\t" \
".previous\n\t" \
: "=&r" (x) : "m" (*__m(addr))); \
else \
__asm__ __volatile__( \
"/* Get user asm ret, inline. */\n" \
"1:\t" "ld"#size " %1, %0\n\n\t" \
".section .fixup,#alloc,#execinstr\n\t" \
".align 4\n" \
"3:\n\t" \
"ret\n\t" \
" restore %%g0, %2, %%o0\n\n\t" \
".previous\n\t" \
".section __ex_table,#alloc\n\t" \
".align 4\n\t" \
".word 1b, 3b\n\n\t" \
".previous\n\t" \
: "=&r" (x) : "m" (*__m(addr)), "i" (retval))

int __get_user_bad(void);

unsigned long __copy_user(void __user *to, const void __user *from, unsigned long size);
Expand Down
40 changes: 0 additions & 40 deletions arch/sparc/include/asm/uaccess_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,6 @@ int __put_user_bad(void);
__gu_ret; \
})

#define __get_user_nocheck_ret(data, addr, size, type, retval) ({ \
register unsigned long __gu_val __asm__ ("l1"); \
switch (size) { \
case 1: __get_user_asm_ret(__gu_val, ub, addr, retval); break; \
case 2: __get_user_asm_ret(__gu_val, uh, addr, retval); break; \
case 4: __get_user_asm_ret(__gu_val, uw, addr, retval); break; \
case 8: __get_user_asm_ret(__gu_val, x, addr, retval); break; \
default: \
if (__get_user_bad()) \
return retval; \
} \
data = (__force type) __gu_val; \
})

#define __get_user_asm(x, size, addr, ret) \
__asm__ __volatile__( \
"/* Get user asm, inline. */\n" \
Expand All @@ -214,32 +200,6 @@ __asm__ __volatile__( \
: "=r" (ret), "=r" (x) : "r" (__m(addr)), \
"i" (-EFAULT))

#define __get_user_asm_ret(x, size, addr, retval) \
if (__builtin_constant_p(retval) && retval == -EFAULT) \
__asm__ __volatile__( \
"/* Get user asm ret, inline. */\n" \
"1:\t" "ld"#size "a [%1] %%asi, %0\n\n\t" \
".section __ex_table,\"a\"\n\t" \
".align 4\n\t" \
".word 1b,__ret_efault\n\n\t" \
".previous\n\t" \
: "=r" (x) : "r" (__m(addr))); \
else \
__asm__ __volatile__( \
"/* Get user asm ret, inline. */\n" \
"1:\t" "ld"#size "a [%1] %%asi, %0\n\n\t" \
".section .fixup,#alloc,#execinstr\n\t" \
".align 4\n" \
"3:\n\t" \
"ret\n\t" \
" restore %%g0, %2, %%o0\n\n\t" \
".previous\n\t" \
".section __ex_table,\"a\"\n\t" \
".align 4\n\t" \
".word 1b, 3b\n\n\t" \
".previous\n\t" \
: "=r" (x) : "r" (__m(addr)), "i" (retval))

int __get_user_bad(void);

unsigned long __must_check ___copy_from_user(void *to,
Expand Down
20 changes: 2 additions & 18 deletions arch/sparc/kernel/mdesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1033,25 +1033,9 @@ static ssize_t mdesc_read(struct file *file, char __user *buf,

static loff_t mdesc_llseek(struct file *file, loff_t offset, int whence)
{
struct mdesc_handle *hp;

switch (whence) {
case SEEK_CUR:
offset += file->f_pos;
break;
case SEEK_SET:
break;
default:
return -EINVAL;
}

hp = file->private_data;
if (offset > hp->handle_size)
return -EINVAL;
else
file->f_pos = offset;
struct mdesc_handle *hp = file->private_data;

return offset;
return no_seek_end_llseek_size(file, offset, whence, hp->handle_size);
}

/* mdesc_close() - /dev/mdesc is being closed, release the reference to
Expand Down
10 changes: 3 additions & 7 deletions arch/um/drivers/hostaudio_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,9 @@ static ssize_t hostaudio_write(struct file *file, const char __user *buffer,
printk(KERN_DEBUG "hostaudio: write called, count = %d\n", count);
#endif

kbuf = kmalloc(count, GFP_KERNEL);
if (kbuf == NULL)
return -ENOMEM;

err = -EFAULT;
if (copy_from_user(kbuf, buffer, count))
goto out;
kbuf = memdup_user(buffer, count);
if (IS_ERR(kbuf))
return PTR_ERR(kbuf);

err = os_write_file(state->fd, kbuf, count);
if (err < 0)
Expand Down
14 changes: 3 additions & 11 deletions arch/um/drivers/mconsole_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,19 +748,11 @@ static ssize_t mconsole_proc_write(struct file *file,
{
char *buf;

buf = kmalloc(count + 1, GFP_KERNEL);
if (buf == NULL)
return -ENOMEM;

if (copy_from_user(buf, buffer, count)) {
count = -EFAULT;
goto out;
}

buf[count] = '\0';
buf = memdup_user_nul(buffer, count);
if (IS_ERR(buf))
return PTR_ERR(buf);

mconsole_notify(notify_socket, MCONSOLE_USER_NOTIFY, buf, count);
out:
kfree(buf);
return count;
}
Expand Down
Loading

0 comments on commit 33caf82

Please sign in to comment.