From patchwork Mon Mar 9 20:35:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Guzik X-Patchwork-Id: 5971171 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 75247BF440 for ; Mon, 9 Mar 2015 20:36:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B80DD2020F for ; Mon, 9 Mar 2015 20:36:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E12F8201FA for ; Mon, 9 Mar 2015 20:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754140AbbCIUgF (ORCPT ); Mon, 9 Mar 2015 16:36:05 -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 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t29KZvFH029373 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 9 Mar 2015 16:35:57 -0400 Received: from localhost.localdomain (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t29KZmYi031311; Mon, 9 Mar 2015 16:35:53 -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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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"