Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S942198AbcLWTtn (ORCPT ); Fri, 23 Dec 2016 14:49:43 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:35107 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S942111AbcLWTtg (ORCPT ); Fri, 23 Dec 2016 14:49:36 -0500 MIME-Version: 1.0 In-Reply-To: <20161223100014.GA29467@lst.de> References: <20161216185906.t2wmrr6wqjdsrduw@straylight.hirudinean.org> <20161221221638.GD4758@dastard> <20161222001303.nvrtm22szn3hgxar@straylight.hirudinean.org> <20161222051322.GF4758@dastard> <20161222065012.GI4758@dastard> <20161222185030.so4btkuzzkih3owz@straylight.hirudinean.org> <20161223000356.dxwkgsei32w7hc4f@straylight.hirudinean.org> <20161223100014.GA29467@lst.de> From: Linus Torvalds Date: Fri, 23 Dec 2016 11:42:45 -0800 X-Google-Sender-Auth: tBdgwueTCfpuVR8lw8Jixg5aX_0 Message-ID: Subject: Re: [4.10, panic, regression] iscsi: null pointer deref at iscsi_tcp_segment_done+0x20d/0x2e0 To: Christoph Hellwig Cc: Chris Leech , Ming Lei , Dave Chinner , Johannes Weiner , Linux Kernel Mailing List , Lee Duncan , open-iscsi@googlegroups.com, Linux SCSI List , linux-block , Jens Axboe , "Michael S. Tsirkin" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1091 Lines: 29 On Fri, Dec 23, 2016 at 2:00 AM, Christoph Hellwig wrote: > > From: Christoph Hellwig > Date: Fri, 23 Dec 2016 10:57:06 +0100 > Subject: virtio_blk: avoid DMA to stack for the sense buffer > > Most users of BLOCK_PC requests allocate the sense buffer on the stack, > so to avoid DMA to the stack copy them to a field in the heap allocated > virtblk_req structure. Without that any attempt at SCSI passthrough I/O, > including the SG_IO ioctl from userspace will crash the kernel. Note that > this includes running tools like hdparm even when the host does not have > SCSI passthrough enabled. Ugh. This patch is nasty. I think we should just fix blk_execute_rq() instead. But from a quick look, we also have at least sg_scsi_ioctl() and sg_io() doing the same thing. And the SG_IO thing in bsg_ioctl(). And spi_execute() in scsi_transport_spi.c And resp_requests() in scsi_debug.c. So I guess ugly it may need to be, and the rule is that the sense buffer really can be on the stack and you can't DMA to/from it. Comments from others? Linus