From patchwork Tue Jan 24 20:48:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Frederick X-Patchwork-Id: 9535877 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1FA636042D for ; Tue, 24 Jan 2017 20:51:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FE0B26E56 for ; Tue, 24 Jan 2017 20:51:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02E6D26E73; Tue, 24 Jan 2017 20:51:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9305526CFF for ; Tue, 24 Jan 2017 20:51:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750861AbdAXUvx (ORCPT ); Tue, 24 Jan 2017 15:51:53 -0500 Received: from mailrelay110.isp.belgacom.be ([195.238.20.137]:31313 "EHLO mailrelay110.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750799AbdAXUvw (ORCPT ); Tue, 24 Jan 2017 15:51:52 -0500 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2AdAwDXvIdY/+M5QFdeHgYMgmpKAQEBA?= =?us-ascii?q?QEfQYEojk2RPgFFkjCCD4INhiKCI0AYAQIBAQEBAQEBYiiFFy8jKXEkE4kNEbA?= =?us-ascii?q?LOoQQhn+GS4YrAYhxBZtNkV8NkG6Sdx84gSsaGIQnAVuBcT01h3kBAQE?= X-IPAS-Result: =?us-ascii?q?A2AdAwDXvIdY/+M5QFdeHgYMgmpKAQEBAQEfQYEojk2RPgF?= =?us-ascii?q?FkjCCD4INhiKCI0AYAQIBAQEBAQEBYiiFFy8jKXEkE4kNEbALOoQQhn+GS4YrA?= =?us-ascii?q?YhxBZtNkV8NkG6Sdx84gSsaGIQnAVuBcT01h3kBAQE?= Received: from 227.57-64-87.adsl-dyn.isp.belgacom.be (HELO localhost.localdomain) ([87.64.57.227]) by relay.skynet.be with ESMTP; 24 Jan 2017 21:48:43 +0100 From: Fabian Frederick To: Jan Kara Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, fabf@skynet.be Subject: [PATCH 1/3 linux-next] udf: fix ioctl errors Date: Tue, 24 Jan 2017 21:48:34 +0100 Message-Id: <20170124204836.22323-1-fabf@skynet.be> X-Mailer: git-send-email 2.9.3 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. 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: