public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] kernel.h: Move lib/cmdline.c prototypes to string.h
@ 2023-10-03 13:01 Andy Shevchenko
  2023-10-03 23:39 ` Kees Cook
  2024-02-23 17:41 ` Kees Cook
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2023-10-03 13:01 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel, linux-hardening; +Cc: Kees Cook, Andy Shevchenko

The lib/cmdline.c is basically a set of some small string parsers
which are wide used in the kernel. Their prototypes belong to the
string.h rather then kernel.h.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/kernel.h | 6 ------
 include/linux/string.h | 8 ++++++++
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index c07f9c779d45..3e6c5ac08f8b 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -195,12 +195,6 @@ static inline void might_fault(void) { }
 
 void do_exit(long error_code) __noreturn;
 
-extern int get_option(char **str, int *pint);
-extern char *get_options(const char *str, int nints, int *ints);
-extern unsigned long long memparse(const char *ptr, char **retptr);
-extern bool parse_option_str(const char *str, const char *option);
-extern char *next_arg(char *args, char **param, char **val);
-
 extern int core_kernel_text(unsigned long addr);
 extern int __kernel_text_address(unsigned long addr);
 extern int kernel_text_address(unsigned long addr);
diff --git a/include/linux/string.h b/include/linux/string.h
index 3c920b6d609b..0995f2a737ef 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -181,9 +181,17 @@ extern void *kmemdup(const void *src, size_t len, gfp_t gfp) __realloc_size(2);
 extern void *kvmemdup(const void *src, size_t len, gfp_t gfp) __realloc_size(2);
 extern char *kmemdup_nul(const char *s, size_t len, gfp_t gfp);
 
+/* lib/argv_split.c */
 extern char **argv_split(gfp_t gfp, const char *str, int *argcp);
 extern void argv_free(char **argv);
 
+/* lib/cmdline.c */
+extern int get_option(char **str, int *pint);
+extern char *get_options(const char *str, int nints, int *ints);
+extern unsigned long long memparse(const char *ptr, char **retptr);
+extern bool parse_option_str(const char *str, const char *option);
+extern char *next_arg(char *args, char **param, char **val);
+
 extern bool sysfs_streq(const char *s1, const char *s2);
 int match_string(const char * const *array, size_t n, const char *string);
 int __sysfs_match_string(const char * const *array, size_t n, const char *s);
-- 
2.40.0.1.gaa8946217a0b


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

* Re: [PATCH v1 1/1] kernel.h: Move lib/cmdline.c prototypes to string.h
  2023-10-03 13:01 [PATCH v1 1/1] kernel.h: Move lib/cmdline.c prototypes to string.h Andy Shevchenko
@ 2023-10-03 23:39 ` Kees Cook
  2023-10-04  9:27   ` Andy Shevchenko
  2024-02-23 17:41 ` Kees Cook
  1 sibling, 1 reply; 5+ messages in thread
From: Kees Cook @ 2023-10-03 23:39 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel, linux-hardening, Andy Shevchenko

On Tue, Oct 03, 2023 at 04:01:42PM +0300, Andy Shevchenko wrote:
> The lib/cmdline.c is basically a set of some small string parsers
> which are wide used in the kernel. Their prototypes belong to the
> string.h rather then kernel.h.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

I think these should live in string_helpers.h not string.h (which is, in
theory, supposed to be used for the standard C string library functions,
though that's not 100% currently)...

-Kees

> ---
>  include/linux/kernel.h | 6 ------
>  include/linux/string.h | 8 ++++++++
>  2 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index c07f9c779d45..3e6c5ac08f8b 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -195,12 +195,6 @@ static inline void might_fault(void) { }
>  
>  void do_exit(long error_code) __noreturn;
>  
> -extern int get_option(char **str, int *pint);
> -extern char *get_options(const char *str, int nints, int *ints);
> -extern unsigned long long memparse(const char *ptr, char **retptr);
> -extern bool parse_option_str(const char *str, const char *option);
> -extern char *next_arg(char *args, char **param, char **val);
> -
>  extern int core_kernel_text(unsigned long addr);
>  extern int __kernel_text_address(unsigned long addr);
>  extern int kernel_text_address(unsigned long addr);
> diff --git a/include/linux/string.h b/include/linux/string.h
> index 3c920b6d609b..0995f2a737ef 100644
> --- a/include/linux/string.h
> +++ b/include/linux/string.h
> @@ -181,9 +181,17 @@ extern void *kmemdup(const void *src, size_t len, gfp_t gfp) __realloc_size(2);
>  extern void *kvmemdup(const void *src, size_t len, gfp_t gfp) __realloc_size(2);
>  extern char *kmemdup_nul(const char *s, size_t len, gfp_t gfp);
>  
> +/* lib/argv_split.c */
>  extern char **argv_split(gfp_t gfp, const char *str, int *argcp);
>  extern void argv_free(char **argv);
>  
> +/* lib/cmdline.c */
> +extern int get_option(char **str, int *pint);
> +extern char *get_options(const char *str, int nints, int *ints);
> +extern unsigned long long memparse(const char *ptr, char **retptr);
> +extern bool parse_option_str(const char *str, const char *option);
> +extern char *next_arg(char *args, char **param, char **val);
> +
>  extern bool sysfs_streq(const char *s1, const char *s2);
>  int match_string(const char * const *array, size_t n, const char *string);
>  int __sysfs_match_string(const char * const *array, size_t n, const char *s);
> -- 
> 2.40.0.1.gaa8946217a0b
> 

-- 
Kees Cook

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

* Re: [PATCH v1 1/1] kernel.h: Move lib/cmdline.c prototypes to string.h
  2023-10-03 23:39 ` Kees Cook
@ 2023-10-04  9:27   ` Andy Shevchenko
  2024-02-22 17:17     ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2023-10-04  9:27 UTC (permalink / raw)
  To: Kees Cook; +Cc: Andy Shevchenko, linux-kernel, linux-hardening, Andy Shevchenko

On Wed, Oct 4, 2023 at 2:39 AM Kees Cook <keescook@chromium.org> wrote:
>
> On Tue, Oct 03, 2023 at 04:01:42PM +0300, Andy Shevchenko wrote:
> > The lib/cmdline.c is basically a set of some small string parsers
> > which are wide used in the kernel. Their prototypes belong to the
> > string.h rather then kernel.h.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> I think these should live in string_helpers.h not string.h (which is, in
> theory, supposed to be used for the standard C string library functions,
> though that's not 100% currently)...

These are being used in the early stages where usually we have
string.h. So, I would argue, but if you insist, I can move them. What
about lib/argv_slit.c then? Because semantically it's quite close to
what the lib/cmdline.c is doing.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH v1 1/1] kernel.h: Move lib/cmdline.c prototypes to string.h
  2023-10-04  9:27   ` Andy Shevchenko
@ 2024-02-22 17:17     ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2024-02-22 17:17 UTC (permalink / raw)
  To: Kees Cook; +Cc: linux-kernel, linux-hardening

On Wed, Oct 04, 2023 at 12:27:41PM +0300, Andy Shevchenko wrote:
> On Wed, Oct 4, 2023 at 2:39 AM Kees Cook <keescook@chromium.org> wrote:
> > On Tue, Oct 03, 2023 at 04:01:42PM +0300, Andy Shevchenko wrote:
> > > The lib/cmdline.c is basically a set of some small string parsers
> > > which are wide used in the kernel. Their prototypes belong to the
> > > string.h rather then kernel.h.
> >
> > I think these should live in string_helpers.h not string.h (which is, in
> > theory, supposed to be used for the standard C string library functions,
> > though that's not 100% currently)...
> 
> These are being used in the early stages where usually we have
> string.h. So, I would argue, but if you insist, I can move them. What
> about lib/argv_slit.c then? Because semantically it's quite close to
> what the lib/cmdline.c is doing.

So, if no further ARs, can we got this applied and move on?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 1/1] kernel.h: Move lib/cmdline.c prototypes to string.h
  2023-10-03 13:01 [PATCH v1 1/1] kernel.h: Move lib/cmdline.c prototypes to string.h Andy Shevchenko
  2023-10-03 23:39 ` Kees Cook
@ 2024-02-23 17:41 ` Kees Cook
  1 sibling, 0 replies; 5+ messages in thread
From: Kees Cook @ 2024-02-23 17:41 UTC (permalink / raw)
  To: linux-kernel, linux-hardening, Andy Shevchenko; +Cc: Kees Cook, Andy Shevchenko

On Tue, 03 Oct 2023 16:01:42 +0300, Andy Shevchenko wrote:
> The lib/cmdline.c is basically a set of some small string parsers
> which are wide used in the kernel. Their prototypes belong to the
> string.h rather then kernel.h.

Applied to for-next/hardening, thanks!

[1/1] kernel.h: Move lib/cmdline.c prototypes to string.h
      https://git.kernel.org/kees/c/9f938458a5dd

Take care,

-- 
Kees Cook


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

end of thread, other threads:[~2024-02-23 17:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-03 13:01 [PATCH v1 1/1] kernel.h: Move lib/cmdline.c prototypes to string.h Andy Shevchenko
2023-10-03 23:39 ` Kees Cook
2023-10-04  9:27   ` Andy Shevchenko
2024-02-22 17:17     ` Andy Shevchenko
2024-02-23 17:41 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox