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]
Message-ID: <bc5d889c-17f0-dcb8-d174-f21b321cf85b@rasmusvillemoes.dk>
Date:   Mon, 21 Sep 2020 12:22:19 +0200
From:   Rasmus Villemoes <linux@...musvillemoes.dk>
To:     Al Viro <viro@...iv.linux.org.uk>,
        Andy Lutomirski <luto@...nel.org>
Cc:     syzbot <syzbot+ea3a78a71705faf41d77@...kaller.appspotmail.com>,
        Aleksa Sarai <cyphar@...har.com>,
        Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        LKML <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        syzkaller-bugs@...glegroups.com,
        Thomas Gleixner <tglx@...utronix.de>, X86 ML <x86@...nel.org>
Subject: Re: WARNING in ex_handler_uaccess

On 19/09/2020 02.17, Al Viro wrote:
> On Fri, Sep 18, 2020 at 05:07:43PM -0700, Andy Lutomirski wrote:
>> On Fri, Sep 18, 2020 at 4:55 PM Al Viro <viro@...iv.linux.org.uk> wrote:
>>>
>>> On Fri, Sep 18, 2020 at 04:31:33PM -0700, Andy Lutomirski wrote:
>>>
>>>> check_zeroed_user() looks buggy.  It does:
>>>>
>>>>        if (!user_access_begin(from, size))
>>>>                return -EFAULT;
>>>>
>>>>        unsafe_get_user(val, (unsigned long __user *) from, err_fault);
>>>>
>>>> This is wrong if size < sizeof(unsigned long) -- you read outside the
>>>> area you verified using user_access_begin().
>>>
>>> Read the code immediately prior to that.  from will be word-aligned,
>>> and size will be extended accordingly.  If the area acceptable for
>>> user_access_begin() ends *NOT* on a word boundary, you have a problem
>>> and I would strongly recommend to seek professional help.
>>>
>>> All reads in that thing are word-aligned and word-sized.  So I very
>>> much doubt that your analysis is correct.
>>
>> Maybe -ETOOTIRED, but I seriously question the math in here.  Suppose
>> from == (unsigned long *)1 and size == 1.  Then align is 1, and we do:
>>
>> from -= align;
>> size += align;
>>
>> So now from = 0 and size = 2.  Now we do user_access_begin(0, 2) and
>> then immediately read 4 or 8 bytes.  No good.
> 
> Could you explain what kind of insane hardware manages to do #PF-related
> checks (including SMAP, whatever) with *sub*WORD* granularity?
> 
> If it's OK with 16bit read from word-aligned address, but barfs on 64bit
> one...  I want to know what the hell had its authors been smoking.
> 

So, not sure how the above got triggered, but I notice there might be an
edge case in check_zeroed_user():

	from -= align;
	size += align;

	if (!user_read_access_begin(from, size))
		return -EFAULT;

	unsafe_get_user(val, (unsigned long __user *) from, err_fault);


Suppose size is (size_t)-3 and align is 3. What's the convention for
access_ok(whatever, 0)? Is that equivalent to access_ok(whatever, 1), or
is it always true (or $ARCH-dependent)?

But, AFAICT, no current caller of check_zeroed_user can end up passing
in a size that can overflow to 0. E.g. for the case at hand, size cannot
be more than SIZE_MAX-24.

Rasmus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ