Message ID | 20220805154231.31257-3-ojeda@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Rust support | expand |
On Fri, Aug 05, 2022 at 05:41:47PM +0200, Miguel Ojeda wrote: > From: Boqun Feng <boqun.feng@gmail.com> > > This introduces `KSYM_NAME_LEN_BUFFER` in place of the previously > hardcoded size of the input buffer. > > It will also make it easier to update the size in a single place > in a later patch. > > Signed-off-by: Boqun Feng <boqun.feng@gmail.com> > Co-developed-by: Miguel Ojeda <ojeda@kernel.org> > Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Does someone want to commit to taking these "prereq" patches? These clean-ups are nice even without adding Rust. -Kees > --- > scripts/kallsyms.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c > index 52f5488c61bc..f3c5a2623f71 100644 > --- a/scripts/kallsyms.c > +++ b/scripts/kallsyms.c > @@ -27,8 +27,14 @@ > > #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) > > +#define _stringify_1(x) #x > +#define _stringify(x) _stringify_1(x) > + > #define KSYM_NAME_LEN 128 > > +/* A substantially bigger size than the current maximum. */ > +#define KSYM_NAME_LEN_BUFFER 499 > + > struct sym_entry { > unsigned long long addr; > unsigned int len; > @@ -198,13 +204,13 @@ static void check_symbol_range(const char *sym, unsigned long long addr, > > static struct sym_entry *read_symbol(FILE *in) > { > - char name[500], type; > + char name[KSYM_NAME_LEN_BUFFER+1], type; > unsigned long long addr; > unsigned int len; > struct sym_entry *sym; > int rc; > > - rc = fscanf(in, "%llx %c %499s\n", &addr, &type, name); > + rc = fscanf(in, "%llx %c %" _stringify(KSYM_NAME_LEN_BUFFER) "s\n", &addr, &type, name); > if (rc != 3) { > if (rc != EOF && fgets(name, sizeof(name), in) == NULL) > fprintf(stderr, "Read error or end of file.\n"); > -- > 2.37.1 >
On Wed, Aug 17, 2022 at 12:37:40PM -0700, Kees Cook wrote: > On Fri, Aug 05, 2022 at 05:41:47PM +0200, Miguel Ojeda wrote: > > From: Boqun Feng <boqun.feng@gmail.com> > > > > This introduces `KSYM_NAME_LEN_BUFFER` in place of the previously > > hardcoded size of the input buffer. > > > > It will also make it easier to update the size in a single place > > in a later patch. > > > > Signed-off-by: Boqun Feng <boqun.feng@gmail.com> > > Co-developed-by: Miguel Ojeda <ojeda@kernel.org> > > Signed-off-by: Miguel Ojeda <ojeda@kernel.org> > > Reviewed-by: Kees Cook <keescook@chromium.org> > > Does someone want to commit to taking these "prereq" patches? These > clean-ups are nice even without adding Rust. Qouting Message-ID: <CANiq72mXDne_WkUCo2oRe+sip7nQWESnouOJrcCYzyJMkG8F6A@mail.gmail.com> https://lore.kernel.org/lkml/CANiq72mXDne_WkUCo2oRe+sip7nQWESnouOJrcCYzyJMkG8F6A@mail.gmail.com/ Miguel Ojeda, 2022-08-05: | > And I think that this patch and all other "rust" kallsyms patches | > allready should have been accepted in the v3 or v5 series. | | Yeah, it could be a good idea to get the prerequisites in first. | Let's see if the patches get some Reviewed-bys Now that there is a 'Reviewed-by: Kees Cook <keescook@chromium.org>' Regards Geert Stappers In an attempt to help making Rust for Linux happen.
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 52f5488c61bc..f3c5a2623f71 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -27,8 +27,14 @@ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) +#define _stringify_1(x) #x +#define _stringify(x) _stringify_1(x) + #define KSYM_NAME_LEN 128 +/* A substantially bigger size than the current maximum. */ +#define KSYM_NAME_LEN_BUFFER 499 + struct sym_entry { unsigned long long addr; unsigned int len; @@ -198,13 +204,13 @@ static void check_symbol_range(const char *sym, unsigned long long addr, static struct sym_entry *read_symbol(FILE *in) { - char name[500], type; + char name[KSYM_NAME_LEN_BUFFER+1], type; unsigned long long addr; unsigned int len; struct sym_entry *sym; int rc; - rc = fscanf(in, "%llx %c %499s\n", &addr, &type, name); + rc = fscanf(in, "%llx %c %" _stringify(KSYM_NAME_LEN_BUFFER) "s\n", &addr, &type, name); if (rc != 3) { if (rc != EOF && fgets(name, sizeof(name), in) == NULL) fprintf(stderr, "Read error or end of file.\n");