Received: from list by lists.gnu.org with archive (Exim 4.71) id 1c7S3N-0001dM-EY for mharc-grub-devel@gnu.org; Thu, 17 Nov 2016 14:08:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7S3L-0001dG-Gh for grub-devel@gnu.org; Thu, 17 Nov 2016 14:08:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7S3I-0008UQ-8A for grub-devel@gnu.org; Thu, 17 Nov 2016 14:08:55 -0500 Received: from boksu.net-space.pl ([185.15.1.105]:35965) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.71) (envelope-from ) id 1c7S3H-0008UK-Tb for grub-devel@gnu.org; Thu, 17 Nov 2016 14:08:52 -0500 Received: (from localhost user: 'dkiper' uid#4000 fake: STDIN (dkiper@boksu.net-space.pl)) by router-fw-old.local.net-space.pl id S1669421AbcKQTIt (ORCPT ); Thu, 17 Nov 2016 20:08:49 +0100 Date: Thu, 17 Nov 2016 20:08:49 +0100 From: Daniel Kiper To: arvidjaar@gmail.com, phcoder@gmail.com, grub-devel@gnu.org Subject: Re: [PATCH v2] grub-file: fix segmentation fault Message-ID: <20161117190849.GC7245@router-fw-old.local.net-space.pl> References: <20160412062412.GA16964@linux-9gqx.suse> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160412062412.GA16964@linux-9gqx.suse> User-Agent: Mutt/1.3.28i X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 185.15.1.105 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Nov 2016 19:08:56 -0000 On Tue, Apr 12, 2016 at 02:24:12PM +0800, Michael Chang wrote: > In grub_file_open the file handle returned by file filters has no file->name > set which leads to segmentation fault later referenced by grub_elf_file. This > patch tries to fix the problem. > > gdb --args ./grub-file --is-x86_64-xen-domu /boot/vmlinux-4.1.12-1-default.gz > > (gdb) bt > #0 0x000000000047597e in grub_strlen (s=0x0) at ../grub-core/kern/misc.c:558 > #1 0x00000000004757e2 in grub_strdup (s=0x0) at ../grub-core/kern/misc.c:463 > #2 0x0000000000406418 in grub_elf_file (file=0x6dfb50, filename=0x0) at ../grub-core/kern/elf.c:89 > #3 0x00000000004043b3 in grub_xen_file (file=0x6dfb50) at ../grub-core/loader/i386/xen_file.c:29 > #4 0x0000000000403930 in grub_cmd_file (ctxt=0x7fffffffe120, argc=1, args=0x6dfa00) at ../grub-core/commands/file.c:425 > #5 0x000000000047e178 in grub_extcmd_dispatcher (cmd=0x6df730, argc=2, args=0x6ddfb0, script=0x0) at ../grub-core/commands/extcmd.c:54 > #6 0x000000000047e1d7 in grub_extcmd_dispatch (cmd=0x6df730, argc=2, args=0x6ddfb0) at ../grub-core/commands/extcmd.c:67 > #7 0x0000000000402945 in main (argc=3, argv=0x7fffffffe2e8) at ../util/grub-file.c:102 > (gdb) frame 3 > #3 0x00000000004043b3 in grub_xen_file (file=0x6dfb50) at ../grub-core/loader/i386/xen_file.c:29 > 29 elf = grub_elf_file (file, file->name); > > v2: Keep the file->name in file io handle for filters as it would be fetched by > progress and used modules, according to the review by Andrei Borzenkov. Vladimir, Andrei, could you take care of it? Daniel