aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHendrik Brueckner <brueckner@linux.vnet.ibm.com>2013-12-16 04:48:00 -0500
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2015-01-22 06:16:56 -0500
commit926a7336a776263b5fdfa7b77fec704be1cae33f (patch)
tree018ccbf11b2943783205561f9d78679dcd0ed0d3
parent2ec504934e43e6c47dfdd4436ca58b36f1ab3218 (diff)
s390/hvc_iucv: add simple wildcard matches to the iucv allow filter
Introduce a wildcard character to filter a range of z/VM user IDs with a single filter entry. Only the leading portion up to the wildcard of an filter entry contributes to the match. This reduces the filter size and avoids configuration updates when deploying new terminal server instances. Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--drivers/tty/hvc/hvc_iucv.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/tty/hvc/hvc_iucv.c b/drivers/tty/hvc/hvc_iucv.c
index ea74460f3638..f78a87b07872 100644
--- a/drivers/tty/hvc/hvc_iucv.c
+++ b/drivers/tty/hvc/hvc_iucv.c
@@ -1,10 +1,10 @@
1/* 1/*
2 * hvc_iucv.c - z/VM IUCV hypervisor console (HVC) device driver 2 * z/VM IUCV hypervisor console (HVC) device driver
3 * 3 *
4 * This HVC device driver provides terminal access using 4 * This HVC device driver provides terminal access using
5 * z/VM IUCV communication paths. 5 * z/VM IUCV communication paths.
6 * 6 *
7 * Copyright IBM Corp. 2008, 2009 7 * Copyright IBM Corp. 2008, 2013
8 * 8 *
9 * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> 9 * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
10 */ 10 */
@@ -102,6 +102,7 @@ static struct hvc_iucv_private *hvc_iucv_table[MAX_HVC_IUCV_LINES];
102#define IUCV_HVC_CON_IDX (0) 102#define IUCV_HVC_CON_IDX (0)
103/* List of z/VM user ID filter entries (struct iucv_vmid_filter) */ 103/* List of z/VM user ID filter entries (struct iucv_vmid_filter) */
104#define MAX_VMID_FILTER (500) 104#define MAX_VMID_FILTER (500)
105#define FILTER_WILDCARD_CHAR '*'
105static size_t hvc_iucv_filter_size; 106static size_t hvc_iucv_filter_size;
106static void *hvc_iucv_filter; 107static void *hvc_iucv_filter;
107static const char *hvc_iucv_filter_string; 108static const char *hvc_iucv_filter_string;
@@ -734,20 +735,31 @@ static void hvc_iucv_notifier_del(struct hvc_struct *hp, int id)
734 * hvc_iucv_filter_connreq() - Filter connection request based on z/VM user ID 735 * hvc_iucv_filter_connreq() - Filter connection request based on z/VM user ID
735 * @ipvmid: Originating z/VM user ID (right padded with blanks) 736 * @ipvmid: Originating z/VM user ID (right padded with blanks)
736 * 737 *
737 * Returns 0 if the z/VM user ID @ipvmid is allowed to connection, otherwise 738 * Returns 0 if the z/VM user ID that is specified with @ipvmid is permitted to
738 * non-zero. 739 * connect, otherwise non-zero.
739 */ 740 */
740static int hvc_iucv_filter_connreq(u8 ipvmid[8]) 741static int hvc_iucv_filter_connreq(u8 ipvmid[8])
741{ 742{
742 size_t i; 743 const char *wildcard, *filter_entry;
744 size_t i, len;
743 745
744 /* Note: default policy is ACCEPT if no filter is set */ 746 /* Note: default policy is ACCEPT if no filter is set */
745 if (!hvc_iucv_filter_size) 747 if (!hvc_iucv_filter_size)
746 return 0; 748 return 0;
747 749
748 for (i = 0; i < hvc_iucv_filter_size; i++) 750 for (i = 0; i < hvc_iucv_filter_size; i++) {
749 if (0 == memcmp(ipvmid, hvc_iucv_filter + (8 * i), 8)) 751 filter_entry = hvc_iucv_filter + (8 * i);
752
753 /* If a filter entry contains the filter wildcard character,
754 * reduce the length to match the leading portion of the user
755 * ID only (wildcard match). Characters following the wildcard
756 * are ignored.
757 */
758 wildcard = strnchr(filter_entry, 8, FILTER_WILDCARD_CHAR);
759 len = (wildcard) ? wildcard - filter_entry : 8;
760 if (0 == memcmp(ipvmid, filter_entry, len))
750 return 0; 761 return 0;
762 }
751 return 1; 763 return 1;
752} 764}
753 765
@@ -1166,6 +1178,7 @@ static void __init hvc_iucv_destroy(struct hvc_iucv_private *priv)
1166/** 1178/**
1167 * hvc_iucv_parse_filter() - Parse filter for a single z/VM user ID 1179 * hvc_iucv_parse_filter() - Parse filter for a single z/VM user ID
1168 * @filter: String containing a comma-separated list of z/VM user IDs 1180 * @filter: String containing a comma-separated list of z/VM user IDs
1181 * @dest: Location where to store the parsed z/VM user ID
1169 */ 1182 */
1170static const char *hvc_iucv_parse_filter(const char *filter, char *dest) 1183static const char *hvc_iucv_parse_filter(const char *filter, char *dest)
1171{ 1184{
@@ -1188,6 +1201,10 @@ static const char *hvc_iucv_parse_filter(const char *filter, char *dest)
1188 if (filter[len - 1] == '\n') 1201 if (filter[len - 1] == '\n')
1189 len--; 1202 len--;
1190 1203
1204 /* prohibit filter entries containing the wildcard character only */
1205 if (len == 1 && *filter == FILTER_WILDCARD_CHAR)
1206 return ERR_PTR(-EINVAL);
1207
1191 if (len > 8) 1208 if (len > 8)
1192 return ERR_PTR(-EINVAL); 1209 return ERR_PTR(-EINVAL);
1193 1210