Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp337239ybc; Tue, 19 Nov 2019 02:09:43 -0800 (PST) X-Google-Smtp-Source: APXvYqxJb/OroEcl3yy0BcsoufqnExiR0INSgnTHUtHyn6zFGBd8vN0wZYbGPr/6cqtFaqP5/UHm X-Received: by 2002:a1c:7f44:: with SMTP id a65mr4502797wmd.19.1574158183711; Tue, 19 Nov 2019 02:09:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574158183; cv=none; d=google.com; s=arc-20160816; b=FBsXpe16THqQ8gupS/jcY81xyYo7k42S7l7cQ4J1F6stCCinFIZbcQV9s68KhPGvRs 5ZBpsiZVEN5DuYVDPVR4+EqtMkyvGjhtT9GZFjqkbD0SbVS2obaN2aCyPkytL/pHiMJw W3YQftoQqqlBlWZkE3xaAA2ZfS/UUi/HSQQQKSLX2lcz1Oxir3hwTqYKtHM0sxduA9ai CDsPlIAGVZjl+v3EZZyJk8RPYpPARU/6E+y13W+HeLHYTDXNFJ1ZcDNnUBW7kbvgLDEG PnuFp11gCAZKD93AF+t5gtSIa71J8Dy36QKe9+HdWhs3GU34Z0IhLV2hMvlD/lp66pPc MRYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Ila9OqBBhoMf/cQ8rlDHnWD68xbWOecYwqrJXXsjQ2M=; b=ojdqFJf9E5odMESon6NBWHOfIRMfoshJURhNeKFrJqWOHuXb4sr9c64if5hJ73ZAV5 kjYfZkrSP87vux7rqpafT68SryzbdIaNSCHwsw7572gSkdIIMORLijHDCeEat2FEvOUh j7hP7qYJ3rZsxbZ5YChbqCFIXuF+9Lt2Ac8LrGzs//kcbvk78DP51qdFaKu3Z86t66dQ TqaVFDTL9HOw0s5Y26h/LtMYYpZkcS56IX3DosCerKA4gIYoZrxjFtfxWl2EkJFKWVM0 NJkBcP6pWR7BbZXf1V9NwzhyJhtQEfGKRJlSuQzOd56mYe7Ami5Yo4dLm5NLCSQgHt0G chZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=gwzlq8t0; 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=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h20si1197294edj.48.2019.11.19.02.09.20; Tue, 19 Nov 2019 02:09:43 -0800 (PST) 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=@alien8.de header.s=dkim header.b=gwzlq8t0; 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=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727560AbfKSKID (ORCPT + 99 others); Tue, 19 Nov 2019 05:08:03 -0500 Received: from mail.skyhub.de ([5.9.137.197]:40012 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726510AbfKSKIC (ORCPT ); Tue, 19 Nov 2019 05:08:02 -0500 Received: from zn.tnic (p200300EC2F0EDC005592EDCF9C877480.dip0.t-ipconnect.de [IPv6:2003:ec:2f0e:dc00:5592:edcf:9c87:7480]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 4458B1EC0C98; Tue, 19 Nov 2019 11:07:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1574158077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=Ila9OqBBhoMf/cQ8rlDHnWD68xbWOecYwqrJXXsjQ2M=; b=gwzlq8t0TWpH0T/KA2xwbyDcLJZXKjADYgqwQIpAjccXpbSy21Gi2zlq+1pxhdvbD2NhsH CEU8lUpFW2uttEinixMhFShVoiHlUDm71dp1VC7wuCF1wKwjera9eyi+5gwTfaTb8tn7gV Ng/9s/5NOjfwIbrTQJxCr/4aYK/T4Mo= Date: Tue, 19 Nov 2019 11:07:53 +0100 From: Borislav Petkov To: Kees Cook Cc: Thomas Gleixner , Zhang Xiaoxu , linux-kernel@vger.kernel.org, x86@kernel.org, tyhicks@canonical.com, colin.king@canonical.com, linux-security-module@vger.kernel.org, Matthew Garrett Subject: Re: [PATCH] x86/mtrr: Require CAP_SYS_ADMIN for all access Message-ID: <20191119100753.GA27787@zn.tnic> References: <201911181308.63F06502A1@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <201911181308.63F06502A1@keescook> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 18, 2019 at 01:09:21PM -0800, Kees Cook wrote: > Zhang Xiaoxu noted that physical address locations for MTRR were > visible to non-root users, which could be considered an information > leak. In discussing[1] the options for solving this, it sounded like > just moving the capable check into open() was the first step. If this > breaks userspace, then we will have a test case for the more conservative > approaches discussed in the thread. In summary: > > - MTRR should check capabilities at open time (or retain the > checks on the opener's permissions for later checks). > > - changing the DAC permissions might break something that expects to > open mtrr when not uid 0. > > - if we leave the DAC permissions alone and just move the capable check > to the opener, we should get the desired protection. (i.e. check > against CAP_SYS_ADMIN not just the wider uid 0.) > > - if that still breaks things, as in userspace expects to be able to > read other parts of the file as non-uid-0 and non-CAP_SYS_ADMIN, then > we need to censor the contents using the opener's permissions. For > example, as done in other /proc cases, like commit 51d7b120418e > ("/proc/iomem: only expose physical resource addresses to privileged > users"). > > [1] https://lore.kernel.org/lkml/201911110934.AC5BA313@keescook/ > > Reported-by: Zhang Xiaoxu > Signed-off-by: Kees Cook > --- > arch/x86/kernel/cpu/mtrr/if.c | 21 ++------------------- > 1 file changed, 2 insertions(+), 19 deletions(-) Yap, LGTM, thanks! Reviewed-by: Borislav Petkov However, as it has a user-visible impact and it is not an urgent thing to have in the tree, I'd not queue this now but after the merge window is done so that we have a maximum time of exposure in linux-next and we can have ample time to addres fallout. /me puts it on the list for after the merge window. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette