From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Brian Foster <bfoster@redhat.com>, Christoph Hellwig <hch@lst.de>,
linux-xfs@vger.kernel.org
Subject: Re: [PATCH v7 5/6] xfs: sanity check inode mode when creating new dentry
Date: Tue, 10 Jan 2017 23:50:27 -0800 [thread overview]
Message-ID: <20170111075027.GR14038@birch.djwong.org> (raw)
In-Reply-To: <CAOQ4uxjcasRkSK0f5OpY5Qtc0iB6uxP5e=XWytSyQM5ni6m2Ow@mail.gmail.com>
On Wed, Jan 11, 2017 at 07:08:57AM +0200, Amir Goldstein wrote:
> On Wed, Jan 11, 2017 at 1:15 AM, Darrick J. Wong
> <darrick.wong@oracle.com> wrote:
> > On Tue, Jan 10, 2017 at 05:39:16PM +0200, Amir Goldstein wrote:
> >> The helper xfs_dentry_to_name() is used by 2 different
> >> classes of callers: Callers that pass zero mode and don't care
> >> about the returned name.type field and Callers that pass
> >> non zero mode and do care about the name.type field.
> >>
> >> Change xfs_dentry_to_name() to not take the mode argument and
> >> change the call sites of the first class to not pass the mode
> >> argument.
> >>
> >> Create a new helper xfs_dentry_mode_to_name() which does pass
> >> the mode argument and returns -EFSCORRUPTED if mode is invalid.
> >> Callers that translate non zero mode to on-disk file type now
> >> check the return value and will export the error to user instead
> >> of staging an invalid file type to be written to directory entry.
> >>
> >> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> >> ---
> ...
> >>
> >> mode = S_IFLNK |
> >> (irix_symlink_mode ? 0777 & ~current_umask() : S_IRWXUGO);
> >> - xfs_dentry_to_name(&name, dentry, mode);
> >> + error = xfs_dentry_mode_to_name(&name, dentry, mode);
> >> + ASSERT(error == 0);
> >
> > Why not the usual 'if (error) goto out;' here?
> >
>
> Because mode here is not coming from disk, nor from user input,
> so an error from converting S_IFLNK would be a programming bug.
> We could also ignore the return value in this case, let me know if you
> prefer that.
Nah, it's just eyebrow-raising since it's a deviation from the usual
paradigm.
> BTW, process question. Do you need me to re-send patched with
> your Reviewed-by, or will you add those when applying?
In general I plan to pull the most recent patch mail and add whatever
tags come in as replies, so if you resend a patch please add the tags
yourself.
--D
>
> Thanks,
> Amir.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-01-11 7:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-10 15:39 [PATCH v7 0/6] xfs: fixes for malformed on-disk i_mode Amir Goldstein
2017-01-10 15:39 ` [PATCH v7 1/6] xfs: make the ASSERT() condition likely Amir Goldstein
2017-01-10 15:39 ` [PATCH v7 2/6] xfs: sanity check directory inode di_size Amir Goldstein
2017-01-10 15:39 ` [PATCH v7 3/6] xfs: add missing include dependencies to xfs_dir2.h Amir Goldstein
2017-01-10 15:39 ` [PATCH v7 4/6] xfs: replace xfs_mode_to_ftype table with switch statement Amir Goldstein
2017-01-10 23:17 ` Darrick J. Wong
2017-01-10 15:39 ` [PATCH v7 5/6] xfs: sanity check inode mode when creating new dentry Amir Goldstein
2017-01-10 23:15 ` Darrick J. Wong
2017-01-11 5:08 ` Amir Goldstein
2017-01-11 7:50 ` Darrick J. Wong [this message]
2017-01-10 15:39 ` [PATCH v7 6/6] xfs: sanity check inode di_mode Amir Goldstein
2017-01-10 23:16 ` Darrick J. Wong
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=20170111075027.GR14038@birch.djwong.org \
--to=darrick.wong@oracle.com \
--cc=amir73il@gmail.com \
--cc=bfoster@redhat.com \
--cc=hch@lst.de \
--cc=linux-xfs@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