]> git.baikalelectronics.ru Git - kernel.git/commit
ovl: fix possible use after free on redirect dir lookup
authorAmir Goldstein <amir73il@gmail.com>
Wed, 18 Jan 2017 14:19:54 +0000 (15:19 +0100)
committerMiklos Szeredi <mszeredi@redhat.com>
Wed, 18 Jan 2017 14:19:54 +0000 (15:19 +0100)
commit81fa33ce6063952b182bc95ea9128c1cbd3e1f7f
treec240721d9ca9339d3bebb3a4bf62112ffb36740e
parentb04106bd595baad714f2242e95fc3893cf047edb
ovl: fix possible use after free on redirect dir lookup

ovl_lookup_layer() iterates on path elements of d->name.name
but also frees and allocates a new pointer for d->name.name.

For the case of lookup in upper layer, the initial d->name.name
pointer is stable (dentry->d_name), but for lower layers, the
initial d->name.name can be d->redirect, which can be freed during
iteration.

[SzM]
Keep the count of remaining characters in the redirect path and calculate
the current position from that.  This works becuase only the prefix is
modified, the ending always stays the same.

Fixes: cd2397a50d34 ("ovl: lookup redirects")
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/namei.c