From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932175AbbCIUgG (ORCPT ); Mon, 9 Mar 2015 16:36:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34206 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754044AbbCIUf7 (ORCPT ); Mon, 9 Mar 2015 16:35:59 -0400 From: Mateusz Guzik To: Alexander Viro , Serge Hallyn Cc: Paul Moore , Eric Paris , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH 1/2] CAPABILITIES: add cap_isequal helper Date: Mon, 9 Mar 2015 21:35:46 +0100 Message-Id: <1425933347-6080-2-git-send-email-mguzik@redhat.com> In-Reply-To: <1425933347-6080-1-git-send-email-mguzik@redhat.com> References: <1425933347-6080-1-git-send-email-mguzik@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Can be used to determine whether two given sets have the same capabilities. Signed-off-by: Mateusz Guzik --- include/linux/capability.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/capability.h b/include/linux/capability.h index af9f0b9..2fcf941 100644 --- a/include/linux/capability.h +++ b/include/linux/capability.h @@ -155,6 +155,16 @@ static inline int cap_isclear(const kernel_cap_t a) return 1; } +static inline int cap_isequal(const kernel_cap_t a, const kernel_cap_t b) +{ + unsigned __capi; + CAP_FOR_EACH_U32(__capi) { + if (a.cap[__capi] != b.cap[__capi]) + return 0; + } + return 1; +} + /* * Check if "a" is a subset of "set". * return 1 if ALL of the capabilities in "a" are also in "set" -- 1.8.3.1