Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "André Almeida" <andrealmeid@igalia.com>
Cc: "Christian Borntraeger" <borntraeger@linux.ibm.vom>,
	linux-s390@vger.kernel.org,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>
Subject: Re: [PATCH v5 10/13] syscalls: Add an option for offsetting the common table
Date: Wed, 12 Aug 2026 17:56:55 +0000	[thread overview]
Message-ID: <20260812175656.1BE8D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812-tonyk-syscall_table-v5-10-3d383927c609@igalia.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The __NR_syscalls macro is calculated incorrectly when --common-offset is used, leading to a severely truncated syscall table bound.
- [Low] Dead and potentially dangerous code block referencing an undefined `offset` variable in `syscalltbl.sh` due to a copy-paste error.
- [Low] Inconsistent indentation in `syscalltbl.sh` using spaces instead of tabs.
--

--- Patch [10]: [PATCH v5 10/13] syscalls: Add an option for offsetting the common table ---
commit ca05bec6578b785868c677c2b401096b6deb225e
Author: André Almeida <andrealmeid@igalia.com>

syscalls: Add an option for offsetting the common table

This commit adds a new --common-offset option to the syscall header and table
generation scripts. It allows shifting the syscall numbers for a common table
by a given value, facilitating reuse for architectures like alpha.

> diff --git a/scripts/syscallhdr.sh b/scripts/syscallhdr.sh
> index 54e09d3e686c4..ce6819111c27d 100755
> --- a/scripts/syscallhdr.sh
> +++ b/scripts/syscallhdr.sh

[ ... ]

> @@ -98,18 +103,24 @@ emit_end_guard() {
>  }
>  
>  max=0
> -# gen_hdr(infile)
> +# gen_hdr(infile, offset_nr)
>  gen_hdr() {
>  	input=$1
> +	offset_nr=$2
>  
>  	while read nr abi name native compat; do
>  
>  		max=$nr
>  
> +		if [ -n "$offset_nr" ]; then
> +			nr=$((nr + offset_nr))
> +		fi

[Severity: High]
Will max be assigned the un-offset syscall number before the offset is
applied?

If max is calculated before the addition, the ultimately emitted __NR_syscalls
macro could be smaller than the highest offsetted syscall number. Architectures
using this to size their syscall tables or bound-check userspace calls might
reject valid syscalls.

> +
>  		if [ -n "$offset" ]; then
>  			nr="($offset + $nr)"
>  		fi
>  

[ ... ]

> diff --git a/scripts/syscalltbl.sh b/scripts/syscalltbl.sh
> index 91c135143b22f..aea00834dd5ab 100755
> --- a/scripts/syscalltbl.sh
> +++ b/scripts/syscalltbl.sh

[ ... ]

> @@ -59,12 +64,21 @@ outfile="$2"
>  
>  nxt=0
>  
> -# gen_tbl(infile)
> +# gen_tbl(infile, offset_nr)
>  gen_tbl() {
>  	input=$1
> +	offset_nr=$2
>  
>  	while read nr abi name native compat noreturn; do
>  
> +                if [ -n "$offset_nr" ]; then
> +                        nr=$((nr + offset_nr))
> +                fi

[Severity: Low]
This isn't a bug, but it looks like these lines are indented with spaces
instead of tabs. The surrounding script appears to use tabs.

> +
> +		if [ -n "$offset" ]; then
> +			nr="($offset + $nr)"
> +		fi

[Severity: Low]
Is the offset variable defined in syscalltbl.sh?

It looks like the --offset argument is parsed in syscallhdr.sh but not in this
script. If an environment variable named offset happens to be set in the build
shell, could this cause a bash syntax error when injected into the arithmetic
context?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260812-tonyk-syscall_table-v5-0-3d383927c609@igalia.com?part=10

  reply	other threads:[~2026-08-12 17:56 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 17:38 [PATCH v5 00/13] syscalls: Add a shared table for all archs André Almeida
2026-08-12 17:38 ` [PATCH v5 01/13] syscalls: Make --abis parsing more robust André Almeida
2026-08-12 17:50   ` sashiko-bot
2026-08-12 17:38 ` [PATCH v5 02/13] syscalls: Create unified partial table for all archs André Almeida
2026-08-12 17:49   ` sashiko-bot
2026-08-12 17:38 ` [PATCH v5 03/13] scripts/syscall.tbl: Use the common table André Almeida
2026-08-12 17:53   ` sashiko-bot
2026-08-12 17:38 ` [PATCH v5 04/13] arm: Use the common syscall table André Almeida
2026-08-12 18:10   ` sashiko-bot
2026-08-12 17:38 ` [PATCH v5 05/13] s390: " André Almeida
2026-08-12 17:50   ` sashiko-bot
2026-08-12 17:38 ` [PATCH v5 06/13] sparc: " André Almeida
2026-08-12 17:48   ` sashiko-bot
2026-08-12 17:38 ` [PATCH v5 07/13] mips: Remove duplicated syscallnr.sh André Almeida
2026-08-12 17:48   ` sashiko-bot
2026-08-12 17:38 ` [PATCH v5 08/13] mips: Get rid of custom mips ABIs for syscall tables André Almeida
2026-08-12 17:49   ` sashiko-bot
2026-08-12 17:38 ` [PATCH v5 09/13] mips: Use the common syscall table André Almeida
2026-08-12 17:53   ` sashiko-bot
2026-08-12 17:38 ` [PATCH v5 10/13] syscalls: Add an option for offsetting the common table André Almeida
2026-08-12 17:56   ` sashiko-bot [this message]
2026-08-12 17:38 ` [PATCH v5 11/13] alpha: Define entry point for set_mempolicy_home_node syscall André Almeida
2026-08-12 17:57   ` sashiko-bot
2026-08-12 17:38 ` [PATCH v5 12/13] alpha: Remove alpha_ prefix from custom syscall entries André Almeida
2026-08-12 17:58   ` sashiko-bot
2026-08-12 17:38 ` [PATCH v5 13/13] alpha: Use the common syscall table André Almeida
2026-08-12 18:01   ` sashiko-bot

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=20260812175656.1BE8D1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=andrealmeid@igalia.com \
    --cc=borntraeger@linux.ibm.vom \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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