Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1727479
| From | Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] of: do not leak console options |
| Date | 2017-09-06 15:40 +0200 |
| Message-ID | <umIIF-2qh-17@gated-at.bofh.it> (permalink) |
| References | <uiqU2-71g-5@gated-at.bofh.it> <uivqG-1qN-1@gated-at.bofh.it> <uj0b8-4uh-5@gated-at.bofh.it> <umHWh-1Qd-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hello,
On (09/06/17 14:40), Petr Mladek wrote:
[..]
> > I wouldn't know :) let's find that out
> >
> > the patch used to pass `of_stdout_options' in v1 and v2
> > https://patches.linaro.org/patch/41559/
> >
> > starting from v3 options are kstrdup-ed
> > https://patchwork.kernel.org/patch/5398761/
>
> I was curious. The const char * was suggested by Grant Likely,
> see https://lkml.kernel.org/r/CACxGe6tQ5rWzCUcS+_fFY+rjEyua2khApAoCVKpTuJAghU=N_w@mail.gmail.com
> I guess that the reason was to make the of_find_node_by_path()
> API clean.
ok, thanks.
> > > AFAICT, the only reason is options within the console/printk code is a
> > > char * and not a const char *. I can't imagine that options need
> > > modifications?
> >
> > as far as I can tell, ->match callback has side efects, sometimes.
>
> I hope that the match() callbacks does not have this kind of side
> effects. I think that they initialize some stuff, assign some values.
> But I hope that they do not modify given strings, like console
> name or options. At leats I am unable to find any place.
> But I am not 100% sure.
yeah, seems like we can pass just char *options.
const-ifying options (and brl options) on the printk side would probably
be a better solution. need to check if we can do that, tho. that also
would require touching printk API, struct console, struct console_cmdline,
->match callbacks of every console in the kernel, etc. not like a big deal,
just potentially a bit of a noisy patch.
Rob, Grant,
will this dirty hack work for you? I can respin the patch.
---
drivers/of/base.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 260d33c0f26c..e6839045c454 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1781,8 +1781,8 @@ bool of_console_check(struct device_node *dn, char *name, int index)
{
if (!dn || dn != of_stdout || console_set_on_cmdline)
return false;
- return !add_preferred_console(name, index,
- kstrdup(of_stdout_options, GFP_KERNEL));
+
+ return !add_preferred_console(name, index, (char *)of_stdout_options);
}
EXPORT_SYMBOL_GPL(of_console_check);
--
2.14.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] of: do not leak console options Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2017-08-25 19:50 +0200
Re: [PATCH] of: do not leak console options Rob Herring <robh@kernel.org> - 2017-08-26 00:40 +0200
Re: [PATCH] of: do not leak console options Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2017-08-27 09:30 +0200
Re: [PATCH] of: do not leak console options Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2017-08-27 10:10 +0200
Re: [PATCH] of: do not leak console options Petr Mladek <pmladek@suse.com> - 2017-09-06 14:50 +0200
Re: [PATCH] of: do not leak console options Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-09-06 15:40 +0200
Re: [PATCH] of: do not leak console options Rob Herring <robh@kernel.org> - 2017-09-06 17:30 +0200
Re: [PATCH] of: do not leak console options Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-09-07 12:10 +0200
csiph-web