diff mbox series

[1/2] capability: add cap_isidentical

Message ID 20230114180224.1777699-1-mjguzik@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/2] capability: add cap_isidentical | expand

Commit Message

Mateusz Guzik Jan. 14, 2023, 6:02 p.m. UTC
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
---
 include/linux/capability.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Serge E. Hallyn Jan. 14, 2023, 7:33 p.m. UTC | #1
On Sat, Jan 14, 2023 at 07:02:23PM +0100, Mateusz Guzik wrote:
> Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>

Reviewed-by: Serge Hallyn <serge@hallyn.com>

> ---
>  include/linux/capability.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/include/linux/capability.h b/include/linux/capability.h
> index 65efb74c3585..736a973c677a 100644
> --- a/include/linux/capability.h
> +++ b/include/linux/capability.h
> @@ -156,6 +156,16 @@ static inline bool cap_isclear(const kernel_cap_t a)
>  	return true;
>  }
>  
> +static inline bool cap_isidentical(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 false;
> +	}
> +	return true;
> +}
> +
>  /*
>   * Check if "a" is a subset of "set".
>   * return true if ALL of the capabilities in "a" are also in "set"
> -- 
> 2.34.1
diff mbox series

Patch

diff --git a/include/linux/capability.h b/include/linux/capability.h
index 65efb74c3585..736a973c677a 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -156,6 +156,16 @@  static inline bool cap_isclear(const kernel_cap_t a)
 	return true;
 }
 
+static inline bool cap_isidentical(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 false;
+	}
+	return true;
+}
+
 /*
  * Check if "a" is a subset of "set".
  * return true if ALL of the capabilities in "a" are also in "set"