linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] init/main.c: minor cleanup/bugfix of envvar handling
@ 2019-11-23 21:08 Arvind Sankar
  2019-11-23 21:08 ` [PATCH 1/3] init/main.c: log arguments and environment passed to init Arvind Sankar
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Arvind Sankar @ 2019-11-23 21:08 UTC (permalink / raw)
  To: linux-kernel

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.



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-12-12 18:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-23 21:08 [PATCH 0/3] init/main.c: minor cleanup/bugfix of envvar handling Arvind Sankar
2019-11-23 21:08 ` [PATCH 1/3] init/main.c: log arguments and environment passed to init Arvind Sankar
2019-11-23 21:08 ` [PATCH 2/3] init/main.c: remove unnecessary repair_env_string in do_initcall_level Arvind Sankar
2019-11-23 21:08 ` [PATCH 3/3] init/main.c: fix quoted value handling in unknown_bootoption Arvind Sankar
2019-11-23 21:20 ` [PATCH 0/3] init/main.c: minor cleanup/bugfix of envvar handling Randy Dunlap
2019-11-23 21:26   ` Arvind Sankar
2019-11-23 21:40 ` [PATCH RESEND " Arvind Sankar
2019-11-23 21:40   ` [PATCH RESEND 1/3] init/main.c: log arguments and environment passed to init Arvind Sankar
2019-11-23 21:40   ` [PATCH RESEND 2/3] init/main.c: remove unnecessary repair_env_string in do_initcall_level Arvind Sankar
2019-11-23 21:40   ` [PATCH RESEND 3/3] init/main.c: fix quoted value handling in unknown_bootoption Arvind Sankar
2019-11-27 19:25   ` [PATCH RESEND 0/3] init/main.c: minor cleanup/bugfix of envvar handling Arvind Sankar
2019-12-12 18:00   ` [PATCH v2 " Arvind Sankar
2019-12-12 18:00     ` [PATCH v2 1/3] init/main.c: log arguments and environment passed to init Arvind Sankar
2019-12-12 18:00     ` [PATCH v2 2/3] init/main.c: remove unnecessary repair_env_string in do_initcall_level Arvind Sankar
2019-12-12 18:00     ` [PATCH v2 3/3] init/main.c: fix quoted value handling in unknown_bootoption Arvind Sankar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).