aboutsummaryrefslogtreecommitdiff
path: root/net/netfilter/x_tables.c
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2018-04-13 11:26:07 +0100
committerMark Brown <broonie@kernel.org>2018-04-13 11:26:07 +0100
commit36e3dd72fb0d2c32f1ba1313d4da22fbb27b5bd4 (patch)
tree4db51d38820eb6883921fa88ff692bc4ca711300 /net/netfilter/x_tables.c
parent5e9e8b891fe489c9ac2270b6e4f2da961ae3c80c (diff)
parentd32da5bd9fd2e6eafa25c82318b55124c54d3a66 (diff)
Merge tag 'v4.9.93' into linux-linaro-lsk-v4.9
This is the 4.9.93 stable release
Diffstat (limited to 'net/netfilter/x_tables.c')
-rw-r--r--net/netfilter/x_tables.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 7ad1a863587a..59be89813a29 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -367,6 +367,36 @@ textify_hooks(char *buf, size_t size, unsigned int mask, uint8_t nfproto)
return buf;
}
+/**
+ * xt_check_proc_name - check that name is suitable for /proc file creation
+ *
+ * @name: file name candidate
+ * @size: length of buffer
+ *
+ * some x_tables modules wish to create a file in /proc.
+ * This function makes sure that the name is suitable for this
+ * purpose, it checks that name is NUL terminated and isn't a 'special'
+ * name, like "..".
+ *
+ * returns negative number on error or 0 if name is useable.
+ */
+int xt_check_proc_name(const char *name, unsigned int size)
+{
+ if (name[0] == '\0')
+ return -EINVAL;
+
+ if (strnlen(name, size) == size)
+ return -ENAMETOOLONG;
+
+ if (strcmp(name, ".") == 0 ||
+ strcmp(name, "..") == 0 ||
+ strchr(name, '/'))
+ return -EINVAL;
+
+ return 0;
+}
+EXPORT_SYMBOL(xt_check_proc_name);
+
int xt_check_match(struct xt_mtchk_param *par,
unsigned int size, u_int8_t proto, bool inv_proto)
{