Re: [PATCH v5 13/13] alpha: Use the common syscall table

[email protected]
Newsgroups org.kernel.vger.linux-s390
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] Incorrect `__NR_syscalls` calculation in `syscallhdr.sh` truncates the syscall table bounds check on Alpha, breaking all syscalls >= 472.
- [Low] The modified syscall build scripts use Bash-specific process substitution, which causes syntax errors and build failures on systems where /bin/sh is dash.
--

--- Patch [13]: [PATCH v5 13/13] alpha: Use the common syscall table ---
commit 8a4799a8727ec390bf08ab1390ac21a27d092616
Author: André Almeida <[email protected]>

    alpha: Use the common syscall table
    
    Remove some of the duplicated code by using the common syscall number
    table.

> diff --git a/arch/alpha/kernel/syscalls/Makefile b/arch/alpha/kernel/syscalls/Makefile
> index b265e4bc16c2e..18682418327bc 100644
> --- a/arch/alpha/kernel/syscalls/Makefile
> +++ b/arch/alpha/kernel/syscalls/Makefile
> @@ -7,12 +7,18 @@ $(shell mkdir -p $(uapi) $(kapi))
>  syscall := $(src)/syscall.tbl
>  syshdr := $(srctree)/scripts/syscallhdr.sh
>  systbl := $(srctree)/scripts/syscalltbl.sh
> +systbl_common := $(srctree)/scripts/syscall_common.tbl
> +abis := common,__clone3
>  
>  quiet_cmd_syshdr = SYSHDR  $@
> -      cmd_syshdr = $(CONFIG_SHELL) $(syshdr) --emit-nr $< $@
> +      cmd_syshdr = $(CONFIG_SHELL) $(syshdr) --emit-nr \
> +		   --common-tbl $(systbl_common) --common-offset 110 \
> +		   --abis $(abis) $< $@

[Severity: Critical]
Does this offset argument truncate the syscall table bounds check on Alpha?

When the common table is processed via scripts/syscallhdr.sh, the maximum
syscall number is stored before applying the offset:

scripts/syscallhdr.sh:gen_hdr() {
    ...
    while read nr abi name native compat; do
        max=$nr

        if [ -n "$offset_nr" ]; then
            nr=$((nr + offset_nr))
        fi
    ...
}

Because max is assigned the un-offset number, it resets to 471 when parsing
the common table, instead of reflecting Alpha's actual maximum (581). This
causes __NR_syscalls to be emitted as 472.

Consequently, does this cause the bounds check in arch/alpha/kernel/entry.S
(entSys) to reject all valid syscalls >= 472 with -ENOSYS? This would break
several valid syscalls when using the offset.

>  
>  quiet_cmd_systbl = SYSTBL  $@
> -      cmd_systbl = $(CONFIG_SHELL) $(systbl) $< $@
> +      cmd_systbl = $(CONFIG_SHELL) $(systbl) \
> +		   --common-tbl $(systbl_common) --common-offset 110 \
> +		   --abis $(abis) $< $@

[Severity: Low]
Do these modified build commands fail on systems where /bin/sh is dash?

Both scripts/syscallhdr.sh and scripts/syscalltbl.sh use a bash-specific
process substitution pattern:

scripts/syscallhdr.sh:gen_hdr() {
    ...
    done < <(grep -E "^[0-9A-Fa-fXx]+[[:space:]]+$abis" "$input")
}

scripts/syscalltbl.sh:gen_tbl() {
    ...
    done < <(grep -E "^[0-9]+[[:space:]]+$abis" "$input")
}

This syntax is a bash extension and results in syntax errors on strictly
POSIX-compliant shells like dash, causing the build to fail.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=13
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.