From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DEDBC43464 for ; Fri, 18 Sep 2020 19:47:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B20D121D42 for ; Fri, 18 Sep 2020 19:47:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="IHvL9aBy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726247AbgIRTrO (ORCPT ); Fri, 18 Sep 2020 15:47:14 -0400 Received: from linux.microsoft.com ([13.77.154.182]:38654 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726168AbgIRTrO (ORCPT ); Fri, 18 Sep 2020 15:47:14 -0400 Received: from [192.168.1.12] (c-24-16-6-251.hsd1.wa.comcast.net [24.16.6.251]) by linux.microsoft.com (Postfix) with ESMTPSA id DABC520B7178 for ; Fri, 18 Sep 2020 12:47:13 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com DABC520B7178 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1600458433; bh=BkCanJGy0PXFLPlnH6zom6LHySP8W9di/NMEUaviEfs=; h=From:To:Subject:Date:From; b=IHvL9aByhlUPH4sHgwxRk5++huiZeeU1P4uoFXOBlyOoKd0qu4r9aXbTmZbz0/mbG Y7165pvFoDOYytm2zAXLm6wBnXHzbBwL7aHn5cAnSuFrLjTVuKPq+Eh2MlTS7I4WQW 87gGSmx61KXxRHWYOCyIyLi8fWdYcQeRmE/6WsQI= From: Raphael Gianotti To: linux-kernel@vger.kernel.org Subject: How to extract linux kernel version information from a kernel image? Message-ID: Date: Fri, 18 Sep 2020 12:47:13 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, I have been investigating a way to extract the version strong from a kernel image (e.g., vmlinux). The version string I've been looking at is essentially the linux_banner symbol. We'll use IMA to measure the version string on the kexec system call, providing a way for an attestation service, for instance, to attest to what version of the kernel is running on the client. I haven't found a way to extract the version from the image that isn't simply searching the whole image for it. I was hoping someone here may be able to point me to a better approach to retrieve the linux_banner symbol value from an image orĀ  any existing kernel code that does similar parsing. If that matters for any suggestions, my current focus is on ARM64 images (if the code ends up having to be arch specific). Thanks, -Raphael