aboutsummaryrefslogtreecommitdiffstats
path: root/scripts (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-01-30Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tipLinus Torvalds1-0/+6
Pull RCU updates from Ingo Molnar: "The main RCU changes in this cycle were: - Updates to use cond_resched() instead of cond_resched_rcu_qs() where feasible (currently everywhere except in kernel/rcu and in kernel/torture.c). Also a couple of fixes to avoid sending IPIs to offline CPUs. - Updates to simplify RCU's dyntick-idle handling. - Updates to remove almost all uses of smp_read_barrier_depends() and read_barrier_depends(). - Torture-test updates. - Miscellaneous fixes" * 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (72 commits) torture: Save a line in stutter_wait(): while -> for torture: Eliminate torture_runnable and perf_runnable torture: Make stutter less vulnerable to compilers and races locking/locktorture: Fix num reader/writer corner cases locking/locktorture: Fix rwsem reader_delay torture: Place all torture-test modules in one MAINTAINERS group rcutorture/kvm-build.sh: Skip build directory check rcutorture: Simplify functions.sh include path rcutorture: Simplify logging rcutorture/kvm-recheck-*: Improve result directory readability check rcutorture/kvm.sh: Support execution from any directory rcutorture/kvm.sh: Use consistent help text for --qemu-args rcutorture/kvm.sh: Remove unused variable, `alldone` rcutorture: Remove unused script, config2frag.sh rcutorture/configinit: Fix build directory error message rcutorture: Preempt RCU-preempt readers more vigorously torture: Reduce #ifdefs for preempt_schedule() rcu: Remove have_rcu_nocb_mask from tree_plugin.h rcu: Add comment giving debug strategy for double call_rcu() tracing, rcu: Hide trace event rcu_nocb_wake when not used ...
2018-01-29Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tipLinus Torvalds1-0/+9
Pull x86/pti updates from Thomas Gleixner: "Another set of melted spectrum related changes: - Code simplifications and cleanups for RSB and retpolines. - Make the indirect calls in KVM speculation safe. - Whitelist CPUs which are known not to speculate from Meltdown and prepare for the new CPUID flag which tells the kernel that a CPU is not affected. - A less rigorous variant of the module retpoline check which merily warns when a non-retpoline protected module is loaded and reflects that fact in the sysfs file. - Prepare for Indirect Branch Prediction Barrier support. - Prepare for exposure of the Speculation Control MSRs to guests, so guest OSes which depend on those "features" can use them. Includes a blacklist of the broken microcodes. The actual exposure of the MSRs through KVM is still being worked on" * 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/speculation: Simplify indirect_branch_prediction_barrier() x86/retpoline: Simplify vmexit_fill_RSB() x86/cpufeatures: Clean up Spectre v2 related CPUID flags x86/cpu/bugs: Make retpoline module warning conditional x86/bugs: Drop one "mitigation" from dmesg x86/nospec: Fix header guards names x86/alternative: Print unadorned pointers x86/speculation: Add basic IBPB (Indirect Branch Prediction Barrier) support x86/cpufeature: Blacklist SPEC_CTRL/PRED_CMD on early Spectre v2 microcodes x86/pti: Do not enable PTI on CPUs which are not vulnerable to Meltdown x86/msr: Add definitions for new speculation control MSRs x86/cpufeatures: Add AMD feature bits for Speculation Control x86/cpufeatures: Add Intel feature bits for Speculation Control x86/cpufeatures: Add CPUID_7_EDX CPUID leaf module/retpoline: Warn about missing retpoline in module KVM: VMX: Make indirect call speculation safe KVM: x86: Make indirect calls in emulator speculation safe
2018-01-29Coccinelle: memdup: drop spurious lineJulia Lawall1-1/+0
The kmemdup line in the non-patch case was left over from the added kmemdup line in the patch case. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-28kconfig: Remove silentoldconfig from help and docs; fix kconfig/conf's helpMarc Herbert2-5/+7
As explained by Michal Marek at https://lkml.org/lkml/2011/8/31/189 silentoldconfig has become a misnomer. It has become an internal interface so remove it from "make help" and Documentation/ to stop confusing people using it as seen for instance at https://chromium-review.googlesource.com/835632 Don't remove it from kconfig/Makefile yet not to break any (other) tool using it. On the other hand, correct and expand its description in the help of the (internal) scripts/kconfig/conf.c Signed-off-by: Marc Herbert <marc.herbert@intel.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-26module/retpoline: Warn about missing retpoline in moduleAndi Kleen1-0/+9
There's a risk that a kernel which has full retpoline mitigations becomes vulnerable when a module gets loaded that hasn't been compiled with the right compiler or the right option. To enable detection of that mismatch at module load time, add a module info string "retpoline" at build time when the module was compiled with retpoline support. This only covers compiled C source, but assembler source or prebuilt object files are not checked. If a retpoline enabled kernel detects a non retpoline protected module at load time, print a warning and report it in the sysfs vulnerability file. [ tglx: Massaged changelog ] Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: David Woodhouse <dwmw2@infradead.org> Cc: gregkh@linuxfoundation.org Cc: torvalds@linux-foundation.org Cc: jeyu@kernel.org Cc: arjan@linux.intel.com Link: https://lkml.kernel.org/r/20180125235028.31211-1-andi@firstfloor.org
2018-01-25kbuild: fix W= option checks for extra DTC warningsMasahiro Yamada1-2/+2
Kbuild supports 3 levels of extra warnings, and multiple levels can be combined, like W=12, W=123. It was added by commit a6de553da01c ("kbuild: Allow to combine multiple W= levels"). From the log of commit 8654cb8d0371 ("dtc: update warning settings for new bus and node/property name checks"), I assume: - unit_address_vs_reg, simple_bus_reg, etc. belong to level 1 - node_name_chars_strict, property_name_chars_strict belong to level 2 However, the level 1 warnings are displayed by any argument to W=. On the other hand, the level 2 warnings are displayed by W=2, but not by W=12, or W=123. Use $(findstring ...) like scripts/Makefile.extrawarn. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Arnd Bergmann <arnd@arndb.de>
2018-01-25kconfig: make "Selected by:" and "Implied by:" readablePetr Vorel3-6/+27
Reverse dependency expressions can get rather unwieldy, especially if a symbol is selected by more than a handful of other symbols. I.e. it's possible to have near endless expressions like: A && B && !C || D || F && (G || H) || [...] Chop these expressions into actually readable chunks: - A && B && !C - D - F && (G || H) - [...] I.e. transform the top level OR tokens into newlines and prepend each line with a minus. This makes the "Selected by:" and "Implied by:" blurb much easier to read. This is done only if there is more than one top level OR. "Depends on:" and "Range :" were deliberately left as they are. Based on idea from Paul Bolle. Suggested-by: Paul Bolle <pebolle@tiscali.nl> Signed-off-by: Petr Vorel <petr.vorel@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-25kconfig: announce removal of oldnoconfig if usedMasahiro Yamada1-0/+2
The 'oldnoconfig' is really confusing due to its counter-intuitive name. It was renamed by commit fb16d8912db5 ("kconfig: replace 'oldnoconfig' with 'olddefconfig', and keep the old name as an alias"). The 'oldnoconfig' has been kept as an alias for enough period of time, and finally I am planning to remove it. I will give people a little more time for migration. Meanwhile, the following message will be displayed if oldnoconfig is used. WARNING: "oldnoconfig" target will be removed after Linux 4.19 Please use "olddefconfig" instead, which is an alias. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-01-22kconfig: fix make xconfig when gettext is missingYaakov Selkowitz1-0/+1
The C-based config programs are properly guarded from a missing (or, currently, external) libintl.h by the HOST_EXTRACFLAGS check, but this does not help the C++-based qconf. Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kconfig: Clarify menu and 'if' dependency propagationUlf Magnusson1-0/+2
It is not obvious that the last two cases refer to menus and ifs, respectively, in the conditional that sets 'parentdep'. Automatic submenu creation is done later, so the parent can't be a symbol here. No functional changes. Only comments added. Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kconfig: Document 'if' flattening logicUlf Magnusson1-0/+29
It is not obvious that this might refer to an 'if', making the code pretty cryptic: if (menu->list && (!menu->prompt || !menu->prompt->text)) { Kconfig keeps the 'if' menu nodes even after flattening. Reflect that in the example to be accurate. No functional changes. Only comments added. Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kconfig: Clarify choice dependency propagationUlf Magnusson1-0/+7
It's easy to miss that choices are special-cased to pass on their mode as the parent dependency. No functional changes. Only comments added. Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kconfig: Document SYMBOL_OPTIONAL logicUlf Magnusson1-0/+9
Not obvious, especially if you don't already know how choices are implemented. No functional changes. Only comments added. Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIXMasahiro Yamada1-6/+2
Kconfig was the only user of these. With Kconfig converted to use the default 'yy' prefix, we do not need them any more. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-01-22kconfig: use default 'yy' prefix for lexer and parserMasahiro Yamada3-22/+19
Flex and Bison provide an option to change the prefix of globally- visible symbols. This is useful to link multiple lexers and/or parsers into the same executable. However, Kconfig (and any other host programs in kernel) uses a single lexer and parser. I do not see a good reason to change the default 'yy' prefix. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-01-22kconfig: make conf_unsaved a local variable of conf_read()Masahiro Yamada1-2/+2
conf_unsaved is initialized by conf_read_simple(), but it is possible to move it to conf_read() so that it can be a local variable. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kconfig: make xfgets() really staticMasahiro Yamada1-10/+7
Sparse reports: warning: symbol 'xfgets' was not declared. Should it be static? It is declared as static, but it is missing in the definition part. Move the definition up and remove the forward declaration. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kconfig: make input_mode staticMasahiro Yamada1-1/+2
Sparse reports: warning: symbol 'input_mode' was not declared. Should it be static? Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kconfig: Warn if there is more than one help textUlf Magnusson1-0/+5
Avoids mistakes like in the following real-world example, where only the final help string ("Say Y...") was used. This particular example was fixed in commit 561b29e4ec8d ("media: fix media Kconfig help syntax issues"). config DVB_NETUP_UNIDVB ... select DVB_CXD2841ER if MEDIA_SUBDRV_AUTOSELECT ---help--- Support for NetUP PCI express Universal DVB card. help Say Y when you want to support NetUP Dual Universal DVB card ... This now prints the following warning: drivers/media/pci/netup_unidvb:13: warning: 'DVB_NETUP_UNIDVB' defined with more than one help text -- only the last one will be used Also free() any extra help strings. Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kconfig: drop 'boolean' keywordMasahiro Yamada6-7/+6
No more users of this keyword. Drop it according to the notice by commit 6341e62b212a ("kconfig: use bool instead of boolean for type definition attributes"). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Luis R. Rodriguez <mcgrof@kernel.org>
2018-01-22kconfig: Remove menu_end_entry()Ulf Magnusson3-11/+1
menu_end_entry() is empty and completely unused as far as I can tell: $ git log -G menu_end_entry --oneline a02f057 [PATCH] kconfig: improve error handling in the parser 1da177e Linux-2.6.12-rc2 Last one is the initial Git commit, where menu_end_entry() is empty as well. I couldn't find anything that redefined it on Google either. It might be a debugging helper for setting a breakpoint after each config, menuconfig, and comment is parsed. IMO it hurts more than it helps in that case by making the parsing code look more complicated at a glance than it really is, and I suspect it doesn't get used much. Tested by running the Kconfiglib test suite, which indirectly verifies that the .config files generated by the C implementation for each defconfig file in the kernel stays the same. Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kconfig: Document important expression functionsUlf Magnusson1-0/+106
Many of these functions are quite the head scratchers if you don't know what they're trying to do. Document them. Also make it clear which functions rewrite expressions in-place and which return new expressions. This prevents memory errors. No functional changes. Only comments added. Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kconfig: Document automatic submenu creation codeUlf Magnusson1-0/+38
It's tricky to figure out what it does (and how) without staring at the code for a long time. Document it to make it more transparent. No functional changes. Only comments added. Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kconfig: Fix choice symbol expression leakUlf Magnusson1-0/+3
When propagating dependencies from parents after parsing, an expression node is allocated if the parent symbol is a 'choice'. This node was never freed. Outline of leak: if (sym && sym_is_choice(sym)) { ... *Allocate (in this case only)* parentdep = expr_alloc_symbol(sym); } else if (parent->prompt) parentdep = parent->prompt->visible.expr; else parentdep = parent->dep; for (menu = parent->list; menu; menu = menu->next) { ... *Copy* basedep = expr_alloc_and(expr_copy(parentdep), basedep); ... } *parentdep lost if the parent is a choice!* Fix by freeing 'parentdep' after the loop if the parent symbol is a choice. Note that this only frees the expression node and not the choice symbol itself. Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix: LEAK SUMMARY: definitely lost: 1,608 bytes in 67 blocks ... Summary after the fix: LEAK SUMMARY: definitely lost: 0 bytes in 0 blocks ... Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kconfig: Fix expr_free() E_NOT leakUlf Magnusson1-1/+1
Only the E_NOT operand and not the E_NOT node itself was freed, due to accidentally returning too early in expr_free(). Outline of leak: switch (e->type) { ... case E_NOT: expr_free(e->left.expr); return; ... } *Never reached, 'e' leaked* free(e); Fix by changing the 'return' to a 'break'. Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix: LEAK SUMMARY: definitely lost: 44,448 bytes in 1,852 blocks ... Summary after the fix: LEAK SUMMARY: definitely lost: 1,608 bytes in 67 blocks ... Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kconfig: Fix automatic menu creation mem leakUlf Magnusson1-0/+1
expr_trans_compare() always allocates and returns a new expression, giving the following leak outline: ... *Allocate* basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); ... for (menu = parent->next; menu; menu = menu->next) { ... *Copy* dep2 = expr_copy(basedep); ... *Free copy* expr_free(dep2); } *basedep lost!* Fix by freeing 'basedep' after the loop. Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix: LEAK SUMMARY: definitely lost: 344,376 bytes in 14,349 blocks ... Summary after the fix: LEAK SUMMARY: definitely lost: 44,448 bytes in 1,852 blocks ... Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22kconfig: Don't leak main menus during parsingUlf Magnusson1-9/+24
If a 'mainmenu' entry appeared in the Kconfig files, two things would leak: - The 'struct property' allocated for the default "Linux Kernel Configuration" prompt. - The string for the T_WORD/T_WORD_QUOTE prompt after the T_MAINMENU token, allocated on the heap in zconf.l. To fix it, introduce a new 'no_mainmenu_stmt' nonterminal that matches if there's no 'mainmenu' and adds the default prompt. That means the prompt only gets allocated once regardless of whether there's a 'mainmenu' statement or not, and managing it becomes simple. Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix: LEAK SUMMARY: definitely lost: 344,568 bytes in 14,352 blocks ... Summary after the fix: LEAK SUMMARY: definitely lost: 344,440 bytes in 14,350 blocks ... Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-19scripts/gdb/linux/tasks.py: fix get_thread_infoXi Kangjie1-0/+2
Since kernel 4.9, the thread_info has been moved into task_struct, no longer locates at the bottom of kernel stack. See commits c65eacbe290b ("sched/core: Allow putting thread_info into task_struct") and 15f4eae70d36 ("x86: Move thread_info into task_struct"). Before fix: (gdb) set $current = $lx_current() (gdb) p $lx_thread_info($current) $1 = {flags = 1470918301} (gdb) p $current.thread_info $2 = {flags = 2147483648} After fix: (gdb) p $lx_thread_info($current) $1 = {flags = 2147483648} (gdb) p $current.thread_info $2 = {flags = 2147483648} Link: http://lkml.kernel.org/r/20180118210159.17223-1-imxikangjie@gmail.com Fixes: 15f4eae70d36 ("x86: Move thread_info into task_struct") Signed-off-by: Xi Kangjie <imxikangjie@gmail.com> Acked-by: Jan Kiszka <jan.kiszka@siemens.com> Acked-by: Kieran Bingham <kbingham@kernel.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-01-19scripts/decodecode: fix decoding for AArch64 (arm64) instructionsWill Deacon1-0/+8
There are a couple of problems with the decodecode script and arm64: 1. AArch64 objdump refuses to disassemble .4byte directives as instructions, insisting that they are data values and displaying them as: a94153f3 .word 0xa94153f3 <-- trapping instruction This is resolved by using the .inst directive instead. 2. Disassembly of branch instructions attempts to provide the target as an offset from a symbol, e.g.: 0: 34000082 cbz w2, 10 <.text+0x10> however this falls foul of the grep -v, which matches lines containing ".text" and ends up removing all branch instructions from the dump. This patch resolves both issues by using the .inst directive for 4-byte quantities on arm64 and stripping the resulting binaries (as is done on arm already) to remove the mapping symbols. Link: http://lkml.kernel.org/r/1506596147-23630-1-git-send-email-will.deacon@arm.com Signed-off-by: Will Deacon <will.deacon@arm.com> Reviewed-by: Dave Martin <Dave.Martin@arm.com> Cc: Michal Marek <mmarek@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-01-18Kbuild: suppress packed-not-aligned warning for default setting onlyXiongfeng Wang1-0/+3
gcc-8 reports many -Wpacked-not-aligned warnings. The below are some examples. ./include/linux/ceph/msgr.h:67:1: warning: alignment 1 of 'struct ceph_entity_addr' is less than 8 [-Wpacked-not-aligned] } __attribute__ ((packed)); ./include/linux/ceph/msgr.h:67:1: warning: alignment 1 of 'struct ceph_entity_addr' is less than 8 [-Wpacked-not-aligned] } __attribute__ ((packed)); ./include/linux/ceph/msgr.h:67:1: warning: alignment 1 of 'struct ceph_entity_addr' is less than 8 [-Wpacked-not-aligned] } __attribute__ ((packed)); This patch suppresses this kind of warnings for default setting. Signed-off-by: Xiongfeng Wang <xiongfeng.wang@linaro.org> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-18fixdep: use existing helper to check modular CONFIG optionsMasahiro Yamada1-12/+12
str_ends_with() tests if the given token ends with a particular string. Currently, it is used to check file paths without $(srctree). Actually, we have one more place where this helper is useful. Use it to check if CONFIG option ends with _MODULE. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-18fixdep: refactor parse_dep_file()Masahiro Yamada1-40/+40
parse_dep_file() has too much indentation, and puts the code far to the right. This commit refactors the code and reduces the one level of indentation. strrcmp() computes 'slen' by itself, but the caller already knows the length of the token, so 'slen' can be passed via function argument. With this, we can swap the order of strrcmp() and "*p = \0;" Also, strrcmp() is an ambiguous function name. Flip the logic and rename it to str_ends_with(). I added a new helper is_ignored_file() - this returns 1 if the token represents a file that should be ignored. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-18fixdep: move global variables to local variables of main()Masahiro Yamada1-26/+16
I do not mind global variables where they are useful enough. In this case, I do not see a good reason to use global variables since they are just referenced in shallow places. It is easy to pass them via function arguments. I squashed print_cmdline() into main() since it is just one line code. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-18fixdep: remove unneeded memcpy() in parse_dep_file()Masahiro Yamada1-13/+9
Each token in the depfile is copied to the temporary buffer 's' to terminate the token with zero. We do not need to do this any more because the parsed buffer is now writable. Insert '\0' directly in the buffer without calling memcpy(). <limits.h> is no longer necessary. (It was needed for PATH_MAX). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-18fixdep: factor out common code for reading filesMasahiro Yamada1-55/+20
Now, do_config_files() and print_deps() are almost the same. Only the difference is the parser function called (parse_config_file vs parse_dep_file). We can reduce the code duplication by factoring out the common code into read_file() - this function allocates a buffer and loads a file to it. It returns the pointer to the allocated buffer. (As before, it bails out by exit(2) for any error.) The caller must free the buffer when done. Having empty source files is possible; fixdep should simply skip them. I deleted the "st.st_size == 0" check, so read_file() allocates 1-byte buffer for an empty file. strstr() will immediately return NULL, and this is what we expect. On the other hand, an empty dep_file should be treated as an error. In this case, parse_dep_file() will error out with "no targets found" and it is a correct error message. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-18fixdep: use malloc() and read() to load dep_file to bufferMasahiro Yamada1-24/+32
Commit dee81e988674 ("fixdep: faster CONFIG_ search") changed how to read files in which CONFIG options are searched. It used malloc() and read() instead of mmap() because it needed to zero-terminate the buffer in order to use strstr(). print_deps() was left untouched since there was no reason to change it. Now, I have two motivations to change it in the same way. - do_config_file() and print_deps() do quite similar things; they open a file, load it onto memory, and pass it to a parser function. If we use malloc() and read() for print_deps() too, we can factor out the common code. (I will do this in the next commit.) - parse_dep_file() copies each token to a temporary buffer because it needs to zero-terminate it to be passed to printf(). It is not possible to modify the buffer directly because it is mmap'ed with O_RDONLY. If we load the file content into a malloc'ed buffer, we can insert '\0' after each token, and save memcpy(). (I will do this in the commit after next.) Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-18fixdep: remove unnecessary <arpa/inet.h> inclusionMasahiro Yamada1-1/+0
<arpa/inet.h> was included for ntohl(), but it was removed by commit dee81e988674 ("fixdep: faster CONFIG_ search"). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-17Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tipLinus Torvalds1-4/+10
Pull x86 pti bits and fixes from Thomas Gleixner: "This last update contains: - An objtool fix to prevent a segfault with the gold linker by changing the invocation order. That's not just for gold, it's a general robustness improvement. - An improved error message for objtool which spares tearing hairs. - Make KASAN fail loudly if there is not enough memory instead of oopsing at some random place later - RSB fill on context switch to prevent RSB underflow and speculation through other units. - Make the retpoline/RSB functionality work reliably for both Intel and AMD - Add retpoline to the module version magic so mismatch can be detected - A small (non-fix) update for cpufeatures which prevents cpu feature clashing for the upcoming extra mitigation bits to ease backporting" * 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: module: Add retpoline tag to VERMAGIC x86/cpufeature: Move processor tracing out of scattered features objtool: Improve error message for bad file argument objtool: Fix seg fault with gold linker x86/retpoline: Add LFENCE to the retpoline/RSB filling RSB macros x86/retpoline: Fill RSB on context switch for affected CPUs x86/kasan: Panic if there is not enough memory to boot
2018-01-16modpost: Remove trailing semicolonLuis de Bethencourt1-1/+1
The trailing semicolon is an empty statement that does no operation. Removing it since it doesn't do anything. Signed-off-by: Luis de Bethencourt <luisbg@kernel.org> Signed-off-by: Jessica Yu <jeyu@kernel.org>
2018-01-16Coccinelle: kzalloc-simple: Rename kzalloc-simple to zalloc-simpleHimanshu Jha1-0/+0
Rename kzalloc-simple to zalloc-simple since now the rule is not specific to kzalloc function only, but also to many other zero memory allocating functions specified in the rule. Suggested-by: SF Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-16Coccinelle: ifnullfree: Trim the warning reported in report modeHimanshu Jha1-1/+1
Remove the unncessary part of the warning reported, in the report mode, so that a single warning produced does not exceed more than line and hence improve readability of the warnings produced in the subsequent reports to a file. Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-16Coccinelle: alloc_cast: Add more memory allocating functions to the listHimanshu Jha1-21/+71
Add more memory allocating functions that are frequently used in the kernel code to the existing list and remove the useless casts where it is unnecessary. But preserve those casts having __attribute__ such as __force, __iomem, etc. which are used by Sparse in the static analysis of the code. Also remove two blank lines at EOF. Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-16Coccinelle: array_size: report even if include is missingJérémy Lefaure1-2/+2
Rule r does not depend on rule i (which is the include of linux/kernel.h) so the output should not depend on i in org and report mode. Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-16Coccinelle: kzalloc-simple: Add all zero allocating functionsHimanshu Jha1-5/+367
There are many instances where memory is allocated using regular allocator functions immediately followed by setting the allocated memory to 0 value using memset. We already have zero memory allocator functions to set the memory to 0 value instead of manually setting it using memset. Therefore, use zero memory allocating functions instead of regular memory allocators followed by memset 0 to remove redundant memset and make the code more cleaner and also reduce the code size. Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-16objtool: Fix seg fault with gold linkerJosh Poimboeuf1-4/+10
Objtool segfaults when the gold linker is used with CONFIG_MODVERSIONS=y and CONFIG_UNWINDER_ORC=y. With CONFIG_MODVERSIONS=y, the .o file gets passed to the linker before being passed to objtool. The gold linker seems to strip unused ELF symbols by default, which confuses objtool and causes the seg fault when it's trying to generate ORC metadata. Objtool should really be running immediately after GCC anyway, without a linker call in between. Change the makefile ordering so that objtool is called before the linker. Reported-and-tested-by: Markus <M4rkusXXL@web.de> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Fixes: ee9f8fce9964 ("x86/unwind: Add the ORC unwinder") Link: http://lkml.kernel.org/r/355f04da33581f4a3bf82e5b512973624a1e23a2.1516025651.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-01-13Merge tag 'kbuild-fixes-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuildLinus Torvalds2-2/+4
Pull Kbuild fixes from Masahiro Yamada: - fix cross-compilation for architectures that setup CROSS_COMPILE in their arch Makefile - fix Kconfig rational operators for bool / tristate - drop a gperf-generated file from .gitignore * tag 'kbuild-fixes-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: genksyms: drop *.hash.c from .gitignore kconfig: fix relational operators for bool and tristate symbols kbuild: move cc-option and cc-disable-warning after incl. arch Makefile
2018-01-13genksyms: drop *.hash.c from .gitignoreMasahiro Yamada1-1/+0
This is a left-over of commit bb3290d91695 ("Remove gperf usage from toolchain"). We do not generate a hash function any more. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-11kconfig: Don't leak 'option' arguments during parsingUlf Magnusson1-1/+3
The following strings would leak before this change: - option env="LEAKED" - option defconfig_list="LEAKED" These come in the form of T_WORD tokens and are always allocated on the heap in zconf.l. Free them. Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix: LEAK SUMMARY: definitely lost: 344,616 bytes in 14,355 blocks ... Summary after the fix: LEAK SUMMARY: definitely lost: 344,568 bytes in 14,352 blocks ... Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-11kconfig: Don't leak 'source' filenames during parsingUlf Magnusson2-0/+5
The 'source_stmt' nonterminal takes a 'prompt', which consists of either a T_WORD or a T_WORD_QUOTE, both of which are always allocated on the heap in zconf.l and need to have their associated strings freed. Free them. The existing code already makes sure to always copy the string, but add a warning to sym_expand_string_value() to make it clear that the string must be copied, just in case. Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix: LEAK SUMMARY: definitely lost: 387,504 bytes in 15,545 blocks ... Summary after the fix: LEAK SUMMARY: definitely lost: 344,616 bytes in 14,355 blocks ... Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-10kconfig: Don't leak symbol names during parsingUlf Magnusson1-17/+19
Prior to this fix, zconf.y did not free symbol names from zconf.l in these contexts: - After T_CONFIG ('config LEAKED') - After T_MENUCONFIG ('menuconfig LEAKED') - After T_SELECT ('select LEAKED') - After T_IMPLY ('imply LEAKED') - After T_DEFAULT in a choice ('default LEAKED') All of these come in the form of T_WORD tokens, which always have their associated string allocated on the heap in zconf.l and need to be freed. Fix by introducing a new nonterminal 'nonconst_symbol' which takes a T_WORD, fetches the symbol, and then frees the T_WORD string. The already existing 'symbol' nonterminal works the same way but also accepts T_WORD_QUOTE, corresponding to a constant symbol. T_WORD_QUOTE should not be accepted in any of the contexts above, so the 'symbol' nonterminal can't be reused here. Fetching the symbol in 'nonconst_symbol' also removes a bunch of sym_lookup() calls from actions. Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix: LEAK SUMMARY: definitely lost: 711,571 bytes in 37,756 blocks ... Summary after the fix: LEAK SUMMARY: definitely lost: 387,504 bytes in 15,545 blocks ... Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>