From owner-freebsd-bugs@freebsd.org Mon Oct 15 15:17:59 2018 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4B98210DE334 for ; Mon, 15 Oct 2018 15:17:59 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id DC634781DD for ; Mon, 15 Oct 2018 15:17:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id A1ADC10DE333; Mon, 15 Oct 2018 15:17:58 +0000 (UTC) Delivered-To: bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7FB3310DE331 for ; Mon, 15 Oct 2018 15:17:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 20098781DA for ; Mon, 15 Oct 2018 15:17:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id 4FA21209F5 for ; Mon, 15 Oct 2018 15:17:57 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id w9FFHvl4003524 for ; Mon, 15 Oct 2018 15:17:57 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id w9FFHvLa003518 for bugs@FreeBSD.org; Mon, 15 Oct 2018 15:17:57 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 232289] kern/link_elf.c fails for small sections sizes ( Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Oct 2018 15:17:59 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D232289 Bug ID: 232289 Summary: kern/link_elf.c fails for small sections sizes (From elfdump -a /boot/kernel/z1.ko: entry: 6 sh_name: set_vnet sh_type: SHT_PROGBITS sh_flags: SHF_WRITE|SHF_ALLOC sh_addr: 0x1270 sh_offset: 624 sh_size: 2 sh_link: 0 sh_info: 0 sh_addralign: 1 sh_entsize: 0 entry: 1 st_name: __stop_set_vnet st_value: 0x1272 st_size: 0 st_info: STT_NOTYPE STB_GLOBAL st_shndx: 65521 entry: 3 st_name: ___set_vnet_pad st_value: 0x1 st_size: 0 st_info: STT_NOTYPE STB_GLOBAL st_shndx: 65521 entry: 9 st_name: __start_set_vnet st_value: 0x1270 st_size: 0 st_info: STT_NOTYPE STB_GLOBAL st_shndx: 65521 entry: 1 st_name: vnet_entry_achar st_value: 0x1270 st_size: 1 st_info: STT_OBJECT STB_LOCAL st_shndx: 6 sys/kern/link_elf.c: link_elf_lookup_set() does read the start and stop symbols: void **start, **stop; int len, error =3D 0, count; .. /* and the number of entries */ count =3D stop - start; printf("XXX-BZ %s: count %d stop %#jx start %#jx\n", __func__, coun= t, (uintmax_t)(uintptr_t)stop, (uintmax_t)(uintptr_t)start); The problem is that the addresses are stored in void ** and so 2 - 0 ! =3D = 2 but 0. Hence, with the count being 0, so when parse_dpcpu() and parse_vnet() do a count *=3D sizeof(void *); 0 * x will stay 0. So the extra memory allocated in the set handlers will be roundup2(size, sizeof(void *)) or 0. Also the copy functions later will copy 0 bytes. While there is no error, neither the memory needed is allocated, nor the da= ta needed is copied into the memory area. With the start/stop symbols stored properly, future relocations would work,= the memory accessed be bogus however. --=20 You are receiving this mail because: You are the assignee for the bug.=