Received: by 10.192.165.156 with SMTP id m28csp537127imm; Tue, 17 Apr 2018 14:51:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx48+rjKaWa9/QPmTLhGttwYIRzYCXe9EiQBJZ4s5+icud13wXSJlOo+YWYuvnqY4Km87ai78 X-Received: by 10.98.32.134 with SMTP id m6mr3471795pfj.27.1524001862642; Tue, 17 Apr 2018 14:51:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524001862; cv=none; d=google.com; s=arc-20160816; b=GV1o543JF0S17Pll/KOzFps48w9SJ4mfHCxuZ1PYy9nmmVkxGUWolW2hVJXzg4v4Dn Iu3jfPCUVZu2CFttHvDOro/OB9+yTmWDMzmxIYUyUMVLzmWo9ynhPUrI84izz/mb9uwQ G2SjBt6UdZ/A8Kixf8a9C2aiCeko/h5cFG3ExxMmViPLYinMfIwmRY80XTRn8RGWY9ny JOZk+C6d9OO6cZERSHAR/X7wu/5MEJmtv3cHD9ECxWwLIOQFTjxqlfiNXZhECDzv03J8 qbdcY7cSZkaRW6eoy81Rcc8hKWgF9vWBkEw9wubLzhvnKLEtbUPN+1UjElkw7YFWRtrN Hc/A== 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=errk48N7mE02yFhJmz87Zzrvizj82T+dLnleZvpoSjg=; b=MknPqmqSJlIFijJqrqZdoZjEqLychf4JB+d5AyDueW+hknVcTWMHxN6j2RPhxHSlIW WU2OleR+EAeJuyirvdWSG+4MiE/hmWEtJivdScVelsDdN9vHurmy8XP7981R0oqPxU/i /czt2rv36igyGKCNsrQXeYR88g88PObOOX3m+s40s6nYRWSUrisrR1AeOn0Dp4FPE+YF N8LUe/4btANZw8TIO2BMtnpInVfEzA+tYrXoC0+Y7zC4wMfDkj5aBvGX6Zx1FFFwXHbh S4FfUym+NsiPY7PQffEBRkk9LzE6JNXGGDks7EVzG6mWQAKxOZ19e1/UGdKvftPWn07g /gGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=Dgd3m40y; 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 g15si12461522pgu.112.2018.04.17.14.50.46; Tue, 17 Apr 2018 14:51:02 -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=Dgd3m40y; 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 S1753178AbeDQVs1 (ORCPT + 99 others); Tue, 17 Apr 2018 17:48:27 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:43386 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753133AbeDQVsX (ORCPT ); Tue, 17 Apr 2018 17:48:23 -0400 Received: by mail-pg0-f43.google.com with SMTP id f132so4873481pgc.10 for ; Tue, 17 Apr 2018 14:48:23 -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=errk48N7mE02yFhJmz87Zzrvizj82T+dLnleZvpoSjg=; b=Dgd3m40yQuZwBJJXeUbMBwhReXAGrJdt82gB/aYZBJcjR+1svk06SBURMfMufW5exz tDpsqCzgRsy+n5uTUWuVdteWIeTBnN0W/BQ4qQ69Lb26no3ZJSW6HXe1J/06en6CVZiW 4mhMAyJAzOmha4MmV4H/EF7TPkfay531A9+w5Cpte7wnWBhrfEWVGW0+lbTAD5ZHTe42 Rox9IVc2wkTDXE+mNweldq3q3lVV84XrODdKnikan3y/5rWV5/CuSubeUCdUAl3xifki uv0w6pjD815EqEeudtyLGocsU4EAK7cQzCK047Ta19vEjkCtfeZjwfV4mnuxbvW2U3wZ D6lQ== 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=errk48N7mE02yFhJmz87Zzrvizj82T+dLnleZvpoSjg=; b=eItSTAW9JnnclTJhJ0a7Coxue7iwIXrDMDtUphBnXqQqVHiEfFHM1EGSCig2R/mePy 4rkJDsjUSBXm/4/JIAh7i/Ntd2UPCAqSxzPHTqYvnswLcIh1kUBuZR/jdflzHhVUQo3N 47irTS5kC5W3mSQRvh7m1QdBJ61D204JDTn1y1HqqXBRDBMn25SQwV9NwKyn1+nRcJhn YTvKiVztQbgqj4tHswngzuTvtYUux8ks/0nyp7qCbppdaPDsLMqoJfMEdVn5N/Q37owG CrjOqkpNW10+7kMaOV8pdcJta1wQJR/ejdMGegSMiwbYofGWfhLL/Chc6d1w5f83IyTN ZXoA== X-Gm-Message-State: ALQs6tACI0rqLVBtCFVsX+D70e+2HGZVBezkGsePpAYDBJfM1CNzS4yZ WEKY4PrGKe1fVFemN8JyDIGSoQ== X-Received: by 10.99.172.26 with SMTP id v26mr3165470pge.105.1524001702723; Tue, 17 Apr 2018 14:48:22 -0700 (PDT) Received: from ?IPv6:2620:10d:c081:1130::10de? ([2620:10d:c090:180::1:b264]) by smtp.gmail.com with ESMTPSA id r23sm10533964pfh.33.2018.04.17.14.48.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Apr 2018 14:48:21 -0700 (PDT) Subject: Re: usercopy whitelist woe in scsi_sense_cache To: Kees Cook Cc: Paolo Valente , 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> <07f263ff-cea6-ac3c-944b-0f36fee8ba25@kernel.dk> From: Jens Axboe Message-ID: <8b32e079-d4e6-3fea-a89d-ff856e4e13b1@kernel.dk> Date: Tue, 17 Apr 2018 15:48:19 -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:47 PM, Kees Cook wrote: > On Tue, Apr 17, 2018 at 2:39 PM, Jens Axboe wrote: >> 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. > > I sent the patch anyway, since it's kind of a robustness improvement, > I'd hope. If you fix BFQ also, please add: It's also a memset() in the hot path, would prefer to avoid that... The issue here is really the convoluted bfq usage of insert/prepare, I'm sure Paolo can take it from here. -- Jens Axboe