Received: by 10.192.165.156 with SMTP id m28csp266784imm; Tue, 17 Apr 2018 09:48:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx48bd4RTV/M5IpgGXtC+O03HWPMgM8HO6dmUF+jcmVeiQqMrKcHf3kXDjOUaIN5DujJOW7yL X-Received: by 10.98.228.13 with SMTP id r13mr2628903pfh.51.1523983716733; Tue, 17 Apr 2018 09:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523983716; cv=none; d=google.com; s=arc-20160816; b=T8bkakhF7zEY2Lw3R0ENSt30X8M81KkdTMd7am1kL8vly/BJtvbaiFtktN1JfgKsDq AeUF2e43OQUeE6UliNDfEwtw9Ytq0Paug5Y3lchOdS+GPb6rYSBuTRy3+0zcpp9o1aM4 1lXNcHJQjR8axkszAehh6VE0S5Tn4bmtcxUB3/RKYKp2KJmpOxsL5FAWNFKCDygOrFVT NT14sM12A/nAALfd3W9rRvwqufgCHBZAweqwoHHte84HJ9isXp7xnSLdhgwwTWXvBiX0 G031wISHrykT1EqIQPjt+V44EBgRxFUc5Co+0zVXVb35hiqiqYDbw0kgSRSrvfzdy0d8 qkWw== 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=lvWwZJgUCuHZ0do+Vj+D43YmLHQD3aTnRWE2DvkyDNc=; b=kvDdLuiCEKVi+DP27z5W0pXOjvCjnhNHmZHI6cW+C+OHG4+C4QH4cF+6MqzRgo9fSU ek0YsL6K7Jgo+FzAUZKPks7KqvgWPn/gipO6+PRINMrXsbjQAYZUKDryX35pkqd/umWi U0daOF2qXXW8CGr3LpGuxsHXWHbATsnHjPKO1KUMuIb1ubkJkd+owFM6t27ILqKwnZxH SGcZvxUh9+8rtvKDFfJbK3L4tTIy22vDx7jSw1/13u0Gi/0pzOXiJfmu52e9mjb1t1tB P0LlPWcsA72sxP2Lyhc209raWOBpNLzM1xAGmRw/EbxtGqT8DBGJahks+ZHb5gv4l4w8 oC9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=i9DUy8Zb; 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 r20si13428775pfk.224.2018.04.17.09.48.22; Tue, 17 Apr 2018 09:48:36 -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=i9DUy8Zb; 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 S1754825AbeDQQq6 (ORCPT + 99 others); Tue, 17 Apr 2018 12:46:58 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:35857 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754474AbeDQQqw (ORCPT ); Tue, 17 Apr 2018 12:46:52 -0400 Received: by mail-io0-f196.google.com with SMTP id c26so10548703iob.3 for ; Tue, 17 Apr 2018 09:46:52 -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=lvWwZJgUCuHZ0do+Vj+D43YmLHQD3aTnRWE2DvkyDNc=; b=i9DUy8Zb7vy8Ln1syCL+W3reEDUcUmFtYMEsZigUI3ulCNMq128epXjs2+K446QAXH +Weogufz/r/WrvT/aznT3OC7Kg0pYKMhDo2A1VMaGXxH3kfEb2l8g7XTl+xiCSorl2R8 HpacimhqSqAwz+IQgNhRs2VJwOuZBTlBIICekGHqOviOVTrfQkwiWqMHfiSbAI7FvGxs YId3yQR9KPNugJStAjI5BcniGORc84C64euSSIicmTAkQW68HNerUaylmhKdUgzqNAEz iBIm0fY/EFEaC83WTF7DvxVyc5EUmG3lSJJcyJGf6qxNfFv8E8nRS/GQ6muHmNZ7+8+s YLuA== 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=lvWwZJgUCuHZ0do+Vj+D43YmLHQD3aTnRWE2DvkyDNc=; b=nh5Xx6scVPtSjY2brf4p3zqr9tzbeFgokwAAhEtzvNuGJ4GWeVzxLVufxuXPlAk1gM 9KuYzrigfxxijiid+XgUO8xw4tWf1P/JUQz31EwoyekZFDLnp4Vw9DhXVuHN1wP/CrR2 fM8cNlAxm5Z/8ZBTX6TDtqR2A4xUjJvDHMweXv790SOEoR7P6AZBJgtCHRJNAkp8fQCP HR75dVR6KsvBpZfxI+UqTpiZ+kOzWxXKnH1PvdMNcEWq11cgKanseUAzhZ2uccxuMFp8 Oi9lm6Ma6yZVIPthzKY0L4233ZgS12iDwb4CG3oGjtFHgznVBb+ZFNxpEjup+Yx9TjHP GdDQ== X-Gm-Message-State: ALQs6tAEGLWgT5VfcQkFL6x1ESgYeHhHTOsy+VABFQ6ulAWldMTQdmEe j377NwbVp1aRIdv9GJi+Tazn2Q== X-Received: by 10.107.35.7 with SMTP id j7mr2948423ioj.176.1523983611822; Tue, 17 Apr 2018 09:46:51 -0700 (PDT) Received: from [192.168.1.168] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id w80-v6sm6026561ita.16.2018.04.17.09.46.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Apr 2018 09:46:50 -0700 (PDT) Subject: Re: usercopy whitelist woe in scsi_sense_cache To: Kees Cook , Oleksandr Natalenko , Bart Van Assche , Paolo Valente Cc: 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> From: Jens Axboe Message-ID: <001d538b-dfc1-b39e-56ad-cd54c807f247@kernel.dk> Date: Tue, 17 Apr 2018 10:46:48 -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 10:42 AM, Kees Cook wrote: > On Mon, Apr 16, 2018 at 8:12 PM, Kees Cook wrote: >> With a hardware watchpoint, I've isolated the corruption to here: >> >> bfq_dispatch_request+0x2be/0x1610: >> __bfq_dispatch_request at block/bfq-iosched.c:3902 >> 3900 if (rq) { >> 3901 inc_in_driver_start_rq: >> 3902 bfqd->rq_in_driver++; >> 3903 start_rq: >> 3904 rq->rq_flags |= RQF_STARTED; >> 3905 } > > FWIW, the stacktrace here (removing the ? lines) is: > > [ 34.311980] RIP: 0010:bfq_dispatch_request+0x2be/0x1610 > [ 34.452491] blk_mq_do_dispatch_sched+0x1d9/0x260 > [ 34.454561] blk_mq_sched_dispatch_requests+0x3da/0x4b0 > [ 34.458789] __blk_mq_run_hw_queue+0xae/0x130 > [ 34.460001] __blk_mq_delay_run_hw_queue+0x192/0x280 > [ 34.460823] blk_mq_run_hw_queue+0x10b/0x1b0 > [ 34.463240] blk_mq_sched_insert_request+0x3bd/0x4d0 > [ 34.467342] blk_execute_rq+0xcf/0x140 > [ 34.468483] sg_io+0x2f7/0x730 > > Can anyone tell me more about the memory allocation layout of the > various variables here? It looks like struct request is a header in > front of struct scsi_request? How do struct elevator_queue, struct > blk_mq_ctx, and struct blk_mq_hw_ctx overlap these? The scsi_request is a payload item for the block request, it's located right after the request in memory. These are persistent allocations, we don't allocate/free them per IO. blk_mq_ctx are the blk-mq software queues, they are percpu and allocated when the queue is setup. blk_mq_hw_ctx is the hardware queue. You probably have just one, it's allocated when the queue is setup. struct elevator_queue is allocated when the scheduler is attached to the queue. This can get freed and allocated if you switch the scheduler on a queue, otherwise it persists until the queue is torn down (and the scheduler data is freed). > Regardless, I'll check for elevator data changing too... It should not change unless you switch IO schedulers. If you're using BFQ and not switching, then it won't change. -- Jens Axboe