From: Herbert Xu <herbert@gondor.apana.org.au>
To: Ayesha Shafique <ayeshashafique123@gmail.com>
Cc: dash@vger.kernel.org
Subject: Re: [PATCH] expand: Fix out-of-bounds syntax table access
Date: Wed, 11 Nov 2026 16:33:44 +0800 [thread overview]
Message-ID: <avQoaJdeFdDypoOU@gondor.apana.org.au> (raw)
In-Reply-To: <20260817202007.93924-1-ayeshashafique123@gmail.com>
On Mon, Aug 17, 2026 at 03:20:07PM -0500, Ayesha Shafique wrote:
> mbtodest passes a signed byte to chtodest. Bytes with the high bit set
> can therefore be negative. The syntax tables are based at SYNBASE so
> that signed character values can be used as indices. However, the
> is_type path did not apply this offset, causing chtodest and mbtodest
> to read before the array:
>
> $ printf 'v=\377\nw=$v\n' | src/dash
> AddressSanitizer: global-buffer-overflow in chtodest
>
> Apply SYNBASE to is_type, as is already done by the is_special macro.
>
> Fixes: c0c860df08c9 ("expand: Count multi-byte characters for VSLENGTH")
> Signed-off-by: Ayesha Shafique <ayeshashafique123@gmail.com>
> ---
>
> Hi,
>
> I found this while working on a research project, testing against
> commit 037bbdf ("Release 0.5.13.5"). Here is the relevant GDB and
> AddressSanitizer trace:
>
> $ printf 'v=\xff\nw=$v\n' > /tmp/s.sh
> $ gdb -q --args ./dash /tmp/s.sh
> Reading symbols from ./dash...
> (gdb) b expand.c:895
> Breakpoint 1 at 0x8c028: file expand.c, line 895.
> (gdb) run
> Starting program: /home/aysha/dash/src/dash /tmp/s.sh
>
> Breakpoint 1, chtodest (c=-1,
> syntax=0x55555562d680 <is_type> "",
> out=0x5555556bea42 <stackbase+98> "\377") at expand.c:895
> 895 {
> (gdb) info args
> c = -1
> syntax = 0x55555562d680 <is_type> ""
> out = 0x5555556bea42 <stackbase+98> "\377"
> (gdb) n
> 896 if (syntax[c] == CCTL)
> (gdb) p c
> $1 = -1
> (gdb) n
> =================================================================
> ERROR: AddressSanitizer: global-buffer-overflow on address
> 0x55555562d67f
> READ of size 1 at 0x55555562d67f thread T0
> #0 in chtodest /home/aysha/dash/src/expand.c:896
> #1 in mbtodest /home/aysha/dash/src/expand.c:918
> #2 in memtodest /home/aysha/dash/src/expand.c:996
> #3 in strtodest /home/aysha/dash/src/expand.c:1017
> #4 in varvalue /home/aysha/dash/src/expand.c:1140
> #5 in evalvar /home/aysha/dash/src/expand.c:811
> #6 in argstr /home/aysha/dash/src/expand.c:391
> #7 in expandarg /home/aysha/dash/src/expand.c:232
> 0x55555562d67f is located 1 bytes before global variable 'is_type'
> defined in 'syntax.c:285:12' (0x55555562d680) of size 257
> SUMMARY: AddressSanitizer: global-buffer-overflow
> /home/aysha/dash/src/expand.c:896 in chtodest
>
> This is my first patch to dash, so apologies for any mistakes I might
> have made. I'm happy to fix anything you point out.
>
> Thanks!
> Ayesha
>
> src/expand.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
next prev parent reply other threads:[~2026-11-11 8:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 20:20 [PATCH] expand: Fix out-of-bounds syntax table access Ayesha Shafique
2026-11-11 1:59 ` Anders Kaseorg
2026-11-11 8:33 ` Herbert Xu [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-11-07 14:37 Pádraig Brady
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=avQoaJdeFdDypoOU@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=ayeshashafique123@gmail.com \
--cc=dash@vger.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