From patchwork Sat May 6 02:25:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9714521 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 D73C360387 for ; Sat, 6 May 2017 02:25:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFCE82845D for ; Sat, 6 May 2017 02:25:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3B0928696; Sat, 6 May 2017 02:25:28 +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,DKIM_SIGNED, DKIM_VALID,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 86F3D2845D for ; Sat, 6 May 2017 02:25:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756728AbdEFCZZ (ORCPT ); Fri, 5 May 2017 22:25:25 -0400 Received: from mail-yb0-f195.google.com ([209.85.213.195]:33073 "EHLO mail-yb0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756508AbdEFCZU (ORCPT ); Fri, 5 May 2017 22:25:20 -0400 Received: by mail-yb0-f195.google.com with SMTP id d72so313294ybh.0 for ; Fri, 05 May 2017 19:25:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=f4Enw+YEokVHAFgTaNT/ZyO00DAYRCBsyZLlAOjRhck=; b=DHHte4onohIOSYuMv+1vzJbsOQg0/aH8HMpgAFrr7UrmvWtW7UTY8jr6/aDiRXf8qd MyYK3q1wwL9pC98u41vQpLyfYG2m0h4QMm4vVYifXigrYxMyXV3mwV1YyubX6DSSGn/N qaCCXXH4hNb6NFPBbfQLc53KfJeOi6rqWzPNLCW+2dc8Bs8y+y17172DGIFeVqeeWrrr kuEhyZJlMeKdqPAgBia/Mw4Sey1MugjJkTv5ky+5jg+e8ftODp/jm1IOfcRsK3nr9Eix dSlRBCVcLoQs7APjVhoN8FwRdFEwwfP4m/iRD1zUUMJbqF8ZZwle5mFZYDk2oUisaZET NguQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=f4Enw+YEokVHAFgTaNT/ZyO00DAYRCBsyZLlAOjRhck=; b=hr7oMLOZflKqymc7SrAcVAvDtoiHYw5ioD7Np7YSxY6F7SGjPoqP12/5aucbDx0GNy Yc+nRO79onIGtWIHX2c0oFj+3NSckgaWfYSOYJ1Ketb+wZOmhOrTuJu75fcXOG6IUZpu +gkF2HpBBWXUifz48lL0omCGgO7hxyBJN3qQLBUPlStu0BsaD047wqohS86yUwAGP/pj A9j4v5PmqAgHHhnJLnQwyCU0IAcU1vIBxLeyChwiRaX7iL1g8ZC/0HGOLocQ1YkaUzvX iLZZyl2O7YGoKph2pALGXSJYwfxppRr4XH8Mi18X/XzgrK0S2YJ2eLCH8x38wo+xef5a X/ZA== X-Gm-Message-State: AODbwcAQtFymIpf8rs2vRCjWnF+FN6J9rb++nEfJj+o+ZE5Hm4smyq0D waOM+57pRysywg== X-Received: by 10.37.78.132 with SMTP id c126mr1361453ybb.138.1494037519320; Fri, 05 May 2017 19:25:19 -0700 (PDT) Received: from localhost ([2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id f130sm3250193ywc.41.2017.05.05.19.25.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 May 2017 19:25:18 -0700 (PDT) From: Josef Bacik X-Google-Original-From: Josef Bacik To: axboe@kernel.dk, nbd-general@lists.sourceforge.net, linux-block@vger.kernel.org, kernel-team@fb.com Subject: [PATCH] nbd: ignore non-nbd ioctl's Date: Fri, 5 May 2017 22:25:18 -0400 Message-Id: <1494037518-31903-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.7.4 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In testing we noticed that nbd would spew if you ran a fio job against the raw device itself. This is because fio calls a block device specific ioctl, however the block layer will first pass this back to the driver ioctl handler in case the driver wants to do something special. Since the device was setup using netlink this caused us to spew every time fio called this ioctl. Since we don't have special handling, just error out for any non-nbd specific ioctl's that come in. This fixes the spew. Signed-off-by: Josef Bacik --- drivers/block/nbd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index e9e2a9e..02dd9b0 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1185,6 +1185,12 @@ static int nbd_ioctl(struct block_device *bdev, fmode_t mode, if (!capable(CAP_SYS_ADMIN)) return -EPERM; + /* The block layer will pass back some non-nbd ioctls in case we have + * special handling for them, but we don't so just return an error. + */ + if (_IOC_TYPE(cmd) != 0xab) + return -EINVAL; + mutex_lock(&nbd->config_lock); /* Don't allow ioctl operations on a nbd device that was created with