From: Jan Kara <jack@suse.cz>
To: Fabian Frederick <fabf@skynet.be>
Cc: Jan Kara <jack@suse.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3 linux-next] udf: fix ioctl errors
Date: Fri, 3 Feb 2017 16:19:07 +0100 [thread overview]
Message-ID: <20170203151907.GD5844@quack2.suse.cz> (raw)
In-Reply-To: <20170124204836.22323-1-fabf@skynet.be>
On Tue 24-01-17 21:48:34, Fabian Frederick wrote:
> Currently, lsattr for instance in udf directory gives
> "udf: Invalid argument While reading flags on ..."
>
> This patch returns -ENOIOCTLCMD
> when command is unknown to have more accurate message like this:
> "Inappropriate ioctl for device While reading flags on ..."
>
> As suggested by Jan Kara, if arg is NULL with a correct ioctl,
> we return -VM_FAULT_SIGBUS to report error.
You cannot return -VM_FAULT_SIGBUS from ioctl handler! Just look how it is
defined - it is an internal error code to the fault handling and in this
case would just get passed as is to userspace. Which suggests you didn't
test this check... Anyway, I've taken the patch and just removed the change
of the error code. Thanks.
Honza
>
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> ---
> fs/udf/file.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/fs/udf/file.c b/fs/udf/file.c
> index dbcb3a4a..d44b3cb 100644
> --- a/fs/udf/file.c
> +++ b/fs/udf/file.c
> @@ -184,9 +184,10 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> goto out;
> }
>
> - if (!arg) {
> + if (!arg && ((cmd == UDF_GETVOLIDENT) || (cmd == UDF_GETEASIZE) ||
> + (cmd == UDF_RELOCATE_BLOCKS) || (cmd == UDF_GETEABLOCK))) {
> udf_debug("invalid argument to udf_ioctl\n");
> - result = -EINVAL;
> + result = -VM_FAULT_SIGBUS;
> goto out;
> }
>
> @@ -220,6 +221,8 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> UDF_I(inode)->i_ext.i_data,
> UDF_I(inode)->i_lenEAttr) ? -EFAULT : 0;
> goto out;
> + default:
> + return -ENOIOCTLCMD;
> }
>
> out:
> --
> 2.9.3
>
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
prev parent reply other threads:[~2017-02-03 15:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-24 20:48 [PATCH 1/3 linux-next] udf: fix ioctl errors Fabian Frederick
2017-01-24 20:48 ` [PATCH 2/3 linux-next] udf: simplify udf_ioctl() Fabian Frederick
2017-02-03 15:25 ` Jan Kara
2017-01-24 20:48 ` [PATCH 3/3 linux-next] udf: remove else after return in udf_ioctl() Fabian Frederick
2017-02-03 15:19 ` Jan Kara [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=20170203151907.GD5844@quack2.suse.cz \
--to=jack@suse.cz \
--cc=fabf@skynet.be \
--cc=jack@suse.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@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).