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=-0.5 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED autolearn=ham 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 52CCBC04A6B for ; Sat, 11 May 2019 02:13:09 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F3F0221841 for ; Sat, 11 May 2019 02:13:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OdY2BslW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3F0221841 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.91) (envelope-from ) id 1hPHVI-0003YA-C7; Fri, 10 May 2019 22:12:48 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1hPHVG-0003Y3-Uy for kernelnewbies@kernelnewbies.org; Fri, 10 May 2019 22:12:47 -0400 Received: by mail-wr1-x443.google.com with SMTP id r7so9010669wrr.13 for ; Fri, 10 May 2019 19:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2NNRmk7p31FU2RThoEnuVl0ygVwUWdRyAa1GNJbaBnA=; b=OdY2BslWc16Se5ZMvRy7Ym1f6pZa3UNz5fmO7hZW0fE1IrJuEIQc0ZZnIxGtFZ7NB6 nd7RObE1oIvpDvKuMiO9phbDev/IGg88txmEuMnJyyuCsfcUZSwRZPO4gLSl9mYODd5B MCqCjoZGA8iqyGqp3r1yAo7tpY+zUGU72YJHTPglhRBbIAjGjSTh5Gnl2bfGi+nlrhdB G9+XL2l3a620jfY3RWG3Lc+kFje7XUiLEGlEIO6gMkQRh4dFXAycl1WpPdlhb29Dla1L POVmpixufXSgm1lcjVg8+Dlv8K6gPFPHgB9oRhFCBgFy0smngBg59ZrsUV7Hu8hUmZIJ 8A4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2NNRmk7p31FU2RThoEnuVl0ygVwUWdRyAa1GNJbaBnA=; b=s+ae/uNdY4+mbnN5uzDgUiJ/nvxR2Gr2WItU1Td2zh3hAm7X5tTGBzJ1yo/9wthno7 pXJVLZg/aHj2ALEAVfdMa7rx9E8ZmkMRKEutLlF9bhRUf/gT5LXf68jsmAbKixJhRvXG ggXRtb9evPuCLJyFuj78QuAa9NDba58j3TaQ6viAVu5iZTVbnrIDA/26uurxagsMcqt4 qd8EblV6py6/KdKGEMs+2UjQM/leBc6tLYV2KCx0HL5EQyNg/t/3vYW0LL99OGHDGagP jZSkhBAN2F9nrWTEFMJkQaBcSBnVVW4OOKQJQHGRk88h3yLwv3pP5yckPnsACIjgF106 E0MQ== X-Gm-Message-State: APjAAAX1eXD89hPRgKQj7//e2hkGj8qvZIgK4uinAtoAjxCmRXLoUn7K 5eNTW3N4u6ovTw7DTAzqUPttc+6Sz5Y8/2tu1/U= X-Google-Smtp-Source: APXvYqzki6J5i37sd/IMBxma4eBU/oFuBqt5m/RLnLVaRS+jcxty8VAeHpvY3KF5djKOiK9O6omnDi/PN9iYAGxbeg8= X-Received: by 2002:adf:dc8e:: with SMTP id r14mr2761935wrj.121.1557540703645; Fri, 10 May 2019 19:11:43 -0700 (PDT) MIME-Version: 1.0 References: <5de6f762.7230c.16a96a52517.Coremail.wuzhouhui14@mails.ucas.ac.cn> In-Reply-To: <5de6f762.7230c.16a96a52517.Coremail.wuzhouhui14@mails.ucas.ac.cn> From: Aruna Hewapathirane Date: Fri, 10 May 2019 22:11:31 -0400 Message-ID: Subject: Re: how to determine whether the source code is same between two kernels To: wuzhouhui Cc: kernelnewbies X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============5870846702439228558==" Errors-To: kernelnewbies-bounces@kernelnewbies.org --===============5870846702439228558== Content-Type: multipart/alternative; boundary="0000000000005d35a305889334d8" --0000000000005d35a305889334d8 Content-Type: text/plain; charset="UTF-8" On Wed, May 8, 2019 at 4:53 AM wuzhouhui wrote: > Hi, > Suppose I have two kernels, one is A.B.C build by people Tom. And > the other is A.B.C build by Jerry. The source code have been deleted > after kernel is build and installed. Now I want to know whether the > source code of these two kernel is the same (even if they have the same > name). All I have is binaries (e.g. vmlinux, config, *.ko, System.map). > Is it possible? Within sane defaults yes it is possible. Think of it this way, if the source code is the 'same' we can safely assume that the kernel built by Tom will function and behave 'exactly' the same as the kernel built by Jerry. Behavior can be traced and analyzed. diff, dmesg, lsmod, tree and objdump are your friends :-) Run diff vmlinuz-Tom vmlinuz-Jerry and see if they differ. Then just to make sure follow below steps: 1 - Boot kernel-Tom and redirect dmesg output to file(s) 2 - dmesg -k > kernel-Tom.txt 3 - dmesg -u > userspace-Tom.txt 4 - lsmod > modules-Tom.txt 5 - tree / > fs-Tom.txt Now we have what the kernel prints while booting in kernel-Tom.txt and what userspace prints in userspace-Tom.txt and loaded modules in modules-Tom.txt and the folder structure under root in fs-Tom.txt. Now repeat the same process with kernel-Jerry 1 - Boot kernel-Jerry 2 - dmesg -k > kernel-Jerry.txt 3 - dmesg -u > userspace-Jerry.txt 4 - lsmod > modules-Jerry.txt 5 - tree / > fs-Jerry.txt Then run diff on those files.. 1 - diff kernel-Tom.txt kernel-Jerry.txt 2 - diff userspace-Tom userspace-Jerry 3 - diff modules-Tom modules-Jerry 4 - diff fs-Tom fs-Jerry if you want to dig deeper use objdump -d vmlinuz-Tom then objdump -d vmlinuz-Jerry which is really overkill unless there is output from diff that says the file(s) differ. If you really really need the source there are decompilers : IDA ghidra snowman hopper Keep in mind what Valdis pointed out that though the source may be exactly the same, depending on what compiler flags were used the binaries may differ. You had asked.. > Is it possible? Simple answer: In the Linux world the impossible becomes very possible :) Good luck - Aruna --0000000000005d35a305889334d8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, May 8, 2019 at 4:53 AM wuzhouhui <wuzhouhui14@mails.ucas.ac.cn> wrote:
<= div dir=3D"ltr" class=3D"gmail_attr">> Hi,

>= Suppose I have two kernels, one is A.B.C build by people Tom. And
> the other is A.B.C build by Jerry. The source code have been deleted=
> after kernel is build and installed. Now I want to know whe= ther the
> source code of these two kernel is the same (even i= f they have the same
> name). All I have is binaries (e.g. vml= inux, config, *.ko, System.map).

> Is it possib= le?
Within sane defaults yes it is possible. Think of it this way, if = the source code is
the 'same'= =C2=A0 we can safely assume that the kernel built by Tom will function and = behave
'exactly' the same as t= he kernel built by Jerry. Behavior can be traced and analyzed.

diff, dmesg, l= smod, tree and objdump are your friends :-)

Run diff vmlinuz-Tom vmlinuz-Jerry an= d see if they differ. Then just=C2=A0 to make
sure follow below steps:

<= div class=3D"gmail_quote">1 - Boot kernel-Tom and=C2=A0 redirect dmesg outp= ut to file(s)
2 - dmesg -k > kernel-Tom.= txt=C2=A0=C2=A0=C2=A0
3 - dmesg -u >= ; userspace-Tom.txt
4 - lsmod > modules-= Tom.txt
5 - tree / > fs-Tom.txt

Now we have wh= at the kernel prints while booting in kernel-Tom.txt and what userspace pri= nts
in userspace-Tom.txt and loaded mo= dules in modules-Tom.txt and the folder structure under root
in fs-Tom.txt.

=
Now repeat the same process with kernel-Jerry

1 - Boot kernel-Jerry
2 - dmesg -k > kernel-Jerry.txt
3 - dm= esg -u > userspace-Jerry.txt
4 - lsmod &= gt; modules-Jerry.txt
5 - tree / > fs-Je= rry.txt

Then run diff on those files..

1 - diff kernel-Tom.txt kernel-Jerry.txt=C2= =A0=C2=A0
2 - diff userspace-Tom users= pace-Jerry
3 - diff modules-Tom modules-Jer= ry
4 - diff fs-Tom fs-Jerry

if you want= to dig deeper use objdump -d vmlinuz-Tom then objdump -d vmlinuz-Jerry
which is really overkill unless there is outpu= t from diff that says the file(s) differ.

If you really really need the sourc= e there are decompilers :
<= a href=3D"https://ghidra-sre.org/">ghidra

Keep in mind what V= aldis pointed out that though the source may be exactly the same,
depending on what compiler flags were used the binar= ies may differ.

You had asked..
> Is it possible?
<= div>Simple answer: In the Linux world the impossible becomes very possible = :)

Good luck - Aruna

=






--0000000000005d35a305889334d8-- --===============5870846702439228558== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============5870846702439228558==--