Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1176369ybj; Fri, 20 Sep 2019 06:23:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwj1Ye0fsU1BSH4wzkfty1lbF+gbs7zj6ILAdxZjWsQtXhJVLY8elzXGYCRcVuZK0/P0/qc X-Received: by 2002:a50:99d5:: with SMTP id n21mr22011509edb.50.1568985821015; Fri, 20 Sep 2019 06:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568985821; cv=none; d=google.com; s=arc-20160816; b=KF3NBgyGZugHbEp20sXtnFAPWazhvjs2hn0TP6NWu4tDaAMdgjH1nPfT7X2X/kZUJy bEIs2c8jdBcrw6Uans2Wd3Vo0Jcr5ER062hYvCDb+rd5Q4fIA7xXeYNciFOE8e9Sv1rQ 9DMJR8fwVtvHOb+M9RSdclSH7km+7NodTRiUwvTs54wiNVSi+dsqnyAJaS7E93I5LFZX 1FdIUvpkYeZ/siNKszXCBoPLeUDhZtWzRFXbQKnSnFPZ49mQR+qUoGVo0BSfw178qNpz 3wyax2PhyIKkV1XncFGjWidbNc2+bdft8tFDvcxM3mre1vxoO+PzUmHtbAeFgMRhDiY2 RQMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4ckFZxFEvoWzRIB4ShK6PkS2E8Byy6XgzR/8RNflP8o=; b=QyMwdf5o6eaGvY84+ww8DyIdXzUjg6Pbo0CMX94r0m9s+Dte52ilQxjrG3ov4xZAg+ LO8oZI+7IJO1+yAKPdBQ2z7Ejki1TNj/WfJDh8Tly7QmG9HWynTROso63cMsQGd5FvCe 3ZwXcskJ5d3bW6AL4C7M46CYyHPnWbAL1kD1gpSx/J/O4l3LqoDvRVkzJsSwa7+B/ZMQ 5Vqgl/aBtWUweHSzXt6dYFU9wJy49B2tuMQirnDHhppUDvKFUCzAIXa+zOOFE8L+5Wzd fJKgPyHrcZPr42DabuM6AMhdBtHv8zbN704MKOPVwYsssPDEDiAbKE6NhtHTcCDFtP2e eHSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CIUgrrmI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b15si1272297edm.395.2019.09.20.06.23.16; Fri, 20 Sep 2019 06:23:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CIUgrrmI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406463AbfISWR2 (ORCPT + 99 others); Thu, 19 Sep 2019 18:17:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:58560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392403AbfISWRZ (ORCPT ); Thu, 19 Sep 2019 18:17:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 13FB9217D6; Thu, 19 Sep 2019 22:17:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568931444; bh=Yl59bSCmjGQO8ga6KfcvRC+PKgjgMXblO8qVnUO1YgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CIUgrrmIKjBa24Ls/FmheSALLE7QUFmxgEq+YEN5mGp746l6j7Dgoxf417CZHxb1T zT2/xRz9La4xM944I++MHvDoDJRlFkC9pVHti5MwEHn3aLBKT9yYmbfyj2W63Pjc73 kG5ksLvWOiRII9OrmXJ9xzszahQXwvJgihV97w1A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Randy Dunlap , "Peter Zijlstra (Intel)" , Josh Poimboeuf , Thomas Gleixner , broonie@kernel.org, sfr@canb.auug.org.au, akpm@linux-foundation.org, mhocko@suse.cz, Sasha Levin Subject: [PATCH 4.14 49/59] x86/uaccess: Dont leak the AC flags into __get_user() argument evaluation Date: Fri, 20 Sep 2019 00:04:04 +0200 Message-Id: <20190919214807.665886883@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919214755.852282682@linuxfoundation.org> References: <20190919214755.852282682@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra [ Upstream commit 9b8bd476e78e89c9ea26c3b435ad0201c3d7dbf5 ] Identical to __put_user(); the __get_user() argument evalution will too leak UBSAN crud into the __uaccess_begin() / __uaccess_end() region. While uncommon this was observed to happen for: drivers/xen/gntdev.c: if (__get_user(old_status, batch->status[i])) where UBSAN added array bound checking. This complements commit: 6ae865615fc4 ("x86/uaccess: Dont leak the AC flag into __put_user() argument evaluation") Tested-by Sedat Dilek Reported-by: Randy Dunlap Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Josh Poimboeuf Reviewed-by: Thomas Gleixner Cc: broonie@kernel.org Cc: sfr@canb.auug.org.au Cc: akpm@linux-foundation.org Cc: Randy Dunlap Cc: mhocko@suse.cz Cc: Josh Poimboeuf Link: https://lkml.kernel.org/r/20190829082445.GM2369@hirez.programming.kicks-ass.net Signed-off-by: Sasha Levin --- arch/x86/include/asm/uaccess.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index 4111edb3188e2..9718303410614 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -451,8 +451,10 @@ do { \ ({ \ int __gu_err; \ __inttype(*(ptr)) __gu_val; \ + __typeof__(ptr) __gu_ptr = (ptr); \ + __typeof__(size) __gu_size = (size); \ __uaccess_begin_nospec(); \ - __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \ + __get_user_size(__gu_val, __gu_ptr, __gu_size, __gu_err, -EFAULT); \ __uaccess_end(); \ (x) = (__force __typeof__(*(ptr)))__gu_val; \ __builtin_expect(__gu_err, 0); \ -- 2.20.1