Received: by 10.192.165.156 with SMTP id m28csp530231imm; Tue, 17 Apr 2018 14:41:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx49RsS7Bec18AqdTkdd2WZ8N7AJxuY0dGVPL4ZecaATn0GJScj3/bOZFHjfNVmyZzzm6x/pE X-Received: by 10.99.110.199 with SMTP id j190mr2863230pgc.71.1524001279932; Tue, 17 Apr 2018 14:41:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524001279; cv=none; d=google.com; s=arc-20160816; b=XYTqm/+tHC8W4CxPBebviazQUEolr2NdmDQcpzIvrN4Nmsn7KaeNez1qQUh6Vz+4uY S61luq59mf2ZlPCAhBSouU8I08OXdr1gLATI/IAVVGDf1as0mP8BC0mcl1eX8bUGELPd cY0/WX8RF7B6M64lB0qkx6JjSK4+I55QNCXcG3v2F6xcHi3cTNp00VmOP5lJOFbWn+IM NRYnztB9+U68UeRWwbCS4qPeNXRWxNHfImfTaIv7/5H8hfEdMWZViGQtsf6FvzreurYr 2AGbpDxU5cyCYyBF3z1Hv9/RdOk2xV6kDhqtok2Xu//hFTbwoMxa0nxuGIk/dDGD33e+ qjIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=wg5ofyQ1qxaVjnjhANyjmSbHhpi4/teOTXKL+FUMoZg=; b=emh1yYoOscK+xmz8vk2lRoHd44QYluAZB6aJ044aAd8vvir/KvLE6vCSjicNNe7NQw C5hLjTTLij86cpO7AcNdhTAJ1d+o1dfuJnz32hzJy9pD0Z6SPuoGeCYao3j1U/SIx2hJ vlhXVas+G9BbtcvBt45prbS6IfkInAaDlOBwDa5R8QSSpSm4N5rZmYouzcfCks21skby qkCq/KgKw5FUAZV3IAGtaNYyj9y09Ta47iIRCd4M61jPRiNjLlSYdPP8spkmjww/vx/G osKNyncG6b8SE4hSBOWgsBbZMtWNT+8uI3FttXuxW8b7FEUaoIwO9UYbpODNHTqW0B0i BVvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=ryMSg513; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s22-v6si5702757plp.216.2018.04.17.14.41.05; Tue, 17 Apr 2018 14:41:19 -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=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=ryMSg513; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752840AbeDQVjw (ORCPT + 99 others); Tue, 17 Apr 2018 17:39:52 -0400 Received: from mail-pl0-f45.google.com ([209.85.160.45]:42023 "EHLO mail-pl0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbeDQVjt (ORCPT ); Tue, 17 Apr 2018 17:39:49 -0400 Received: by mail-pl0-f45.google.com with SMTP id t20-v6so12733577ply.9 for ; Tue, 17 Apr 2018 14:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=wg5ofyQ1qxaVjnjhANyjmSbHhpi4/teOTXKL+FUMoZg=; b=ryMSg513z0hmVj/R+T6XITUlrDG81BkFEMS/dIc8mC9k7wmybXin0OkFMPBB9k6Fo0 2/SKPFiOdP2JpCUye+aDxaFby420hCrEOp+yy+uxPBgTSNjwPpAxc88UJZfahTQp/tge FRYVs9gQcHeyyl5kshWHDAY6JNDbhKbynL81MLdsZlRKlFIZO8KpYIhyd/xwE1sB3vNg F5q0bNwr1EazZHpwmWRTzeRA4sCuarvPQ6usmGULa4/opKbKXygBLruiJ7+flikPAJPh Aop/dLXtaDAJLN5HoUNRU1pwG66qMMD56KQVTm8iJ1p4Or0Fkrd76rhunLg+ICehNXD7 FOYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=wg5ofyQ1qxaVjnjhANyjmSbHhpi4/teOTXKL+FUMoZg=; b=CASxZEVAM4p7JAjXsnzN/UCoNqlruubo4J+KpcvbZR59IaDBk19uqmsbxCfrmexOza l3LuZZx1VP1bEyMNxvkk9WhqIDQvr9q7X58C4Cl13qGuvdqpW6dNwPr5iW2HQPhign8K x1ppQQEQ5tm1LCBMGlCMV0j1wfpNBs3NzU+dpy/uUEpAcsnGRo320ljt3N2sKFqn99u4 j56RcPogaaD/72cs3Uhni5Sz8gPLvFDkPJ9DOeqFAsJciDXaw+YFOu/vfL1uGvT7PtYs wWbWBqJ8Ne68BfmQWKHYmeks2znNwDdJBGbb7zpTVDsDDdfe+/13anmZLy2KnXYNBpve 4Now== X-Gm-Message-State: ALQs6tB1qcoX2g4zL7JNfG7eBuxSWGxW1eNjrE1eQP6X5WedO7mEPKGh 8ljSDxR1sSbrSDbhsSs8faiQiw== X-Received: by 2002:a17:902:b60f:: with SMTP id b15-v6mr3640406pls.12.1524001188781; Tue, 17 Apr 2018 14:39:48 -0700 (PDT) Received: from ?IPv6:2620:10d:c081:1130::10de? ([2620:10d:c090:180::1:b264]) by smtp.gmail.com with ESMTPSA id p1sm29449516pfp.48.2018.04.17.14.39.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Apr 2018 14:39:47 -0700 (PDT) Subject: Re: usercopy whitelist woe in scsi_sense_cache To: Kees Cook , Paolo Valente Cc: Oleksandr Natalenko , Bart Van Assche , David Windsor , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, LKML , Christoph Hellwig , Hannes Reinecke , Johannes Thumshirn , linux-block@vger.kernel.org References: <10360653.ov98egbaqx@natalenko.name> <2864697.7uzmEJovl2@natalenko.name> <8473f909-2123-0cfc-43b1-beba0b1aef9b@kernel.dk> From: Jens Axboe Message-ID: <07f263ff-cea6-ac3c-944b-0f36fee8ba25@kernel.dk> Date: Tue, 17 Apr 2018 15:39:44 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/17/18 3:25 PM, Kees Cook wrote: > On Tue, Apr 17, 2018 at 1:46 PM, Kees Cook wrote: >> I see elv.priv[1] assignments made in a few places -- is it possible >> there is some kind of uninitialized-but-not-NULL state that can leak >> in there? > > Got it. This fixes it for me: > > diff --git a/block/blk-mq.c b/block/blk-mq.c > index 0dc9e341c2a7..859df3160303 100644 > --- a/block/blk-mq.c > +++ b/block/blk-mq.c > @@ -363,7 +363,7 @@ static struct request *blk_mq_get_request(struct > request_queue *q, > > rq = blk_mq_rq_ctx_init(data, tag, op); > if (!op_is_flush(op)) { > - rq->elv.icq = NULL; > + memset(&rq->elv, 0, sizeof(rq->elv)); > if (e && e->type->ops.mq.prepare_request) { > if (e->type->icq_cache && rq_ioc(bio)) > blk_mq_sched_assign_ioc(rq, bio); > @@ -461,7 +461,7 @@ void blk_mq_free_request(struct request *rq) > e->type->ops.mq.finish_request(rq); > if (rq->elv.icq) { > put_io_context(rq->elv.icq->ioc); > - rq->elv.icq = NULL; > + memset(&rq->elv, 0, sizeof(rq->elv)); > } > } This looks like a BFQ problem, this should not be necessary. Paolo, you're calling your own prepare request handler from the insert as well, and your prepare request does nothing if rq->elv.icq == NULL. -- Jens Axboe