Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp600458imu; Tue, 27 Nov 2018 18:10:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/XcGiIIVgY+jl2b5MVpHQaTjVOwGr1k7ObaQM7zKHCV8IjfehKyv0y85XpMIKON471hthu5 X-Received: by 2002:a63:f515:: with SMTP id w21mr31376960pgh.220.1543371042873; Tue, 27 Nov 2018 18:10:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543371042; cv=none; d=google.com; s=arc-20160816; b=oPlLM6IMZ4F7URGrEIv4mlmU+tv1+wNh3zZ4tbkBTDDvbupnXzbRddk2vYhazUDwlA 35y3bACdOuehzX8hBBVUIxu+Vy3ypK23e5wy5uwtarwj6mS0JrG3S8Mp7jMTlYWkWmp+ dDysxhwk3vrVYUTbp9eFxQ7YcZXcXNOAkuLBNH0qD06iNZ4ee6xPXX8mg6nogFnwnMTs 3qTTNlDcD0TzmuEE2ojuacWiI7dxO9LKR1gOSHuFpHsqS6FJiu+k3nWaBVkp82pck8vb rxq7rRFbz7jydqRF+Qk+KJp1FkXDZRJ/OnhYoo0WPXw8ZbGvnFFFhXTNfa7dm3gVQ4IJ Ghcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=WQXPQPmJrmdFh+xOZ94U8J259dFIHTG+znmuT5ZCV7c=; b=dMZI7qDhfMnylbL4kFtLT/fXC4yRS1ZqDCpbpAKp1Q4VWuyq5ylDbC+LsXZ7GkJucA I+NDkOR/+pZTFCb4P28jrBdYGtX2BiF5QxOh0MrX097L9rw6dTiKTtyNpKEs2ZKrATFb OqqYXLGbTyjO/3pzjqAPoUGQJ5fX05YJVwVrblLYHpSXLpUDpPNCMHUGgQTVBCrR2HXs O47eUAzimKohC5kaiksvzjJZBkRVyRInb6+35V1foKJZJQID1V0XfT9dJLwBn3Gv6161 SKhlRb+/jUjoMdXoPlThs+yYAceQOELkbiGHaScLD6iDxSQGo/qCb7+nujknizNw62cj HAyQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k2si5415152pgh.63.2018.11.27.18.10.26; Tue, 27 Nov 2018 18:10:42 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727121AbeK1NJj (ORCPT + 99 others); Wed, 28 Nov 2018 08:09:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:34432 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbeK1NJj (ORCPT ); Wed, 28 Nov 2018 08:09:39 -0500 Received: from vmware.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 470172082F; Wed, 28 Nov 2018 02:09:45 +0000 (UTC) Date: Tue, 27 Nov 2018 21:09:42 -0500 From: Steven Rostedt To: Joe Lawrence Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: Re: [RFC PATCH 0/1] support ftrace and -ffunction-sections Message-ID: <20181127210942.4067ad46@vmware.local.home> In-Reply-To: References: <1542745158-25392-1-git-send-email-joe.lawrence@redhat.com> X-Mailer: Claws Mail 3.15.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 27 Nov 2018 15:27:14 -0500 Joe Lawrence wrote: > Gentle ping... I took a dive through the rhkl-archives and found a few > older discussions: Thanks for the reminder, my INBOX is totally out of control with Plumbers followed by Turkey Day. > > [PATCH] scripts/recordmcount.pl: Support build with -ffunction-sections. > https://lore.kernel.org/lkml/CAFbHwiRtBaHkpZqTm6VZ=fCJcyu+dsdpo_kxMHy1egce=rTuyA@mail.gmail.com/ > > and related LWN article: > > The source of the e1000e corruption bug > https://lwn.net/Articles/304105/ > > Catching up with those, I assume that this has never been implemented in > the past due to fear of ftrace modifying a potentially freed section > (and bricking NICs in the process :( Actually, we have a lot more safe guards against that today. > > Looking through the kernel sources (like Will in 2008) I don't see any > code jumping out at me that frees code other than .init. However a > quick code inspection is no guarantee. > > Assuming the same use-after-free reservation holds true today: > > 1: Is there any reasonable way to mark code sections (pages?) as > in-use to avoid memory freeing mechanisms from releasing them? The > logic for .init is mostly arch-specific, so there could be many > different ways random arches may try to pull this off. > > 2: Would/could it be safer to restrict __mcount_loc detection of > ".text.*" sections to modules? The recordmcount.pl script already > knows about is_module... that information could be provided to > recordmcount.c as well for consideration. I'm fine with just applying your patch. Today, for x86, there's a gcc option that adds the __mcount_loc automatically without doing any whitelisting (it doesn't run recordmcount.*). It just adds anything that is traced, thus it has to work for all possible cases now. -- Steve