filter: setup automatic per-vid checks in the plugin whitelist

Until now, the plugin whitelist rule in the filter would only handle
those plugins that require specific udev tags, and those that had
explicit full vid:pid pairs.

This update makes a new implicit automatic whitelist for all devices
that match any of the vids managed by the different plugins.

Looking at the current list of devices in the blacklist and greylist
maintained by ModemManager, there are no devices falling under the
list of supported plugin vids that would need to be blacklisted;
except for u-blox GPS modules:

  huawei    -> 0x12d1        -> None in blacklist/greylist
  thuraya   -> 0x1a26        -> None in blacklist/greylist
  telit     -> 0x1bc7        -> None in blacklist/greylist
  dLink     -> 0x2001        -> None in blacklist/greylist
  wavecom   -> 0x114f        -> None in blacklist/greylist
  x22x      -> 0x1bbb,0x0b3c -> None in blacklist/greylist
  anydata   -> 0x16d5        -> None in blacklist/greylist
  quectel   -> 0x2c7c        -> None in blacklist/greylist
  haier     -> 0x201e        -> None in blacklist/greylist
  novatel   -> 0x1410        -> None in blacklist/greylist
  dell      -> 0x413c        -> None in blacklist/greylist
  option    -> 0x0af0,0x1931 -> None in blacklist/greylist
  nokia     -> 0x0421        -> None in blacklist/greylist
  cinterion -> 0x1e2d,0x0681 -> None in blacklist/greylist
  simtech   -> 0x1e0e        -> None in blacklist/greylist
  iridium   -> 0x1edd        -> None in blacklist/greylist
  pantech   -> 0x106c        -> None in blacklist/greylist
  longcheer -> 0x1c9e,0x1bbb -> None in blacklist/greylist
  linktop   -> 0x230d        -> None in blacklist/greylist
  sierra    -> 0x1199        -> None in blacklist/greylist
  ublox     -> 0x1546        -------------> GPS chips blacklisted !!!!!
  foxconn   -> 0x0489        -> None in blacklist/greylist
  broadmobi -> 0x2020        -> None in blacklist/greylist
  fibocom   -> 0x2cb7        -> None in blacklist/greylist
  tplink    -> 0x2357        -> None in blacklist/greylist
  zte       -> 0x19d2        -> None in blacklist/greylist

The rules used to blacklist the u-blox GPS chips have already been
moved to the u-blox plugin itself, and now they use the broader
ID_MM_DEVICE_IGNORE tag that applies in all filter modes.
This commit is contained in:
Aleksander Morgado
2020-06-02 15:42:58 +02:00
parent bbeca60113
commit a5c060ef87
6 changed files with 67 additions and 1 deletions

View File

@@ -39,6 +39,7 @@ enum {
struct _MMFilterPrivate {
MMFilterRule enabled_rules;
GList *plugin_whitelist_tags;
GArray *plugin_whitelist_vendor_ids;
GArray *plugin_whitelist_product_ids;
};
@@ -54,6 +55,27 @@ mm_filter_register_plugin_whitelist_tag (MMFilter *self,
}
}
void
mm_filter_register_plugin_whitelist_vendor_id (MMFilter *self,
guint16 vid)
{
guint i;
if (!self->priv->plugin_whitelist_vendor_ids)
self->priv->plugin_whitelist_vendor_ids = g_array_sized_new (FALSE, FALSE, sizeof (guint16), 64);
for (i = 0; i < self->priv->plugin_whitelist_vendor_ids->len; i++) {
guint16 item;
item = g_array_index (self->priv->plugin_whitelist_vendor_ids, guint16, i);
if (item == vid)
return;
}
g_array_append_val (self->priv->plugin_whitelist_vendor_ids, vid);
mm_obj_dbg (self, "registered plugin whitelist vendor id: %04x", vid);
}
void
mm_filter_register_plugin_whitelist_product_id (MMFilter *self,
guint16 vid,
@@ -140,6 +162,20 @@ mm_filter_port (MMFilter *self,
}
}
}
if (vid && self->priv->plugin_whitelist_vendor_ids) {
guint i;
for (i = 0; i < self->priv->plugin_whitelist_vendor_ids->len; i++) {
guint16 item;
item = g_array_index (self->priv->plugin_whitelist_vendor_ids, guint16, i);
if (item == vid) {
mm_obj_dbg (self, "(%s/%s) port allowed: device is whitelisted by plugin (vid)", subsystem, name);
return TRUE;
}
}
}
}
/* If this is a virtual device, don't allow it */
@@ -483,6 +519,7 @@ finalize (GObject *object)
{
MMFilter *self = MM_FILTER (object);
g_clear_pointer (&self->priv->plugin_whitelist_vendor_ids, g_array_unref);
g_clear_pointer (&self->priv->plugin_whitelist_product_ids, g_array_unref);
g_list_free_full (self->priv->plugin_whitelist_tags, g_free);