From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751338AbdBCPTg (ORCPT ); Fri, 3 Feb 2017 10:19:36 -0500 Received: from mx2.suse.de ([195.135.220.15]:36446 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751000AbdBCPTV (ORCPT ); Fri, 3 Feb 2017 10:19:21 -0500 Date: Fri, 3 Feb 2017 16:19:07 +0100 From: Jan Kara To: Fabian Frederick Cc: Jan Kara , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3 linux-next] udf: fix ioctl errors Message-ID: <20170203151907.GD5844@quack2.suse.cz> References: <20170124204836.22323-1-fabf@skynet.be> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170124204836.22323-1-fabf@skynet.be> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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 SUSE Labs, CR