Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6113781ybi; Wed, 31 Jul 2019 08:33:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKeOSTjXvaS9SslAm7xK1G1TJhqnuw6b84b8v1nTiaWo047bX22WTC8Af38tD+Vol6tcjq X-Received: by 2002:a62:6454:: with SMTP id y81mr46381975pfb.13.1564587200922; Wed, 31 Jul 2019 08:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564587200; cv=none; d=google.com; s=arc-20160816; b=Z3jxyfjYPAfMNB+WYjiC+lk2HzTlVGlr/9hcoMG9Xw2qL7bOVSDYOJZMrtwXNKhbGk W0X1xCJS1weH3+s3uZ8Ofj7vAKKgoaj4Z2Qrxq+u4n3RggF4mgt9v2Ru2Db5rnd1fBsP KGAsCQqUXV46/798IjfFuvjyx9fISNjCp7tzP9cUAtAbQd/khtLzZkBqb7lk1VKKoa+H VcSAIhWJgsdMp7z5zaZf5tY8P/7TFFg6p/R9Io93BPIbKnAUvcEzZp/4x4ZfuvV0OsVn bMiPC108EqH+SBOcw/IM2RORq9LUtZ1j01EMaXFsz0ZQTvMyK7Vv9OCaZdylY4o2/srH 7GGA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Pyaxzbpsx58odlzi9CMlCU1WWA9qqTOgEqw5C9FEBVg=; b=iWzg9wnYW2CX2P8h2smfB63AG9+3N9tqSCUOSmO3cVaikuG2j3xjfq9O9ZreDA89Xs NbcHEKkGCc7s5qvCc63wPYuIOPBeNEHQ8qEkNZjrn85GzbPjFdoXYCvK7COCYMxced7a /Gjh8493FcFMDhy90b9+Z2GqdD2N2g32K3bkh1Y2pt9/bfhmOs7RUZiYfM1S7TJWKhzi xXh9BIMUK4/64Ao9776A6BRL/nyin6N+mllJVpay1G3loSv9qfeBfY8zz2SmVUAr/p2C tE/W23nkPiq/mmJaQT8/PsadYeFvMOW2tz5KnxzOd6VS6z71VwSx7mjlwmSOZaxlVFzo MrbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=TdeP43VI; 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 x69si31441751pgd.168.2019.07.31.08.33.05; Wed, 31 Jul 2019 08:33:20 -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=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=TdeP43VI; 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 S1729912AbfGaPYK (ORCPT + 99 others); Wed, 31 Jul 2019 11:24:10 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:39984 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729208AbfGaPXx (ORCPT ); Wed, 31 Jul 2019 11:23:53 -0400 Received: by mail-ed1-f67.google.com with SMTP id k8so66044874eds.7 for ; Wed, 31 Jul 2019 08:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Pyaxzbpsx58odlzi9CMlCU1WWA9qqTOgEqw5C9FEBVg=; b=TdeP43VIsvZBSvidBd63JYHMxnbdwhhCTLKUiBkNxJ1dN5ZesnIcrufzgwhWgQyHPq i7R3oVQxFEJynf2mhmWeT0e02bFtLfYtRn6p0VgZ/9Cfk6L2HmVLTwyWiesqSFHcOuWI C7Kd8pQSESCHFSvOb3B4KDGD0ws8qGv6qEQ5VxcXS9cAH00eVayINE6xKGf1l8i8BukU egoKu79G/bPpu3bRP9GqYkSE1/6ni+LU5rtZqvn7BKSJqvWNGHFJFeVK/BRE5mk85JT0 SAUKBlIR/5r0VZdnIOVvK9sEH41/fY04cVEyxQuZT0wYs85IiJA+jJz7ToKIsDLSVFEp FYqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Pyaxzbpsx58odlzi9CMlCU1WWA9qqTOgEqw5C9FEBVg=; b=nVMtgc+6UJR0IFWByKbQVkHR9YpDyLNEFeEYqcfBmmxdB1IjYHnJKX3aHsOIRU6S1P ty/OsHQ85TMPTVI8qmC8DxgbRsCBTAiDht5A8ZMer7pGgP61+TKZk7nsiI3f3197Ew43 kXg0bcScOjHZnMovQT1BbZfOt29djIAfptBQ/jT+o4B/VdserKQWJQeGgxu2bnwcbC2G vnT0neVSGnKGYNx8buj04fqFD7qAcwSkkwjR3KBjI3j3lzwPvveMripEDy/75z9Vwkkc 1+zHEUOMiKkdIyDIvRq+lhDf2ABPJO66u3+H97DmoO+B3JNySZc18H9HUlVyKb5rQRjg o/Pg== X-Gm-Message-State: APjAAAWOY04y3kKzwNlJ3C8zVE8ewiZNl9lSJKReD+fy9AMzKBcXlAvh 6C9z8VEAWth2TkL/3SH+KCs= X-Received: by 2002:a17:906:5409:: with SMTP id q9mr97412776ejo.209.1564586631213; Wed, 31 Jul 2019 08:23:51 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id u7sm12527377ejm.48.2019.07.31.08.23.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jul 2019 08:23:49 -0700 (PDT) From: "Kirill A. Shutemov" X-Google-Original-From: "Kirill A. Shutemov" Received: by box.localdomain (Postfix, from userid 1000) id D3EBD1045F6; Wed, 31 Jul 2019 18:08:16 +0300 (+03) To: Andrew Morton , x86@kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Borislav Petkov , Peter Zijlstra , Andy Lutomirski , David Howells Cc: Kees Cook , Dave Hansen , Kai Huang , Jacob Pan , Alison Schofield , linux-mm@kvack.org, kvm@vger.kernel.org, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, "Kirill A . Shutemov" Subject: [PATCHv2 33/59] keys/mktme: Require CAP_SYS_RESOURCE capability for MKTME keys Date: Wed, 31 Jul 2019 18:07:47 +0300 Message-Id: <20190731150813.26289-34-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190731150813.26289-1-kirill.shutemov@linux.intel.com> References: <20190731150813.26289-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alison Schofield The MKTME key type uses capabilities to restrict the allocation of keys to privileged users. CAP_SYS_RESOURCE is required, but the broader capability of CAP_SYS_ADMIN is accepted. Signed-off-by: Alison Schofield Signed-off-by: Kirill A. Shutemov --- security/keys/mktme_keys.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/security/keys/mktme_keys.c b/security/keys/mktme_keys.c index 1e2afcce7d85..2d90cc83e5ce 100644 --- a/security/keys/mktme_keys.c +++ b/security/keys/mktme_keys.c @@ -2,6 +2,7 @@ /* Documentation/x86/mktme/ */ +#include #include #include #include @@ -371,6 +372,9 @@ int mktme_preparse_payload(struct key_preparsed_payload *prep) char *options; int ret; + if (!capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN)) + return -EACCES; + if (datalen <= 0 || datalen > 1024 || !prep->data) return -EINVAL; -- 2.21.0