From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752975AbeDQVpr (ORCPT ); Tue, 17 Apr 2018 17:45:47 -0400 Received: from mail-pl0-f47.google.com ([209.85.160.47]:39130 "EHLO mail-pl0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752786AbeDQVpn (ORCPT ); Tue, 17 Apr 2018 17:45:43 -0400 X-Google-Smtp-Source: AIpwx48UDyw6+9b3clMSrCskH8iLvuKZ6WBEeefwjEqFSnRIv/s/lMXawOGMV12dr4uxmDlJXTYgQw== Subject: Re: [PATCH] blk-mq: Clear out elevator private data To: Kees Cook Cc: Oleksandr Natalenko , linux-kernel@vger.kernel.org, Paolo Valente , Bart Van Assche , David Windsor , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, Christoph Hellwig , Hannes Reinecke , Johannes Thumshirn , linux-block@vger.kernel.org References: <20180417214218.GA44753@beast> From: Jens Axboe Message-ID: <7d192394-568c-53e0-4359-723769c3ed7d@kernel.dk> Date: Tue, 17 Apr 2018 15:45:38 -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: <20180417214218.GA44753@beast> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/17/18 3:42 PM, Kees Cook wrote: > Some elevators may not correctly check rq->rq_flags & RQF_ELVPRIV, and > may attempt to read rq->elv fields. When requests got reused, this > caused BFQ to think it already had a bfqq (rq->elv.priv[1]) allocated. > This could lead to odd behaviors like having the sense buffer address > slowly start incrementing. This eventually tripped HARDENED_USERCOPY > and KASAN. > > This patch wipes all of rq->elv instead of just rq->elv.icq. While > it shouldn't technically be needed, this ends up being a robustness > improvement that should lead to at least finding bugs in elevators faster. Comments from the other email still apply, we should not need to do this full memset() for every request. From a quick look, BFQ needs to straighten out its usage of prepare request and interactions with insert_request. > Reported-by: Oleksandr Natalenko > Fixes: bd166ef183c26 ("blk-mq-sched: add framework for MQ capable IO schedulers") > Cc: stable@vger.kernel.org > Signed-off-by: Kees Cook > --- > In theory, BFQ needs to also check the RQF_ELVPRIV flag, but I'll leave that > to Paolo to figure out. Also, my Fixes line is kind of a best-guess. This > is where icq was originally wiped, so it seemed as good a commit as any. Yeah, that's probably a bit too broad for fixes :-) -- Jens Axboe