Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1218089 > unrolled thread

Re: [PATCH] clk_register_clkdev: handle callers needing format string

Started byTomeu Vizoso <tomeu@tomeuvizoso.net>
First post2015-09-03 10:00 +0200
Last post2015-09-04 07:20 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] clk_register_clkdev: handle callers needing format string Tomeu Vizoso <tomeu@tomeuvizoso.net> - 2015-09-03 10:00 +0200
    Re: [PATCH] clk_register_clkdev: handle callers needing format string Stephen Boyd <sboyd@codeaurora.org> - 2015-09-03 19:40 +0200
      Re: [PATCH] clk_register_clkdev: handle callers needing format string Tomeu Vizoso <tomeu@tomeuvizoso.net> - 2015-09-04 07:20 +0200

#1218089 — Re: [PATCH] clk_register_clkdev: handle callers needing format string

FromTomeu Vizoso <tomeu@tomeuvizoso.net>
Date2015-09-03 10:00 +0200
SubjectRe: [PATCH] clk_register_clkdev: handle callers needing format string
Message-ID<q4xB8-5Ju-23@gated-at.bofh.it>
On 5 August 2015 at 15:09, Tomeu Vizoso <tomeu@tomeuvizoso.net> wrote:
> On 31 July 2015 at 21:03, Kees Cook <keescook@chromium.org> wrote:
>> On Fri, Jul 31, 2015 at 2:13 AM, Tomeu Vizoso <tomeu@tomeuvizoso.net> wrote:
>>> On 25 July 2015 at 01:20, Kees Cook <keescook@chromium.org> wrote:
>>>> Many callers either use NULL or const strings for the third argument of
>>>> clk_register_clkdev. For those that do not, this is a risk for format
>>>> strings being accidentally processed (for example in device names). This
>>>> adds the missing "%s" arguments to make sure format strings will not leak
>>>> into the clkdev.
>>>>
>>>> Signed-off-by: Kees Cook <keescook@chromium.org>
>>>> ---
>>>
>>> [...]
>>>
>>>> diff --git a/drivers/clk/tegra/clk.c b/drivers/clk/tegra/clk.c
>>>> index 41cd87c67be6..97d9fb7e89ad 100644
>>>> --- a/drivers/clk/tegra/clk.c
>>>> +++ b/drivers/clk/tegra/clk.c
>>>> @@ -296,7 +296,7 @@ void __init tegra_register_devclks(struct tegra_devclk *dev_clks, int num)
>>>>
>>>>         for (i = 0; i < num; i++, dev_clks++)
>>>>                 clk_register_clkdev(clks[dev_clks->dt_id], dev_clks->con_id,
>>>> -                               dev_clks->dev_id);
>>>> +                               "%s", dev_clks->dev_id);
>>>
>>> This causes clocks to be registered with a dev_id string of "(null)",
>>> which is causing lookups that used to succeed before to fail.
>>
>> Oh yuck. Yeah, clk_register_clkdev handles a NULL argument differently
>> than other format-string style functions. Using
>> clk_register_clkdev(..., dev_clks->dev_id ? "%s" : NULL,
>> dev_clks->dev_id) seems really ugly to work around this, though.
>> Perhaps the format string capability should be removed?
>
> Yeah, that sounds good to me. At least, I don't see as that good of an
> idea to save a few lines of code by making the API so prone to
> mistakes.
>
> Could this patch be removed from linux-next in the meantime?

Stephen, Mike,

the Tegra portion of this patch is wrong because it registers some
clocks with a dev_id of "(null)", which is really inconvenient when
debugging because one cannot tell from the logs if it's NULL or that
actual string.

Could this be reverted?

Thanks,

Tomeu

> Thanks,
>
> Tomeu
>
>> -Kees
>>
>> --
>> Kees Cook
>> Chrome OS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1218463

FromStephen Boyd <sboyd@codeaurora.org>
Date2015-09-03 19:40 +0200
Message-ID<q4GEr-1WX-29@gated-at.bofh.it>
In reply to#1218089
On 09/03, Tomeu Vizoso wrote:
> On 5 August 2015 at 15:09, Tomeu Vizoso <tomeu@tomeuvizoso.net> wrote:
> >
> > Could this patch be removed from linux-next in the meantime?
> 
> Stephen, Mike,
> 
> the Tegra portion of this patch is wrong because it registers some
> clocks with a dev_id of "(null)", which is really inconvenient when
> debugging because one cannot tell from the logs if it's NULL or that
> actual string.
> 
> Could this be reverted?

Was this patch applied somewhere? clkdev is maintained by
Russell, so Mike and I didn't apply this patch to begin with.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1218679

FromTomeu Vizoso <tomeu@tomeuvizoso.net>
Date2015-09-04 07:20 +0200
Message-ID<q4RzQ-Rm-11@gated-at.bofh.it>
In reply to#1218463
On 3 September 2015 at 19:34, Stephen Boyd <sboyd@codeaurora.org> wrote:
> On 09/03, Tomeu Vizoso wrote:
>> On 5 August 2015 at 15:09, Tomeu Vizoso <tomeu@tomeuvizoso.net> wrote:
>> >
>> > Could this patch be removed from linux-next in the meantime?
>>
>> Stephen, Mike,
>>
>> the Tegra portion of this patch is wrong because it registers some
>> clocks with a dev_id of "(null)", which is really inconvenient when
>> debugging because one cannot tell from the logs if it's NULL or that
>> actual string.
>>
>> Could this be reverted?
>
> Was this patch applied somewhere? clkdev is maintained by
> Russell, so Mike and I didn't apply this patch to begin with.

Sorry about that, it came into -next via mmotm.

Regards,

Tomeu

> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web