Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2146803imm; Tue, 10 Jul 2018 14:12:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeZ3WxDl8Lbae6VVXxU2e46h0n9Tbcw2fwN6P5b05nTslNDb7qvLTLCGq8i3GIXoV4F4zpS X-Received: by 2002:a17:902:b48f:: with SMTP id y15-v6mr459668plr.44.1531257176025; Tue, 10 Jul 2018 14:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531257175; cv=none; d=google.com; s=arc-20160816; b=whCdAH6dJ7pxQcLXC99dbLRMA1+yEOrjmzYzkmvHQluEYRBHTPM0E8VVGA4+Ms2xvU dO1TbwLRi8MJh9dkUwpJfOWZim9rTPi/qmASlLwSK/7Wnp5NU9tinBK8okrP49o08wjA Bj3ERQKhgA9JKyNBIKURPsPK9F9Qdy1m5anl9gYzmjqLDDDpP5vj7DO+3r+R9kfITZSx 1Ra/GGKu2/myGR4jxzGOX9XZmH5o1s5NFWDDNSjqUkFGdRzMxIrpAyZJh7W6tpyPm2J4 rxw/N8n0YY3q2hdMp4zDFH32CuqZeS9A31N7eObur5rTuOXSO+Zk/aLWjJhk6FNKyruj L44w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=4aeF/lXgFL++fBXjL+3yHruyIesoO9Za2ub5glg7VlI=; b=uHqA4rmRz+BuAwfjL4Lfk4HkCczEJxwcU/ntwtxrUMk02Ix4sarJV1ROy/ZPjgIOh1 x+5rjdZf0bNPivp/HnF8FgC9rNBl/64Kox7T/u/rqQqWfjLQOH+kKMfJ13iwIwYj73ue V/Um/ukXrCCKoGupK1uC9X5qdSAobGUkB9NqK6iUdd056oafiM9Cq6AgAii1X4qZnuVh P2z2vj7e7FCP4RhlnPUFcEXMTBl+uaZGaqadmC9yaBpuacCemriwrDjbhQR8yiNFRo9G iC3SfpOzc4FWs5smYWCTznZkQOI3ZXuc3jfoxSktZDKP7wr/STRbtYJZNwbcNmgG0vPd OcYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=wFVLIwpd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r28-v6si17171401pgk.458.2018.07.10.14.12.40; Tue, 10 Jul 2018 14:12:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=wFVLIwpd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732498AbeGJUyT (ORCPT + 99 others); Tue, 10 Jul 2018 16:54:19 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:33815 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732438AbeGJUyQ (ORCPT ); Tue, 10 Jul 2018 16:54:16 -0400 Received: by mail-oi0-f67.google.com with SMTP id 13-v6so45313030ois.1 for ; Tue, 10 Jul 2018 13:53:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4aeF/lXgFL++fBXjL+3yHruyIesoO9Za2ub5glg7VlI=; b=wFVLIwpdT2UBw5il+RdXhWsE5gWINi2ggudwpnhzKR1SZT0sP5Wa9ArJXZhPmj/PD4 RIwowehk46G9nlqvw7KEtLIHSCp8/VAi+E6ZhwPYUMCI6gehv+oz8828ZhhrHs2CTsTp kFXwI0923F5Z2M4H/7PpqcVHK8tSuKg3odaEJ5m/cdl3lilt+xTXctXNlqYxim47eDSJ tbbgDqFB0Fd7lVfv69TeXXwjgVz3+0FXUfa57Hx41WkoBdPlNFFJauADwT3T6/LGT4Be lE6lrnCDBSZXvdrZY7S/3GJx5kp0YadwocEXZIiqqJPEzb1lu7MT5MSsw1XfZyLMqy3D +jZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4aeF/lXgFL++fBXjL+3yHruyIesoO9Za2ub5glg7VlI=; b=WMmgZ00PAe3GL43TKIIwQ7/99Z+CgOTEjrEJhZOvkaZKITi++3PAmzuMPwKadLkn5c 5whserGhwyN9obumSSo1WKCn8u3gWPO9X31myPzKIv/2ZJJkUU0vhKSVenJ/IFB2NJTX 28dE4Ta3Mwo66UiO6uIYo+z9fFNUV7RY4+7P4FG7VKvZCYOltGWdfc6fuIHVwwZOpS9o 0f6T1q4zHsizN2r+w8Ng4AvtxQDbihP2CbXPrUWj/6Q8Ly7RiOxNxZMCFVb+TvK9kqn1 1foiJQb2BPcm34DyM2p/sOM+yJ/vEDRSSqqfFYQD9vLOz+pWGCz9FAwtFOpCiykVq8M7 lStw== X-Gm-Message-State: APt69E3wP370exFD+f2UfPMWsFfh3YRzS+6bWuFWFlBbAlYeVSuc5sdn W3/p+A7NTn/VphBKIKq91iCJ0TApNwXYM+We3CkgPQ== X-Received: by 2002:aca:3002:: with SMTP id w2-v6mr27095457oiw.29.1531256008706; Tue, 10 Jul 2018 13:53:28 -0700 (PDT) MIME-Version: 1.0 References: <20180615152335.208202-1-jannh@google.com> <20180615164009.GD30522@ZenIV.linux.org.uk> <90063ef3-68fa-e983-9b47-838e6076b0f4@interlog.com> <813e817b-bb2f-4a47-6225-9e39f19be278@kernel.dk> <20180621123431.GA558@infradead.org> <36a641db-fb1d-6c4c-7f1b-172f2b1cde32@kernel.dk> <20180708145840.GA22949@infradead.org> In-Reply-To: <20180708145840.GA22949@infradead.org> From: Jann Horn Date: Tue, 10 Jul 2018 13:53:02 -0700 Message-ID: Subject: Re: [PATCH] sg, bsg: mitigate read/write abuse, block uaccess in release To: Christoph Hellwig Cc: axboe@kernel.dk, Douglas Gilbert , Al Viro , fujita.tomonori@lab.ntt.co.jp, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, kernel list , Kernel Hardening , security@kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jul 8, 2018 at 7:58 AM Christoph Hellwig wrote: > > On Thu, Jun 21, 2018 at 08:07:23AM -0600, Jens Axboe wrote: > > I'd be fine with that, if we knew that nobody uses it. But that's > > really hard to figure out. I did see Jann's source code scan, which > > even if non-exhaustive, still shows at least one user of it. > > One is an example, and the other looks very close to an example, > as far as I can tell it was Nic doing a bsg read/write WIP for a > tgt module without anyone every picking up on it. I did add the tgt > list to Cc and no one seemed to care about the bsg read/write support. > Adding the tgt list back, but I doubt anyone ever actually used it. > > > How about we just make the write interface sync? Then any copy can > > happen while the we block the task, and the read side is just > > copying the header info back, or dumping it if the task didn't > > read it before it went away. > > How is that going to work? As far as I can tell each I/O using > bsg read/write needs a write and a read, so they need to pair > and thus can't be a purely sync interface. > > It also doesn't help with the issue that bsg_write may possible > write to user memory, which is highly unusal and asking for security > issues itself. > > Either way, we should probably at very least apply a respun version > of the patch from Jann to 4.18-rc and -stable while we keep discussing > this. > > Jann, can you respin the bsg patch with the same changes as the now > included sg one? With the error messages like in my sg patch or like with Linus' proposed patch (https://lore.kernel.org/lkml/CA+55aFwg-2GP4ASTdd1pusmZkF7c8AN9febVDCaioDxzYJSLfw@mail.gmail.com/) applied?