lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 18 Mar 2022 08:44:07 +0100
From:   Arnd Bergmann <arnd@...db.de>
To:     Chen Jiahao <chenjiahao16@...wei.com>
Cc:     Arnd Bergmann <arnd@...db.de>,
        "Eric W . Biederman" <ebiederm@...ssion.com>,
        Sam Ravnborg <sam@...nborg.org>,
        Stafford Horne <shorne@...il.com>,
        Dinh Nguyen <dinguyen@...nel.org>,
        linux-arch <linux-arch@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH -next] uaccess: fix __access_ok limit setup in compat mode

On Fri, Mar 18, 2022 at 8:11 AM Chen Jiahao <chenjiahao16@...wei.com> wrote:
>
> In __access_ok, TASK_SIZE_MAX is used to check if a memory access
> is in user address space, but some cases may get omitted in compat
> mode.
>
> For example, a 32-bit testcase calling pread64(fd, buf, -1, 1)
> and running in x86-64 kernel, the obviously illegal size "-1" will
> get ignored by __access_ok. Since from the kernel point of view,
> 32-bit userspace 0xffffffff is within the limit of 64-bit
> TASK_SIZE_MAX.
>
> Replacing the limit TASK_SIZE_MAX with TASK_SIZE in __access_ok
> will fix the problem above.

I don't see what problem this fixes, the choice of TASK_SIZE_MAX in
__access_ok() is intentional, as this means we can use a compile-time
constant as the limit, which produces better code.

Any user pointer between COMPAT_TASK_SIZE and TASK_SIZE_MAX is
not accessible by a user process but will not let user space access
any kernel data either, which is the point of the check.

In your example of using '-1' as the pointer, access_ok() returns true,
so the kernel can go on to perform an unchecked __get_user() on
__put_user() on 0xffffffffull, which causes page fault that is intercepted
by the ex_table fixup.

This should not result in any user visible difference, in both cases
user process will see a -EFAULT return code from its system call.
Are you able to come up with a test case that shows an observable
difference in behavior?

      Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ