Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1582366pxk; Fri, 18 Sep 2020 17:18:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxE6+cnK06HELkzLqvjSlyyJR7U3z2OEGPpn/W5Oh4QULZGo15DIjlQsEvvGNKxpF3/sK34 X-Received: by 2002:a17:906:c411:: with SMTP id u17mr37823355ejz.319.1600474737949; Fri, 18 Sep 2020 17:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600474737; cv=none; d=google.com; s=arc-20160816; b=uxjpRDUjZC/PPl8siDPA2bzBe7cI42rYyTH3sRi1CZW8zxCxnNPTs9n36S0gRg3RFn DngQMnopcJDB4uOHnxZCALe1cH+75WizHlnOeOEQcSjhIGWIXooRn2t6zeKai9O6J6FY ovLmpKQF/hGptfZi+OdwB/A7oTm3JefYXeQXhQ76/OJ5J9hKFSxVsfTVmasYbFY8ktHp 2DXvyGr0iR/2U2VBnqPHBlLv1gvNQLo9opz7z48hbnz1NeUsXk4z6yBoz8p9pBYZJT7F ZXC9ALrFBLaf+SdNrvUIE8YlW6U1MC8EVZi6w2fAnKlH1PwCD041ZNENLvuplxgIv/HS eemw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=b/v2nYfBumTxb9gDGBv3XDsHSkJN/fKE2B3XfNwVBfI=; b=dCKx2zwuVn1DisYOsQnu9blWETeHVYt/vjXPDJAQSjFs6PeabgI+CrJ3Y59BqIgC+b HNhDPHa8caC6vN2DoCp8OXj2N8NroqaidfnLfj/9UO1zC/lBfdMb53n4q3S0fe/R9aWF mFx9wD/YoIQ1/lSW4hX2LI10Lxl44KcTb0/ka6AJeEX3/McUwGmxbmfvm3zEVjAwFzYb APUd/P9OyoZrVPtSkV+rdXY/6o7Hbeqb1fY0rfmAw+Xn8MLpQrdDZ0EPA9RTZQYultCc 7SiGcDuy45+PAnjgUi3nYfGJSZLrSF15qJ6ygF6DPxvl0Cm6a/1OrOWzPrVPD5yLbRwH U2vw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z3si3219689ede.201.2020.09.18.17.18.33; Fri, 18 Sep 2020 17:18:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726126AbgISARY (ORCPT + 99 others); Fri, 18 Sep 2020 20:17:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbgISARY (ORCPT ); Fri, 18 Sep 2020 20:17:24 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44AE2C0613CE for ; Fri, 18 Sep 2020 17:17:24 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kJQZ0-001MQx-FB; Sat, 19 Sep 2020 00:17:14 +0000 Date: Sat, 19 Sep 2020 01:17:14 +0100 From: Al Viro To: Andy Lutomirski Cc: syzbot , Aleksa Sarai , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , LKML , Ingo Molnar , Peter Zijlstra , syzkaller-bugs@googlegroups.com, Thomas Gleixner , X86 ML Subject: Re: WARNING in ex_handler_uaccess Message-ID: <20200919001714.GC3421308@ZenIV.linux.org.uk> References: <000000000000762dee05af9ccd01@google.com> <20200918235528.GB3421308@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 18, 2020 at 05:07:43PM -0700, Andy Lutomirski wrote: > On Fri, Sep 18, 2020 at 4:55 PM Al Viro 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.