Skip to content

PHP CLI segfault when INI file is not readable #7883

Description

@milo

Description

Redirected there by oerdnj/deb.sury.org#1703

When mods-available INI file, e.g. /etc/php/8.1/mods-available/opcache.ini, has no sufficient permission to read by user, PHP CLI ends by segmentation fault.

php8.1[5509]: segfault at 0 ip 00007f4a768c97e4 sp 00007ffdae393780 error 4 in libc-2.28.so[7f4a7687c000+148000]

I've removed INI file permission by mistake and had no glue what happend to CLI scripts.

Steps to reproduce the behavior:

# Probably not needed, this is default after installation
chown root:root /etc/php/8.1/mods-available/opcache.ini

# Remove read permission for others
chmod 640 /etc/php/8.1/mods-available/opcache.ini

# Run php as non-root user
su username -c php8.1

Segmentation fault

Expected behavior
Not segafult. Probably, extension should not be loaded, or emit warning.

Distribution

  • Linux alfa-01 4.19.0-18-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64 GNU/Linux
  • OS: Debian 10.11
  • Architecture: amd64
  • Repository: deb https://packages.sury.org/php/ buster main

Last lines of strace:

stat("/etc/php/8.1/cli/conf.d/10-opcache.ini", {st_mode=S_IFREG|0640, st_size=79, ...}) = 0
openat(AT_FDCWD, "/etc/php/8.1/cli/conf.d/10-opcache.ini", O_RDONLY) = -1 EACCES (Permission denied)
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
+++ killed by SIGSEGV +++

PHP Version

PHP 8.1.1

Operating System

Debian 10.11

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions