Received: by 10.223.164.221 with SMTP id h29csp1313366wrb; Wed, 1 Nov 2017 14:14:43 -0700 (PDT) X-Google-Smtp-Source: ABhQp+T+eh9RGMicl9sonix5F+BV+5ZXGxgQQubISvWXk/CBkkGJEdvf5WqPOtynGPQXGZrXOzAE X-Received: by 10.84.192.131 with SMTP id c3mr879584pld.435.1509570883459; Wed, 01 Nov 2017 14:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509570883; cv=none; d=google.com; s=arc-20160816; b=uZRks6ogdcsGp2YJeZ5K/NGpVNcX/oKMxoCUdAAdkY8GpY9Qs1/cpK7SDeK6SvD2DK zlpl6oTeK9tWpU3Kc1yKyvb/mZirKDENN4B2ubKxUs2+Ks4aPWvDqGmtcxwoplfTRY+m 4AbTL4nkkEU6W1K7oTmSZaNteFhqnHwe8Tvj7ZxxJUOi9YWQNwSepKFnltygjAF8cROt eGv8HZhyDfHhNuUlZvyqyQOIfj1MJTuSx/s5qqE7RTHT36aaKq3ZYIR0oNdJ4E0hgJPg w1AaYVo/FChMVvcQVmtqDqO9PkptMh567/R9G1UaKSb0j5MYBhx65cae+bCnymLllZjq R87g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=SxHbU7+d9seK2j7Cq+zkFBCF49mlMaZT6/BtwbWl9Eg=; b=vtdrf1CuMeNbr+ALaVxZ37n0OmtlyH5FHX6XmcpSyxCrr/j1uPqCDNsy/FHhCclX/p lD5a5dQrjJOYjTuQfB1E2gxZGq6RR24RulDRdwJEy9yNQrkY7CxIRWPDIYuDGojBeID7 Dej54VbP3ee+Xd09OJwdLSlfEfC+l7AZGkXQMFZMuXw/dj7mdFDevHZ/uz/EPxJJ7YHs YZNdfDSOW9+QFM5bqDb2zSTZqc1yOF9k745SBsNJTamylaOatzhvBl4GyLr4/Hz5Qxw3 gwm4ymZUSwg3popfOChHwSVD35ImnOkkNrG5NdUF9cULEZfIqRkKY0d0P5j8c/ydNc5v MM3g== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c80si1887619pfb.238.2017.11.01.14.14.29; Wed, 01 Nov 2017 14:14:43 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933380AbdKAVNu (ORCPT + 99 others); Wed, 1 Nov 2017 17:13:50 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:56125 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933191AbdKAVNt (ORCPT ); Wed, 1 Nov 2017 17:13:49 -0400 Received: by mail-oi0-f65.google.com with SMTP id g125so6523282oib.12 for ; Wed, 01 Nov 2017 14:13:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=SxHbU7+d9seK2j7Cq+zkFBCF49mlMaZT6/BtwbWl9Eg=; b=AB8KuwJ5LxcHB48xnqLgXMHC7uUVOcFZwCVwsNToCYgteuqsqmG0KVx1zJtfLdbp/l IVZmMFiq9TzSEXUroehi+0qmHOnUO4ULh5FdRENtXmN3nleMa5Kj6YPWsPdQE3Fi0Lmw aO0rimDKLBxVvNyJX2xFO9fJ9GOH45T1WhG3SeJvvb+BMsrSA5BcyiWmM5aDa3suO7T/ GSTwJKN3QGOsaEHfFT9Dbnq495DcT7rKinsI2Gg/0OLTsawuMVLdGSe/SYPXCefax9lY LD8d2xUuZOK9qwAwVWQ+6M4vbNY7dFrp5DjebbZ4U1OW1KVONncKkk8b06KdPkJrsFoM JgIA== X-Gm-Message-State: AMCzsaU+v0gAw39JCUA5MAP8L7J1NYOjqUhH99T1JiUEShX5rpevMEki nUi85fnPrZyZRUqszEjuYRsMDA== X-Received: by 10.202.223.10 with SMTP id w10mr633858oig.299.1509570828552; Wed, 01 Nov 2017 14:13:48 -0700 (PDT) Received: from ?IPv6:2601:602:9802:a8dc::e174? ([2601:602:9802:a8dc::e174]) by smtp.gmail.com with ESMTPSA id w3sm719470ota.38.2017.11.01.14.13.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Nov 2017 14:13:47 -0700 (PDT) Subject: Re: [RFC PATCH 0/2] arm64: optional paranoid __{get,put}_user checks To: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Catalin Marinas , Kees Cook , Will Deacon References: <20171026090942.7041-1-mark.rutland@arm.com> <77c80381-cf68-aa1a-9112-e057c068eeb6@redhat.com> <20171101120555.yvb65g3wgtxskfh3@lakrids.cambridge.arm.com> From: Laura Abbott Message-ID: <0f2d5f89-2939-06ec-9b59-b19f828d8968@redhat.com> Date: Wed, 1 Nov 2017 14:13:45 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20171101120555.yvb65g3wgtxskfh3@lakrids.cambridge.arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/01/2017 05:05 AM, Mark Rutland wrote: > On Tue, Oct 31, 2017 at 04:56:39PM -0700, Laura Abbott wrote: >> On 10/26/2017 02:09 AM, Mark Rutland wrote: >>> In Prague, Kees mentioned that it would be nice to have a mechanism to >>> catch bad __{get,put}_user uses, such as the recent CVE-2017-5123 [1,2] >>> issue with unsafe_put_user() in waitid(). >>> >>> These patches allow an optional access_ok() check to be dropped in >>> arm64's __{get,put}_user() primitives. These will then BUG() if a bad >>> user pointer is passed (which should only happen in the absence of an >>> earlier access_ok() check). > >> Turning on the option fails as soon as we hit userspace. On my buildroot >> based environment I get the help text for ld.so (????) and then a message >> about attempting to kill init. > > Ouch. Thanks for the report, and sorry about this. > > The problem is that I evaluate the ptr argument twice in > __{get,put}_user(), and this may have side effects. > > e.g. when the ELF loader does things like: > > __put_user((elf_addr_t)p, sp++) > > ... we increment sp twice, and write to the wrong user address, leaving > sp corrupt. > > I have an additional patch [1] to fix this, which is in my > arm64/access-ok branch [2]. > > Thanks, > Mark. > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/commit/?h=arm64/access-ok&id=ebb7ff83eb53b8810395d5cf48712a4ae6d678543 > [2] https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/log/?h=arm64/access-ok > Thanks, the updated patch works. I wrote an LKDTM test to verify the expected behavior (__{get,put}_user panic whereas {get,put}_user do not). You're welcome to add Tested-by or I can wait for v2. Thanks, Laura From 1582865361633402524@xxx Wed Nov 01 12:07:21 +0000 2017 X-GM-THRID: 1582310663202567364 X-Gmail-Labels: Inbox,Category Forums