UBIFS: fix use of freed ubifs_orphan objects
authorAdam Thomas <adamthomas1111@gmail.com>
Sat, 2 Feb 2013 22:32:31 +0000 (22:32 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 3 Mar 2013 22:03:33 +0000 (06:03 +0800)
commitce7f4e84411ba5280e3b781f1da56de95e1fd3e7
tree0af03b598850fe04f154ffb98437ec7da9536c45
parent66c45d44d42012bd9ad5e5154cd7d2b391b1183e
UBIFS: fix use of freed ubifs_orphan objects

commit 2928f0d0c5ebd6c9605c0d98207a44376387c298 upstream.

The last orphan in the cnext list has its cnext set to NULL. Because
of that, ubifs_delete_orphan assumes that it is not on the cnext list
and frees it immediately instead of adding it to the dnext list. The
freed orphan is later modified by write_orph_node.

This can cause various inconsistencies including directory entries
that cannot be removed and this error:

UBIFS error (pid 20685): layout_cnodes: LPT out of space at LEB 14:129009 needing 17, done_ltab 1, done_lsave 1

This is a regression introduced by
"7074e5eb UBIFS: remove invalid reference to list iterator variable".

This change adds an explicit flag to ubifs_orphan indicating whether
it is pending commit.

Signed-off-by: Adam Thomas <adamthomas1111@gmail.com>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ubifs/orphan.c
fs/ubifs/ubifs.h