Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1578655pxk; Fri, 18 Sep 2020 17:10:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvV3rHX3f7uATglGd+CNs8f8mngCbrY9tT0hwR0NomtWGf0fraWI4Miu3rG3OuNg6bDBCi X-Received: by 2002:aa7:d1ce:: with SMTP id g14mr41616212edp.153.1600474241845; Fri, 18 Sep 2020 17:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600474241; cv=none; d=google.com; s=arc-20160816; b=g1ly1ZU6zQmTxXBGFvc1Z3cotPIiWUJDcI8HAIQp8c6MXE+ckNY5I1Ol3fM4EhcS1Y BIrDvJiD8HGiYG3Dcn2gC9s2l/Pogv8mJseuvx4SzHsXEUzmA7TC6MmD1V0hFtTCr18B Kx8bPvN/fZ8MA9DHy6pjikr+bKck7HtgmX+OXjzerq14oN7PBFNRLomwH7Okm4hRJCf2 m6DY2hActvXC670KF1qqMZrHyskdHGrRjKlJrreu7yqrhrSAZr2cuoCo5TVbFHKJuW39 cx0ToizDzguGA2c6JbybCQcUa5lCG+shcQ/rJ4KSki9sZXkc+Z+L8+d/CNMDlQJ9Wp8t MoBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9NilPH8pYX5BqCF7j5IBif41NzLHOxKSBVtEDdMMCrQ=; b=ZAJrKs3INx/ChsuvwA5IQtAsHV8xTCBRpglYDbF+3gEsgyzLeV3w2uy5CwwFpaH3VQ N9fL0FbvyXLnCXye5ES5+H1tPAS0ntLEBMn9v21425Lzl0WiC0mflFxl0e03vR5m8ynA xDg1s0JBDWJL3qRIzQ0a5i4VTU/IXx9zxul6O1LJDFBrmpwSq7OozLMDt26qzedvIzYc FF/tvPMyBf8B5ZqcqIHDsEo453SWI/7Ceh0tMULXhYXN/BcPklZkwgRQ72zt+CUO/O03 UpiajerLNXjNwZpMnvhNrdGfV3Flv2g4sEvvQEWY/7Xiwhg9IyTn1CgFqUp/J3ZzCTQ6 rFWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k+lwYjdy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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.10.18; Fri, 18 Sep 2020 17:10:41 -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; dkim=pass header.i=@kernel.org header.s=default header.b=k+lwYjdy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726119AbgISAH5 (ORCPT + 99 others); Fri, 18 Sep 2020 20:07:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:50750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726009AbgISAH4 (ORCPT ); Fri, 18 Sep 2020 20:07:56 -0400 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1CDCD2311D for ; Sat, 19 Sep 2020 00:07:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600474076; bh=IFhPMAJb6PNwWq9NoYxwMsTqQBwaA1aOWnx3onz4Ync=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=k+lwYjdyq1o6wiXh6Tb/eb11uEUB56b9QlJW7D+aKDaltQAJszCNrbhS46GePFaCQ P2CvhEEkyPJ4pnprDaxH9BgkxF9H1SgFdfewKCAWbcU5xG5rROdMiqagCv7UKTJ36x IW3jt2GvCotT2/XLlDCmK2iwhKlutsiLRzcxfjPM= Received: by mail-wm1-f51.google.com with SMTP id l15so7677429wmh.1 for ; Fri, 18 Sep 2020 17:07:56 -0700 (PDT) X-Gm-Message-State: AOAM531jYfjW3ZoJUcfTtsYEOWXwszvTTiqlj5WiP+xu79QKmgw7Cl8B dI4usiwjaHaQc6Wc/vGDoFzDNBaiOpMhLz5cDfxo5A== X-Received: by 2002:a1c:7e15:: with SMTP id z21mr17750393wmc.21.1600474074629; Fri, 18 Sep 2020 17:07:54 -0700 (PDT) MIME-Version: 1.0 References: <000000000000762dee05af9ccd01@google.com> <20200918235528.GB3421308@ZenIV.linux.org.uk> In-Reply-To: <20200918235528.GB3421308@ZenIV.linux.org.uk> From: Andy Lutomirski Date: Fri, 18 Sep 2020 17:07:43 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: WARNING in ex_handler_uaccess To: Al Viro Cc: Andy Lutomirski , syzbot , Aleksa Sarai , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , LKML , Ingo Molnar , Peter Zijlstra , syzkaller-bugs@googlegroups.com, Thomas Gleixner , X86 ML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. --Andy