Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2922445rdb; Tue, 6 Feb 2024 01:37:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYgNvpoiqQVXHXPEcxtf5IbkicyxZU0FXspPKRYRkSJo3upB00gPQlOxUCGisR3Kd4eshC X-Received: by 2002:a05:6870:82a0:b0:218:d0e5:4800 with SMTP id q32-20020a05687082a000b00218d0e54800mr2541547oae.48.1707212223614; Tue, 06 Feb 2024 01:37:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707212223; cv=pass; d=google.com; s=arc-20160816; b=i+n9yErIecwgTC3TmmJfr/U73cG1aXRkQjJopojgFSVHbWVb1FgsGeBCwkTzLp4UyZ BnZfti5FRu82lEwaFEuOUJpZg7eQVH2CcAfAwuwoTLcPkztg5upCjo77WjgF9wMwKNne rdliWV71uudckPBuAfCKSqr8CozpkmrbDmYJooXLmbbQdgE7wUTay90WMVhI3KfjXYZ9 d3bqh7hwmg9VM0F2lpNzR3kQkxgvfhrS61goGRvM+s9hyQazQCWRptuTPf2FeNFWsTlc UIP6a3twBs1WQcA9MCPYjfalgE/PCqbr3a/1qi7wYcBXKemDu1fXmQCS0uWXfE3A8G4g amtg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=on79fhII02mEwej/WPS02bX/q4h1znp3R1RIv7m+C8M=; fh=pHFVzod9qwm2Ll2Ttte48Yyf2JOtHjGHDwO7AyIH7EE=; b=DallddDGjPi4U8gXOS9tH5zXHjyg8yuKbcETtn89kHzm3kcHMYUdaDq9LSeUQVx/iI 8pf5I6XP2KM8AVob5wPKD3RXK5yY3Z6+sChtQCvibfWWEyJsyyg1OVUDx5OI2tRK0eTb Fl/Bo82Ek4W9EPpHX0Ix+qTyOiQ32oKz7o/ErHTqps3M3nKH7UUr32s5w9SPA0c7+D/q CihsfzUTxYOImNhtF2E0VjT28Ku2VMaQTzVIzmiXVCPfUKWDoglPZNt7DxbkwRGRJYTA fo89DqxHAa5k6QxVjCLShGNpBSYXUuO7xusn+corRV0bJ3hXm05RsJf8ZLvq7JzXFO3U HVuw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OFZAAUlP; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-54602-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCVpkiXgZiOfkxAQrt6MPa0MZ710sYpaexXA1PQs5RaIK3u5sXU+ouOzgU46E4Jq1i1DUvRqc2I5h6UlDw7q12mEPogzmrHZulKt020dHA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w24-20020a63fb58000000b005d4664c06cbsi1436362pgj.227.2024.02.06.01.37.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:37:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54602-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OFZAAUlP; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-54602-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 40938284CDF for ; Tue, 6 Feb 2024 09:37:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 073E012D148; Tue, 6 Feb 2024 09:36:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OFZAAUlP" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC0B412D140 for ; Tue, 6 Feb 2024 09:36:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707212212; cv=none; b=hZgNDHXjCLcAoXk1+KpISwU7cezySMeQDACxzC4erAFJnbMRzE5EI0J+dt0S72ST6q3c2MwqwYxY5grm+FHF6b7fhNeA3eztxSIOPsY/M3Y5ppBLPmWYTAzEYC1OK71cXl/NfCoDTgjPlr0lpgWbDo5q1pfmUHZRq+4jTZ/d/iI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707212212; c=relaxed/simple; bh=on79fhII02mEwej/WPS02bX/q4h1znp3R1RIv7m+C8M=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=jh3ij9sa14QjHXXeZZEuVHoWyfVFz459yK9tt29WYXOYlwGkBXPa0Nr/A3MMpI0KkVzCHxWifLSJi2eJZlwmo0gJyar4Cy4Vlja/qcAodWFAvyBqU8loueJaEjt20PG5GMgy7T1/SHHxBrF9ecirRWGftSgVlCEkSmpFe0aZuF4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=OFZAAUlP; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707212209; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=on79fhII02mEwej/WPS02bX/q4h1znp3R1RIv7m+C8M=; b=OFZAAUlPN2RxtqjHbVFRIKAoLUW+9yo5X4Ip6/29VDzPJyAJrl7TP3EDk2JmZVk3xb6sVa 7VbZg4QAsKjSsEbt7GiSZ+spyQ0dug7eiwZ4WAldVxfauQm24o298T3icF/fDH09ckLs/d Og/WkujNjTzPd7ZxVjL67pnBklGGbLE= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-682-v64sQYZFNKaJCoS-qn9FCQ-1; Tue, 06 Feb 2024 04:36:47 -0500 X-MC-Unique: v64sQYZFNKaJCoS-qn9FCQ-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-78130939196so245261985a.1 for ; Tue, 06 Feb 2024 01:36:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707212207; x=1707817007; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=on79fhII02mEwej/WPS02bX/q4h1znp3R1RIv7m+C8M=; b=XnE2WXvEeVZ37kPf2MqZgddZ83vBsuvrEe+pFi2dhSmHbMqDl7O4g4aOenjII9B9Pd /uu+W2BQy03Cli3XCzTbd62917BKHB1y+LlUO+8uvp7R3ym6fvzwHljP+I5X6dw9O59H ZlmyKUd8RxYq66hJ/sVC7APhMHtWU+tntDIS4FFiFAS2grBSYXUEv8OyP5wZldVWmuA+ vAuqVTMb3ZWF7KlI4m6ugp9HjIPHdt4g0uvoBvM/EnpiPDLfdMrm82Ql5WO87sr+LVHu 1IRJdsgG/TbuCMz/n4c+f8MNfR34V1IvVeZd2QR+fGfdTYE9F1GOZCD4DTdbzvL5wZtR RMrQ== X-Gm-Message-State: AOJu0YyWvYrRZ6ir3Tv+qqTb7+j32VOuAYb0CKd25rvGkKlr1u6TgygV Gfo+w28NEXDDonn4rzKepD7WGGn51vd9nb6nEyl/9+KksBgCO/9HqNRS5sN/4KRq12I0nnqxGo0 iYs52Noq2xhUZM0qKR/DE7T45yuFWgplJEH/VnmWuSVdduX27kQrA9U/ShWTZCg== X-Received: by 2002:a05:620a:2944:b0:785:9521:9603 with SMTP id n4-20020a05620a294400b0078595219603mr41476qkp.0.1707212207150; Tue, 06 Feb 2024 01:36:47 -0800 (PST) X-Received: by 2002:a05:620a:2944:b0:785:9521:9603 with SMTP id n4-20020a05620a294400b0078595219603mr41440qkp.0.1707212206863; Tue, 06 Feb 2024 01:36:46 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCX0eTKyaNqU4MvNt6IPt9W+TM5FdOYvSlOLajLKFA2fW8GASp50CgRgqzJy77fGHzP9yOeUwO9ikj2fYEgJJLsLQdl9kxKq4o8tc3cAK9Mel02Ms9kSK23XBQHTBJ53pmBI8N4wE+go0Fh+3IFr1rfFQuMuO99odI+3nJImFay5fb2m4vKqe1ceYf7fsj2Gf1QI0LYbv8sOVezeWygJn/VB62Niy2i7UOS7hKJe6Ixx4S+LUvUVSCigmNC3SLNy82hrPzx+DVkZdfzBvnTwlQyqBvuwwg7Th4Rsym1aD75U9qdtaMhbN9gVR5EUGLZIklbgMT6yucWQT8PlYpf4vGZjoHvStofuQGec/WBk+zb4ICzA/62QGfP8hePqOHtB366RdqbFUICUAlY+QLg6dzMsk0rH9lED0/bJdZj1DT3QURaf6UIUTvCEUkgG7ILXnHxd+VdMZIegrl/Wa9Yddyz/F8L/Rl+84nqIpP9ihh2W3z4o/kcEOwrY8Rqxa3YwnBelLSpv7ewRnSIp3Q+ULAD9vdu+BpUHuhIGNN7Fd+2LKFUrEdj1tlaJ4LA6s6EC/wnanDBWIjtGPqg/b5KG9uXlceQmehYCeO5oVUxTuihcucKTaeYrhnkQpf25uSZgry4b5OPq36tkYEQwQMtDmLF3nds/1s9S+G7cBbHlVAHIF+uUznuW+seY0FapwWP3RLh7+0x/ugrK6TiK/ryiDuWYyxzj1T1vuBaMPDhGB1DAb72Yx6ToV18nmE26WUA4kY9aueYsX38HcddJw+59lDAy6xjITysumcSLrIy+Aoke05ZoDkEgvSlEncuA5p2vQB4tsWNI8zIZFWlW94Q9jDYf2AYNUY6riqeW Received: from pstanner-thinkpadt14sgen1.remote.csb (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id x7-20020a05620a0ec700b0078552f53b85sm750891qkm.86.2024.02.06.01.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 01:36:46 -0800 (PST) Message-ID: <1797620e544e77cad9a8cc86d9145e1046d84e6b.camel@redhat.com> Subject: Re: [PATCH v6 1/4] lib/pci_iomap.c: fix cleanup bug in pci_iounmap() From: Philipp Stanner To: Bjorn Helgaas Cc: Bjorn Helgaas , Arnd Bergmann , Johannes Berg , Randy Dunlap , NeilBrown , John Sanpe , Kent Overstreet , Niklas Schnelle , Dave Jiang , Uladzislau Koshchanka , "Masami Hiramatsu (Google)" , David Gow , Kees Cook , Rae Moar , Geert Uytterhoeven , "wuqiang.matt" , Yury Norov , Jason Baron , Thomas Gleixner , Marco Elver , Andrew Morton , Ben Dooks , dakr@redhat.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-arch@vger.kernel.org, stable@vger.kernel.org, Arnd Bergmann Date: Tue, 06 Feb 2024 10:36:42 +0100 In-Reply-To: <20240131210944.GA599710@bhelgaas> References: <20240131210944.GA599710@bhelgaas> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Wed, 2024-01-31 at 15:09 -0600, Bjorn Helgaas wrote: > On Wed, Jan 31, 2024 at 10:00:20AM +0100, Philipp Stanner wrote: > > The #ifdef for the ioport-ranges accidentally also guards > > iounmap(), > > potentially compiling an empty function. This would cause the > > mapping to > > be leaked. > >=20 > > Move the guard so that iounmap() will always be part of the > > function. >=20 > I tweaked the subject and commit log to be more explicit about what > the bug is.=C2=A0 Let me know if I got it wrong: Mostly correct IMO >=20 > =C2=A0 pci_iounmap(): Fix MMIO mapping leak >=20 > =C2=A0 The #ifdef ARCH_HAS_GENERIC_IOPORT_MAP accidentally also guards > iounmap(), > =C2=A0 which means MMIO mappings are leaked. nit: I wasn't entirely sure when they are actually leaked, just that they _could_ be leaked. To know for sure we'd need to search who sets ARCH_WANTS_GENERIC_PCI_IOUNMAP without setting ARCH_HAS_GENERIC_IOPORT_MAP. I think your formulation should be fine, though, since it's definitely a bug. P. >=20 > =C2=A0 Move the guard so we call iounmap() for MMIO mappings. >=20 > Bjorn >=20