From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA3BEC43464 for ; Sat, 19 Sep 2020 00:17:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD61821D20 for ; Sat, 19 Sep 2020 00:17:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726022AbgISARY (ORCPT ); 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.