<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/scripts/kallsyms.c, branch v5.6</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v5.6</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.6'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2020-03-19T14:40:20Z</updated>
<entry>
<title>scripts/kallsyms: fix wrong kallsyms_relative_base</title>
<updated>2020-03-19T14:40:20Z</updated>
<author>
<name>Mikhail Petrov</name>
<email>Mikhail.Petrov@mir.dev</email>
</author>
<published>2020-03-11T20:37:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7883a14339299773b2ce08dcfd97c63c199a9289'/>
<id>urn:sha1:7883a14339299773b2ce08dcfd97c63c199a9289</id>
<content type='text'>
There is the code in the read_symbol function in 'scripts/kallsyms.c':

	if (is_ignored_symbol(name, type))
		return NULL;

	/* Ignore most absolute/undefined (?) symbols. */
	if (strcmp(name, "_text") == 0)
		_text = addr;

But the is_ignored_symbol function returns true for name="_text" and
type='A'. So the next condition is not executed and the _text variable
is always zero.

It makes the wrong kallsyms_relative_base symbol as a result of the code
(CONFIG_KALLSYMS_BASE_RELATIVE is defined):

	if (base_relative) {
		output_label("kallsyms_relative_base");
		output_address(relative_base);
		printf("\n");
	}

Because the output_address function uses the _text variable.

So the kallsyms_lookup function and all related functions in the kernel
do not work properly. For example, the stack trace in oops:

 Call Trace:
 [aa095e58] [809feab8] kobj_ns_ops_tbl+0x7ff09ac8/0x7ff1c1c4 (unreliable)
 [aa095e98] [80002b64] kobj_ns_ops_tbl+0x7f50db74/0x80000010
 [aa095ef8] [809c3d24] kobj_ns_ops_tbl+0x7feced34/0x7ff1c1c4
 [aa095f28] [80002ed0] kobj_ns_ops_tbl+0x7f50dee0/0x80000010
 [aa095f38] [8000f238] kobj_ns_ops_tbl+0x7f51a248/0x80000010

The right stack trace:

 Call Trace:
 [aa095e58] [809feab8] module_vdu_video_init+0x2fc/0x3bc (unreliable)
 [aa095e98] [80002b64] do_one_initcall+0x40/0x1f0
 [aa095ef8] [809c3d24] kernel_init_freeable+0x164/0x1d8
 [aa095f28] [80002ed0] kernel_init+0x14/0x124
 [aa095f38] [8000f238] ret_from_kernel_thread+0x14/0x1c

[masahiroy@kernel.org:

This issue happens on binutils &lt;= 2.22
The following commit fixed it:
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d2667025dd30611514810c28bee9709e4623012a

The symbol type of _text is 'T' on binutils &gt;= 2.23
The minimal supported binutils version for the kernel build is 2.21
]

Signed-off-by: Mikhail Petrov &lt;Mikhail.Petrov@mir.dev&gt;
Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>scripts/kallsyms: fix memory corruption caused by write over-run</title>
<updated>2020-02-10T20:18:09Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2020-02-10T16:18:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9d1b38958b077f6c8d4bd196a115b643d7bd6717'/>
<id>urn:sha1:9d1b38958b077f6c8d4bd196a115b643d7bd6717</id>
<content type='text'>
memcpy() writes one more byte than allocated.

Fixes: 8d60526999aa ("scripts/kallsyms: change table to store (strcut sym_entry *)")
Reported-by: youling257 &lt;youling257@gmail.com&gt;
Reported-by: Pavel Machek &lt;pavel@ucw.cz&gt;
Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Tested-by: Pavel Machek &lt;pavel@ucw.cz&gt;
</content>
</entry>
<entry>
<title>scripts/kallsyms: change table to store (strcut sym_entry *)</title>
<updated>2020-02-03T16:54:30Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2020-02-02T05:09:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8d60526999aace135de37220ec94ba40bc792234'/>
<id>urn:sha1:8d60526999aace135de37220ec94ba40bc792234</id>
<content type='text'>
The symbol table is extended every 10000 addition by using realloc(),
where data copy might occur to the new buffer.

To decrease the amount of possible data copy, let's change the table
to store the pointer.

The symbol type + symbol name part is appended at the end of
(struct sym_entry), and allocated together with the struct body.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>scripts/kallsyms: rename local variables in read_symbol()</title>
<updated>2020-02-03T16:54:15Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2020-02-02T05:09:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=be9f6133f8770bb9c5f4a3cb3df6d30d7d3f7e5b'/>
<id>urn:sha1:be9f6133f8770bb9c5f4a3cb3df6d30d7d3f7e5b</id>
<content type='text'>
I will use 'sym' for the point to struce sym_entry in the next commit.
Rename 'sym', 'stype' to 'name', 'type', which are more intuitive.

Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>scripts/kallsyms: fix offset overflow of kallsyms_relative_base</title>
<updated>2019-12-14T06:53:04Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>masahiroy@kernel.org</email>
</author>
<published>2019-12-09T03:51:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fd2ab2f6610b2bec70e626c38de8a4242fa88e48'/>
<id>urn:sha1:fd2ab2f6610b2bec70e626c38de8a4242fa88e48</id>
<content type='text'>
Since commit 5e5c4fa78745 ("scripts/kallsyms: shrink table before
sorting it"), kallsyms_relative_base can be larger than _text, which
causes overflow when building the 32-bit kernel.

https://lkml.org/lkml/2019/12/7/156

This is because _text is, unless --all-symbols is specified, now
trimmed from the symbol table before record_relative_base() is called.

Handle the offset signedness also for kallsyms_relative_base. Introduce
a new helper, output_address(), to reduce the code duplication.

Fixes: 5e5c4fa78745 ("scripts/kallsyms: shrink table before sorting it")
Reported-by: Olof Johansson &lt;olof@lixom.net&gt;
Signed-off-by: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
</content>
</entry>
<entry>
<title>scripts/kallsyms: remove redundant initializers</title>
<updated>2019-11-25T12:07:05Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>yamada.masahiro@socionext.com</email>
</author>
<published>2019-11-23T16:04:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=831362fc317ae60413879deacdcc9617d9ce9e20'/>
<id>urn:sha1:831362fc317ae60413879deacdcc9617d9ce9e20</id>
<content type='text'>
These are set to zero without the explicit initializers.

Signed-off-by: Masahiro Yamada &lt;yamada.masahiro@socionext.com&gt;
</content>
</entry>
<entry>
<title>scripts/kallsyms: put check_symbol_range() calls close together</title>
<updated>2019-11-25T12:06:49Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>yamada.masahiro@socionext.com</email>
</author>
<published>2019-11-23T16:04:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d44270fc976b6c3b9e742e398580e4af8c69f7bd'/>
<id>urn:sha1:d44270fc976b6c3b9e742e398580e4af8c69f7bd</id>
<content type='text'>
Put the relevant code close together.

Signed-off-by: Masahiro Yamada &lt;yamada.masahiro@socionext.com&gt;
</content>
</entry>
<entry>
<title>scripts/kallsyms: make check_symbol_range() void function</title>
<updated>2019-11-25T12:06:37Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>yamada.masahiro@socionext.com</email>
</author>
<published>2019-11-23T16:04:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b6233d0ded3391a33bb0047edafe15169131eadb'/>
<id>urn:sha1:b6233d0ded3391a33bb0047edafe15169131eadb</id>
<content type='text'>
There is no more reason to check the return value of
check_symbol_range().

Signed-off-by: Masahiro Yamada &lt;yamada.masahiro@socionext.com&gt;
</content>
</entry>
<entry>
<title>scripts/kallsyms: move ignored symbol types to is_ignored_symbol()</title>
<updated>2019-11-25T12:06:14Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>yamada.masahiro@socionext.com</email>
</author>
<published>2019-11-23T16:04:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=887df76de67f5a6dd423e5763c22ff07f0e50048'/>
<id>urn:sha1:887df76de67f5a6dd423e5763c22ff07f0e50048</id>
<content type='text'>
Collect the ignored patterns to is_ignored_symbol().

Signed-off-by: Masahiro Yamada &lt;yamada.masahiro@socionext.com&gt;
</content>
</entry>
<entry>
<title>scripts/kallsyms: move more patterns to the ignored_prefixes array</title>
<updated>2019-11-25T12:06:01Z</updated>
<author>
<name>Masahiro Yamada</name>
<email>yamada.masahiro@socionext.com</email>
</author>
<published>2019-11-23T16:04:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=97261e1e2240f627e27e93f7e410be1a7c97c80a'/>
<id>urn:sha1:97261e1e2240f627e27e93f7e410be1a7c97c80a</id>
<content type='text'>
Refactoring for shortening the code.

Signed-off-by: Masahiro Yamada &lt;yamada.masahiro@socionext.com&gt;
</content>
</entry>
</feed>
