netfilter: xt_owner: bail out with EINVAL in case of unsupported flags 05/209205/1 accepted/tizen/unified/20190705.110612 submit/tizen/20190705.061120
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 7 Jun 2019 14:37:30 +0000 (16:37 +0200)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 3 Jul 2019 09:43:15 +0000 (18:43 +0900)
Reject flags that are not supported with EINVAL.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
[sw0312.kim: backport from mainline to support supplementary groups on netfilter]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I6d86e2db548445d29405fb9cbec540f7d1a196ef

include/uapi/linux/netfilter/xt_owner.h
net/netfilter/xt_owner.c

index e7731dc..e5c670d 100644 (file)
@@ -10,6 +10,11 @@ enum {
        XT_OWNER_SUPPL_GROUPS = 1 << 3,
 };
 
+#define XT_OWNER_MASK  (XT_OWNER_UID |         \
+                        XT_OWNER_GID |         \
+                        XT_OWNER_SOCKET |      \
+                        XT_OWNER_SUPPL_GROUPS)
+
 struct xt_owner_match_info {
        __u32 uid_min, uid_max;
        __u32 gid_min, gid_max;
index 5b21999..2289544 100644 (file)
@@ -21,6 +21,9 @@ static int owner_check(const struct xt_mtchk_param *par)
 {
        struct xt_owner_match_info *info = par->matchinfo;
 
+       if (info->match & ~XT_OWNER_MASK)
+               return -EINVAL;
+
        /* For now only allow adding matches from the initial user namespace */
        if ((info->match & (XT_OWNER_UID|XT_OWNER_GID)) &&
            (current_user_ns() != &init_user_ns))