All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ubifs: Fix O_TMPFILE corner case in ubifs_link()
@ 2017-03-30  8:56 Richard Weinberger
  2017-03-30  8:59 ` Amir Goldstein
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Richard Weinberger @ 2017-03-30  8:56 UTC (permalink / raw)
  To: linux-mtd
  Cc: linux-kernel, adrian.hunter, dedekind1, richard, stable,
	Ralph Sennhauser, Amir Goldstein

It is perfectly fine to link a tmpfile back using linkat().
Since tmpfiles are created with a link count of 0 they appear
on the orphan list, upon re-linking the inode has to be removed
from the orphan list again.

Cc: <stable@vger.kernel.org>
Cc: Ralph Sennhauser <ralph.sennhauser@gmail.com>
Cc: Amir Goldstein <amir73il@gmail.com
Reported-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
Tested-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
Reported-by: Amir Goldstein <amir73il@gmail.com
Fixes: 474b93704f321 ("ubifs: Implement O_TMPFILE")
Signed-off-by: Richard Weinberger <richard@nod.at>
---
 fs/ubifs/dir.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 0858213a4e63..0139155045fe 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -748,6 +748,11 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
 		goto out_fname;
 
 	lock_2_inodes(dir, inode);
+
+	/* Handle O_TMPFILE corner case, it is allowed to link a O_TMPFILE. */
+	if (inode->i_nlink == 0)
+		ubifs_delete_orphan(c, inode->i_ino);
+
 	inc_nlink(inode);
 	ihold(inode);
 	inode->i_ctime = ubifs_current_time(inode);
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2017-04-17 15:54 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-30  8:56 [PATCH] ubifs: Fix O_TMPFILE corner case in ubifs_link() Richard Weinberger
2017-03-30  8:59 ` Amir Goldstein
2017-03-30  9:03   ` Richard Weinberger
2017-03-30  9:07     ` Amir Goldstein
2017-03-30  9:09       ` Richard Weinberger
2017-03-30  9:10   ` Ralph Sennhauser
2017-03-30  9:32 ` Adrian Hunter
2017-03-30  9:49   ` Richard Weinberger
2017-03-30 10:23     ` Richard Weinberger
2017-03-30 10:35       ` Amir Goldstein
2017-03-30 10:51         ` Richard Weinberger
2017-03-30 11:57       ` Adrian Hunter
2017-03-30 12:27         ` Richard Weinberger
2017-04-06 12:06           ` Amir Goldstein
2017-04-06 12:09             ` Richard Weinberger
2017-04-06 12:26               ` Richard Weinberger
2017-04-11 10:20                 ` Amir Goldstein
2017-04-11 10:50                   ` Richard Weinberger
2017-04-11 15:04                     ` Amir Goldstein
2017-04-17 15:27                       ` Ralph Sennhauser
2017-04-17 15:54                         ` Richard Weinberger
2017-03-30 10:34 ` Hyunchul Lee

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.