Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758671Ab0FJXIY (ORCPT ); Thu, 10 Jun 2010 19:08:24 -0400 Received: from khc.piap.pl ([195.187.100.11]:56123 "EHLO khc.piap.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753351Ab0FJXIX convert rfc822-to-8bit (ORCPT ); Thu, 10 Jun 2010 19:08:23 -0400 From: Krzysztof Halasa To: Alan Cc: Michal Marek , =?utf-8?Q?Am=C3=A9rico?= Wang , linux-kernel@vger.kernel.org Subject: Re: Additional info on modpost segfault References: <20100604045118.GC5167@cr0.nay.redhat.com> <4C08A9D0.8000505@suse.cz> <1275929979.2923.0.camel@zowie.clueserver.org> Date: Fri, 11 Jun 2010 01:08:20 +0200 In-Reply-To: <1275929979.2923.0.camel@zowie.clueserver.org> (alan@clueserver.org's message of "Mon, 07 Jun 2010 09:59:39 -0700") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1323 Lines: 38 Alan writes: > program: /home/alan/GitTrees/linux-2.6-mid-ref/scripts/mod/modpost -o > Module.symvers -S vmlinux.o > > Program received signal SIGSEGV, Segmentation fault. It just hit me. It's the offset calculation in reloc_location() which overflows: return (void *)elf->hdr + sechdrs[section].sh_offset + (r->r_offset - sechdrs[section].sh_addr); E.g. for the first rodata r entry: r->r_offset < sechdrs[section].sh_addr and the expression in the parenthesis produces 0xFFFFFFE0 or something equally wise. Does the attached patch fix it? Signed-off-by: Krzysztof HaƂasa --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1317,8 +1317,8 @@ static unsigned int *reloc_location(struct elf_info *elf, Elf_Shdr *sechdrs = elf->sechdrs; int section = sechdr->sh_info; return (void *)elf->hdr + sechdrs[section].sh_offset + - (r->r_offset - sechdrs[section].sh_addr); + r->r_offset - sechdrs[section].sh_addr; } static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/