Re: [PATCH v4 3/9] vsprintf: Do not check address of well-known strings

2018-04-10 Thread Andy Shevchenko
On Mon, 2018-04-09 at 14:19 +0200, Petr Mladek wrote:
> On Sat 2018-04-07 17:12:35, Andy Shevchenko wrote:
> > On Fri, 2018-04-06 at 11:15 +0200, Petr Mladek wrote:
> > > On Thu 2018-04-05 15:30:51, Rasmus Villemoes wrote:
> > > > On 2018-04-04 10:58, Petr Mladek wrote:

> > > > > 
> > > > Please leave string() alone, except for moving the < PAGE_SIZE
> > > > check
> > > > to
> > > > a new helper checked_string (feel free to find a better name),
> > > > and
> > > > use
> > > > checked_string for handling %s and possibly the few other cases
> > > > where
> > > > we're passing a user-supplied pointer. That avoids cluttering
> > > > the
> > > > entire
> > > > file with double-underscore calls, and e.g. in the %pO case,
> > > > it's
> > > > easier
> > > > to understand why one uses two different *string() helpers if
> > > > the
> > > > name
> > > > of one somehow conveys how it is different from the other.
> > > 
> > > I understand your reasoning. I thought about exactly this as well.
> > > My problem is that string() will then be unsafe. It might be
> > > dangerous
> > > when porting patches.
> > 
> > I agree with Rasmus, and your argument here from my point of view
> > kinda
> > weak. Are we really going to backport this patches? Why? We lived
> > w/o
> > them for a long time. What's changed now?
> 
> Someone might have out-of-tree patch that adds yet another format
> specifier. It might call string() that checks for (null) now but
> it it won't if we rename it as you suggest. People used to safe
> string() might miss this when the patch is send upstream for
> inclusion, ...

This is even weaker argument. Sorry, but I don't care about out-of-tree
core patches. If they have them, they are doing completely wrong, or the
patches are crappy.

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH v4 3/9] vsprintf: Do not check address of well-known strings

2018-04-10 Thread Andy Shevchenko
On Mon, 2018-04-09 at 14:19 +0200, Petr Mladek wrote:
> On Sat 2018-04-07 17:12:35, Andy Shevchenko wrote:
> > On Fri, 2018-04-06 at 11:15 +0200, Petr Mladek wrote:
> > > On Thu 2018-04-05 15:30:51, Rasmus Villemoes wrote:
> > > > On 2018-04-04 10:58, Petr Mladek wrote:

> > > > > 
> > > > Please leave string() alone, except for moving the < PAGE_SIZE
> > > > check
> > > > to
> > > > a new helper checked_string (feel free to find a better name),
> > > > and
> > > > use
> > > > checked_string for handling %s and possibly the few other cases
> > > > where
> > > > we're passing a user-supplied pointer. That avoids cluttering
> > > > the
> > > > entire
> > > > file with double-underscore calls, and e.g. in the %pO case,
> > > > it's
> > > > easier
> > > > to understand why one uses two different *string() helpers if
> > > > the
> > > > name
> > > > of one somehow conveys how it is different from the other.
> > > 
> > > I understand your reasoning. I thought about exactly this as well.
> > > My problem is that string() will then be unsafe. It might be
> > > dangerous
> > > when porting patches.
> > 
> > I agree with Rasmus, and your argument here from my point of view
> > kinda
> > weak. Are we really going to backport this patches? Why? We lived
> > w/o
> > them for a long time. What's changed now?
> 
> Someone might have out-of-tree patch that adds yet another format
> specifier. It might call string() that checks for (null) now but
> it it won't if we rename it as you suggest. People used to safe
> string() might miss this when the patch is send upstream for
> inclusion, ...

This is even weaker argument. Sorry, but I don't care about out-of-tree
core patches. If they have them, they are doing completely wrong, or the
patches are crappy.

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH v4 3/9] vsprintf: Do not check address of well-known strings

2018-04-09 Thread Petr Mladek
On Sat 2018-04-07 17:12:35, Andy Shevchenko wrote:
> On Fri, 2018-04-06 at 11:15 +0200, Petr Mladek wrote:
> > On Thu 2018-04-05 15:30:51, Rasmus Villemoes wrote:
> > > On 2018-04-04 10:58, Petr Mladek wrote:
> > > > We are going to check the address using probe_kernel_address(). It
> > > > will
> > > > be more expensive and it does not make sense for well known
> > > > address.
> > > > 
> > > > This patch splits the string() function. The variant without the
> > > > check
> > > > is then used on locations that handle string constants or strings
> > > > defined
> > > > as local variables.
> > > > 
> > > > This patch does not change the existing behavior.
> > > 
> > > Please leave string() alone, except for moving the < PAGE_SIZE check
> > > to
> > > a new helper checked_string (feel free to find a better name), and
> > > use
> > > checked_string for handling %s and possibly the few other cases
> > > where
> > > we're passing a user-supplied pointer. That avoids cluttering the
> > > entire
> > > file with double-underscore calls, and e.g. in the %pO case, it's
> > > easier
> > > to understand why one uses two different *string() helpers if the
> > > name
> > > of one somehow conveys how it is different from the other.
> > 
> > I understand your reasoning. I thought about exactly this as well.
> > My problem is that string() will then be unsafe. It might be dangerous
> > when porting patches.
> 
> I agree with Rasmus, and your argument here from my point of view kinda
> weak. Are we really going to backport this patches? Why? We lived w/o
> them for a long time. What's changed now?

Someone might have out-of-tree patch that adds yet another format
specifier. It might call string() that checks for (null) now but
it it won't if we rename it as you suggest. People used to safe
string() might miss this when the patch is send upstream for
inclusion, ...


> > Is _string() really that bad? 
> 
> I would think so.

OK, I am going to use valid_string() instead of _string().
Feel free to suggest anything better. Just please no bike-shedding.

Best Regards,
Petr


Re: [PATCH v4 3/9] vsprintf: Do not check address of well-known strings

2018-04-09 Thread Petr Mladek
On Sat 2018-04-07 17:12:35, Andy Shevchenko wrote:
> On Fri, 2018-04-06 at 11:15 +0200, Petr Mladek wrote:
> > On Thu 2018-04-05 15:30:51, Rasmus Villemoes wrote:
> > > On 2018-04-04 10:58, Petr Mladek wrote:
> > > > We are going to check the address using probe_kernel_address(). It
> > > > will
> > > > be more expensive and it does not make sense for well known
> > > > address.
> > > > 
> > > > This patch splits the string() function. The variant without the
> > > > check
> > > > is then used on locations that handle string constants or strings
> > > > defined
> > > > as local variables.
> > > > 
> > > > This patch does not change the existing behavior.
> > > 
> > > Please leave string() alone, except for moving the < PAGE_SIZE check
> > > to
> > > a new helper checked_string (feel free to find a better name), and
> > > use
> > > checked_string for handling %s and possibly the few other cases
> > > where
> > > we're passing a user-supplied pointer. That avoids cluttering the
> > > entire
> > > file with double-underscore calls, and e.g. in the %pO case, it's
> > > easier
> > > to understand why one uses two different *string() helpers if the
> > > name
> > > of one somehow conveys how it is different from the other.
> > 
> > I understand your reasoning. I thought about exactly this as well.
> > My problem is that string() will then be unsafe. It might be dangerous
> > when porting patches.
> 
> I agree with Rasmus, and your argument here from my point of view kinda
> weak. Are we really going to backport this patches? Why? We lived w/o
> them for a long time. What's changed now?

Someone might have out-of-tree patch that adds yet another format
specifier. It might call string() that checks for (null) now but
it it won't if we rename it as you suggest. People used to safe
string() might miss this when the patch is send upstream for
inclusion, ...


> > Is _string() really that bad? 
> 
> I would think so.

OK, I am going to use valid_string() instead of _string().
Feel free to suggest anything better. Just please no bike-shedding.

Best Regards,
Petr


Re: [PATCH v4 3/9] vsprintf: Do not check address of well-known strings

2018-04-07 Thread Andy Shevchenko
On Fri, 2018-04-06 at 11:15 +0200, Petr Mladek wrote:
> On Thu 2018-04-05 15:30:51, Rasmus Villemoes wrote:
> > On 2018-04-04 10:58, Petr Mladek wrote:
> > > We are going to check the address using probe_kernel_address(). It
> > > will
> > > be more expensive and it does not make sense for well known
> > > address.
> > > 
> > > This patch splits the string() function. The variant without the
> > > check
> > > is then used on locations that handle string constants or strings
> > > defined
> > > as local variables.
> > > 
> > > This patch does not change the existing behavior.
> > 
> > Please leave string() alone, except for moving the < PAGE_SIZE check
> > to
> > a new helper checked_string (feel free to find a better name), and
> > use
> > checked_string for handling %s and possibly the few other cases
> > where
> > we're passing a user-supplied pointer. That avoids cluttering the
> > entire
> > file with double-underscore calls, and e.g. in the %pO case, it's
> > easier
> > to understand why one uses two different *string() helpers if the
> > name
> > of one somehow conveys how it is different from the other.
> 
> I understand your reasoning. I thought about exactly this as well.
> My problem is that string() will then be unsafe. It might be dangerous
> when porting patches.

I agree with Rasmus, and your argument here from my point of view kinda
weak. Are we really going to backport this patches? Why? We lived w/o
them for a long time. What's changed now?

> Is _string() really that bad? 

I would think so.

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH v4 3/9] vsprintf: Do not check address of well-known strings

2018-04-07 Thread Andy Shevchenko
On Fri, 2018-04-06 at 11:15 +0200, Petr Mladek wrote:
> On Thu 2018-04-05 15:30:51, Rasmus Villemoes wrote:
> > On 2018-04-04 10:58, Petr Mladek wrote:
> > > We are going to check the address using probe_kernel_address(). It
> > > will
> > > be more expensive and it does not make sense for well known
> > > address.
> > > 
> > > This patch splits the string() function. The variant without the
> > > check
> > > is then used on locations that handle string constants or strings
> > > defined
> > > as local variables.
> > > 
> > > This patch does not change the existing behavior.
> > 
> > Please leave string() alone, except for moving the < PAGE_SIZE check
> > to
> > a new helper checked_string (feel free to find a better name), and
> > use
> > checked_string for handling %s and possibly the few other cases
> > where
> > we're passing a user-supplied pointer. That avoids cluttering the
> > entire
> > file with double-underscore calls, and e.g. in the %pO case, it's
> > easier
> > to understand why one uses two different *string() helpers if the
> > name
> > of one somehow conveys how it is different from the other.
> 
> I understand your reasoning. I thought about exactly this as well.
> My problem is that string() will then be unsafe. It might be dangerous
> when porting patches.

I agree with Rasmus, and your argument here from my point of view kinda
weak. Are we really going to backport this patches? Why? We lived w/o
them for a long time. What's changed now?

> Is _string() really that bad? 

I would think so.

-- 
Andy Shevchenko 
Intel Finland Oy


Re: [PATCH v4 3/9] vsprintf: Do not check address of well-known strings

2018-04-06 Thread Petr Mladek
On Thu 2018-04-05 15:30:51, Rasmus Villemoes wrote:
> On 2018-04-04 10:58, Petr Mladek wrote:
> > We are going to check the address using probe_kernel_address(). It will
> > be more expensive and it does not make sense for well known address.
> > 
> > This patch splits the string() function. The variant without the check
> > is then used on locations that handle string constants or strings defined
> > as local variables.
> > 
> > This patch does not change the existing behavior.
> 
> Please leave string() alone, except for moving the < PAGE_SIZE check to
> a new helper checked_string (feel free to find a better name), and use
> checked_string for handling %s and possibly the few other cases where
> we're passing a user-supplied pointer. That avoids cluttering the entire
> file with double-underscore calls, and e.g. in the %pO case, it's easier
> to understand why one uses two different *string() helpers if the name
> of one somehow conveys how it is different from the other.

I understand your reasoning. I thought about exactly this as well.
My problem is that string() will then be unsafe. It might be dangerous
when porting patches.

This is why I wanted a different name for the variant without the
check. But I was not able to come up with anything short and clear
at the same time.

Is _string() really that bad? I think that it is a rather common
practice to use _func() for functions that are less safe than func()
variants. People should use _func() variants with care and this is
what we want here.

In addition, it is an internal API. IMHO, only few people do changes
there. They will get used to it quickly. Which is not true for people
that might need to port patches.

Best Regards,
Petr


Re: [PATCH v4 3/9] vsprintf: Do not check address of well-known strings

2018-04-06 Thread Petr Mladek
On Thu 2018-04-05 15:30:51, Rasmus Villemoes wrote:
> On 2018-04-04 10:58, Petr Mladek wrote:
> > We are going to check the address using probe_kernel_address(). It will
> > be more expensive and it does not make sense for well known address.
> > 
> > This patch splits the string() function. The variant without the check
> > is then used on locations that handle string constants or strings defined
> > as local variables.
> > 
> > This patch does not change the existing behavior.
> 
> Please leave string() alone, except for moving the < PAGE_SIZE check to
> a new helper checked_string (feel free to find a better name), and use
> checked_string for handling %s and possibly the few other cases where
> we're passing a user-supplied pointer. That avoids cluttering the entire
> file with double-underscore calls, and e.g. in the %pO case, it's easier
> to understand why one uses two different *string() helpers if the name
> of one somehow conveys how it is different from the other.

I understand your reasoning. I thought about exactly this as well.
My problem is that string() will then be unsafe. It might be dangerous
when porting patches.

This is why I wanted a different name for the variant without the
check. But I was not able to come up with anything short and clear
at the same time.

Is _string() really that bad? I think that it is a rather common
practice to use _func() for functions that are less safe than func()
variants. People should use _func() variants with care and this is
what we want here.

In addition, it is an internal API. IMHO, only few people do changes
there. They will get used to it quickly. Which is not true for people
that might need to port patches.

Best Regards,
Petr


Re: [PATCH v4 3/9] vsprintf: Do not check address of well-known strings

2018-04-05 Thread Rasmus Villemoes
On 2018-04-04 10:58, Petr Mladek wrote:
> We are going to check the address using probe_kernel_address(). It will
> be more expensive and it does not make sense for well known address.
> 
> This patch splits the string() function. The variant without the check
> is then used on locations that handle string constants or strings defined
> as local variables.
> 
> This patch does not change the existing behavior.

Please leave string() alone, except for moving the < PAGE_SIZE check to
a new helper checked_string (feel free to find a better name), and use
checked_string for handling %s and possibly the few other cases where
we're passing a user-supplied pointer. That avoids cluttering the entire
file with double-underscore calls, and e.g. in the %pO case, it's easier
to understand why one uses two different *string() helpers if the name
of one somehow conveys how it is different from the other.

Rasmus


Re: [PATCH v4 3/9] vsprintf: Do not check address of well-known strings

2018-04-05 Thread Rasmus Villemoes
On 2018-04-04 10:58, Petr Mladek wrote:
> We are going to check the address using probe_kernel_address(). It will
> be more expensive and it does not make sense for well known address.
> 
> This patch splits the string() function. The variant without the check
> is then used on locations that handle string constants or strings defined
> as local variables.
> 
> This patch does not change the existing behavior.

Please leave string() alone, except for moving the < PAGE_SIZE check to
a new helper checked_string (feel free to find a better name), and use
checked_string for handling %s and possibly the few other cases where
we're passing a user-supplied pointer. That avoids cluttering the entire
file with double-underscore calls, and e.g. in the %pO case, it's easier
to understand why one uses two different *string() helpers if the name
of one somehow conveys how it is different from the other.

Rasmus