stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: linux-mtd@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, adrian.hunter@intel.com,
	dedekind1@gmail.com, richard@nod.at, stable@vger.kernel.org,
	Ralph Sennhauser <ralph.sennhauser@gmail.com>,
	Amir Goldstein <amir73il@gmail.com>
Subject: [PATCH] ubifs: Fix O_TMPFILE corner case in ubifs_link()
Date: Thu, 30 Mar 2017 10:56:21 +0200	[thread overview]
Message-ID: <1490864181-2192-1-git-send-email-richard@nod.at> (raw)

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

             reply	other threads:[~2017-03-30  8:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-30  8:56 Richard Weinberger [this message]
2017-03-30  8:59 ` [PATCH] ubifs: Fix O_TMPFILE corner case in ubifs_link() 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1490864181-2192-1-git-send-email-richard@nod.at \
    --to=richard@nod.at \
    --cc=adrian.hunter@intel.com \
    --cc=amir73il@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=ralph.sennhauser@gmail.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).