From patchwork Wed Oct 25 09:56:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10026305 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 588E860375 for ; Wed, 25 Oct 2017 10:04:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5872228AAE for ; Wed, 25 Oct 2017 10:04:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D16328B2A; Wed, 25 Oct 2017 10:04:08 +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.8 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SBL 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 B2F2F28AAE for ; Wed, 25 Oct 2017 10:04:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932438AbdJYKEF (ORCPT ); Wed, 25 Oct 2017 06:04:05 -0400 Received: from osseu17.kernel.org ([147.75.100.161]:34016 "EHLO localhost" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932399AbdJYKED (ORCPT ); Wed, 25 Oct 2017 06:04:03 -0400 X-Greylist: delayed 464 seconds by postgrey-1.27 at vger.kernel.org; Wed, 25 Oct 2017 06:04:02 EDT Received: by localhost (Postfix, from userid 1000) id AB256940717; Wed, 25 Oct 2017 11:56:17 +0200 (CEST) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , "Michael S . Tsirkin" , Dann Frazier , stable@vger.kernel.org Subject: [PATCH v2] virtio_blk: Fix an SG_IO regression Date: Wed, 25 Oct 2017 11:56:17 +0200 Message-Id: <20171025095617.7315-1-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.14.2 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 Avoid that submitting an SG_IO ioctl triggers a kernel oops that is preceded by: usercopy: kernel memory overwrite attempt detected to (null) () (6 bytes) kernel BUG at mm/usercopy.c:72! Reported-by: Dann Frazier Fixes: commit ca18d6f769d2 ("block: Make most scsi_req_init() calls implicit") Signed-off-by: Bart Van Assche Tested-by: Dann Frazier Cc: Michael S. Tsirkin Cc: Dann Frazier Cc: # v4.13 --- drivers/block/Kconfig | 1 + drivers/block/virtio_blk.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 4a438b8abe27..b0b2100763bf 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -450,6 +450,7 @@ config VIRTIO_BLK_SCSI bool "SCSI passthrough request for the Virtio block driver" depends on VIRTIO_BLK select BLK_SCSI_REQUEST + select SCSI_MOD ---help--- Enable support for SCSI passthrough (e.g. the SG_IO ioctl) on virtio-blk devices. This is only supported for the legacy diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 34e17ee799be..15e11a519801 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -597,6 +597,7 @@ static const struct blk_mq_ops virtio_mq_ops = { .queue_rq = virtio_queue_rq, .complete = virtblk_request_done, .init_request = virtblk_init_request, + .initialize_rq_fn = scsi_initialize_rq, .map_queues = virtblk_map_queues, };