From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79824C433F5 for ; Thu, 7 Apr 2022 23:47:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECB186B0073; Thu, 7 Apr 2022 19:46:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E53B86B0074; Thu, 7 Apr 2022 19:46:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA6956B0075; Thu, 7 Apr 2022 19:46:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id B5DEA6B0073 for ; Thu, 7 Apr 2022 19:46:58 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7BDC28249980 for ; Thu, 7 Apr 2022 23:46:48 +0000 (UTC) X-FDA: 79331720496.26.B9A3DD4 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf08.hostedemail.com (Postfix) with ESMTP id 0503D160004 for ; Thu, 7 Apr 2022 23:46:47 +0000 (UTC) Received: by mail-pl1-f178.google.com with SMTP id m16so6451899plx.3 for ; Thu, 07 Apr 2022 16:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=T2ZSBezV+f6piMbIWQu4Bg05zBONMw4MFkVYAUPknE0=; b=FGPFYssugxMdDKKPrbzXyPUdSY8SlSjAl3J4V8yiXxt5A7uHo07eafozgA06mInERz CkwMo601Kn/O1YSTCAOMVAx/rl0egoGpwYx5Tlwgbg0p3kRh/8GVGfsWBsqFw7ZpLLMg wJYcjHf0Et/w6IImST71JfLD3voKPg7RXZ/I8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=T2ZSBezV+f6piMbIWQu4Bg05zBONMw4MFkVYAUPknE0=; b=EcSeM1xfb56OnzWhKdWR3eCSxftwUQN3WdpKguAAEyvqzYK7ALExl0wlalJ7eS+MxP NH8vFeHhaOXliLGoOvZfpRp901LWH8du7AKv9xYVOlhQwI+xd9iQXyT2NyPQrcgY5iKh 7F1aT2YRWn/dtTOTdgybDppnn9jfFpwyUXi5CKaqpFGTvTTXGFnhn40g46CRQSqnnjFI OlwoP/pXi4GztX8uCtxuBrzWV9uPrv+ch9pcsNCJvkKWByHJUR+SYvVuBUJpGHWBq2vq eKjhVdBCg1k+EjMaGz3vUdz2QZ3A7AjQsF/UCCMG7zZYUJNPBIVFHsr10xAW07L4dV0l eRKg== X-Gm-Message-State: AOAM533vBuq0/sFCt7EZ3kInEWJ9sTpJqZ67oSoXd+BRCxGq0prtazht LTRGYZk5aWqaXtSGtOKTZDCohg== X-Google-Smtp-Source: ABdhPJwuDiF2YI6RHRwB5ITufJK/aIWQORhXPS0E3RZzPUYeFhnKdJ6zJmO95lnS3mYNygSJXc98zA== X-Received: by 2002:a17:90b:4d88:b0:1ca:a5c5:1386 with SMTP id oj8-20020a17090b4d8800b001caa5c51386mr18742618pjb.43.1649375207069; Thu, 07 Apr 2022 16:46:47 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id i187-20020a62c1c4000000b004faafada2ffsm24632609pfg.204.2022.04.07.16.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 16:46:46 -0700 (PDT) Date: Thu, 7 Apr 2022 16:46:45 -0700 From: Kees Cook To: Dan Williams Cc: Greg KH , Arnd Bergmann , Ingo Molnar , Matthew Wilcox , Russell King , Andrew Morton , Linux Kernel Mailing List , Linux MM Subject: Re: [PATCH v4] /dev/mem: Revoke mappings when a driver claims the region Message-ID: <202204071526.37364B5E3@keescook> References: <159009507306.847224.8502634072429766747.stgit@dwillia2-desk3.amr.corp.intel.com> <202005211950.D56130B81@keescook> <202204061243.FB134CA4B1@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: te47gbzmg4ts1s5dxohidf4az9ryso99 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0503D160004 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=FGPFYssu; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf08.hostedemail.com: domain of keescook@chromium.org designates 209.85.214.178 as permitted sender) smtp.mailfrom=keescook@chromium.org X-Rspam-User: X-HE-Tag: 1649375207-746112 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Apr 07, 2022 at 11:47:40AM -0700, Dan Williams wrote: > On Wed, Apr 6, 2022 at 12:46 PM Kees Cook wrote: > > > > *thread necromancy* > > It's alive! *lightning* > > I'm doing a KSPP bug scrub and am reviewing > > https://github.com/KSPP/linux/issues/74 again. > > > > Do you have a chance to look at this? I'd love a way to make mmap() > > behave the same way as read() for the first meg of /dev/mem. > > You want 0-reads or SIGBUS when attempting to access the first 1MB? > > Because it sounds like what you want is instead of loudly failing with > -EPERM in drivers/char/mem.c::mmap_mem() you want it to silently > succeed but swap in the zero page, right? Otherwise if it's SIGBUS > then IO_STRICT_DEVMEM=y + marking that span as IORESOURCE_BUSY will > "Do the Right Thing (TM).". I'd like it to just return zeros, which is what "read" currently does. (i.e. if page_is_allowed(), really devmem_is_allowed(), returns 2, then the user should see all zeros.) So, yes, "silently succeed but swap in the zero page" is exactly what I'd like. When I last looked, for the first meg, mmap did _not_ fail, but _actually_ reads it. -- Kees Cook