From: Hyunchul Lee <hyc.lee@gmail.com>
To: Richard Weinberger <richard@nod.at>
Cc: linux-mtd@lists.infradead.org, dedekind1@gmail.com,
Amir Goldstein <amir73il@gmail.com>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
adrian.hunter@intel.com,
Ralph Sennhauser <ralph.sennhauser@gmail.com>,
kernel-team@lge.com
Subject: Re: [PATCH] ubifs: Fix O_TMPFILE corner case in ubifs_link()
Date: Thu, 30 Mar 2017 19:34:12 +0900 [thread overview]
Message-ID: <20170330103412.GA12014@sebu> (raw)
In-Reply-To: <1490864181-2192-1-git-send-email-richard@nod.at>
[-- Attachment #1: Type: text/plain, Size: 1552 bytes --]
Richard,
On Thu, Mar 30, 2017 at 10:56:21AM +0200, Richard Weinberger wrote:
> 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);
> +
I guess that ubifs_delete_orphan should be called if ubifs_jnl_update
succeeds.
> inc_nlink(inode);
> ihold(inode);
> inode->i_ctime = ubifs_current_time(inode);
> --
> 2.7.3
>
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
[-- Attachment #2: fix-unlink --]
[-- Type: text/plain, Size: 422 bytes --]
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 528369f..a2e4a4b 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -757,6 +757,8 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
err = ubifs_jnl_update(c, dir, &nm, inode, 0, 0);
if (err)
goto out_cancel;
+ if (inode->i_nlink == 1)
+ ubifs_delete_orphan(c, inode->i_ino);
unlock_2_inodes(dir, inode);
ubifs_release_budget(c, &req);
prev parent reply other threads:[~2017-03-30 10:34 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=20170330103412.GA12014@sebu \
--to=hyc.lee@gmail.com \
--cc=adrian.hunter@intel.com \
--cc=amir73il@gmail.com \
--cc=dedekind1@gmail.com \
--cc=kernel-team@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=ralph.sennhauser@gmail.com \
--cc=richard@nod.at \
--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).