Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5123452imm; Tue, 21 Aug 2018 06:42:17 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzfWYBbnY7KnYVe8Gi6z2GOXITJjr0avStxCLmFkzxzetJadWqW8eV+lY27NvSamyPfM0w7 X-Received: by 2002:a63:9741:: with SMTP id d1-v6mr6106059pgo.208.1534858937146; Tue, 21 Aug 2018 06:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534858937; cv=none; d=google.com; s=arc-20160816; b=ZUvGGn7mRO+EC8g31OwojjEULG9ifH8+QdxP1EL4M6wrgPba20plr9hhxAE2DxYW87 +o9dXWuLhdPxnpFo+vfShmYdkeFFOQ+t9l5sPfcK1gppQLTJfhELUacF+iEnWGAUoKut 0lPzehgjdW0b+lC1lMYELS7uIO+ySbKTlQAynp7m+hExfNdvA4vFQJepAy6+SJETDg8Z ZoF75hjjDsN4Yyqm8cHvkLd6kAi7XJFDyjMSg3nD2/Nv2gei0ldB9i7bBCYqUOmeTYmd l0IcJfwFbwHn/OCOb+kpPG2EFMb7ZWG/PvXioSwpahid/E6qrs9Zi8KKzt09laIDDDsa yypA== 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 :arc-authentication-results; bh=FS+N45EMI6S5platJWC6hB8JY8ElJv6/uwIx9m4wVJ4=; b=E0g0tJELS2F5vH2Y10ITvkXhYXrwmphgOAfy4m+CclndcEt89sb7MKcSi6brYDb0NR GDwem86k92BY0hUQSVlQ1J3Y9vDitG5otY86yU/kQNMkP/X5R4dkwshG+7Z9Vw5/Tlfp 437nAJLgy/ujBDdQa1DkhwvSLr/rBDKdZdG1TS74SZ85aN/whgHw2TJtuGTLki8pgRhn avJR2R68k9RFKMpLAkhqbhU7Gs2W+wwlfBTFRnKwQkHBK7W26svZNdw9YTKe1jzVDTGN 3nrO8Rs5Djl4OvwdGEJuWUlSJjLwsfezKyKGbKLEq9247yvMGi9qSHQYzrhR4IGEOXd/ tnkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GJg+VFba; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 144-v6si13146442pfw.95.2018.08.21.06.42.01; Tue, 21 Aug 2018 06:42:17 -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=@linaro.org header.s=google header.b=GJg+VFba; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727113AbeHUQ7Q (ORCPT + 99 others); Tue, 21 Aug 2018 12:59:16 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:53467 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726843AbeHUQ7Q (ORCPT ); Tue, 21 Aug 2018 12:59:16 -0400 Received: by mail-it0-f65.google.com with SMTP id 72-v6so4136114itw.3 for ; Tue, 21 Aug 2018 06:39:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=FS+N45EMI6S5platJWC6hB8JY8ElJv6/uwIx9m4wVJ4=; b=GJg+VFba+GzT4It0f3CZEf6b7MJ+HhkFLNLUPHpFVErtncyyzpcgeJy/eFd9zzIyEq uD7ynNYiIQW1/PgIQx4iyAyzePvsDcbuXzcbZHeb3PFzbomjEBbcgKs6BYkuZrjxtuZW oRDr8KbG7pZgvhWMyg3guX1qDO1A/NUY5XPvo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=FS+N45EMI6S5platJWC6hB8JY8ElJv6/uwIx9m4wVJ4=; b=Nl8+SWi4iJ8tVNX25zFLx9xCSx/AfNd1lZbbU+HQcuYZGEca1f/Xod05dcmegY45Z6 YhmMQEhKXpa/euDhPxWysKit8ukhbV/mTt84xn1J4OkMhYMAO/Vzia00x0vO9GClPNaV nCnWcPC6SF1NtOrOhIhc27YhnwZ9Q5Cr+TXdU3WgPmvQB3tOqogJWaOs9uWofEBzkW1U pzqemOlFmv3s8/sNsOXJB9HFzTLw9OcGpaNjd+5mLMmbddNdQI240wSRNCyNa2igwDM+ VNkMDvKg+kB5AzGM07p6Gz7kBmn0DFVbWQJ2x2PlDf5XiM0FWq/mikvKSpvMYuOh25TM qPRQ== X-Gm-Message-State: AOUpUlH4ihfb0+jSAtjOHpUqtTTLF5dcYHifaJZlOX/N8oPGn4AgdQwD YRFzEYEPG8yjmKnU3WAqQWLsKuVpg7zthOvNsY9KVQ== X-Received: by 2002:a24:4c0b:: with SMTP id a11-v6mr37133772itb.123.1534858744641; Tue, 21 Aug 2018 06:39:04 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:ac05:0:0:0:0:0 with HTTP; Tue, 21 Aug 2018 06:39:04 -0700 (PDT) In-Reply-To: <20180809091333.GA8008@dhcp-128-65.nay.redhat.com> References: <1533737025.4936.3.camel@gmx.de> <20180809042153.GA4377@dhcp-128-65.nay.redhat.com> <1533800010.5087.71.camel@gmx.de> <20180809091333.GA8008@dhcp-128-65.nay.redhat.com> From: Ard Biesheuvel Date: Tue, 21 Aug 2018 15:39:04 +0200 Message-ID: Subject: Re: [PATCH] x86, kdump: Fix efi=noruntime NULL pointer dereference To: Dave Young Cc: Mike Galbraith , Baoquan He , Sebastian Andrzej Siewior , lkml , Kexec Mailing List , linux-efi 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 9 August 2018 at 11:13, Dave Young wrote: > On 08/09/18 at 09:33am, Mike Galbraith wrote: >> On Thu, 2018-08-09 at 12:21 +0800, Dave Young wrote: >> > Hi Mike, >> > >> > Thanks for the patch! >> > On 08/08/18 at 04:03pm, Mike Galbraith wrote: >> > > When booting with efi=noruntime, we call efi_runtime_map_copy() while >> > > loading the kdump kernel, and trip over a NULL efi.memmap.map. Avoid >> > > that and a useless allocation when the only mapping we can use (1:1) >> > > is not available. >> > >> > At first glance, efi_get_runtime_map_size should return 0 in case >> > noruntime. >> >> What efi does internally at unmap time is to leave everything except >> efi.mmap.map untouched, setting it to NULL and turning off EFI_MEMMAP, >> rendering efi.mmap.map accessors useless/unsafe without first checking >> EFI_MEMMAP. > > Probably the x86 efi_init should reset nr_map to zero in case runtime is > disabled. But let's see how Ard thinks about this and cc linux-efi. > > As for efi_get_runtime_map_size, it was introduced for x86 kexec use. > for copying runtime maps, so I think it is reasonable this function > return zero in case no runtime. > I don't see the patch in the context so I cannot comment in great detail. In any case, it is better to decouple EFI_MEMMAP from EFI_RUNTIME dependencies. On x86, one may imply the other, but this is not generally the case. That means that efi_get_runtime_map_size() should probably check the EFI_RUNTIME flag, and return 0 if it is cleared. Perhaps there are other places where EFI_MEMMAP flag checks are missing, but I consider that a separate issue.