Rasmus Villemoes
41416f2330
lib/string_helpers.c: change semantics of string_escape_mem
...
The current semantics of string_escape_mem are inadequate for one of its
current users, vsnprintf(). If that is to honour its contract, it must
know how much space would be needed for the entire escaped buffer, and
string_escape_mem provides no way of obtaining that (short of allocating a
large enough buffer (~4 times input string) to let it play with, and
that's definitely a big no-no inside vsnprintf).
So change the semantics for string_escape_mem to be more snprintf-like:
Return the size of the output that would be generated if the destination
buffer was big enough, but of course still only write to the part of dst
it is allowed to, and (contrary to snprintf) don't do '\0'-termination.
It is then up to the caller to detect whether output was truncated and to
append a '\0' if desired. Also, we must output partial escape sequences,
otherwise a call such as snprintf(buf, 3, "%1pE", "\123") would cause
printf to write a \0 to buf[2] but leaving buf[0] and buf[1] with whatever
they previously contained.
This also fixes a bug in the escaped_string() helper function, which used
to unconditionally pass a length of "end-buf" to string_escape_mem();
since the latter doesn't check osz for being insanely large, it would
happily write to dst. For example, kasprintf(GFP_KERNEL, "something and
then %pE", ...); is an easy way to trigger an oops.
In test-string_helpers.c, the -ENOMEM test is replaced with testing for
getting the expected return value even if the buffer is too small. We
also ensure that nothing is written (by relying on a NULL pointer deref)
if the output size is 0 by passing NULL - this has to work for
kasprintf("%pE") to work.
In net/sunrpc/cache.c, I think qword_add still has the same semantics.
Someone should definitely double-check this.
In fs/proc/array.c, I made the minimum possible change, but longer-term it
should stop poking around in seq_file internals.
[andriy.shevchenko@linux.intel.com: simplify qword_add]
[andriy.shevchenko@linux.intel.com: add missed curly braces]
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-04-15 16:35:24 -07:00
..
9p
Merge branch 'iocb' into for-next
2015-04-11 22:24:41 -04:00
adfs
affs
Merge branch 'for-linus-1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2015-04-14 15:31:03 -07:00
afs
Merge remote-tracking branch 'dh/afs' into for-davem
2015-04-11 15:51:09 -04:00
autofs4
autofs4 copy_dev_ioctl(): keep the value of ->size we'd used for allocation
2015-02-22 11:43:34 -05:00
befs
fs/befs/linuxvfs.c: remove unnecessary casting
2015-02-17 14:34:50 -08:00
bfs
fs: move struct kiocb to fs.h
2015-03-25 20:28:11 -04:00
btrfs
Merge branch 'iocb' into for-next
2015-04-11 22:24:41 -04:00
cachefiles
Cachefiles: Fix up scripted S_ISDIR/S_ISREG/S_ISLNK conversions
2015-02-22 11:38:41 -05:00
ceph
Merge branch 'iocb' into for-next
2015-04-11 22:24:41 -04:00
cifs
mm, mempool: do not allow atomic resizing
2015-04-14 16:49:06 -07:00
coda
VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry)
2015-02-22 11:38:41 -05:00
configfs
configfs: Fix potential NULL d_inode dereference
2015-02-20 04:56:43 -05:00
cramfs
debugfs
debugfs: allow bad parent pointers to be passed in
2015-04-03 16:30:12 +02:00
devpts
dlm
netlink: make nlmsg_end() and genlmsg_end() void
2015-01-18 01:03:45 -05:00
ecryptfs
Merge branch 'iocb' into for-next
2015-04-11 22:24:41 -04:00
efivarfs
* Move efivarfs from the misc filesystem section to pseudo filesystem,
2015-01-29 19:16:40 +01:00
efs
exofs
vfs: remove get_xip_mem
2015-02-16 17:56:03 -08:00
exportfs
VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry)
2015-02-22 11:38:41 -05:00
ext2
dax: unify ext2/4_{dax,}_file_operations
2015-04-15 16:35:20 -07:00
ext3
fs: move struct kiocb to fs.h
2015-03-25 20:28:11 -04:00
ext4
dax: unify ext2/4_{dax,}_file_operations
2015-04-15 16:35:20 -07:00
f2fs
fs: move struct kiocb to fs.h
2015-03-25 20:28:11 -04:00
fat
fs: move struct kiocb to fs.h
2015-03-25 20:28:11 -04:00
freevxfs
fscache
fs/fscache/object-list.c: use __seq_open_private()
2014-10-13 17:52:21 +01:00
fuse
Merge branch 'iocb' into for-next
2015-04-11 22:24:41 -04:00
gfs2
GFS2: merge window
2015-04-14 16:09:18 -07:00
hfs
fs: move struct kiocb to fs.h
2015-03-25 20:28:11 -04:00
hfsplus
Merge branch 'for-linus-1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2015-04-14 15:31:03 -07:00
hostfs
hpfs
hppfs
VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry)
2015-02-22 11:38:41 -05:00
hugetlbfs
hugetlbfs: accept subpool min_size mount option and setup accordingly
2015-04-15 16:35:18 -07:00
isofs
isofs: Fix bug in the way to check if the year is a leap year
2015-01-07 09:51:49 +01:00
jbd
jbd: Deletion of an unnecessary check before the function call "iput"
2014-11-18 10:15:29 +01:00
jbd2
jbd2: complain about descriptor block checksum errors
2015-01-19 15:59:58 -05:00
jffs2
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial
2015-04-14 09:50:27 -07:00
jfs
fs, jfs: remove slab object constructor
2015-04-15 16:35:18 -07:00
kernfs
kernfs: handle poll correctly on 'direct_read' files.
2015-03-16 21:51:20 +01:00
lockd
Merge branch 'for-3.20' of git://linux-nfs.org/~bfields/linux
2015-02-12 10:39:41 -08:00
logfs
minix
ncpfs
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2015-02-17 14:56:45 -08:00
nfs
kernel: conditionally support non-root users, groups and capabilities
2015-04-15 16:35:22 -07:00
nfs_common
nfsd
kernel: conditionally support non-root users, groups and capabilities
2015-04-15 16:35:22 -07:00
nilfs2
Merge branch 'iocb' into for-next
2015-04-11 22:24:41 -04:00
nls
notify
fanotify: fix event filtering with FAN_ONDIR set
2015-03-12 18:46:08 -07:00
ntfs
Merge branch 'iocb' into for-next
2015-04-11 22:24:41 -04:00
ocfs2
Merge branch 'akpm' (patches from Andrew)
2015-04-14 16:49:17 -07:00
omfs
FS/OMFS: block number sanity check during fill_super operation
2014-10-14 02:18:22 +02:00
openpromfs
overlayfs
ovl: upper fs should not be R/O
2015-03-18 10:29:48 +01:00
proc
lib/string_helpers.c: change semantics of string_escape_mem
2015-04-15 16:35:24 -07:00
pstore
pstore: Fix the ramoops module parameters update
2015-03-16 11:14:10 -07:00
qnx4
qnx6
quota
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
2015-02-10 15:52:38 -08:00
ramfs
fs: remove mapping->backing_dev_info
2015-01-20 14:03:05 -07:00
reiserfs
Merge branch 'iocb' into for-next
2015-04-11 22:24:41 -04:00
romfs
fs: remove mapping->backing_dev_info
2015-01-20 14:03:05 -07:00
squashfs
Squashfs: Add LZ4 compression configuration option
2014-11-27 18:48:44 +00:00
sysfs
sysfs: Only accept read/write permissions for file attributes
2015-03-25 13:27:57 +01:00
sysv
tracefs
tracing: Have mkdir and rmdir be part of tracefs
2015-02-03 12:48:43 -05:00
ubifs
fs: move struct kiocb to fs.h
2015-03-25 20:28:11 -04:00
udf
fs: move struct kiocb to fs.h
2015-03-25 20:28:11 -04:00
ufs
fs/ufs/super.c: fix potential race condition
2015-02-17 14:34:51 -08:00
xfs
Merge branch 'iocb' into for-next
2015-04-11 22:24:41 -04:00
aio.c
Merge branch 'for-linus-1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2015-04-14 15:31:03 -07:00
anon_inodes.c
attr.c
bad_inode.c
don't bother with most of the bad_file_ops methods
2015-02-20 04:03:58 -05:00
binfmt_aout.c
assorted conversions to %p[dD]
2014-11-19 13:01:20 -05:00
binfmt_elf.c
mm: fold arch_randomize_brk into ARCH_HAS_ELF_RANDOMIZE
2015-04-14 16:49:05 -07:00
binfmt_elf_fdpic.c
handle suicide on late failure exits in execve() in search_binary_handler()
2014-10-09 02:39:00 -04:00
binfmt_em86.c
syscalls: implement execveat() system call
2014-12-13 12:42:51 -08:00
binfmt_flat.c
binfmt_misc.c
unfuck binfmt_misc.c (broken by commit e6084d4)
2014-12-17 08:27:14 -05:00
binfmt_script.c
syscalls: implement execveat() system call
2014-12-13 12:42:51 -08:00
block_dev.c
fs: move struct kiocb to fs.h
2015-03-25 20:28:11 -04:00
buffer.c
page_writeback: clean up mess around cancel_dirty_page()
2015-04-14 16:49:01 -07:00
char_dev.c
fs: introduce f_op->mmap_capabilities for nommu mmap support
2015-01-20 14:02:58 -07:00
compat.c
vfs: make first argument of dir_context.actor typed
2014-10-31 17:48:54 -04:00
compat_binfmt_elf.c
compat_ioctl.c
Bluetooth: bnep: Add support for get bnep features via ioctl
2015-04-03 23:21:34 +02:00
coredump.c
coredump: Fix do_coredump() comment
2015-03-06 23:10:29 +01:00
dax.c
dax: use pfn_mkwrite to update c/mtime + freeze protection
2015-04-15 16:35:20 -07:00
dcache.c
dcache: return -ESTALE not -EBUSY on distributed fs race
2015-04-11 22:24:33 -04:00
dcookies.c
direct-io.c
fs: move struct kiocb to fs.h
2015-03-25 20:28:11 -04:00
drop_caches.c
vmscan: per memory cgroup slab shrinkers
2015-02-12 18:54:09 -08:00
eventfd.c
eventfd: don't take the spinlock in eventfd_poll
2015-02-17 14:34:52 -08:00
eventpoll.c
epoll: optimize setting task running after blocking
2015-02-13 21:21:40 -08:00
exec.c
fs: create proper filename objects using getname_kernel()
2015-01-23 00:22:20 -05:00
fcntl.c
vfs: renumber FMODE_NONOTIFY and add to uniqueness check
2015-01-08 15:10:52 -08:00
fhandle.c
file.c
fs/file.c: replace get_unused_fd() with get_unused_fd_flags(0)
2014-12-10 17:41:10 -08:00
file_table.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2014-10-13 11:28:42 +02:00
filesystems.c
fs-writeback.c
fs: add dirtytime_expire_seconds sysctl
2015-03-17 12:23:32 -04:00
fs_pin.c
switch the IO-triggering parts of umount to fs_pin
2015-01-25 23:17:29 -05:00
fs_struct.c
inode.c
Merge branch 'lazytime' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2015-02-17 16:12:34 -08:00
internal.h
trylock_super(): replacement for grab_super_passive()
2015-02-22 11:38:42 -05:00
ioctl.c
fsioctl.c: make generic_block_fiemap() signal-tolerant
2015-02-10 14:30:30 -08:00
Kconfig
dax: does not work correctly with virtual aliasing caches
2015-02-16 17:56:04 -08:00
Kconfig.binfmt
mm: split ET_DYN ASLR from mmap ASLR
2015-04-14 16:49:05 -07:00
libfs.c
VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry)
2015-02-22 11:38:41 -05:00
locks.c
locks: fix file_lock deletion inside loop
2015-03-27 07:18:20 -04:00
Makefile
This adds the new tracefs file system. This has been in linux-next for
2015-04-14 10:22:29 -07:00
mbcache.c
mount.h
switch the IO-triggering parts of umount to fs_pin
2015-01-25 23:17:29 -05:00
mpage.c
vfs: guard end of device for mpage interface
2014-10-09 22:25:53 -04:00
namei.c
remove incorrect comment in lookup_one_len()
2015-04-11 22:24:30 -04:00
namespace.c
VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry)
2015-02-22 11:38:41 -05:00
no-block.c
nsfs.c
take the targets of /proc/*/ns/* symlinks to separate fs
2014-12-10 21:30:20 -05:00
open.c
NFS: fix BUG() crash in notify_change() with patch to chown_common()
2015-04-11 22:24:34 -04:00
pipe.c
fs: move struct kiocb to fs.h
2015-03-25 20:28:11 -04:00
pnode.c
mnt: Move the clear of MNT_LOCKED from copy_tree to it's callers.
2014-12-02 10:46:50 -06:00
pnode.h
posix_acl.c
VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry)
2015-02-22 11:38:41 -05:00
proc_namespace.c
vfs: add support for a lazytime mount option
2015-02-05 02:45:00 -05:00
read_write.c
switch {compat_,}do_readv_writev() to {compat_,}import_iovec()
2015-04-11 22:27:12 -04:00
readdir.c
vfs: make first argument of dir_context.actor typed
2014-10-31 17:48:54 -04:00
select.c
all arches, signal: move restart_block to struct task_struct
2015-02-12 18:54:12 -08:00
seq_file.c
bitmap, cpumask, nodemask: remove dedicated formatting functions
2015-02-13 21:21:39 -08:00
signalfd.c
fs: Convert show_fdinfo functions to void
2014-11-05 14:13:23 -05:00
splice.c
dax: unify ext2/4_{dax,}_file_operations
2015-04-15 16:35:20 -07:00
stack.c
stat.c
switch security_inode_getattr() to struct path *
2015-04-11 22:24:32 -04:00
statfs.c
super.c
cleancache: remove limit on the number of cleancache enabled filesystems
2015-04-14 16:49:03 -07:00
sync.c
vfs: add support for a lazytime mount option
2015-02-05 02:45:00 -05:00
timerfd.c
fs: Convert show_fdinfo functions to void
2014-11-05 14:13:23 -05:00
utimes.c
xattr.c
new helper: audit_file()
2014-11-19 13:01:26 -05:00