lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  8 Jul 2021 10:57:08 +0200
From:   "H. Nikolaus Schaller" <hns@...delico.com>
To:     Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, Jessica Yu <jeyu@...nel.org>,
        Miroslav Benes <mbenes@...e.cz>,
        Emil Velikov <emil.l.velikov@...il.com>,
        Nick Desaulniers <ndesaulniers@...gle.com>
Cc:     letux-kernel@...nphoenux.org, "H. Peter Anvin" <hpa@...or.com>,
        linux-mips@...r.kernel.org, linux-kernel@...r.kernel.org,
        kernel@...a-handheld.com,
        "H. Nikolaus Schaller" <hns@...delico.com>
Subject: [PATCH 0/2] Regex fixes for mips and x86 cross-compile

Trying to run the x86 relocs tool on a BSD based HOSTCC (cross
compilation environment) leads to errors like

  VOFFSET arch/x86/boot/compressed/../voffset.h - due to: vmlinux
  CC      arch/x86/boot/compressed/misc.o - due to: arch/x86/boot/compressed/../voffset.h
  OBJCOPY arch/x86/boot/compressed/vmlinux.bin - due to: vmlinux
  RELOCS  arch/x86/boot/compressed/vmlinux.relocs - due to: vmlinux
empty (sub)expressionarch/x86/boot/compressed/Makefile:118: recipe for target 'arch/x86/boot/compressed/vmlinux.relocs' failed
make[3]: *** [arch/x86/boot/compressed/vmlinux.relocs] Error 1

and when cross compiling a MIPS kernel on a BSD based HOSTCC
we get errors like

  SYNC    include/config/auto.conf.cmd - due to: .config
egrep: empty (sub)expression
  UPD     include/config/kernel.release
  HOSTCC  scripts/dtc/dtc.o - due to target missing

It turns out that relocs.c on x86 uses patterns like

	"something(|_end)"

while MIPS uses egrep with

	(|MINOR_|PATCHLEVEL_)

In both cases it is not valid syntax or gives undefined results
according to POSIX 9.5.3 ERE Grammar

	https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

It seems to be silently accepted by the Linux regcmp() or egrep
implementation while a BSD host complains.

Such patterns can be replaced by a transformation like

	"(|p1|p2)" -> "(p1|p2)?"

Test Linux:

root@...ux:~# echo foo | egrep '^(|foo)$'
foo
root@...ux:~# echo fool | egrep '^(foo)?$'
root@...ux:~# echo fun | egrep '^(|foo)$'
root@...ux:~# echo f | egrep '^(|foo)$'
root@...ux:~# echo | egrep '^(|foo)$'

root@...ux:~# echo foo | egrep '^(foo)?$'
foo
root@...ux:~# echo fool | egrep '^(foo)?$'
root@...ux:~# echo fun | egrep '^(foo)?$'
root@...ux:~# echo f | egrep '^(foo)?$'
root@...ux:~# echo | egrep '^(foo)?$'

root@...ux:~# 

Test BSD:

iMac:master hns$ echo foo | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo fool | egrep '^(foo)?$'
egrep: empty (sub)expression
iMac:master hns$ echo fun | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo f | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo | egrep '^(|foo)$'
egrep: empty (sub)expression
iMac:master hns$ echo foo | egrep '^(foo)?$'
foo
iMac:master hns$ echo fool | egrep '^(foo)?$'
iMac:master hns$ echo fun | egrep '^(foo)?$'
iMac:master hns$ echo f | egrep '^(foo)?$'
iMac:master hns$ echo | egrep '^(foo)?$'

iMac:master hns$ 


H. Nikolaus Schaller (2):
  x86/tools/relocs: Fix non-POSIX regexp
  arch: mips: Fix non-POSIX regexp

 arch/mips/Makefile      | 2 +-
 arch/x86/tools/relocs.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ