1. 21 Jan, 2018 18 commits
  2. 10 Jan, 2018 3 commits
    • Ulf Magnusson's avatar
      kconfig: Don't leak 'option' arguments during parsing · bc28fe1d
      Ulf Magnusson authored
      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: default avatarUlf Magnusson <ulfalizer@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      bc28fe1d
    • Ulf Magnusson's avatar
      kconfig: Don't leak 'source' filenames during parsing · 24161a67
      Ulf Magnusson authored
      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: default avatarUlf Magnusson <ulfalizer@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      24161a67
    • Ulf Magnusson's avatar
      kconfig: Don't leak symbol names during parsing · 26e47a3c
      Ulf Magnusson authored
      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: default avatarUlf Magnusson <ulfalizer@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      26e47a3c
  3. 16 Dec, 2017 4 commits
    • Masahiro Yamada's avatar
      kconfig: generate lexer and parser during build instead of shipping · 29c83306
      Masahiro Yamada authored
      zconf.lex.c is generated by flex, zconf.tab.c by bison.  Instead of
      running flex and bison during the kernel building, we conventionally
      version-control those artifacts with _shipped suffix.
      
      It is tedious to manually regenerate them every time we change the
      real sources, zconf.l and zconf.y.
      
      Remove the _shipped files and switch over to build-time generation
      of the intermediate C files.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      29c83306
    • Masahiro Yamada's avatar
      kbuild: prepare to remove C files pre-generated by flex and bison · 033dba2e
      Masahiro Yamada authored
      In Linux build system convention, pre-generated files are version-
      controlled with a "_shipped" suffix.  During the kernel building,
      they are simply shipped (copied) removing the suffix.
      
      This approach can reduce external tool dependency for the kernel build,
      but it is tedious to manually regenerate such artifacts from developers'
      point of view.  (We need to do "make REGENERATE_PARSERS=1" every time
      we touch real source files such as *.l, *.y)
      
      Some months ago, I sent out RFC patches to run flex, bison, and gperf
      during the build.
      
      In the review and test, Linus noticed gperf-3.1 had changed the lookup
      function prototype.  Then, the use of gperf in kernel was entirely
      removed by commit bb3290d9 ("Remove gperf usage from toolchain").
      
      This time, I tested several versions of flex and bison, and I was not
      hit by any compatibility issue except a flaw in flex-2.6.3; if you
      generate lexer for dtc and genksyms with flex-2.6.3, you will see
      "yywrap redefined" warning.  This was not intentional, but a bug,
      fixed by flex-2.6.4.  Otherwise, both flex and bison look fairly
      stable for a long time.
      
      This commit prepares some build rules to remove the _shipped files.
      Also, document minimal requirement for flex and bison.
      
      Rationale for the minimal version:
      The -Wmissing-prototypes option of GCC warns "no previous prototype"
      for lexers generated by flex-2.5.34 or older, so I chose 2.5.35 as the
      required version for flex.  Flex-2.5.35 was released in 2008.  Bison
      looks more stable.  I did not see any problem with bison-2.0, released
      in 2004.  I did not test bison-1.x, but bison-2.0 should be old enough.
      
      Tested flex versions:
        2.5.35
        2.5.36
        2.5.37
        2.5.39
        2.6.0
        2.6.1
        2.6.2
        2.6.3   (*)
        2.6.4
      
       (*) flex-2.6.3 causes "yywrap redefined" warning
      
      Tested bison versions:
        2.0
        2.1
        2.2
        2.3
        2.4
        2.4.1
        2.5.1
        2.6
        2.6.1
        2.6.2
        2.6.3
        2.6.4
        2.6.5
        2.7
        2.7.1
        3.0
        3.0.1
        3.0.2
        3.0.3
        3.0.4
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      033dba2e
    • Masahiro Yamada's avatar
      kbuild: add LEX and YACC variables · 73a4f6db
      Masahiro Yamada authored
      Allow users to use their favorite lexer / parser generators.
      This is useful for me to test various flex and bison versions.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      73a4f6db
    • Masahiro Yamada's avatar
      kconfig: display recursive dependency resolution hint just once · e3b03bf2
      Masahiro Yamada authored
      Commit 1c199f28 ("kbuild: document recursive dependency limitation
      / resolution") probably intended to show a hint along with "recursive
      dependency detected!" error, but it missed to add {...} guard, and the
      hint is displayed in every loop of the dep_stack traverse, annoyingly.
      
      This error was detected by GCC's -Wmisleading-indentation when switching
      to build-time generation of lexer/parser.
      
      scripts/kconfig/symbol.c: In function ‘sym_check_print_recursive’:
      scripts/kconfig/symbol.c:1150:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
         if (stack->sym == last_sym)
         ^~
      scripts/kconfig/symbol.c:1153:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
          fprintf(stderr, "For a resolution refer to Documentation/kbuild/kconfig-language.txt\n");
          ^~~~~~~
      
      I could simply add {...} to surround the three fprintf(), but I rather
      chose to move the hint after the loop to make the whole message readable.
      
      Fixes: 1c199f28 ("kbuild: document recursive dependency limitation / resolution"
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarLuis R. Rodriguez <mcgrof@kernel.org>
      e3b03bf2
  4. 14 Dec, 2017 3 commits
    • Ulf Magnusson's avatar
      kconfig: Clean up modules handling and fix crash · f77850d3
      Ulf Magnusson authored
      Kconfig currently doesn't handle 'm' appearing in a Kconfig file before
      the modules symbol is defined (the symbol with 'option modules'). The
      problem is the following code, which runs during parsing:
      
      	/* change 'm' into 'm' && MODULES */
      	if (e->left.sym == &symbol_mod)
      		return expr_alloc_and(e, expr_alloc_symbol(modules_sym));
      
      If the modules symbol has not yet been defined, modules_sym is NULL,
      giving an invalid expression.
      
      Here is a test file where both BEFORE_1 and BEFORE_2 trigger a segfault.
      If the modules symbol is removed, all symbols trigger segfaults.
      
      	config BEFORE_1
      		def_tristate y if m
      
      	if m
      	config BEFORE_2
      		def_tristate y
      	endif
      
      	config MODULES
      		def_bool y
      		option modules
      
      	config AFTER_1
      		def_tristate y if m
      
      	if m
      	config AFTER_2
      		def_tristate y
      	endif
      
      Fix the issue by rewriting 'm' in menu_finalize() instead. This function
      runs after parsing and is the proper place to do it. The following
      existing code in conf_parse() in zconf.y ensures that the modules symbol
      exists at that point:
      
      	if (!modules_sym)
      		modules_sym = sym_find( "n" );
      
      	...
      
      	menu_finalize(&rootmenu);
      
      The following tests were done to ensure no functional changes for
      configurations that don't reference 'm' before the modules symbol:
      
      	- zconfdump(stdout) was run with ARCH=x86 and ARCH=arm before
      	  and after the change and verified to produce identical output.
      	  This function prints all symbols, choices, and menus together
      	  with their properties and their dependency expressions. A
      	  rewritten 'm' appears as 'm && MODULES'.
      
      	  A small annoyance is that the assert(len != 0) in xfwrite()
      	  needs to be disabled in order to use zconfdump(), because it
      	  chokes on e.g. 'default ""'.
      
      	- The Kconfiglib test suite was run to indirectly verify that
      	  alldefconfig, allyesconfig, allnoconfig, and all defconfigs in
      	  the kernel still generate the same final .config.
      
      	- Valgrind was used to check for memory errors and (new) memory
      	  leaks.
      Signed-off-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      f77850d3
    • Ulf Magnusson's avatar
      kconfig: Clarify expression rewriting · fa8cedae
      Ulf Magnusson authored
      menu_finalize() is one of the more opaque parts of Kconfig, and I need
      to make some changes to it to fix an issue related to modules. Add some
      comments related to expression rewriting and dependency propagation as a
      review aid. They will also help other people trying to understand the
      code.
      Signed-off-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      fa8cedae
    • Ulf Magnusson's avatar
      kconfig: Rename menu_check_dep() to rewrite_m() · 9a826842
      Ulf Magnusson authored
      More directly describes the only thing it does.
      Signed-off-by: default avatarUlf Magnusson <ulfalizer@gmail.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      9a826842
  5. 12 Dec, 2017 1 commit
  6. 07 Dec, 2017 3 commits
  7. 03 Dec, 2017 5 commits
  8. 02 Dec, 2017 3 commits
    • Linus Torvalds's avatar
      Merge tag 'nfs-for-4.15-2' of git://git.linux-nfs.org/projects/anna/linux-nfs · 2db767d9
      Linus Torvalds authored
      Pull NFS client fixes from Anna Schumaker:
       "These patches fix a problem with compiling using an old version of
        gcc, and also fix up error handling in the SUNRPC layer.
      
         - NFSv4: Ensure gcc 4.4.4 can compile initialiser for
           "invalid_stateid"
      
         - SUNRPC: Allow connect to return EHOSTUNREACH
      
         - SUNRPC: Handle ENETDOWN errors"
      
      * tag 'nfs-for-4.15-2' of git://git.linux-nfs.org/projects/anna/linux-nfs:
        SUNRPC: Handle ENETDOWN errors
        SUNRPC: Allow connect to return EHOSTUNREACH
        NFSv4: Ensure gcc 4.4.4 can compile initialiser for "invalid_stateid"
      2db767d9
    • Linus Torvalds's avatar
      Merge tag 'xfs-4.15-fixes-4' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · 788c1da0
      Linus Torvalds authored
      Pull xfs fixes from Darrick Wong:
       "Here are some bug fixes for 4.15-rc2.
      
         - fix memory leaks that appeared after removing ifork inline data
           buffer
      
         - recover deferred rmap update log items in correct order
      
         - fix memory leaks when buffer construction fails
      
         - fix memory leaks when bmbt is corrupt
      
         - fix some uninitialized variables and math problems in the quota
           scrubber
      
         - add some omitted attribution tags on the log replay commit
      
         - fix some UBSAN complaints about integer overflows with large sparse
           files
      
         - implement an effective inode mode check in online fsck
      
         - fix log's inability to retry quota item writeout due to transient
           errors"
      
      * tag 'xfs-4.15-fixes-4' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
        xfs: Properly retry failed dquot items in case of error during buffer writeback
        xfs: scrub inode mode properly
        xfs: remove unused parameter from xfs_writepage_map
        xfs: ubsan fixes
        xfs: calculate correct offset in xfs_scrub_quota_item
        xfs: fix uninitialized variable in xfs_scrub_quota
        xfs: fix leaks on corruption errors in xfs_bmap.c
        xfs: fortify xfs_alloc_buftarg error handling
        xfs: log recovery should replay deferred ops in order
        xfs: always free inline data before resetting inode fork during ifree
      788c1da0
    • Linus Torvalds's avatar
      Merge tag 'riscv-for-linus-4.15-rc2_cleanups' of... · e1ba1c99
      Linus Torvalds authored
      Merge tag 'riscv-for-linus-4.15-rc2_cleanups' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux
      
      Pull RISC-V cleanups and ABI fixes from Palmer Dabbelt:
       "This contains a handful of small cleanups that are a result of
        feedback that didn't make it into our original patch set, either
        because the feedback hadn't been given yet, I missed the original
        emails, or we weren't ready to submit the changes yet.
      
        I've been maintaining the various cleanup patch sets I have as their
        own branches, which I then merged together and signed. Each merge
        commit has a short summary of the changes, and each branch is based on
        your latest tag (4.15-rc1, in this case). If this isn't the right way
        to do this then feel free to suggest something else, but it seems sane
        to me.
      
        Here's a short summary of the changes, roughly in order of how
        interesting they are.
      
         - libgcc.h has been moved from include/lib, where it's the only
           member, to include/linux. This is meant to avoid tab completion
           conflicts.
      
         - VDSO entries for clock_get/gettimeofday/getcpu have been added.
           These are simple syscalls now, but we want to let glibc use them
           from the start so we can make them faster later.
      
         - A VDSO entry for instruction cache flushing has been added so
           userspace can flush the instruction cache.
      
         - The VDSO symbol versions for __vdso_cmpxchg{32,64} have been
           removed, as those VDSO entries don't actually exist.
      
         - __io_writes has been corrected to respect the given type.
      
         - A new READ_ONCE in arch_spin_is_locked().
      
         - __test_and_op_bit_ord() is now actually ordered.
      
         - Various small fixes throughout the tree to enable allmodconfig to
           build cleanly.
      
         - Removal of some dead code in our atomic support headers.
      
         - Improvements to various comments in our atomic support headers"
      
      * tag 'riscv-for-linus-4.15-rc2_cleanups' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux: (23 commits)
        RISC-V: __io_writes should respect the length argument
        move libgcc.h to include/linux
        RISC-V: Clean up an unused include
        RISC-V: Allow userspace to flush the instruction cache
        RISC-V: Flush I$ when making a dirty page executable
        RISC-V: Add missing include
        RISC-V: Use define for get_cycles like other architectures
        RISC-V: Provide stub of setup_profiling_timer()
        RISC-V: Export some expected symbols for modules
        RISC-V: move empty_zero_page definition to C and export it
        RISC-V: io.h: type fixes for warnings
        RISC-V: use RISCV_{INT,SHORT} instead of {INT,SHORT} for asm macros
        RISC-V: use generic serial.h
        RISC-V: remove spin_unlock_wait()
        RISC-V: `sfence.vma` orderes the instruction cache
        RISC-V: Add READ_ONCE in arch_spin_is_locked()
        RISC-V: __test_and_op_bit_ord should be strongly ordered
        RISC-V: Remove smb_mb__{before,after}_spinlock()
        RISC-V: Remove __smp_bp__{before,after}_atomic
        RISC-V: Comment on why {,cmp}xchg is ordered how it is
        ...
      e1ba1c99