+config KVM_MAX_IOSIGNALFD_ITEMSIs there a per-vm limit on iosignalfds? if not, userspace can exhaust
+ int "Maximum IOSIGNALFD items per address"
+ depends on KVM
+ default "32"
+ ---help---
+ This option influences the maximum number of fd's per PIO/MMIO
+ address that are allowed to register
+
kernel memory in that way.
Yeah, its already naturally limited by the maximum number of MMIO/PIO
devices we can register (today this is 6 per VM). I should have
documented that fact somewhere, tho.
+struct _iosignalfd_item {Why not u64 match?
+ struct list_head list;
+ struct file *file;
+ unsigned char *match;
+ struct rcu_head rcu;
+};
Well, tbh it was primarily because it was starting to make my head hurt
w.r.t. endianness ;). For instance, if someone wanted a u16 match, I
would presumably have to understand the relevant endianess of the u64 so
I compare the appropriate bytes against the data-register coming in from
the [MM|P]IO. Using a pointer, I simply copy/memcmp the specified
number of bytes and never have to worry about endianness.
As a minor bonus, item->match == NULL tells me its a wildcard. If I had
item->match as a u64, I'd need a different state flag for "wildcard".
NBD, but thought I would point it out.
+static intShould check length before match (i.e. require correctly sized access).
+iosignalfd_is_match(struct _iosignalfd_group *group,
+ struct _iosignalfd_item *item,
+ const void *val,
+ int len)
+{
+ if (!item->match)
+ /* wildcard is a hit */
+ return true;
+
+ if (len != group->length)
+ /* mis-matched length is a miss */
+ return false;
Perhaps, but my thinking is that group->length only matters for
data-matching. You could conceivably have a larger window registered if
you are using all wildcards. Not sure if this is really useful, but its
the reason the code is that way today.