Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1609735pxb; Fri, 10 Sep 2021 09:35:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPW9fjwZDzm+xd2WYQ9cDJTQoq9K+gHWdGMRuo3iS6ALHcOR7YDtnggK2+BMI0rqTZFNKj X-Received: by 2002:a02:ba1a:: with SMTP id z26mr5304652jan.98.1631291750108; Fri, 10 Sep 2021 09:35:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631291750; cv=none; d=google.com; s=arc-20160816; b=EwPZafzfrXAnPiItvWbJVgoPjn/94tsG8EhLUnBb6u9sywLBTRcvrhYJM88VuAZCLD fDyb7zXrq5dIfxc+For8D1whywQVksfVBmRZCx5hq77GKIrErh/XjvCeX12kkd666A0C XeX8GlBG0xYfcnL23xpAfh706P9PorcHIl+5DdcXmxdQ3zgJi8pJx+hQ8KyYuVckQw5l TVbhmqpEBwLpHQ3WZRCxoWMLtAa8fl+uL3WHzgMmwiOhnkpnV5G41IE9KRiq9ZRmmAIs BzS25b7S8zalRBkXO0n5tkNK40Q3at/VtNWZrUXEXvrpe0zfcGX93eID8gLif3l+AIEZ J28g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=AOhoNLbGc1wTrgku5TCdbfI0hBgaFoPfXCa4gAbNCGE=; b=FWHiG47v075RRunA9mPAGj0z6OVJ+JZV5bc2pFJZp/5GF9KX50XQ0ID5BGXrdxEnWm y8205FCZ4DFfNUhaQUmkH76yiSfmg6uyaXeaqpaofoiZBvlEyRU0haCdQp5yIPt9UAKn p47g2OZ4S7zKgZlZU6LagTh6Sb29WBvi9EzjGTQ1ygqJdzR8/bUol2xsnBfgQgfG/eVG AtOJ4cwS3ik2lFRmwqTPekXeI9M1tFgP5bAE0l7/3AIJ+pPO7lmRj3hzhyuq0cVQqHX6 VVnoUjZu7rSR9npWcNbJ+3SAu1GSYyLKTKIbSXOdraQIzD8UxoDPpcyjGeGAilX4Uq0V tC8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x22si5057669iow.31.2021.09.10.09.35.38; Fri, 10 Sep 2021 09:35:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229712AbhIJQgA (ORCPT + 99 others); Fri, 10 Sep 2021 12:36:00 -0400 Received: from mga18.intel.com ([134.134.136.126]:41169 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbhIJQf7 (ORCPT ); Fri, 10 Sep 2021 12:35:59 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10103"; a="208226577" X-IronPort-AV: E=Sophos;i="5.85,283,1624345200"; d="scan'208";a="208226577" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2021 09:34:47 -0700 X-IronPort-AV: E=Sophos;i="5.85,283,1624345200"; d="scan'208";a="581420171" Received: from akleen-mobl1.amr.corp.intel.com (HELO [10.212.255.212]) ([10.212.255.212]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2021 09:34:46 -0700 Subject: Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range} To: "Michael S. Tsirkin" Cc: Dan Williams , "Kuppuswamy, Sathyanarayanan" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Andy Lutomirski , Bjorn Helgaas , Richard Henderson , Thomas Bogendoerfer , James E J Bottomley , Helge Deller , "David S . Miller" , Arnd Bergmann , Jonathan Corbet , Peter H Anvin , Dave Hansen , Tony Luck , Kirill Shutemov , Sean Christopherson , Kuppuswamy Sathyanarayanan , X86 ML , Linux Kernel Mailing List , Linux PCI , linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-arch , Linux Doc Mailing List , virtualization@lists.linux-foundation.org References: <20210824053830-mutt-send-email-mst@kernel.org> <20210829112105-mutt-send-email-mst@kernel.org> <09b340dd-c8a8-689c-4dad-4fe0e36d39ae@linux.intel.com> <20210829181635-mutt-send-email-mst@kernel.org> <3a88a255-a528-b00a-912b-e71198d5f58f@linux.intel.com> <20210830163723-mutt-send-email-mst@kernel.org> <69fc30f4-e3e2-add7-ec13-4db3b9cc0cbd@linux.intel.com> <20210910054044-mutt-send-email-mst@kernel.org> From: Andi Kleen Message-ID: Date: Fri, 10 Sep 2021 09:34:45 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20210910054044-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>>> And we've been avoiding that drivers can self declare auditing, we've been >>>> trying to have a separate centralized list so that it's easier to enforce >>>> and avoids any cut'n'paste mistakes. >>>> >>>> -Andi >>> Now I'm confused. What is proposed here seems to be basically that, >>> drivers need to declare auditing by replacing ioremap with >>> ioremap_shared. >> Auditing is declared on the device model level using a central allow list. > Can we not have an init call allow list instead of, or in addition to, a > device allow list? That would be quite complicated and intrusive. In fact I'm not even sure how to do maintain something like this. There are a lot of needed initcalls, they would all need to be marked. How can we distinguish them? It would be a giant auditing project. And of course how would you prevent it from bitrotting? Basically it would be hundreds of changes all over the tree, just to avoid two changes in virtio and MSI. Approach of just stopping the initcalls from doing bad things is much less intrusive. > >> But this cannot do anything to initcalls that run before probe, > Can't we extend module_init so init calls are validated against the > allow list? See above. Also the problem isn't really with modules (we rely on udev not loading them), but with builtin initcalls > >> that's why >> an extra level of defense of ioremap opt-in is useful. > OK even assuming this, why is pci_iomap opt-in useful? > That never happens before probe - there's simply no pci_device then. Hmm, yes that's true. I guess we can make it default to opt-in for pci_iomap. It only really matters for device less ioremaps. > > It looks suspiciously like drivers self-declaring auditing to me which > we both seem to agree is undesirable. What exactly is the difference? Just allow listing the ioremaps is not self declaration because the device will still not initialize due to the central device filter. If you want to use it that has to be changed. It's just an additional safety net to contain code running before probe. > > Or are you just trying to disable anything that runs before probe? Well anything that could do dangerous host interactions (like processing ioremap data) A lot of things are harmless and can be allowed, or already blocked elsewhere (e.g. we have a IO port filter). This just handles the ioremap/MMIO case. > In that case I don't see a reason to touch pci drivers though. > These should be fine with just the device model list. That won't stop initcalls. -Andi >