1. 04 6月, 2020 1 次提交
    • D
      padata: initialize earlier · f1b192b1
      Daniel Jordan 提交于
      padata will soon initialize the system's struct pages in parallel, so it
      needs to be ready by page_alloc_init_late().
      
      The error return from padata_driver_init() triggers an initcall warning,
      so add a warning to padata_init() to avoid silent failure.
      Signed-off-by: NDaniel Jordan <daniel.m.jordan@oracle.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Tested-by: NJosh Triplett <josh@joshtriplett.org>
      Cc: Alexander Duyck <alexander.h.duyck@linux.intel.com>
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
      Cc: Michal Hocko <mhocko@kernel.org>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Robert Elliott <elliott@hpe.com>
      Cc: Shile Zhang <shile.zhang@linux.alibaba.com>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Cc: Steven Sistare <steven.sistare@oracle.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Zi Yan <ziy@nvidia.com>
      Link: http://lkml.kernel.org/r/20200527173608.2885243-3-daniel.m.jordan@oracle.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f1b192b1
  2. 15 5月, 2020 3 次提交
    • S
      scs: Add support for Clang's Shadow Call Stack (SCS) · d08b9f0c
      Sami Tolvanen 提交于
      This change adds generic support for Clang's Shadow Call Stack,
      which uses a shadow stack to protect return addresses from being
      overwritten by an attacker. Details are available here:
      
        https://clang.llvm.org/docs/ShadowCallStack.html
      
      Note that security guarantees in the kernel differ from the ones
      documented for user space. The kernel must store addresses of
      shadow stacks in memory, which means an attacker capable reading
      and writing arbitrary memory may be able to locate them and hijack
      control flow by modifying the stacks.
      Signed-off-by: NSami Tolvanen <samitolvanen@google.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      [will: Numerous cosmetic changes]
      Signed-off-by: NWill Deacon <will@kernel.org>
      d08b9f0c
    • D
      bpf: Restrict bpf_probe_read{, str}() only to archs where they work · 0ebeea8c
      Daniel Borkmann 提交于
      Given the legacy bpf_probe_read{,str}() BPF helpers are broken on archs
      with overlapping address ranges, we should really take the next step to
      disable them from BPF use there.
      
      To generally fix the situation, we've recently added new helper variants
      bpf_probe_read_{user,kernel}() and bpf_probe_read_{user,kernel}_str().
      For details on them, see 6ae08ae3 ("bpf: Add probe_read_{user, kernel}
      and probe_read_{user,kernel}_str helpers").
      
      Given bpf_probe_read{,str}() have been around for ~5 years by now, there
      are plenty of users at least on x86 still relying on them today, so we
      cannot remove them entirely w/o breaking the BPF tracing ecosystem.
      
      However, their use should be restricted to archs with non-overlapping
      address ranges where they are working in their current form. Therefore,
      move this behind a CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE and
      have x86, arm64, arm select it (other archs supporting it can follow-up
      on it as well).
      
      For the remaining archs, they can workaround easily by relying on the
      feature probe from bpftool which spills out defines that can be used out
      of BPF C code to implement the drop-in replacement for old/new kernels
      via: bpftool feature probe macro
      Suggested-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Reviewed-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Link: https://lore.kernel.org/bpf/20200515101118.6508-2-daniel@iogearbox.net
      0ebeea8c
    • B
      x86: Fix early boot crash on gcc-10, third try · a9a3ed1e
      Borislav Petkov 提交于
      ... or the odyssey of trying to disable the stack protector for the
      function which generates the stack canary value.
      
      The whole story started with Sergei reporting a boot crash with a kernel
      built with gcc-10:
      
        Kernel panic — not syncing: stack-protector: Kernel stack is corrupted in: start_secondary
        CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.6.0-rc5—00235—gfffb08b3 #139
        Hardware name: Gigabyte Technology Co., Ltd. To be filled by O.E.M./H77M—D3H, BIOS F12 11/14/2013
        Call Trace:
          dump_stack
          panic
          ? start_secondary
          __stack_chk_fail
          start_secondary
          secondary_startup_64
        -—-[ end Kernel panic — not syncing: stack—protector: Kernel stack is corrupted in: start_secondary
      
      This happens because gcc-10 tail-call optimizes the last function call
      in start_secondary() - cpu_startup_entry() - and thus emits a stack
      canary check which fails because the canary value changes after the
      boot_init_stack_canary() call.
      
      To fix that, the initial attempt was to mark the one function which
      generates the stack canary with:
      
        __attribute__((optimize("-fno-stack-protector"))) ... start_secondary(void *unused)
      
      however, using the optimize attribute doesn't work cumulatively
      as the attribute does not add to but rather replaces previously
      supplied optimization options - roughly all -fxxx options.
      
      The key one among them being -fno-omit-frame-pointer and thus leading to
      not present frame pointer - frame pointer which the kernel needs.
      
      The next attempt to prevent compilers from tail-call optimizing
      the last function call cpu_startup_entry(), shy of carving out
      start_secondary() into a separate compilation unit and building it with
      -fno-stack-protector, was to add an empty asm("").
      
      This current solution was short and sweet, and reportedly, is supported
      by both compilers but we didn't get very far this time: future (LTO?)
      optimization passes could potentially eliminate this, which leads us
      to the third attempt: having an actual memory barrier there which the
      compiler cannot ignore or move around etc.
      
      That should hold for a long time, but hey we said that about the other
      two solutions too so...
      Reported-by: NSergei Trofimovich <slyfox@gentoo.org>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Tested-by: NKalle Valo <kvalo@codeaurora.org>
      Cc: <stable@vger.kernel.org>
      Link: https://lkml.kernel.org/r/20200314164451.346497-1-slyfox@gentoo.org
      a9a3ed1e
  3. 12 5月, 2020 1 次提交
  4. 10 5月, 2020 2 次提交
    • L
      gcc-10: mark more functions __init to avoid section mismatch warnings · e99332e7
      Linus Torvalds 提交于
      It seems that for whatever reason, gcc-10 ends up not inlining a couple
      of functions that used to be inlined before.  Even if they only have one
      single callsite - it looks like gcc may have decided that the code was
      unlikely, and not worth inlining.
      
      The code generation difference is harmless, but caused a few new section
      mismatch errors, since the (now no longer inlined) function wasn't in
      the __init section, but called other init functions:
      
         Section mismatch in reference from the function kexec_free_initrd() to the function .init.text:free_initrd_mem()
         Section mismatch in reference from the function tpm2_calc_event_log_size() to the function .init.text:early_memremap()
         Section mismatch in reference from the function tpm2_calc_event_log_size() to the function .init.text:early_memunmap()
      
      So add the appropriate __init annotation to make modpost not complain.
      In both cases there were trivially just a single callsite from another
      __init function.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e99332e7
    • L
      Stop the ad-hoc games with -Wno-maybe-initialized · 78a5255f
      Linus Torvalds 提交于
      We have some rather random rules about when we accept the
      "maybe-initialized" warnings, and when we don't.
      
      For example, we consider it unreliable for gcc versions < 4.9, but also
      if -O3 is enabled, or if optimizing for size.  And then various kernel
      config options disabled it, because they know that they trigger that
      warning by confusing gcc sufficiently (ie PROFILE_ALL_BRANCHES).
      
      And now gcc-10 seems to be introducing a lot of those warnings too, so
      it falls under the same heading as 4.9 did.
      
      At the same time, we have a very straightforward way to _enable_ that
      warning when wanted: use "W=2" to enable more warnings.
      
      So stop playing these ad-hoc games, and just disable that warning by
      default, with the known and straight-forward "if you want to work on the
      extra compiler warnings, use W=123".
      
      Would it be great to have code that is always so obvious that it never
      confuses the compiler whether a variable is used initialized or not?
      Yes, it would.  In a perfect world, the compilers would be smarter, and
      our source code would be simpler.
      
      That's currently not the world we live in, though.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      78a5255f
  5. 06 5月, 2020 1 次提交
  6. 28 4月, 2020 2 次提交
    • P
      rcu-tasks: Split ->trc_reader_need_end · 276c4104
      Paul E. McKenney 提交于
      This commit splits ->trc_reader_need_end by using the rcu_special union.
      This change permits readers to check to see if a memory barrier is
      required without any added overhead in the common case where no such
      barrier is required.  This commit also adds the read-side checking.
      Later commits will add the machinery to properly set the new
      ->trc_reader_special.b.need_mb field.
      
      This commit also makes rcu_read_unlock_trace_special() tolerate nested
      read-side critical sections within interrupt and NMI handlers.
      Signed-off-by: NPaul E. McKenney <paulmck@kernel.org>
      276c4104
    • P
      rcu-tasks: Add an RCU Tasks Trace to simplify protection of tracing hooks · d5f177d3
      Paul E. McKenney 提交于
      Because RCU does not watch exception early-entry/late-exit, idle-loop,
      or CPU-hotplug execution, protection of tracing and BPF operations is
      needlessly complicated.  This commit therefore adds a variant of
      Tasks RCU that:
      
      o	Has explicit read-side markers to allow finite grace periods in
      	the face of in-kernel loops for PREEMPT=n builds.  These markers
      	are rcu_read_lock_trace() and rcu_read_unlock_trace().
      
      o	Protects code in the idle loop, exception entry/exit, and
      	CPU-hotplug code paths.  In this respect, RCU-tasks trace is
      	similar to SRCU, but with lighter-weight readers.
      
      o	Avoids expensive read-side instruction, having overhead similar
      	to that of Preemptible RCU.
      
      There are of course downsides:
      
      o	The grace-period code can send IPIs to CPUs, even when those
      	CPUs are in the idle loop or in nohz_full userspace.  This is
      	mitigated by later commits.
      
      o	It is necessary to scan the full tasklist, much as for Tasks RCU.
      
      o	There is a single callback queue guarded by a single lock,
      	again, much as for Tasks RCU.  However, those early use cases
      	that request multiple grace periods in quick succession are
      	expected to do so from a single task, which makes the single
      	lock almost irrelevant.  If needed, multiple callback queues
      	can be provided using any number of schemes.
      
      Perhaps most important, this variant of RCU does not affect the vanilla
      flavors, rcu_preempt and rcu_sched.  The fact that RCU Tasks Trace
      readers can operate from idle, offline, and exception entry/exit in no
      way enables rcu_preempt and rcu_sched readers to do so.
      
      The memory ordering was outlined here:
      https://lore.kernel.org/lkml/20200319034030.GX3199@paulmck-ThinkPad-P72/
      
      This effort benefited greatly from off-list discussions of BPF
      requirements with Alexei Starovoitov and Andrii Nakryiko.  At least
      some of the on-list discussions are captured in the Link: tags below.
      In addition, KCSAN was quite helpful in finding some early bugs.
      
      Link: https://lore.kernel.org/lkml/20200219150744.428764577@infradead.org/
      Link: https://lore.kernel.org/lkml/87mu8p797b.fsf@nanos.tec.linutronix.de/
      Link: https://lore.kernel.org/lkml/20200225221305.605144982@linutronix.de/
      Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      [ paulmck: Apply feedback from Steve Rostedt and Joel Fernandes. ]
      [ paulmck: Decrement trc_n_readers_need_end upon IPI failure. ]
      [ paulmck: Fix locking issue reported by rcutorture. ]
      Signed-off-by: NPaul E. McKenney <paulmck@kernel.org>
      d5f177d3
  7. 27 4月, 2020 1 次提交
    • R
      x86/setup: Add an initrdmem= option to specify initrd physical address · 694cfd87
      Ronald G. Minnich 提交于
      Add the initrdmem option:
      
        initrdmem=ss[KMG],nn[KMG]
      
      which is used to specify the physical address of the initrd, almost
      always an address in FLASH. Also add code for x86 to use the existing
      phys_init_start and phys_init_size variables in the kernel.
      
      This is useful in cases where a kernel and an initrd is placed in FLASH,
      but there is no firmware file system structure in the FLASH.
      
      One such situation occurs when unused FLASH space on UEFI systems has
      been reclaimed by, e.g., taking it from the Management Engine. For
      example, on many systems, the ME is given half the FLASH part; not only
      is 2.75M of an 8M part unused; but 10.75M of a 16M part is unused. This
      space can be used to contain an initrd, but need to tell Linux where it
      is.
      
      This space is "raw": due to, e.g., UEFI limitations: it can not be added
      to UEFI firmware volumes without rebuilding UEFI from source or writing
      a UEFI device driver. It can be referenced only as a physical address
      and size.
      
      At the same time, if a kernel can be "netbooted" or loaded from GRUB or
      syslinux, the option of not using the physical address specification
      should be available.
      
      Then, it is easy to boot the kernel and provide an initrd; or boot the
      the kernel and let it use the initrd in FLASH. In practice, this has
      proven to be very helpful when integrating Linux into FLASH on x86.
      
      Hence, the most flexible and convenient path is to enable the initrdmem
      command line option in a way that it is the last choice tried.
      
      For example, on the DigitalLoggers Atomic Pi, an image into FLASH can be
      burnt in with a built-in command line which includes:
      
        initrdmem=0xff968000,0x200000
      
      which specifies a location and size.
      
       [ bp: Massage commit message, make it passive. ]
      
      [akpm@linux-foundation.org: coding style fixes]
      Signed-off-by: NRonald G. Minnich <rminnich@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Reviewed-by: NH. Peter Anvin (Intel) <hpa@zytor.com>
      Link: http://lkml.kernel.org/r/CAP6exYLK11rhreX=6QPyDQmW7wPHsKNEFtXE47pjx41xS6O7-A@mail.gmail.com
      Link: https://lkml.kernel.org/r/20200426011021.1cskg0AGd%akpm@linux-foundation.org
      694cfd87
  8. 11 4月, 2020 1 次提交
  9. 08 4月, 2020 4 次提交
  10. 01 4月, 2020 1 次提交
  11. 31 3月, 2020 1 次提交
  12. 30 3月, 2020 1 次提交
  13. 27 3月, 2020 1 次提交
  14. 25 3月, 2020 1 次提交
  15. 24 3月, 2020 1 次提交
    • C
      block: remove __bdevname · ea3edd4d
      Christoph Hellwig 提交于
      There is no good reason for __bdevname to exist.  Just open code
      printing the string in the callers.  For three of them the format
      string can be trivially merged into existing printk statements,
      and in init/do_mounts.c we can at least do the scnprintf once at
      the start of the function, and unconditional of CONFIG_BLOCK to
      make the output for tiny configfs a little more helpful.
      
      Acked-by: Theodore Ts'o <tytso@mit.edu> # for ext4
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      ea3edd4d
  16. 12 3月, 2020 1 次提交
    • M
      int128: fix __uint128_t compiler test in Kconfig · 3a7c7331
      Masahiro Yamada 提交于
      The support for __uint128_t is dependent on the target bit size.
      
      GCC that defaults to the 32-bit can still build the 64-bit kernel
      with -m64 flag passed.
      
      However, $(cc-option,-D__SIZEOF_INT128__=0) is evaluated against the
      default machine bit, which may not match to the kernel it is building.
      
      Theoretically, this could be evaluated separately for 64BIT/32BIT.
      
        config CC_HAS_INT128
                bool
                default !$(cc-option,$(m64-flag) -D__SIZEOF_INT128__=0) if 64BIT
                default !$(cc-option,$(m32-flag) -D__SIZEOF_INT128__=0)
      
      I simplified it more because the 32-bit compiler is unlikely to support
      __uint128_t.
      
      Fixes: c12d3362 ("int128: move __uint128_t compiler test to Kconfig")
      Reported-by: NGeorge Spelvin <lkml@sdf.org>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Tested-by: NGeorge Spelvin <lkml@sdf.org>
      3a7c7331
  17. 06 3月, 2020 1 次提交
  18. 04 3月, 2020 1 次提交
  19. 03 3月, 2020 2 次提交
    • Q
      kbuild: allow symbol whitelisting with TRIM_UNUSED_KSYMS · 1518c633
      Quentin Perret 提交于
      CONFIG_TRIM_UNUSED_KSYMS currently removes all unused exported symbols
      from ksymtab. This works really well when using in-tree drivers, but
      cannot be used in its current form if some of them are out-of-tree.
      
      Indeed, even if the list of symbols required by out-of-tree drivers is
      known at compile time, the only solution today to guarantee these don't
      get trimmed is to set CONFIG_TRIM_UNUSED_KSYMS=n. This not only wastes
      space, but also makes it difficult to control the ABI usable by vendor
      modules in distribution kernels such as Android. Being able to control
      the kernel ABI surface is particularly useful to ship a unique Generic
      Kernel Image (GKI) for all vendors, which is a first step in the
      direction of getting all vendors to contribute their code upstream.
      
      As such, attempt to improve the situation by enabling users to specify a
      symbol 'whitelist' at compile time. Any symbol specified in this
      whitelist will be kept exported when CONFIG_TRIM_UNUSED_KSYMS is set,
      even if it has no in-tree user. The whitelist is defined as a simple
      text file, listing symbols, one per line.
      Acked-by: NJessica Yu <jeyu@kernel.org>
      Acked-by: NNicolas Pitre <nico@fluxnic.net>
      Tested-by: NMatthias Maennich <maennich@google.com>
      Reviewed-by: NMatthias Maennich <maennich@google.com>
      Signed-off-by: NQuentin Perret <qperret@google.com>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      1518c633
    • M
      kbuild: use KBUILD_DEFCONFIG as the fallback for DEFCONFIG_LIST · 2a86f661
      Masahiro Yamada 提交于
      Most of the Kconfig commands (except defconfig and all*config) read
      the .config file as a base set of CONFIG options.
      
      When it does not exist, the files in DEFCONFIG_LIST are searched in
      this order and loaded if found.
      
      I do not see much sense in the last two lines in DEFCONFIG_LIST.
      
      [1] ARCH_DEFCONFIG
      
      The entry for DEFCONFIG_LIST is guarded by 'depends on !UML'. So, the
      ARCH_DEFCONFIG definition in arch/x86/um/Kconfig is meaningless.
      
      arch/{sh,sparc,x86}/Kconfig define ARCH_DEFCONFIG depending on 32 or
      64 bit variant symbols. This is a little bit strange; ARCH_DEFCONFIG
      should be a fixed string because the base config file is loaded before
      the symbol evaluation stage.
      
      Using KBUILD_DEFCONFIG makes more sense because it is fixed before
      Kconfig is invoked. Fortunately, arch/{sh,sparc,x86}/Makefile define it
      in the same way, and it works as expected. Hence, replace ARCH_DEFCONFIG
      with "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)".
      
      [2] arch/$(ARCH)/defconfig
      
      This file path is no longer valid. The defconfig files are always located
      in the arch configs/ directories.
      
        $ find arch -name defconfig | sort
        arch/alpha/configs/defconfig
        arch/arm64/configs/defconfig
        arch/csky/configs/defconfig
        arch/nds32/configs/defconfig
        arch/riscv/configs/defconfig
        arch/s390/configs/defconfig
        arch/unicore32/configs/defconfig
      
      The path arch/*/configs/defconfig is already covered by
      "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)". So, this file path is
      not necessary.
      
      I moved the default KBUILD_DEFCONFIG to the top Makefile. Otherwise,
      the 7 architectures listed above would end up with endless loop of
      syncconfig.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      2a86f661
  20. 26 2月, 2020 1 次提交
  21. 21 2月, 2020 4 次提交
  22. 11 2月, 2020 2 次提交
  23. 06 2月, 2020 2 次提交
  24. 05 2月, 2020 1 次提交
  25. 01 2月, 2020 3 次提交
    • C
      init/main.c: fix misleading "This architecture does not have kernel memory protection" message · f596ded1
      Christophe Leroy 提交于
      This message leads to thinking that memory protection is not implemented
      for the said architecture, whereas absence of CONFIG_STRICT_KERNEL_RWX
      only means that memory protection has not been selected at compile time.
      
      Don't print this message when CONFIG_ARCH_HAS_STRICT_KERNEL_RWX is
      selected by the architecture.  Instead, print "Kernel memory protection
      not selected by kernel config."
      
      Link: http://lkml.kernel.org/r/62477e446d9685459d4f27d193af6ff1bd69d55f.1578557581.git.christophe.leroy@c-s.frSigned-off-by: NChristophe Leroy <christophe.leroy@c-s.fr>
      Acked-by: NKees Cook <keescook@chromium.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f596ded1
    • A
      init/main.c: fix quoted value handling in unknown_bootoption · 283900e8
      Arvind Sankar 提交于
      Patch series "init/main.c: minor cleanup/bugfix of envvar handling", v2.
      
      unknown_bootoption passes unrecognized command line arguments to init as
      either environment variables or arguments.  Some of the logic in the
      function is broken for quoted command line arguments.
      
      When an argument of the form param="value" is processed by parse_args
      and passed to unknown_bootoption, the command line has
      
        param\0"value\0
      
      with val pointing to the beginning of value.  The helper function
      repair_env_string is then used to restore the '=' character that was
      removed by parse_args, and strip the quotes off fully.  This results in
      
        param=value\0\0
      
      and val ends up pointing to the 'a' instead of the 'v' in value.  This
      bug was introduced when repair_env_string was refactored into a separate
      function, and the decrement of val in repair_env_string became dead
      code.
      
      This causes two problems in unknown_bootoption in the two places where
      the val pointer is used as a substitute for the length of param:
      
      1. An argument of the form param=".value" is misinterpreted as a
         potential module parameter, with the result that it will not be
         placed in init's environment.
      
      2. An argument of the form param="value" is checked to see if param is
         an existing environment variable that should be overwritten, but the
         comparison is off-by-one and compares 'param=v' instead of 'param='
         against the existing environment. So passing, for example,
         TERM="vt100" on the command line results in init being passed both
         TERM=linux and TERM=vt100 in its environment.
      
      Patch 1 adds logging for the arguments and environment passed to init
      and is independent of the rest: it can be dropped if this is
      unnecessarily verbose.
      
      Patch 2 removes repair_env_string from initcall parameter parsing in
      do_initcall_level, as that uses a separate copy of the command line now
      and the repairing is no longer necessary.
      
      Patch 3 fixes the bug in unknown_bootoption by recording the length of
      param explicitly instead of implying it from val-param.
      
      This patch (of 3):
      
      Commit a99cd112 ("init: fix bug where environment vars can't be
      passed via boot args") introduced two minor bugs in unknown_bootoption
      by factoring out the quoted value handling into a separate function.
      
      When value is quoted, repair_env_string will move the value up 1 byte to
      strip the quotes, so val in unknown_bootoption no longer points to the
      actual location of the value.
      
      The result is that an argument of the form param=".value" is mistakenly
      treated as a potential module parameter and is not placed in init's
      environment, and an argument of the form param="value" can result in a
      duplicate environment variable: eg TERM="vt100" on the command line will
      result in both TERM=linux and TERM=vt100 being placed into init's
      environment.
      
      Fix this by recording the length of the param before calling
      repair_env_string instead of relying on val.
      
      Link: http://lkml.kernel.org/r/20191212180023.24339-4-nivedita@alum.mit.eduSigned-off-by: NArvind Sankar <nivedita@alum.mit.edu>
      Cc: Chris Metcalf <cmetcalf@tilera.com>
      Cc: Krzysztof Mazur <krzysiek@podlesie.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      283900e8
    • A
      init/main.c: remove unnecessary repair_env_string in do_initcall_level · 7e2762e1
      Arvind Sankar 提交于
      Since commit 08746a65 ("init: fix in-place parameter modification
      regression"), parse_args in do_initcall_level is called on a copy of
      saved_command_line.  It is unnecessary to call repair_env_string during
      this parsing, as this copy is not used for anything later.
      
      Remove the now unnecessary arguments from repair_env_string as well.
      
      Link: http://lkml.kernel.org/r/20191212180023.24339-3-nivedita@alum.mit.eduSigned-off-by: NArvind Sankar <nivedita@alum.mit.edu>
      Cc: Krzysztof Mazur <krzysiek@podlesie.net>
      Cc: Chris Metcalf <cmetcalf@tilera.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7e2762e1