From patchwork Fri Dec 22 14:32:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsu Park X-Patchwork-Id: 10130561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A336860318 for ; Fri, 22 Dec 2017 14:32:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9982229FA9 for ; Fri, 22 Dec 2017 14:32:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E48E29FE9; Fri, 22 Dec 2017 14:32:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 108B029FA9 for ; Fri, 22 Dec 2017 14:32:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756186AbdLVOc2 (ORCPT ); Fri, 22 Dec 2017 09:32:28 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:42019 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756209AbdLVObc (ORCPT ); Fri, 22 Dec 2017 09:31:32 -0500 Received: by mail-wm0-f65.google.com with SMTP id b199so22295626wme.1 for ; Fri, 22 Dec 2017 06:31:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kinvolk.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jqiv81xI/uuTat3QvN/5fUrDutGV31c0I2/xrHviQL0=; b=UYycT01tUQiDB0vLnzaNDAoXL+ClMj0UdtT++wld+4qNYB7YhBT0Z6rcMnAOSjXN7a z6FGUxybnuS46ab9XBobh4FXBh84xHuUfiVJSnZed8ExkNRvjjw/E4D6PIq+8sJrVUZp d0DZ+Zc062JN9L2itkZ8DSLjg6lQL9lAa326w= 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; bh=jqiv81xI/uuTat3QvN/5fUrDutGV31c0I2/xrHviQL0=; b=KW1IuRt0/tOVB0sY96af2m0OqwemUYydCLXrJz6/aQnEnZMV6+QC00CE/D9gZk5C8I agoCYNeDk9ENQeEksqxBbxmPB6y0X8RK+GcBpAiGEEoODwlWUh9hsJee66zXv4DSCc5m /mNDlgihqRmBwsH8n2oXk7pYjGGjoHZKa94N1/KRxYNd2Ek982oaBvlI9Nn+AA/PEFts DoTE4E8nk+CpKPZFPqqA9QUqD/28fmiK4B97L6n66Eggs/qCH7bVieB8TiJcVkc5qBiD HcsFpekXJtQ29V6SEQYaziftv2kHKUZ+2uXDvRbp9hKnxsUXTM4g3gjZ0iA4rhSmo9ON Ul+A== X-Gm-Message-State: AKGB3mJAR47zGEcGfc6/JBVYMI+j0HF+j1fFZNVRIwBzTimlxB7Mz5Ic IcAmvZVoeY/I0hnEs2Uyzvm70A== X-Google-Smtp-Source: ACJfBotGqwS+GEONMWass59PwgH5dapWeA8CQZFdHB5HLK5yhApTgO0D0+ij8jkPimxGR+A+f0GQ4Q== X-Received: by 10.80.184.83 with SMTP id k19mr15743995ede.190.1513953090761; Fri, 22 Dec 2017 06:31:30 -0800 (PST) Received: from dberlin.localdomain ([178.19.216.175]) by smtp.gmail.com with ESMTPSA id j39sm19698065ede.38.2017.12.22.06.31.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Dec 2017 06:31:30 -0800 (PST) From: Dongsu Park To: linux-kernel@vger.kernel.org Cc: containers@lists.linux-foundation.org, Alban Crequy , "Eric W . Biederman" , Miklos Szeredi , Seth Forshee , Sargun Dhillon , Dongsu Park , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, James Morris , Mimi Zohar , "Serge E. Hallyn" Subject: [PATCH 11/11] evm: Don't update hmacs in user ns mounts Date: Fri, 22 Dec 2017 15:32:35 +0100 Message-Id: <1f2233a1a028f1eb1e9bea7d06efa6d34e69e752.1512041070.git.dongsu@kinvolk.io> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Seth Forshee The kernel should not calculate new hmacs for mounts done by non-root users. Update evm_calc_hmac_or_hash() to refuse to calculate new hmacs for mounts for non-init user namespaces. Cc: linux-integrity@vger.kernel.org Cc: linux-security-module@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: James Morris Cc: Mimi Zohar Cc: "Serge E. Hallyn" Signed-off-by: Seth Forshee Signed-off-by: Dongsu Park --- security/integrity/evm/evm_crypto.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c index bcd64baf..729f4545 100644 --- a/security/integrity/evm/evm_crypto.c +++ b/security/integrity/evm/evm_crypto.c @@ -190,7 +190,8 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry, int error; int size; - if (!(inode->i_opflags & IOP_XATTR)) + if (!(inode->i_opflags & IOP_XATTR) || + inode->i_sb->s_user_ns != &init_user_ns) return -EOPNOTSUPP; desc = init_desc(type);