dentry name snapshots 33/155233/1 submit/tizen/20171013.014523 submit/tizen_4.0/20171013.014521
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 7 Jul 2017 18:51:19 +0000 (14:51 -0400)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Thu, 12 Oct 2017 10:12:39 +0000 (19:12 +0900)
commit4dd291a003705cd9820a27f3b59a1511930fe26c
tree742659e3755a5b5539026e7b521bc249bc40404e
parent79199edf5bac260c0e9162b58cdbdd340b68d0e2
dentry name snapshots

commit 49d31c2f389acfe83417083e1208422b4091cd9e upstream.

take_dentry_name_snapshot() takes a safe snapshot of dentry name;
if the name is a short one, it gets copied into caller-supplied
structure, otherwise an extra reference to external name is grabbed
(those are never modified).  In either case the pointer to stable
string is stored into the same structure.

dentry must be held by the caller of take_dentry_name_snapshot(),
but may be freely dropped afterwards - the snapshot will stay
until destroyed by release_dentry_name_snapshot().

Intended use:
struct name_snapshot s;

take_dentry_name_snapshot(&s, dentry);
...
access s.name
...
release_dentry_name_snapshot(&s);

Replaces fsnotify_oldname_...(), gets used in fsnotify to obtain the name
to pass down with event.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
[carnil: backport 4.9: adjust context]
[bwh: Backported to 3.16:
 - External names are not ref-counted, so copy them
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
[sw0312.kim: cherry-pick from linux-3.16.y to fix CVE-2017-7533]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: Ied190805c27c67c4e02dac3a1260a2eb202301b7
fs/dcache.c
fs/debugfs/inode.c
fs/namei.c
fs/notify/fsnotify.c
include/linux/dcache.h
include/linux/fsnotify.h