devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Petr Mladek <pmladek@suse.com>, Rob Herring <robh@kernel.org>,
	Grant Likely <grant.likely@secretlab.ca>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andrew Lunn <andrew@lunn.ch>
Subject: Re: [PATCH] of: do not leak console options
Date: Wed, 6 Sep 2017 22:29:23 +0900	[thread overview]
Message-ID: <20170906132923.GA805@jagdpanzerIV.localdomain> (raw)
In-Reply-To: <20170906124033.GB3143@pathway.suse.cz>

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

  reply	other threads:[~2017-09-06 13:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-25 17:36 [PATCH] of: do not leak console options Sergey Senozhatsky
     [not found] ` <20170825173647.1004-1-sergey.senozhatsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-08-25 22:37   ` Rob Herring
2017-08-27  7:19     ` Sergey Senozhatsky
2017-08-27  8:01       ` Sergey Senozhatsky
2017-09-06 12:40       ` Petr Mladek
2017-09-06 13:29         ` Sergey Senozhatsky [this message]
2017-09-06 15:27           ` Rob Herring
2017-09-07  9:57             ` Sergey Senozhatsky
     [not found]             ` <CAL_JsqKRPGFUzLVbyU_=GZzsy87Mc6x43DtmUQ758-nrZZF_jA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-09-26  6:31               ` Sergey Senozhatsky
  -- strict thread matches above, loose matches on Subject: below --
2017-09-26  6:25 Sergey Senozhatsky
2017-10-03  7:20 ` Petr Mladek
     [not found]   ` <20171003072007.GB9706-KsEp0d+Q8qECVLCxKZUutA@public.gmane.org>
2017-10-13 19:48     ` Geert Uytterhoeven
     [not found]       ` <CAMuHMdXL1v20PvP2=jv_YdNgk0afkrgfZf1b21LrTWXGoPDMhg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-10-13 20:44         ` Rob Herring
2017-10-12 17:24 ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170906132923.GA805@jagdpanzerIV.localdomain \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=robh@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).