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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 408F3C433F5 for ; Sun, 12 Dec 2021 19:06:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232136AbhLLTGa (ORCPT ); Sun, 12 Dec 2021 14:06:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231902AbhLLTG3 (ORCPT ); Sun, 12 Dec 2021 14:06:29 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18838C061714 for ; Sun, 12 Dec 2021 11:06:29 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id m15so12653051pgu.11 for ; Sun, 12 Dec 2021 11:06:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=W0LQCmBUo5l+B03Yci3e9G28eq224UAGiywQoY0pTbs=; b=XcQYzNjq0Gih5xdCdgm+TZNbopMi4SMFwA2HdFQRTYIxjk02GDTLVkVPpfLfuW25Ss lpF5MjAT6uD3DWZTvo6i2A4dU8DLdTEuLeYHUFFOOU+znHYOhpTVEntd5+anIX190u04 x7rkqc/rcMAJ93unNj1LM71DJx1PICntgoTNBXtGGEGd6WZsjbhWySsm+FWvJl2i4ARd H6pp9P1oh6DbXDnGSHmrQ8kfYgFPfeP/Qr0QIEPNAQDK5YUv20qVMifiUmsF4uUpkQT4 VdJkPj/XI3aFKm15f9QeYCLjczAQZWavQBkcv6pDSSYNvoClH2D4Wa4ZEcvQJEbo2dWv XD+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=W0LQCmBUo5l+B03Yci3e9G28eq224UAGiywQoY0pTbs=; b=vgcbYaPaYe15gXHkkFBCFcFFvMSg1UFfBYYBKOdJFdhIMOLOcvMSKm7PkSyuU8Rp8c zG4K8tjI9GWGqXsZqcZ/2mW1RjECK299J8fypxmtgWioDf/76sOu2iBiK5rzEuoHH5o2 WFzwids0u8xz7VzYHH8QcAOJ90oFMfEN1SxBexV2ra+Em/T083hfg/5I/4CiTzs9uAe+ fJf+NlmGqRUNNYthMBXtFrDjQ0HsTgdU0HbEqeutJhXWWNCqQPkYLNVSzlKCQKsyKANQ EkgGHv6pbnh5y5Dfwi7NY7eAkBTxBnicKZYQZ2F9gHHcNuSQL7uyUkYewUygEKPg68Hv ubuQ== X-Gm-Message-State: AOAM533pZLKTS6IwzqPz/KZg72U5PEmSKOR1Syk/m+8ylbQNgftE7bhb v3LXW+Az8KWt4Zv9L0v0NDaAfV5BxnMxax/eWMuxnEv8qgw= X-Google-Smtp-Source: ABdhPJxUQHd9QoZz7FNqIKhdGiKXqBzU5NwMp0zUQydY4g2yAEIUD2AL1dPaarNlItsriDlYa5Z9Nyvduqhp1t+0QSM= X-Received: by 2002:a63:4f42:: with SMTP id p2mr49517130pgl.381.1639335988559; Sun, 12 Dec 2021 11:06:28 -0800 (PST) MIME-Version: 1.0 References: <20211211173447.4155374-1-hjl.tools@gmail.com> In-Reply-To: From: "H.J. Lu" Date: Sun, 12 Dec 2021 11:05:52 -0800 Message-ID: Subject: Re: [PATCH] fs/binfmt_elf.c: disallow zero entry point address To: Linus Torvalds Cc: Alexey Dobriyan , LKML , Andrew Morton Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 12, 2021 at 10:29 AM Linus Torvalds wrote: > > On Sun, Dec 12, 2021 at 5:52 AM H.J. Lu wrote: > > > > On Sat, Dec 11, 2021 at 11:38 PM Alexey Dobriyan wrote: > > > > > > Why not let it segfault? > > > > Why let it segfault? > > That's not my main worry - what if somebody has a code section with a > zero vaddr and intentionally put the entry at the beginning? > > Maybe it's not supposed to work by some paper standatd, but afaik > currently it _would_ work. > > All these things are relative to the load address, so a zero e_entry > doesn't mean NULL, and may be a perfectly valid address. > > No? According to the ELF specification, zero entry point value means there is no entry point. Such ELF binary doesn't conform to the ELF specification. -- H.J.