Bug#904385: arm64: sigaltstack fails with MINSIGSTKSZ for 32-bit processes

2019-07-29 Thread Aurelien Jarno
control: notfixed -1 linux/4.18.20-1
control: found -1 4.19.37-6

On 2018-09-26 11:41, Steve McIntyre wrote:
> On Wed, Jul 25, 2018 at 04:25:03PM +0100, Steve McIntyre wrote:
> >On Mon, Jul 23, 2018 at 09:40:33PM +0200, Aurelien Jarno wrote:
> >>control: affects -1 glibc
> >>control: found linux/4.17.6-2
> >>
> >>On 2018-07-23 21:31, Aurelien Jarno wrote:
> >>> Package: src:linux
> >>> Version: 4.9.110-1
> >>> Severity: normal
> >>> 
> >>> Dear Maintainer,
> >>> 
> >>> The arm64 kernel allows one to run aarch32 processes on an aarch64
> >>> processor (if it has support for it), using the standard 32/64-bit
> >>> syscall compatibility. However this compat layer does not correctly
> >>> validate the arguments of the sigaltstack syscall.
> >>> 
> >>
> >>I forgot to say that the problem is reproducible with kernel 4.17.6.
> >
> >Fix proposed in https://lkml.org/lkml/2018/7/25/409 
> 
> At Will's suggestion, I've just tested that patchset locally and it
> definitely fixes this problem so I've added a Tested-by: for him.
> 

The fix is composed of two patches, and only the first one went to the
stable releases. Therefore both our oldstable and stable kernels used on
the build daemons are still buggy.

The following one is still missing in at least 4.9 and 4.19:

| commit 24951465cbd279f60b1fdc2421b3694405bcff42
| Author: Will Deacon 
| Date:   Wed Sep 5 15:34:43 2018 +0100
| 
| arm64: compat: Provide definition for COMPAT_SIGMINSTKSZ
| 
| arch/arm/ defines a SIGMINSTKSZ of 2k, so we should use the same value
| for compat tasks.
| 
| Cc: Arnd Bergmann 
| Cc: Dominik Brodowski 
| Cc: "Eric W. Biederman" 
| Cc: Andrew Morton 
| Cc: Al Viro 
| Cc: Oleg Nesterov 
| Reviewed-by: Dave Martin 
| Reported-by: Steve McIntyre 
| Tested-by: Steve McIntyre <93...@debian.org>
| Signed-off-by: Will Deacon 
| Signed-off-by: Catalin Marinas 

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



Bug#904385: arm64: sigaltstack fails with MINSIGSTKSZ for 32-bit processes

2018-09-26 Thread Steve McIntyre
On Wed, Jul 25, 2018 at 04:25:03PM +0100, Steve McIntyre wrote:
>On Mon, Jul 23, 2018 at 09:40:33PM +0200, Aurelien Jarno wrote:
>>control: affects -1 glibc
>>control: found linux/4.17.6-2
>>
>>On 2018-07-23 21:31, Aurelien Jarno wrote:
>>> Package: src:linux
>>> Version: 4.9.110-1
>>> Severity: normal
>>> 
>>> Dear Maintainer,
>>> 
>>> The arm64 kernel allows one to run aarch32 processes on an aarch64
>>> processor (if it has support for it), using the standard 32/64-bit
>>> syscall compatibility. However this compat layer does not correctly
>>> validate the arguments of the sigaltstack syscall.
>>> 
>>
>>I forgot to say that the problem is reproducible with kernel 4.17.6.
>
>Fix proposed in https://lkml.org/lkml/2018/7/25/409 

At Will's suggestion, I've just tested that patchset locally and it
definitely fixes this problem so I've added a Tested-by: for him.

-- 
Steve McIntyre, Cambridge, UK.st...@einval.com
There's no sensation to compare with this
Suspended animation, A state of bliss



Bug#904385: arm64: sigaltstack fails with MINSIGSTKSZ for 32-bit processes

2018-07-25 Thread Steve McIntyre
On Mon, Jul 23, 2018 at 09:40:33PM +0200, Aurelien Jarno wrote:
>control: affects -1 glibc
>control: found linux/4.17.6-2
>
>On 2018-07-23 21:31, Aurelien Jarno wrote:
>> Package: src:linux
>> Version: 4.9.110-1
>> Severity: normal
>> 
>> Dear Maintainer,
>> 
>> The arm64 kernel allows one to run aarch32 processes on an aarch64
>> processor (if it has support for it), using the standard 32/64-bit
>> syscall compatibility. However this compat layer does not correctly
>> validate the arguments of the sigaltstack syscall.
>> 
>
>I forgot to say that the problem is reproducible with kernel 4.17.6.

Fix proposed in https://lkml.org/lkml/2018/7/25/409 

-- 
Steve McIntyre, Cambridge, UK.st...@einval.com
You raise the blade, you make the change... You re-arrange me 'til I'm sane...



Bug#904385: arm64: sigaltstack fails with MINSIGSTKSZ for 32-bit processes

2018-07-23 Thread Aurelien Jarno
control: affects -1 glibc
control: found linux/4.17.6-2

On 2018-07-23 21:31, Aurelien Jarno wrote:
> Package: src:linux
> Version: 4.9.110-1
> Severity: normal
> 
> Dear Maintainer,
> 
> The arm64 kernel allows one to run aarch32 processes on an aarch64
> processor (if it has support for it), using the standard 32/64-bit
> syscall compatibility. However this compat layer does not correctly
> validate the arguments of the sigaltstack syscall.
> 

I forgot to say that the problem is reproducible with kernel 4.17.6.

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



Bug#904385: arm64: sigaltstack fails with MINSIGSTKSZ for 32-bit processes

2018-07-23 Thread Aurelien Jarno
Package: src:linux
Version: 4.9.110-1
Severity: normal

Dear Maintainer,

The arm64 kernel allows one to run aarch32 processes on an aarch64
processor (if it has support for it), using the standard 32/64-bit
syscall compatibility. However this compat layer does not correctly
validate the arguments of the sigaltstack syscall.

arch/arm64/include/uapi/asm/signal.h defines SIGSTKSZ and MINSIGSTKSZ
as follow:
| #define MINSIGSTKSZ 5120
| #define SIGSTKSZ16384

arch/arm/include/uapi/asm/signal.h defines SIGSTKSZ and MINSIGSTKSZ as
follow:
| #define MINSIGSTKSZ 2048
| #define SIGSTKSZ8192

It seems to be the only 32/64-bit architecture for which those constants
differ. The do_compat_sigaltstack function in kernel/signal.c passes
ss.ss_size to do_sigaltstack unchanged, and the latter validates it
against the native MINSIGSTKSZ.

This causes the glibc test nptl/tst-signal6 to fail, but I guess it can
also affects other packages at runtime. This is also reproducible with
the following simple testcase:

| #include 
| #include 
| #include 
| 
| int main(int argc, char *argv[])
| {
| stack_t ss;
| 
| ss.ss_sp = malloc(MINSIGSTKSZ);
| if (ss.ss_sp == NULL) {
| perror("malloc");
| exit(EXIT_FAILURE);
| }
| 
| ss.ss_size = MINSIGSTKSZ;
| ss.ss_flags = 0;
| if (sigaltstack(, NULL)) {
| perror("sigaltstack");
| exit(EXIT_FAILURE);
| }
| 
| return 0;
| }

| $ ./sigaltstack 
| sigaltstack: Cannot allocate memory

| $ strace ./sigaltstack
| execve("./sigaltstack", ["./sigaltstack"], [/* 23 vars */]) = 0
| strace: [ Process PID=694 runs in 32 bit mode. ]
| uname({sysname="Linux", nodename="arm64", ...}) = 0
| brk(NULL)   = 0x35d000
| brk(0x35dd00)   = 0x35dd00
| set_tls(0x35d4c0, 0x78f7c, 0, 0x24, 0x78f6c) = 0
| readlink("/proc/self/exe", "/home/aurel32/sigaltstack", 4096) = 25
| brk(0x37ed00)   = 0x37ed00
| brk(0x37f000)   = 0x37f000
| access("/etc/ld.so.nohwcap", F_OK)  = -1 ENOENT (No such file or 
directory)
| sigaltstack({ss_sp=0x35e8b0, ss_flags=0x800 /* SS_??? */, ss_size=67191}, 
NULL) = -1 ENOMEM (Cannot allocate memory)
| dup(2)  = 3
| fcntl64(3, F_GETFL) = 0x20002 (flags O_RDWR|0x2)
| fstat64(3, 0xff96bf28)  = 0
| write(3, "sigaltstack: Cannot allocate mem"..., 36sigaltstack: Cannot 
allocate memory
| ) = 36
| close(3)= 0
| exit_group(1)   = ?
| +++ exited with 1 +++

-- System Information:
Debian Release: 9.5
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: arm64 (aarch64)

Kernel: Linux 4.9.0-7-arm64 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), 
LANGUAGE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)