Received: by 10.192.165.156 with SMTP id m28csp467947imm; Tue, 17 Apr 2018 13:21:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx48bjgefFVE+YvFTvMP1HEuBNbUH4DKSda7Ynimjbf3buw5rBkg4rzHGK/1jzcrVdHyok0Lo X-Received: by 10.98.207.130 with SMTP id b124mr3288946pfg.9.1523996512087; Tue, 17 Apr 2018 13:21:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523996512; cv=none; d=google.com; s=arc-20160816; b=Kw1k7xuxNByTUal45aZdSDh6VOroTTdv+lU26rniE0DlgUOMqepQdmZ3i8qSsnguv6 AmcpYYsdsHfVMHJnWaNy7p/2hLsrFmTZ1exrIYUFgZFijHXjYoF10K4xM7xK3G8gkv2g toY9pYUqi5usYDmgU8eQ8+fe+yWH0JcPzRoRPocvoMumLUpqYf8mjUkzVL3Nh+40S1pv W/n75Mj4JKwywOR60v/nYEae1CLaEFepHVNric23AMx0vyKXFk6F3xW6wzqHhDNmAXrN evUvaUxIl2hA87NBo5tXcHyc0gNT+8+hQQrZm7fEKmuB9WXQYRcGlVcAXF+3deMSOH1/ xItA== 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 :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=IZaRxOwjdlE2hlUOOgs/dXWaVNxGpIGXlYwCYKagmZc=; b=0Rcl8kdfNMcjQvz+bZIB+5v8vGok0HynyZEbZRaVehdYBStRep9iCyMcSVgCYteXMi xiHNDlsJS6uSvHt3uY+Zwc7Yqt0CMst7hX8Kr/D+49ybYYtpOyqVy7nDszoThHYYc+5C TrcvfaolyIQboTHpAf4urj/G/i7sAgdy7Rz+2/IG5o6zFw/XKfcmgVq31eGR3hPNLQ4O OUfeObERitjzW5YJsp6gKgZXQXzioQccelMoDJQrStW+KO8iWHLvJzSDsOUdu9I0KVAv JiryQZIpbAICWbgjlTPPznICgBnXOI1it69hT0xXrWUad87oGwJ5pOEeF2NBGPPR35wg JveA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=tfC2nC8c; dkim=fail header.i=@chromium.org header.s=google header.b=Q9get8ic; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o8si6107854pgv.375.2018.04.17.13.21.36; Tue, 17 Apr 2018 13:21:52 -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=fail header.i=@google.com header.s=20161025 header.b=tfC2nC8c; dkim=fail header.i=@chromium.org header.s=google header.b=Q9get8ic; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752620AbeDQUUV (ORCPT + 99 others); Tue, 17 Apr 2018 16:20:21 -0400 Received: from mail-vk0-f68.google.com ([209.85.213.68]:39644 "EHLO mail-vk0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752043AbeDQUUQ (ORCPT ); Tue, 17 Apr 2018 16:20:16 -0400 Received: by mail-vk0-f68.google.com with SMTP id n124so12682728vkd.6 for ; Tue, 17 Apr 2018 13:20:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=IZaRxOwjdlE2hlUOOgs/dXWaVNxGpIGXlYwCYKagmZc=; b=tfC2nC8cIXX1r//n8+AV8b8dlY81ASjosnFIz+GPU1jjRuUVBA7UhrV0TzteyVzjBA xYdq8vzseyL+pGz1ZbhJ7QGoFkgZb67QAGTO/qGayxc3H0SItKNim0Oz3DPRu2+Bbibi FYBDYE85paQy2UMq1KKojU8TF391ykrmb8ZvWXo0kF1YetqzL6Gi0FyAjlvWfqVkaIyQ HkEifPUFsKCr94bH2Xg19WIOxP8Edrjnuvufegj7gz/Jar3Cmu0w1Nmh1VR76/8vx0ER r3VTbfOUlQkRPy3Hi4oLwTtM3A2BgHSg96lmO1gSFRZwE7wboPXW5j1UeWRN4TSbW4Th fWdg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=IZaRxOwjdlE2hlUOOgs/dXWaVNxGpIGXlYwCYKagmZc=; b=Q9get8icjg2q1rEjyab7vH+orlCamZjB68hEUvMJEe1fAw2fGf9r4B+/yUynteCSWF rUxybl5LcH2ge8olC6j9dKRW/fXKvq08ZeQK0Imccb8iGB8eU5uFpCfRfRyQhTetvoq2 RJLy/k5LDj3ehOaSw+PEYgmUj+lhnK0kU8neo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=IZaRxOwjdlE2hlUOOgs/dXWaVNxGpIGXlYwCYKagmZc=; b=D+51eWoV6ZHKmo6lKl5D6hKAftwvJMwoyAd4rswAt8J/KqNkWgkvjBKu4xmiJ0isoz FkhtBLqZxFDwk7tgb3QL2BK9JL++hI/9uawf6Yq0S+iY0pKjZDRcVGnBgF7dmfRP+GTw 7ZMXenBnCgWYOuFRWo0Q9v82GahwAEOxz8zRNTwkSqCcKWP9EZTWeXYHLMRcv923uwbu TgIpjTmAWeXP51dccit58/XBlHmDznL+2pDjP6TcmLXapEWCdwSFEUgh29Z3G99vjEHj 5JZoSbd+kE5C4DdQ4IvOXNrozYjJEg5AlUbiI6bbyIb5xCUAwU8eEAjwrYfOAa8ud3f1 0D7g== X-Gm-Message-State: ALQs6tBIoKwp3az9IF8ySu0wFrTfnG3Q10OAiQcOnuGGrdDWm0AHO2y0 vwIsCqzID4nuAs34jK4IdMX4fi0cywv4oiXRU3wycw== X-Received: by 10.31.168.213 with SMTP id r204mr2616719vke.84.1523996415718; Tue, 17 Apr 2018 13:20:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.164.81 with HTTP; Tue, 17 Apr 2018 13:20:14 -0700 (PDT) In-Reply-To: References: <10360653.ov98egbaqx@natalenko.name> <2864697.7uzmEJovl2@natalenko.name> From: Kees Cook Date: Tue, 17 Apr 2018 13:20:14 -0700 X-Google-Sender-Auth: zaV131s9lt8tYhGwh8TYfpLcof4 Message-ID: Subject: Re: usercopy whitelist woe in scsi_sense_cache To: Oleksandr Natalenko , Jens Axboe , 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 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 Tue, Apr 17, 2018 at 1:03 PM, Kees Cook wrote: > The above bfq_dispatch_request+0x99/0xad0 is still > __bfq_dispatch_request at block/bfq-iosched.c:3902, just with KASAN > removed. 0x99 is 153 decimal: > > (gdb) disass bfq_dispatch_request > Dump of assembler code for function bfq_dispatch_request: > ... > 0xffffffff8134b2ad <+141>: test %rax,%rax > 0xffffffff8134b2b0 <+144>: je 0xffffffff8134b2bd > > 0xffffffff8134b2b2 <+146>: addl $0x1,0x100(%rax) > 0xffffffff8134b2b9 <+153>: addl $0x1,0x3c(%rbx) > 0xffffffff8134b2bd <+157>: orl $0x2,0x18(%r12) > 0xffffffff8134b2c3 <+163>: test %ebp,%ebp > 0xffffffff8134b2c5 <+165>: je 0xffffffff8134b2ce > > 0xffffffff8134b2c7 <+167>: mov 0x108(%r14),%rax > 0xffffffff8134b2ce <+174>: mov %r15,%rdi > 0xffffffff8134b2d1 <+177>: callq 0xffffffff81706f90 <_raw_spin_unlock_irq> > > Just as a sanity-check, at +157 %r12 should be rq, rq_flags is 0x18 > offset from, $0x2 is RQF_STARTED, so that maps to "rq->rq_flags |= > RQF_STARTED", the next C statement. I don't know what +146 is, though? > An increment of something 256 bytes offset? There's a lot of inline > fun and reordering happening here, so I'm ignoring that for the > moment. No -- I'm reading this wrong. The RIP is the IP _after_ the trap, so +146 is the offender. [ 29.284746] watchpoint @ ffff95d41a0fe580 triggered [ 29.285349] sense before:ffff95d41f45f700 after:ffff95d41f45f701 (@ffff95d41a 0fe580) [ 29.286176] elevator before:ffff95d419419c00 after:ffff95d419419c00 [ 29.286847] elevator_data before:ffff95d419418c00 after:ffff95d419418c00 ... [ 29.295069] RIP: 0010:bfq_dispatch_request+0x99/0xbb0 [ 29.295622] RSP: 0018:ffffb26e01707a40 EFLAGS: 00000002 [ 29.296181] RAX: ffff95d41a0fe480 RBX: ffff95d419418c00 RCX: ffff95d419418c08 RAX is ffff95d41a0fe480 and sense is stored at ffff95d41a0fe580, exactly 0x100 away. WTF is this addl? -Kees -- Kees Cook Pixel Security