Re: [tip:x86/urgent] x86/vdso: Discard the __bug_table section

From: H. Peter Anvin
Date: Tue Jun 24 2014 - 14:44:13 EST


On 06/24/2014 11:37 AM, Andy Lutomirski wrote:
>>
>> diff --git a/arch/x86/vdso/vdso2c.h b/arch/x86/vdso/vdso2c.h
>> index f42e2ddc663d..94158e100f26 100644
>> --- a/arch/x86/vdso/vdso2c.h
>> +++ b/arch/x86/vdso/vdso2c.h
>> @@ -99,8 +99,9 @@ static void BITSFUNC(copy_section)(struct
>> BITSFUNC(fake_sections) *out,
>> if (!copy)
>> return;
>>
>> - if (out->count >= out->max_count)
>> - fail("too many copied sections (max = %d)\n",
>> out->max_count);
>> + if (out->count > out->max_count)
>> + fail("too many copied sections (max = %d, need = %d)\n",
>> + out->max_count, out->count);
>>
>
> I think the old test was correct: we haven't incremented count yet
> (it's a couple lines below), so count is the zero-based index to which
> we're writing.
>
> I thought of doing the need = %d thing, but I think that the output is
> a foregone conclusion: count == max_count + 1 when this fails. A list
> of all the section names would be more interesting, but eu-readelf -S
> will tell is that.
>

Well, I have reproduced this failure. eu-readelf output included.

-hpa

o.test/arch/x86/vdso/vdso32-int80.so.dbg
There are 27 section headers, starting at offset 0x9774:

Section Headers:
[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
[ 0] NULL 00000000 000000 000000 0 0 0 0
[ 1] .hash HASH 000000b4 0000b4 000038 4 A 2 0 4
[ 2] .dynsym DYNSYM 000000ec 0000ec 000090 16 A 3 1 4
[ 3] .dynstr STRTAB 0000017c 00017c 000095 0 A 0 0 1
[ 4] .gnu.version GNU_versym 00000212 000212 000012 2 A 2 0 2
[ 5] .gnu.version_d GNU_verdef 00000224 000224 000054 0 A 3 3 4
[ 6] .dynamic DYNAMIC 00000278 000278 000080 8 WA 3 0 4
[ 7] .rodata PROGBITS 000002f8 0002f8 000228 4 WA 0 0 4
[ 8] .fake_shstrtab PROGBITS 00000520 000520 000076 0 A 0 0 32
[ 9] .note NOTE 00000598 000598 000060 0 A 0 0 4
[10] .eh_frame_hdr PROGBITS 000005f8 0005f8 000024 0 A 0 0 4
[11] .eh_frame PROGBITS 0000061c 00061c 0000f4 0 A 0 0 4
[12] .text PROGBITS 00000710 000710 000633 0 AX 0 0 16
[13] .altinstructions PROGBITS 00000d43 000d43 000018 0 A 0 0 1
[14] .altinstr_replacement PROGBITS 00000d5b 000d5b 000006 0 AX 0 0 1
[15] .debug_info PROGBITS 00000000 000d61 004a84 0 0 0 1
[16] .debug_abbrev PROGBITS 00000000 0057e5 000519 0 0 0 1
[17] .debug_loc PROGBITS 00000000 005cfe 00064f 0 0 0 1
[18] .debug_aranges PROGBITS 00000000 006350 000058 0 0 0 8
[19] .debug_ranges PROGBITS 00000000 0063a8 000208 0 0 0 1
[20] .debug_line PROGBITS 00000000 0065b0 00077b 0 0 0 1
[21] .debug_str PROGBITS 00000000 006d2b 0027f2 1 MS 0 0 1
[22] .comment PROGBITS 00000000 00951d 00002c 1 MS 0 0 1
[23] .debug_frame PROGBITS 00000000 00954c 000100 0 0 0 4
[24] .shstrtab STRTAB 00000000 00964c 000127 0 0 0 1
[25] .symtab SYMTAB 00000000 009bac 000380 16 26 48 4
[26] .strtab STRTAB 00000000 009f2c 000226 0 0 0 1

o.test/arch/x86/vdso/vdso32-syscall.so.dbg
There are 27 section headers, starting at offset 0x979c:

Section Headers:
[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
[ 0] NULL 00000000 000000 000000 0 0 0 0
[ 1] .hash HASH 000000b4 0000b4 000038 4 A 2 0 4
[ 2] .dynsym DYNSYM 000000ec 0000ec 000090 16 A 3 1 4
[ 3] .dynstr STRTAB 0000017c 00017c 000095 0 A 0 0 1
[ 4] .gnu.version GNU_versym 00000212 000212 000012 2 A 2 0 2
[ 5] .gnu.version_d GNU_verdef 00000224 000224 000054 0 A 3 3 4
[ 6] .dynamic DYNAMIC 00000278 000278 000080 8 WA 3 0 4
[ 7] .rodata PROGBITS 000002f8 0002f8 000220 4 WA 0 0 4
[ 8] .fake_shstrtab PROGBITS 00000520 000520 000076 0 A 0 0 32
[ 9] .note NOTE 00000598 000598 000060 0 A 0 0 4
[10] .eh_frame_hdr PROGBITS 000005f8 0005f8 000024 0 A 0 0 4
[11] .eh_frame PROGBITS 0000061c 00061c 0000fc 0 A 0 0 4
[12] .text PROGBITS 00000720 000720 000640 0 AX 0 0 16
[13] .altinstructions PROGBITS 00000d60 000d60 000018 0 A 0 0 1
[14] .altinstr_replacement PROGBITS 00000d78 000d78 000006 0 AX 0 0 1
[15] .debug_info PROGBITS 00000000 000d7e 004a84 0 0 0 1
[16] .debug_abbrev PROGBITS 00000000 005802 000519 0 0 0 1
[17] .debug_loc PROGBITS 00000000 005d1b 00064f 0 0 0 1
[18] .debug_aranges PROGBITS 00000000 006370 000058 0 0 0 8
[19] .debug_ranges PROGBITS 00000000 0063c8 000208 0 0 0 1
[20] .debug_line PROGBITS 00000000 0065d0 000783 0 0 0 1
[21] .debug_str PROGBITS 00000000 006d53 0027f2 1 MS 0 0 1
[22] .comment PROGBITS 00000000 009545 00002c 1 MS 0 0 1
[23] .debug_frame PROGBITS 00000000 009574 000100 0 0 0 4
[24] .shstrtab STRTAB 00000000 009674 000127 0 0 0 1
[25] .symtab SYMTAB 00000000 009bd4 000380 16 26 48 4
[26] .strtab STRTAB 00000000 009f54 000228 0 0 0 1

o.test/arch/x86/vdso/vdso32-sysenter.so.dbg
There are 27 section headers, starting at offset 0x97ac:

Section Headers:
[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
[ 0] NULL 00000000 000000 000000 0 0 0 0
[ 1] .hash HASH 000000b4 0000b4 000038 4 A 2 0 4
[ 2] .dynsym DYNSYM 000000ec 0000ec 000090 16 A 3 1 4
[ 3] .dynstr STRTAB 0000017c 00017c 000095 0 A 0 0 1
[ 4] .gnu.version GNU_versym 00000212 000212 000012 2 A 2 0 2
[ 5] .gnu.version_d GNU_verdef 00000224 000224 000054 0 A 3 3 4
[ 6] .dynamic DYNAMIC 00000278 000278 000080 8 WA 3 0 4
[ 7] .rodata PROGBITS 000002f8 0002f8 000214 4 WA 0 0 4
[ 8] .fake_shstrtab PROGBITS 00000520 000520 000076 0 A 0 0 32
[ 9] .note NOTE 00000598 000598 000060 0 A 0 0 4
[10] .eh_frame_hdr PROGBITS 000005f8 0005f8 000024 0 A 0 0 4
[11] .eh_frame PROGBITS 0000061c 00061c 000108 0 A 0 0 4
[12] .text PROGBITS 00000730 000730 000644 0 AX 0 0 16
[13] .altinstructions PROGBITS 00000d74 000d74 000018 0 A 0 0 1
[14] .altinstr_replacement PROGBITS 00000d8c 000d8c 000006 0 AX 0 0 1
[15] .debug_info PROGBITS 00000000 000d92 004a84 0 0 0 1
[16] .debug_abbrev PROGBITS 00000000 005816 000519 0 0 0 1
[17] .debug_loc PROGBITS 00000000 005d2f 00064f 0 0 0 1
[18] .debug_aranges PROGBITS 00000000 006380 000058 0 0 0 8
[19] .debug_ranges PROGBITS 00000000 0063d8 000208 0 0 0 1
[20] .debug_line PROGBITS 00000000 0065e0 000784 0 0 0 1
[21] .debug_str PROGBITS 00000000 006d64 0027f2 1 MS 0 0 1
[22] .comment PROGBITS 00000000 009556 00002c 1 MS 0 0 1
[23] .debug_frame PROGBITS 00000000 009584 000100 0 0 0 4
[24] .shstrtab STRTAB 00000000 009684 000127 0 0 0 1
[25] .symtab SYMTAB 00000000 009be4 000390 16 26 49 4
[26] .strtab STRTAB 00000000 009f74 000240 0 0 0 1

o.test/arch/x86/vdso/vdso64.so.dbg
There are 28 section headers, starting at offset 0xfb38:

Section Headers:
[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
[ 1] .hash HASH 0000000000000120 00000120 00000040 4 A 2 0 8
[ 2] .dynsym DYNSYM 0000000000000160 00000160 00000108 24 A 3 2 8
[ 3] .dynstr STRTAB 0000000000000268 00000268 0000005e 0 A 0 0 1
[ 4] .gnu.version GNU_versym 00000000000002c6 000002c6 00000016 2 A 2 0 2
[ 5] .gnu.version_d GNU_verdef 00000000000002e0 000002e0 00000038 0 A 3 2 8
[ 6] .dynamic DYNAMIC 0000000000000318 00000318 00000130 16 WA 3 0 8
[ 7] .rodata PROGBITS 0000000000000448 00000448 0000039c 8 WA 0 0 8
[ 8] _ftrace_branch PROGBITS 00000000000007e4 000007e4 00000078 0 WA 0 0 4
[ 9] .fake_shstrtab PROGBITS 0000000000000860 00000860 00000076 0 A 0 0 32
[10] .note NOTE 00000000000008d8 000008d8 0000003c 0 A 0 0 4
[11] .eh_frame_hdr PROGBITS 0000000000000914 00000914 0000002c 0 A 0 0 4
[12] .eh_frame PROGBITS 0000000000000940 00000940 000000e8 0 A 0 0 8
[13] .text PROGBITS 0000000000000a30 00000a30 000008bc 0 AX 0 0 16
[14] .altinstructions PROGBITS 00000000000012ec 000012ec 000000d8 0 A 0 0 1
[15] .altinstr_replacement PROGBITS 00000000000013c4 000013c4 00000036 0 AX 0 0 1
[16] .rela.dyn RELA 0000000000001400 00001400 00000090 24 A 2 0 8
[17] .debug_info PROGBITS 0000000000000000 00001490 0000719f 0 0 0 1
[18] .debug_abbrev PROGBITS 0000000000000000 0000862f 0000083c 0 0 0 1
[19] .debug_loc PROGBITS 0000000000000000 00008e6b 0000296c 0 0 0 1
[20] .debug_aranges PROGBITS 0000000000000000 0000b7d7 00000080 0 0 0 1
[21] .debug_ranges PROGBITS 0000000000000000 0000b857 00000bb0 0 0 0 1
[22] .debug_line PROGBITS 0000000000000000 0000c407 00000afd 0 0 0 1
[23] .debug_str PROGBITS 0000000000000000 0000cf04 00002ad2 1 MS 0 0 1
[24] .comment PROGBITS 0000000000000000 0000f9d6 0000002c 1 MS 0 0 1
[25] .shstrtab STRTAB 0000000000000000 0000fa02 00000133 0 0 0 1
[26] .symtab SYMTAB 0000000000000000 00010238 000004f8 24 27 44 8
[27] .strtab STRTAB 0000000000000000 00010730 0000018f 0 0 0 1