From: Borislav Petkov <bp@alien8.de>
To: John Millikin <john@john-millikin.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH] x86/tools: Use POSIX-compliant syntax for empty regex groups
Date: Wed, 3 Feb 2021 13:08:14 +0100 [thread overview]
Message-ID: <20210203120814.GB13819@zn.tnic> (raw)
In-Reply-To: <ed1d5611-a0e6-7629-c827-a17112944c5f@john-millikin.com>
On Fri, Dec 25, 2020 at 10:30:43PM +0900, John Millikin wrote:
> The syntax for POSIX regexes technically doesn't allow empty branches in
> conditional match groups. GNU libc accepts them as equivalent to `()',
> but other libc implementations (e.g. macOS libc) reject them with a
> parse error.
>
> Changing to compliant syntax, `(|_sym)' to `(()|_sym)', lets the `relocs'
> tool run successfully when using a non-GNU platform as a build host for
> cross-compiling the kernel.
>
> Signed-off-by: John Millikin <john@john-millikin.com>
> ---
>
> Helper binary to verify behavior for the current platform:
>
> #include <regex.h>
> #include <stdio.h>
> int main(int argc, char **argv) {
> regex_t compiled;
> int err = regcomp(&compiled, argv[1], REG_EXTENDED|REG_NOSUB);
> if (err != 0) {
> char errbuf[128];
> regerror(err, &compiled, errbuf, sizeof(errbuf));
> printf("regcomp(\"%s\"): %s\n", argv[1], errbuf);
> return 1;
> }
> printf("regcomp(\"%s\"): OK\n", argv[1]);
> return 0;
> }
>
> Output from GNU libc 2.28 and a fussier non-GNU libc:
>
> debian:~$ ./regcomp '^a(|b)$'
> regcomp("^a(|b)$"): OK
> debian:~$ ./regcomp '^a(()|b)$'
> regcomp("^a(()|b)$"): OK
>
> darwin:~$ ./regcomp '^a(|b)$'
> regcomp("^a(|b)$"): empty (sub)expression
> darwin:~$ ./regcomp '^a(()|b)$'
> regcomp("^a(()|b)$"): OK
>
I guess you can add those to the commit message as they explain in
detail what the situation is.
> arch/x86/tools/relocs.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
> index ce7188cbdae5..e6f28616a625 100644
> --- a/arch/x86/tools/relocs.c
> +++ b/arch/x86/tools/relocs.c
> @@ -57,12 +57,12 @@ static const char * const sym_regex_kernel[S_NSYMTYPES] = {
> [S_REL] =
$ test-apply.sh /tmp/build.01
checking file arch/x86/tools/relocs.c
patch: **** malformed patch at line 67: [S_REL] =
Don't tell me the apple mangles patches...
:-)
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
prev parent reply other threads:[~2021-02-03 12:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-25 13:30 [PATCH] x86/tools: Use POSIX-compliant syntax for empty regex groups John Millikin
2021-02-03 12:08 ` Borislav Petkov [this message]
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=20210203120814.GB13819@zn.tnic \
--to=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=john@john-millikin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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).