--ahZICQ7iXVM/oLYH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hi, the following patch fixes the symlink bug I mentioned a few days ago.
Thanks for your comments.
Louis
--=20
Dr Louis Rilling Kerlabs
Skype: louis.rilling Batiment Germanium
Phone: (+33|0) 6 80 89 08 23 80 avenue des Buttes de Coesmes
http://www.kerlabs.com/ 35700 Rennes
--ahZICQ7iXVM/oLYH
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="configfs-do-not-symlink-to-removing-item.patch"
Content-Transfer-Encoding: quoted-printable
configfs: Fix symlink() to a removing item
[Applies on top of rename() vs rmdir() deadlock fix patchset]
The rule for configfs symlinks is that symlinks always point to valid
config_items, and prevent the target from being removed. However,
configfs_symlink() only checks that it can grab a reference on the target i=
tem,
without ensuring that it remains alive until the symlink is correctly attac=
hed.
This patch makes configfs_symlink() fail whenever the target is being remov=
ed,
using the CONFIGFS_USET_DROPPING flag set by configfs_detach_prep() and
protected by configfs_dirent_lock.
This patch introduces a similar (weird?) behavior as with mkdir failures ma=
king
rmdir fail: if symlink() races with rmdir() of the parent directory (or its
youngest user-created ancestor if parent is a default group) or rmdir() of =
the
target directory, and then fails in configfs_create(), this can make the ra=
cing
rmdir() fail despite the concerned directory having no user-created entry (=
resp.
no symlink pointing to it or one of its default groups) in the end.
If this behavior is found unacceptable, I'll submit a fix in the same spiri=
t as
the racing mkdir() fix.
Signed-off-by: Louis Rilling <Louis.Rilling@kerlabs.com>
---
fs/configfs/dir.c | 14 +++++++-------
fs/configfs/symlink.c | 6 ++++++
2 files changed, 13 insertions(+), 7 deletions...