From patchwork Thu Oct 3 15:54:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11172903 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9987214DB for ; Thu, 3 Oct 2019 17:16:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7677920842 for ; Thu, 3 Oct 2019 17:16:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570122961; bh=SAVbqIJhRYHkOPmJ45qk1R9z0FcxOwplAbdfGkY42Zs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=eOnRFB3sQy9lD16FzXnOAAPiNh2/QQVRK/dkoOjKQhGApeh3krwamo5j3iLYPjj+y wArWs523OW7GunGuQ2NdI7qmCr7Aplp/DdNVCWAOHkWoYgYSchkDhZy2mMigQy5FH/ TagCedDcchg6qVnE60kZ8t7gvjEjRKKWKUJ8nd1I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390859AbfJCQZC (ORCPT ); Thu, 3 Oct 2019 12:25:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:51886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390430AbfJCQXB (ORCPT ); Thu, 3 Oct 2019 12:23:01 -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 17F5320867; Thu, 3 Oct 2019 16:22:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570119780; bh=SAVbqIJhRYHkOPmJ45qk1R9z0FcxOwplAbdfGkY42Zs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yAEDHAFZwWkyOIuUE8SlvXNkDQkskt5PKaHiD0K/rqOUiaJ4ql8NdC9HIDC/X+EYW v1ctPZCrdkza8I8QEFbk/+zFpAnSH+yUDfyJyF2jUEW4uHi4k8eC7gRvNHoSb1phu9 ZRULjYBhRFp3JD77ncgQBd/nl+gyKmhfZ8FRNByI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Salyzyn , linux-security-module@vger.kernel.org, kernel-team@android.com, Miklos Szeredi Subject: [PATCH 4.19 189/211] ovl: filter of trusted xattr results in audit Date: Thu, 3 Oct 2019 17:54:15 +0200 Message-Id: <20191003154528.368762802@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154447.010950442@linuxfoundation.org> References: <20191003154447.010950442@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: From: Mark Salyzyn commit 5c2e9f346b815841f9bed6029ebcb06415caf640 upstream. When filtering xattr list for reading, presence of trusted xattr results in a security audit log. However, if there is other content no errno will be set, and if there isn't, the errno will be -ENODATA and not -EPERM as is usually associated with a lack of capability. The check does not block the request to list the xattrs present. Switch to ns_capable_noaudit to reflect a more appropriate check. Signed-off-by: Mark Salyzyn Cc: linux-security-module@vger.kernel.org Cc: kernel-team@android.com Cc: stable@vger.kernel.org # v3.18+ Fixes: a082c6f680da ("ovl: filter trusted xattr for non-admin") Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/overlayfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -386,7 +386,8 @@ static bool ovl_can_list(const char *s) return true; /* Never list trusted.overlay, list other trusted for superuser only */ - return !ovl_is_private_xattr(s) && capable(CAP_SYS_ADMIN); + return !ovl_is_private_xattr(s) && + ns_capable_noaudit(&init_user_ns, CAP_SYS_ADMIN); } ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)