platform/kernel/linux-rpi3.git
9 years agonamei: path_init() calling conventions change
Al Viro [Fri, 8 May 2015 21:19:59 +0000 (17:19 -0400)]
namei: path_init() calling conventions change

* lift link_path_walk() into callers; moving it down into path_init()
had been a mistake.  Stack footprint, among other things...
* do _not_ call path_cleanup() after path_init() failure; on all failure
exits out of it we have nothing for path_cleanup() to do
* have path_init() return pathname or ERR_PTR(-E...)

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: get rid of nameidata->base
Al Viro [Mon, 11 May 2015 12:05:05 +0000 (08:05 -0400)]
namei: get rid of nameidata->base

we can do fdput() under rcu_read_lock() just fine; all we need to take
care of is fetching nd->inode value first.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: split off filename_lookupat() with LOOKUP_PARENT
Al Viro [Fri, 8 May 2015 20:59:20 +0000 (16:59 -0400)]
namei: split off filename_lookupat() with LOOKUP_PARENT

new functions: filename_parentat() and path_parentat() resp.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: may_follow_link() - lift terminate_walk() on failures into caller
Al Viro [Fri, 8 May 2015 20:38:31 +0000 (16:38 -0400)]
namei: may_follow_link() - lift terminate_walk() on failures into caller

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: take increment of nd->depth into pick_link()
Al Viro [Sun, 10 May 2015 15:50:01 +0000 (11:50 -0400)]
namei: take increment of nd->depth into pick_link()

Makes the situation much more regular - we avoid a strange state
when the element just after the top of stack is used to store
struct path of symlink, but isn't counted in nd->depth.  This
is much more regular, so the normal failure exits, etc., work
fine.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: kill nd->link
Al Viro [Wed, 6 May 2015 20:01:56 +0000 (16:01 -0400)]
namei: kill nd->link

Just store it in nd->stack[nd->depth].link right in pick_link().
Now that we make sure of stack expansion in pick_link(), we can
do so...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agomay_follow_link(): trim arguments
Al Viro [Wed, 6 May 2015 19:58:18 +0000 (15:58 -0400)]
may_follow_link(): trim arguments

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: move bumping the refcount of link->mnt into pick_link()
Al Viro [Tue, 5 May 2015 14:52:35 +0000 (10:52 -0400)]
namei: move bumping the refcount of link->mnt into pick_link()

update the failure cleanup in may_follow_link() to match that.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: fold put_link() into the failure case of complete_walk()
Al Viro [Fri, 8 May 2015 20:28:42 +0000 (16:28 -0400)]
namei: fold put_link() into the failure case of complete_walk()

... and don't open-code unlazy_walk() in there - the only reason
for that is to avoid verfication of cached nd->root, which is
trivially avoided by discarding said cached nd->root first.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: take the treatment of absolute symlinks to get_link()
Al Viro [Sun, 10 May 2015 15:01:00 +0000 (11:01 -0400)]
namei: take the treatment of absolute symlinks to get_link()

rather than letting the callers handle the jump-to-root part of
semantics, do it right in get_link() and return the rest of the
body for the caller to deal with - at that point it's treated
the same way as relative symlinks would be.  And return NULL
when there's no "rest of the body" - those are treated the same
as pure jump symlink would be.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: simpler treatment of symlinks with nothing other that / in the body
Al Viro [Sun, 10 May 2015 14:50:41 +0000 (10:50 -0400)]
namei: simpler treatment of symlinks with nothing other that / in the body

Instead of saving name and branching to OK:, where we'll immediately restore
it, and call walk_component() with WALK_PUT|WALK_GET and nd->last_type being
LAST_BIND, which is equivalent to put_link(nd), err = 0, we can just treat
that the same way we'd treat procfs-style "jump" symlinks - do put_link(nd)
and move on.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: simplify failure exits in get_link()
Al Viro [Sun, 10 May 2015 14:43:46 +0000 (10:43 -0400)]
namei: simplify failure exits in get_link()

when cookie is NULL, put_link() is equivalent to path_put(), so
as soon as we'd set last->cookie to NULL, we can bump nd->depth and
let the normal logics in terminate_walk() to take care of cleanups.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agodon't pass nameidata to ->follow_link()
Al Viro [Sat, 2 May 2015 17:37:52 +0000 (13:37 -0400)]
don't pass nameidata to ->follow_link()

its only use is getting passed to nd_jump_link(), which can obtain
it from current->nameidata

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: simplify the callers of follow_managed()
Al Viro [Wed, 22 Apr 2015 14:30:08 +0000 (10:30 -0400)]
namei: simplify the callers of follow_managed()

now that it gets nameidata, no reason to have setting LOOKUP_JUMPED on
mountpoint crossing and calling path_put_conditional() on failures
done in every caller.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoVFS: replace {, total_}link_count in task_struct with pointer to nameidata
NeilBrown [Mon, 23 Mar 2015 02:37:38 +0000 (13:37 +1100)]
VFS: replace {, total_}link_count in task_struct with pointer to nameidata

task_struct currently contains two ad-hoc members for use by the VFS:
link_count and total_link_count.  These are only interesting to fs/namei.c,
so exposing them explicitly is poor layering.  Incidentally, link_count
isn't used anymore, so it can just die.

This patches replaces those with a single pointer to 'struct nameidata'.
This structure represents the current filename lookup of which
there can only be one per process, and is a natural place to
store total_link_count.

This will allow the current "nameidata" argument to all
follow_link operations to be removed as current->nameidata
can be used instead in the _very_ few instances that care about
it at all.

As there are occasional circumstances where pathname lookup can
recurse, such as through kern_path_locked, we always save and old
current->nameidata (if there is one) when setting a new value, and
make sure any active link_counts are preserved.

follow_mount and follow_automount now get a 'struct nameidata *'
rather than 'int flags' so that they can directly access
total_link_count, rather than going through 'current'.

Suggested-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolustre: rip the private symlink nesting limit out
Al Viro [Sat, 18 Apr 2015 03:02:40 +0000 (23:02 -0400)]
lustre: rip the private symlink nesting limit out

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: move link count check and stack allocation into pick_link()
Al Viro [Mon, 4 May 2015 22:26:59 +0000 (18:26 -0400)]
namei: move link count check and stack allocation into pick_link()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: make should_follow_link() store the link in nd->link
Al Viro [Mon, 4 May 2015 22:13:23 +0000 (18:13 -0400)]
namei: make should_follow_link() store the link in nd->link

... if it decides to follow, that is.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: new calling conventions for walk_component()
Al Viro [Mon, 4 May 2015 21:47:11 +0000 (17:47 -0400)]
namei: new calling conventions for walk_component()

instead of a single flag (!= 0 => we want to follow symlinks) pass
two bits - WALK_GET (want to follow symlinks) and WALK_PUT (put_link()
once we are done looking at the name).  The latter matters only for
success exits - on failure the caller will discard everything anyway.

Suggestions for better variant are welcome; what this thing aims for
is making sure that pending put_link() is done *before* walk_component()
decides to pick a symlink up, rather than between picking it up and
acting upon it.  See the next commit for payoff.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: move the OK: inside the loop
Al Viro [Mon, 4 May 2015 12:58:35 +0000 (08:58 -0400)]
link_path_walk: move the OK: inside the loop

fewer labels that way; in particular, resuming after the end of
nested symlink is straight-line.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: have terminate_walk() do put_link() on everything left
Al Viro [Mon, 4 May 2015 12:34:59 +0000 (08:34 -0400)]
namei: have terminate_walk() do put_link() on everything left

All callers of terminate_walk() are followed by more or less
open-coded eqiuvalent of "do put_link() on everything left
in nd->stack".  Better done in terminate_walk() itself, and
when we go for RCU symlink traversal we'll have to do it
there anyway.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: take put_link() into {lookup,mountpoint,do}_last()
Al Viro [Mon, 4 May 2015 12:26:45 +0000 (08:26 -0400)]
namei: take put_link() into {lookup,mountpoint,do}_last()

rationale: we'll need to have terminate_walk() do put_link() on
everything, which will mean that in some cases ..._last() will do
put_link() anyway.  Easier to have them do it in all cases.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: lift (open-coded) terminate_walk() into callers of get_link()
Al Viro [Mon, 4 May 2015 12:15:36 +0000 (08:15 -0400)]
namei: lift (open-coded) terminate_walk() into callers of get_link()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolift terminate_walk() into callers of walk_component()
Al Viro [Mon, 4 May 2015 11:59:30 +0000 (07:59 -0400)]
lift terminate_walk() into callers of walk_component()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: lift (open-coded) terminate_walk() in follow_dotdot_rcu() into callers
Al Viro [Mon, 4 May 2015 11:53:00 +0000 (07:53 -0400)]
namei: lift (open-coded) terminate_walk() in follow_dotdot_rcu() into callers

follow_dotdot_rcu() does an equivalent of terminate_walk() on failure;
shifting it into callers makes for simpler rules and those callers
already have terminate_walk() on other failure exits.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: we never need more than MAXSYMLINKS entries in nd->stack
Al Viro [Mon, 4 May 2015 01:30:27 +0000 (21:30 -0400)]
namei: we never need more than MAXSYMLINKS entries in nd->stack

The only reason why we needed one more was that purely nested
MAXSYMLINKS symlinks could lead to path_init() using that many
entries in addition to nd->stack[0] which it left unused.

That can't happen now - path_init() starts with entry 0 (and
trailing_symlink() is called only when we'd already encountered
one symlink, so no more than MAXSYMLINKS-1 are left).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: end of nd->depth massage
Al Viro [Mon, 4 May 2015 01:27:36 +0000 (21:27 -0400)]
link_path_walk: end of nd->depth massage

get rid of orig_depth - we only use it on error exit to tell whether
to stop doing put_link() when depth reaches 0 (call from path_init())
or when it reaches 1 (call from trailing_symlink()).  However, in
the latter case the caller would immediately follow with one more
put_link().  Just keep doing it until the depth reaches zero (and
simplify trailing_symlink() as the result).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: nd->depth massage, part 10
Al Viro [Mon, 4 May 2015 01:21:44 +0000 (21:21 -0400)]
link_path_walk: nd->depth massage, part 10

Get rid of orig_depth checks in OK: logics.  If nd->depth is
zero, we had been called from path_init() and we are done.
If it is greater than 1, we are not done, whether we'd been
called from path_init() or trailing_symlink().  And in
case when it's 1, we might have been called from path_init()
and reached the end of nested symlink (in which case
nd->stack[0].name will point to the rest of pathname and
we are not done) or from trailing_symlink(), in which case
we are done.

Just have trailing_symlink() leave NULL in nd->stack[0].name
and use that to discriminate between those cases.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: nd->depth massage, part 9
Al Viro [Mon, 4 May 2015 01:16:35 +0000 (21:16 -0400)]
link_path_walk: nd->depth massage, part 9

Make link_path_walk() work with any value of nd->depth on entry -
memorize it and use it in tests instead of comparing with 1.
Don't bother with increment/decrement in path_init().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoput_link: nd->depth massage, part 8
Al Viro [Mon, 4 May 2015 01:06:24 +0000 (21:06 -0400)]
put_link: nd->depth massage, part 8

all calls are preceded by decrement of nd->depth; move it into
put_link() itself.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agotrailing_symlink: nd->depth massage, part 7
Al Viro [Mon, 4 May 2015 01:04:07 +0000 (21:04 -0400)]
trailing_symlink: nd->depth massage, part 7

move decrement of nd->depth on successful returns into the callers.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoget_link: nd->depth massage, part 6
Al Viro [Mon, 4 May 2015 01:02:40 +0000 (21:02 -0400)]
get_link: nd->depth massage, part 6

make get_link() increment nd->depth on successful exit

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agotrailing_symlink: nd->depth massage, part 5
Al Viro [Mon, 4 May 2015 00:59:58 +0000 (20:59 -0400)]
trailing_symlink: nd->depth massage, part 5

move increment of ->depth to the point where we'd discovered
that get_link() has not returned an error, adjust exits
accordingly.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: nd->depth massage, part 4
Al Viro [Mon, 4 May 2015 00:54:27 +0000 (20:54 -0400)]
link_path_walk: nd->depth massage, part 4

lift increment/decrement into link_path_walk() callers.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: nd->depth massage, part 3
Al Viro [Mon, 4 May 2015 00:52:15 +0000 (20:52 -0400)]
link_path_walk: nd->depth massage, part 3

remove decrement/increment surrounding nd_alloc_stack(), adjust the
test in it.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: nd->depth massage, part 2
Al Viro [Mon, 4 May 2015 00:46:54 +0000 (20:46 -0400)]
link_path_walk: nd->depth massage, part 2

collapse adjacent increment/decrement pairs.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: nd->depth massage, part 1
Al Viro [Mon, 4 May 2015 00:01:27 +0000 (20:01 -0400)]
link_path_walk: nd->depth massage, part 1

nd->stack[0] is unused until the handling of trailing symlinks and
we want to get rid of that.  Having fucked that transformation up
several times, I went for bloody pedantic series of provably equivalent
transformations.  Sorry.

Step 1: keep nd->depth higher by one in link_path_walk() - increment upon
entry, decrement on exits, adjust the arithmetics inside and surround the
calls of functions that care about nd->depth value (nd_alloc_stack(),
get_link(), put_link()) with decrement/increment pairs.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: remove restrictions on nesting depth
Al Viro [Sat, 2 May 2015 11:16:16 +0000 (07:16 -0400)]
namei: remove restrictions on nesting depth

The only restriction is that on the total amount of symlinks
crossed; how they are nested does not matter

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: trim the arguments of get_link()
Al Viro [Sun, 19 Apr 2015 04:53:50 +0000 (00:53 -0400)]
namei: trim the arguments of get_link()

same story as the previous commit

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: trim redundant arguments of fs/namei.c:put_link()
Al Viro [Sun, 3 May 2015 00:19:23 +0000 (20:19 -0400)]
namei: trim redundant arguments of fs/namei.c:put_link()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: trim redundant arguments of trailing_symlink()
Al Viro [Sat, 2 May 2015 23:48:56 +0000 (19:48 -0400)]
namei: trim redundant arguments of trailing_symlink()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: move link/cookie pairs into nameidata
Al Viro [Sat, 2 May 2015 23:38:35 +0000 (19:38 -0400)]
namei: move link/cookie pairs into nameidata

Array of MAX_NESTED_LINKS + 1 elements put into nameidata;
what used to be a local array in link_path_walk() occupies
entries 1 .. MAX_NESTED_LINKS in it, link and cookie from
the trailing symlink handling loops - entry 0.

This is _not_ the final arrangement; just an easily verified
incremental step.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: cleanup - turn goto start; into continue;
Al Viro [Sun, 19 Apr 2015 00:44:34 +0000 (20:44 -0400)]
link_path_walk: cleanup - turn goto start; into continue;

Deal with skipping leading slashes before what used to be the
recursive call.  That way we can get rid of that goto completely.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: split "return from recursive call" path
Al Viro [Sun, 19 Apr 2015 00:40:04 +0000 (20:40 -0400)]
link_path_walk: split "return from recursive call" path

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: kill the recursion
Al Viro [Sun, 19 Apr 2015 00:30:49 +0000 (20:30 -0400)]
link_path_walk: kill the recursion

absolutely straightforward now - the only variables we need to preserve
across the recursive call are name, link and cookie, and recursion depth
is limited (and can is equal to nd->depth).  So arrange an array of
triples to hold instances of those and be done with that.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: final preparations to killing recursion
Al Viro [Sun, 19 Apr 2015 00:21:40 +0000 (20:21 -0400)]
link_path_walk: final preparations to killing recursion

reduce the number of returns in there - turn all places
where it returns zero into goto OK and places where it
returns non-zero into goto Err.  The only non-trivial
detail is that all breaks in the loop are guaranteed
to be with non-zero err.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: get rid of duplication
Al Viro [Sun, 19 Apr 2015 00:14:20 +0000 (20:14 -0400)]
link_path_walk: get rid of duplication

What we do after the second walk_component() + put_link() + depth
decrement in there is exactly equivalent to what's done right
after the first walk_component().  Easy to verify and not at all
surprising, seeing that there we have just walked the last
component of nested symlink.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: massage a bit more
Al Viro [Sun, 19 Apr 2015 00:09:08 +0000 (20:09 -0400)]
link_path_walk: massage a bit more

Pull the block after the if-else in the end of what used to be do-while
body into all branches there.  We are almost done with the massage...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: turn inner loop into explicit goto
Al Viro [Sun, 19 Apr 2015 00:03:03 +0000 (20:03 -0400)]
link_path_walk: turn inner loop into explicit goto

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: don't bother with walk_component() after jumping link
Al Viro [Sat, 18 Apr 2015 23:19:01 +0000 (19:19 -0400)]
link_path_walk: don't bother with walk_component() after jumping link

... it does nothing if nd->last_type is LAST_BIND.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolink_path_walk: handle get_link() returning ERR_PTR() immediately
Al Viro [Sat, 18 Apr 2015 23:10:36 +0000 (19:10 -0400)]
link_path_walk: handle get_link() returning ERR_PTR() immediately

If we get ERR_PTR() from get_link(), we are guaranteed to get err != 0
when we break out of do-while, so we are going to hit if (err) return err;
shortly after it.  Pull that into the if (IS_ERR(s)) body.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: rename follow_link to trailing_symlink, move it down
Al Viro [Wed, 22 Apr 2015 17:46:57 +0000 (13:46 -0400)]
namei: rename follow_link to trailing_symlink, move it down

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: move the calls of may_follow_link() into follow_link()
Al Viro [Sun, 19 Apr 2015 04:16:37 +0000 (00:16 -0400)]
namei: move the calls of may_follow_link() into follow_link()

All remaining callers of the former are preceded by the latter

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: expand the call of follow_link() in link_path_walk()
Al Viro [Sat, 18 Apr 2015 22:45:16 +0000 (18:45 -0400)]
namei: expand the call of follow_link() in link_path_walk()

... and strip __always_inline from follow_link() - remaining callers
don't need that.

Now link_path_walk() recursion is a direct one.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: expand nested_symlink() in its only caller
Al Viro [Sat, 18 Apr 2015 03:44:45 +0000 (23:44 -0400)]
namei: expand nested_symlink() in its only caller

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agodo_last: move path there from caller's stack frame
Al Viro [Wed, 22 Apr 2015 22:02:17 +0000 (18:02 -0400)]
do_last: move path there from caller's stack frame

We used to need it to feed to follow_link().  No more...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: introduce nameidata->link
Al Viro [Wed, 22 Apr 2015 21:52:47 +0000 (17:52 -0400)]
namei: introduce nameidata->link

shares space with nameidata->next, walk_component() et.al. store
the struct path of symlink instead of returning it into a variable
passed by caller.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: don't bother with ->follow_link() if ->i_link is set
Al Viro [Fri, 1 May 2015 00:08:02 +0000 (20:08 -0400)]
namei: don't bother with ->follow_link() if ->i_link is set

with new calling conventions it's trivial

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Conflicts:
fs/namei.c

9 years agonamei.c: separate the parts of follow_link() that find the link body
Al Viro [Sat, 18 Apr 2015 22:23:41 +0000 (18:23 -0400)]
namei.c: separate the parts of follow_link() that find the link body

Split a piece of fs/namei.c:follow_link() that does obtaining the link
body into a separate function.  follow_link() itself is converted to
calling get_link() and then doing the body traversal (if any).

The next step will expand follow_link() call in link_path_walk()
and this helps to keep the size down...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonew ->follow_link() and ->put_link() calling conventions
Al Viro [Sat, 2 May 2015 17:32:22 +0000 (13:32 -0400)]
new ->follow_link() and ->put_link() calling conventions

a) instead of storing the symlink body (via nd_set_link()) and returning
an opaque pointer later passed to ->put_link(), ->follow_link() _stores_
that opaque pointer (into void * passed by address by caller) and returns
the symlink body.  Returning ERR_PTR() on error, NULL on jump (procfs magic
symlinks) and pointer to symlink body for normal symlinks.  Stored pointer
is ignored in all cases except the last one.

Storing NULL for opaque pointer (or not storing it at all) means no call
of ->put_link().

b) the body used to be passed to ->put_link() implicitly (via nameidata).
Now only the opaque pointer is.  In the cases when we used the symlink body
to free stuff, ->follow_link() now should store it as opaque pointer in addition
to returning it.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: lift nameidata into filename_mountpoint()
Al Viro [Sat, 2 May 2015 02:08:30 +0000 (22:08 -0400)]
namei: lift nameidata into filename_mountpoint()

when we go for on-demand allocation of saved state in
link_path_walk(), we'll want nameidata to stay around
for all 3 calls of path_mountpoint().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoname: shift nameidata down into user_path_walk()
Al Viro [Thu, 30 Apr 2015 20:09:11 +0000 (16:09 -0400)]
name: shift nameidata down into user_path_walk()

that avoids having nameidata on stack during the calls of
->rmdir()/->unlink() and *two* of those during the calls
of ->rename().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: get rid of lookup_hash()
Al Viro [Thu, 30 Apr 2015 16:25:18 +0000 (12:25 -0400)]
namei: get rid of lookup_hash()

it's a convenient helper, but we'll want to shift nameidata
down the call chain, so it won't be available there...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agodo_last: regularize the logics around following symlinks
Al Viro [Wed, 22 Apr 2015 16:10:45 +0000 (12:10 -0400)]
do_last: regularize the logics around following symlinks

With LOOKUP_FOLLOW we unlazy and return 1; without it we either
fail with ELOOP or, for O_PATH opens, succeed.  No need to mix
those cases...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agodo_last: kill symlink_ok
Al Viro [Wed, 22 Apr 2015 16:02:25 +0000 (12:02 -0400)]
do_last: kill symlink_ok

When O_PATH is present, O_CREAT isn't, so symlink_ok is always equal to
(open_flags & O_PATH) && !(nd->flags & LOOKUP_FOLLOW).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agonamei: take O_NOFOLLOW treatment into do_last()
Al Viro [Wed, 22 Apr 2015 15:27:43 +0000 (11:27 -0400)]
namei: take O_NOFOLLOW treatment into do_last()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agouninline walk_component()
Al Viro [Sun, 19 Apr 2015 11:48:53 +0000 (07:48 -0400)]
uninline walk_component()

seriously improves the stack *and* I-cache footprint...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoSECURITY: remove nameidata arg from inode_follow_link.
NeilBrown [Mon, 23 Mar 2015 02:37:39 +0000 (13:37 +1100)]
SECURITY: remove nameidata arg from inode_follow_link.

No ->inode_follow_link() methods use the nameidata arg, and
it is about to become private to namei.c.
So remove from all inode_follow_link() functions.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agologfs: fix a pagecache leak for symlinks
Al Viro [Tue, 21 Apr 2015 14:48:50 +0000 (10:48 -0400)]
logfs: fix a pagecache leak for symlinks

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoceph: switch to simple_follow_link()
Al Viro [Sat, 2 May 2015 14:50:05 +0000 (10:50 -0400)]
ceph: switch to simple_follow_link()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoexofs: switch to {simple,page}_symlink_inode_operations
Al Viro [Sat, 2 May 2015 14:46:42 +0000 (10:46 -0400)]
exofs: switch to {simple,page}_symlink_inode_operations

ACK-by: Boaz Harrosh <ooo@electrozaur.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agofreevxfs: switch to simple_follow_link()
Al Viro [Sat, 2 May 2015 14:43:25 +0000 (10:43 -0400)]
freevxfs: switch to simple_follow_link()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agojfs: switch to simple_follow_link()
Al Viro [Sat, 2 May 2015 14:41:20 +0000 (10:41 -0400)]
jfs: switch to simple_follow_link()

Reviewed-by: Jan Kara <jack@suse.cz>
Acked-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agosysv: switch to simple_follow_link()
Al Viro [Sat, 2 May 2015 14:37:09 +0000 (10:37 -0400)]
sysv: switch to simple_follow_link()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoubifs: switch to simple_follow_link()
Al Viro [Sat, 2 May 2015 14:35:42 +0000 (10:35 -0400)]
ubifs: switch to simple_follow_link()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoufs: switch to simple_follow_link()
Al Viro [Sat, 2 May 2015 14:28:56 +0000 (10:28 -0400)]
ufs: switch to simple_follow_link()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agodebugfs: switch to simple_follow_link()
Al Viro [Sat, 2 May 2015 14:27:18 +0000 (10:27 -0400)]
debugfs: switch to simple_follow_link()

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoshmem: switch to simple_follow_link()
Al Viro [Sat, 2 May 2015 14:24:43 +0000 (10:24 -0400)]
shmem: switch to simple_follow_link()

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agojffs2: switch to simple_follow_link()
Al Viro [Sat, 2 May 2015 14:21:20 +0000 (10:21 -0400)]
jffs2: switch to simple_follow_link()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoext4: switch to simple_follow_link()
Al Viro [Sat, 2 May 2015 14:13:58 +0000 (10:13 -0400)]
ext4: switch to simple_follow_link()

for fast symlinks only, of course...

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoext3: switch to simple_follow_link()
Al Viro [Sat, 2 May 2015 14:10:02 +0000 (10:10 -0400)]
ext3: switch to simple_follow_link()

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agobefs: switch to simple_follow_link()
Al Viro [Sat, 2 May 2015 14:06:54 +0000 (10:06 -0400)]
befs: switch to simple_follow_link()

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoext2: use simple_follow_link()
Al Viro [Sat, 2 May 2015 14:02:46 +0000 (10:02 -0400)]
ext2: use simple_follow_link()

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agolibfs: simple_follow_link()
Al Viro [Sat, 2 May 2015 13:54:06 +0000 (09:54 -0400)]
libfs: simple_follow_link()

let "fast" symlinks store the pointer to the body into ->i_link and
use simple_follow_link for ->follow_link()

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoext4: split inode_operations for encrypted symlinks off the rest
Al Viro [Mon, 27 Apr 2015 21:51:30 +0000 (17:51 -0400)]
ext4: split inode_operations for encrypted symlinks off the rest

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoovl: rearrange ovl_follow_link to it doesn't need to call ->put_link
NeilBrown [Mon, 23 Mar 2015 02:37:39 +0000 (13:37 +1100)]
ovl: rearrange ovl_follow_link to it doesn't need to call ->put_link

ovl_follow_link current calls ->put_link on an error path.
However ->put_link is about to change in a way that it will be
impossible to call it from ovl_follow_link.

So rearrange the code to avoid the need for that error path.
Specifically: move the kmalloc() call before the ->follow_link()
call to the subordinate filesystem.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years ago9p: don't bother with __getname() in ->follow_link()
Al Viro [Tue, 14 Apr 2015 21:42:49 +0000 (17:42 -0400)]
9p: don't bother with __getname() in ->follow_link()

We copy there a kmalloc'ed string and proceed to kfree that string immediately
after that.  Easier to just feed that string to nd_set_link() and _not_
kfree it until ->put_link() (which becomes kfree_put_link() in that case).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years ago9p: don't bother with 4K allocation for 24-byte local array...
Al Viro [Tue, 14 Apr 2015 16:10:34 +0000 (12:10 -0400)]
9p: don't bother with 4K allocation for 24-byte local array...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
9 years agoLinux 4.1-rc3
Linus Torvalds [Sun, 10 May 2015 22:12:29 +0000 (15:12 -0700)]
Linux 4.1-rc3

9 years agoMerge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux
Linus Torvalds [Sun, 10 May 2015 21:58:53 +0000 (14:58 -0700)]
Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux

Pull drm fixes from Dave Airlie:
 "I really need to get back to sending these on my Friday, instead of my
  Monday morning, but nothing too amazing in here: a few amdkfd fixes, a
  few radeon fixes, i915 fixes, one tegra fix and one core fix"

* 'drm-fixes' of git://people.freedesktop.org/~airlied/linux:
  drm: Zero out invalid vblank timestamp in drm_update_vblank_count.
  drm/tegra: Don't use vblank_disable_immediate on incapable driver.
  drm/radeon: stop trying to suspend UVD sessions
  drm/radeon: more strictly validate the UVD codec
  drm/radeon: make UVD handle checking more strict
  drm/radeon: make VCE handle check more strict
  drm/radeon: fix userptr lockup
  drm/radeon: fix userptr BO unpin bug v3
  drm/amdkfd: Initialize sdma vm when creating sdma queue
  drm/amdkfd: Don't report local memory size
  drm/amdkfd: allow unregister process with queues
  drm/i915: Drop PIPE-A quirk for 945GSE HP Mini
  drm/i915: Sink rate read should be saved in deca-kHz
  drm/i915/dp: there is no audio on port A
  drm/i915: Add missing MacBook Pro models with dual channel LVDS
  drm/i915: Assume dual channel LVDS if pixel clock necessitates it
  drm/radeon: don't setup audio on asics that don't support it
  drm/radeon: disable semaphores for UVD V1 (v2)

9 years agoMerge tag 'drm-intel-fixes-2015-05-08' of git://anongit.freedesktop.org/drm-intel...
Dave Airlie [Sun, 10 May 2015 20:06:22 +0000 (06:06 +1000)]
Merge tag 'drm-intel-fixes-2015-05-08' of git://anongit.freedesktop.org/drm-intel into drm-fixes

misc i915 fixes.

* tag 'drm-intel-fixes-2015-05-08' of git://anongit.freedesktop.org/drm-intel:
  drm/i915: Drop PIPE-A quirk for 945GSE HP Mini
  drm/i915: Sink rate read should be saved in deca-kHz
  drm/i915/dp: there is no audio on port A
  drm/i915: Add missing MacBook Pro models with dual channel LVDS
  drm/i915: Assume dual channel LVDS if pixel clock necessitates it

9 years agodrm: Zero out invalid vblank timestamp in drm_update_vblank_count.
Mario Kleiner [Tue, 7 Apr 2015 04:31:09 +0000 (06:31 +0200)]
drm: Zero out invalid vblank timestamp in drm_update_vblank_count.

Since commit 844b03f27739135fe1fed2fef06da0ffc4c7a081 we make
sure that after vblank irq off, we return the last valid
(vblank count, vblank timestamp) pair to clients, e.g., during
modesets, which is good.

An overlooked side effect of that commit for kms drivers without
support for precise vblank timestamping is that at vblank irq
enable, when we update the vblank counter from the hw counter, we
can't update the corresponding vblank timestamp, so now we have a
totally mismatched timestamp for the new count to confuse clients.

Restore old client visible behaviour from before Linux 3.17, but
zero out the timestamp at vblank counter update (instead of disable
as in original implementation) if we can't generate a meaningful
timestamp immediately for the new vblank counter. This will fix
this regression, so callers know they need to retry again later
if they need a valid timestamp, but at the same time preserves
the improvements made in the commit mentioned above.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: <stable@vger.kernel.org> #v3.17+
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agoMerge branch 'fixes' of git://ftp.arm.linux.org.uk/~rmk/linux-arm
Linus Torvalds [Sun, 10 May 2015 18:16:48 +0000 (11:16 -0700)]
Merge branch 'fixes' of git://ftp.arm.linux.org.uk/~rmk/linux-arm

Pull ARM fixes from Russell King:
 "A set of ARM fixes:

   - fix an off-by-one error in the iommu DMA ops, which caused errors
     with a 4GiB size.

   - remove comments mentioning the non-existent CONFIG_CPU_ARM1020_CPU_IDLE
     macro.

   - remove useless CONFIG_CPU_ICACHE_STREAMING_DISABLE blocks, where
     this symbol never appeared in any Kconfig.

   - fix Feroceon code to cope with a previous change correctly (it
     incorrectly left an additional word in an assembly structure
     definition)

   - avoid a misleading IRQ affinity warning in the ARM PMU code for
     IRQs which are already affine to their CPUs.

   - fix the node name printed in the IRQ affinity warning"

* 'fixes' of git://ftp.arm.linux.org.uk/~rmk/linux-arm:
  ARM: 8352/1: perf: Fix the pmu node name in warning message
  ARM: 8351/1: perf: don't warn about missing interrupt-affinity property for PPIs
  ARM: 8350/1: proc-feroceon: Fix feroceon_proc_info macro
  ARM: 8349/1: arch/arm/mm/proc-arm925.S: remove dead #ifdef block
  ARM: 8348/1: remove comments on CPU_ARM1020_CPU_IDLE
  ARM: 8347/1: dma-mapping: fix off-by-one check in arm_setup_iommu_dma_ops

9 years agoMerge tag 'samsung-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene...
Linus Torvalds [Sun, 10 May 2015 18:13:19 +0000 (11:13 -0700)]
Merge tag 'samsung-fixes-1' of git://git./linux/kernel/git/kgene/linux-samsung

Pull samsung fixes from Kukjin Kim:
 "Here is Samsung fixes for v4.1.  Since I've missed to send this via
  arm-soc tree before v4.1-rc3, so I'm sending this to you directly

   - fix commit ea08de16eb1b ("ARM: dts: Add DISP1 power domain for
     exynos5420") which causes 'unhandled fault: imprecise external
     abort' error when PD turned off.  ("make DP a consumer of DISP1
     power domain")

   - fix 's3c-rtc' probe failure on Odriod-X2/U2/U3 boards ("add
     'rtc_src' clock to rtc node for source clock of rtc")

   - fix typo for 'cpu-crit-0' trip point on exynos5420/5440

   - fix S2R failure on exynos5250-snow due to card power of Marvell
     WiFi driver (suspend/resume) ("add keep-power-in-susped to WiFi
     SDIO node")"

* tag 'samsung-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung:
  ARM: dts: Add keep-power-in-suspend to WiFi SDIO node for exynos5250-snow
  ARM: dts: Fix typo in trip point temperature for exynos5420/5440
  ARM: dts: add 'rtc_src' clock to rtc node for exynos4412-odroid boards
  ARM: dts: Make DP a consumer of DISP1 power domain on Exynos5420

9 years agoMerge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm...
Linus Torvalds [Sat, 9 May 2015 23:13:38 +0000 (16:13 -0700)]
Merge tag 'fixes-for-linus' of git://git./linux/kernel/git/arm/arm-soc

Pull ARM SoC fixes from Arnd Bergmann:
 "A few patches have come up since the merge window.  The largest one is
  a rewrite of the PXA lubbock/mainstone IRQ handling.  This was already
  broken in 2011 by a change to the GPIO code and only noticed now.

  The other changes contained here are:

  MAINTAINERS file updates:

   - Ray Jui and Scott Branden are now co-maintainers for some of the
     mach-bcm chips, while Christian Daudt and Marc Carino have stepped
     down.

   - Andrew Victor is no longer maintaining at91.  Instead, Alexandre
     Belloni now becomes an official maintainer, after having done a
     bulk of the work for a while.

   - Baruch Siach, who added the mach-digicolor platform in 4.1 is now
     listed as maintainer

   - The git URL for mach-socfpga has changed

  Bug fixes:

   - Three bug fixes for new rockchip rk3288 code

   - A regression fix to make SD card support work on certain ux500
     boards

   - multiple smaller dts fixes for imx, omap, mvebu, and shmobile

   - a regression fiix for omap3 power consumption

   - a fix for regression in the ARM CCI bus driver

  Configuration changes:

   - more imx platforms are now enabled in multi_v7_defconfig"

* tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (39 commits)
  MAINTAINERS: add Conexant Digicolor machines entry
  MAINTAINERS: socfpga: update the git repo for SoCFPGA
  ARM: multi_v7_defconfig: Select more FSL SoCs
  MAINTAINERS: replace an AT91 maintainer
  drivers: CCI: fix used_mask init in validate_group()
  bus: omap_l3_noc: Fix master id address decoding for OMAP5
  bus: omap_l3_noc: Fix offset for DRA7 CLK1_HOST_CLK1_2 instance
  ARM: dts: dra7: Fix efuse register size for ABB
  ARM: dts: am57xx-beagle-x15: Switch GPIO fan number
  ARM: dts: am57xx-beagle-x15: Switch UART mux pins
  ARM: dts: am437x-sk: reduce col-scan-delay-us
  ARM: dts: am437x-sk: fix for new newhaven display module revision
  ARM: dts: am57xx-beagle-x15: Fix RTC aliases
  ARM: dts: am57xx-beagle-x15: Fix IRQ type for mcp7941x
  ARM: dts: omap3: Add #iommu-cells to isp and iva iommu
  ARM: omap2plus_defconfig: Enable EXTCON_USB_GPIO
  ARM: dts: OMAP3-N900: Add microphone bias voltages
  ARM: OMAP2+: Fix omap off idle power consumption creeping up
  MAINTAINERS: Update brcmstb entry
  MAINTAINERS: Remove Christian Daudt for mach-bcm
  ...

9 years agoMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm...
Linus Torvalds [Sat, 9 May 2015 23:07:14 +0000 (16:07 -0700)]
Merge branch 'for-linus' of git://git./linux/kernel/git/ebiederm/user-namespace

Pull user-namespace fix from Eric Biederman:
 "Eric Windish recently reported a really bug that allows mounting fresh
  copies of proc and sysfs when it really should not be allowed.  The
  code attempted to verify that proc and sysfs were fully visible but
  there is a test missing to ensure that the root of the filesystem is
  visible.  Doh!

  The following patch fixes that.

  This fixes a containment issue that the docker folks are seeing"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace:
  mnt: Fix fs_fully_visible to verify the root directory is visible

9 years agoMerge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 9 May 2015 21:59:05 +0000 (14:59 -0700)]
Merge branch 'irq-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

Pull irq updates from Thomas Gleixner:
 "Two patches from the irq departement:

   - a simple fix to make dummy_irq_chip usable for wakeup scenarios

   - removal of the gic arch_extn hackery.  Now that all users are
     converted we really want to get rid of the interface so people wont
     come up with new use cases"

* 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  irqchip: gic: Drop support for gic_arch_extn
  genirq: Set IRQCHIP_SKIP_SET_WAKE flag for dummy_irq_chip

9 years agoMerge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 9 May 2015 21:57:49 +0000 (14:57 -0700)]
Merge branch 'timers-urgent-for-linus' of git://git./linux/kernel/git/tip/tip

Pull timer fix from Thomas Gleixner:
 "A simple fix to actually shut down a detached device instead of
  keeping it active"

* 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  clockevents: Shutdown detached clockevent device

9 years agom32r: make flush_cpumask non-volatile.
Rusty Russell [Fri, 8 May 2015 18:09:52 +0000 (03:39 +0930)]
m32r: make flush_cpumask non-volatile.

We cast away the volatile, but really, why make it volatile at all?
We already do a mb() inside the cpumask_empty() loop.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9 years agomnt: Fix fs_fully_visible to verify the root directory is visible
Eric W. Biederman [Fri, 8 May 2015 21:36:50 +0000 (16:36 -0500)]
mnt: Fix fs_fully_visible to verify the root directory is visible

This fixes a dumb bug in fs_fully_visible that allows proc or sys to
be mounted if there is a bind mount of part of /proc/ or /sys/ visible.

Cc: stable@vger.kernel.org
Reported-by: Eric Windisch <ewindisch@docker.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>