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

4
NEWS
View File

@@ -44,6 +44,10 @@ The most important features and changes in this release are the following:
port probing mechanism uses its own heuristics to guess whether a given TTY port probing mechanism uses its own heuristics to guess whether a given TTY
is owned by a modem or not. is owned by a modem or not.
* Added a new implicit whitelist rules applicable in 'STRICT' filter mode, so
that all devices with a USB vid matching one of the vids allowed by the
different installed plugins are implicitly allowed.
* Updated daemon logging so that we always prefix the messages with a string * Updated daemon logging so that we always prefix the messages with a string
identifying which modem the log refers to, making it easy to grep logs for identifying which modem the log refers to, making it easy to grep logs for
one specific device if the system has more than one. one specific device if the system has more than one.

View File

@@ -39,6 +39,7 @@ enum {
struct _MMFilterPrivate { struct _MMFilterPrivate {
MMFilterRule enabled_rules; MMFilterRule enabled_rules;
GList *plugin_whitelist_tags; GList *plugin_whitelist_tags;
GArray *plugin_whitelist_vendor_ids;
GArray *plugin_whitelist_product_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 void
mm_filter_register_plugin_whitelist_product_id (MMFilter *self, mm_filter_register_plugin_whitelist_product_id (MMFilter *self,
guint16 vid, 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 */ /* If this is a virtual device, don't allow it */
@@ -483,6 +519,7 @@ finalize (GObject *object)
{ {
MMFilter *self = MM_FILTER (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_clear_pointer (&self->priv->plugin_whitelist_product_ids, g_array_unref);
g_list_free_full (self->priv->plugin_whitelist_tags, g_free); g_list_free_full (self->priv->plugin_whitelist_tags, g_free);

View File

@@ -145,6 +145,8 @@ gboolean mm_filter_device_and_port (MMFilter *self,
void mm_filter_register_plugin_whitelist_tag (MMFilter *self, void mm_filter_register_plugin_whitelist_tag (MMFilter *self,
const gchar *tag); const gchar *tag);
void mm_filter_register_plugin_whitelist_vendor_id (MMFilter *self,
guint16 vid);
void mm_filter_register_plugin_whitelist_product_id (MMFilter *self, void mm_filter_register_plugin_whitelist_product_id (MMFilter *self,
guint16 vid, guint16 vid,
guint16 pid); guint16 pid);

View File

@@ -1616,6 +1616,21 @@ register_plugin_whitelist_tags (MMPluginManager *self,
mm_filter_register_plugin_whitelist_tag (self->priv->filter, tags[i]); mm_filter_register_plugin_whitelist_tag (self->priv->filter, tags[i]);
} }
static void
register_plugin_whitelist_vendor_ids (MMPluginManager *self,
MMPlugin *plugin)
{
const guint16 *vendor_ids;
guint i;
if (!mm_filter_check_rule_enabled (self->priv->filter, MM_FILTER_RULE_PLUGIN_WHITELIST))
return;
vendor_ids = mm_plugin_get_allowed_vendor_ids (plugin);
for (i = 0; vendor_ids && vendor_ids[i]; i++)
mm_filter_register_plugin_whitelist_vendor_id (self->priv->filter, vendor_ids[i]);
}
static void static void
register_plugin_whitelist_product_ids (MMPluginManager *self, register_plugin_whitelist_product_ids (MMPluginManager *self,
MMPlugin *plugin) MMPlugin *plugin)
@@ -1812,7 +1827,8 @@ load_plugins (MMPluginManager *self,
self->priv->plugins = g_list_append (self->priv->plugins, plugin); self->priv->plugins = g_list_append (self->priv->plugins, plugin);
/* Register plugin whitelist rules in filter, if any */ /* Register plugin whitelist rules in filter, if any */
register_plugin_whitelist_tags (self, plugin); register_plugin_whitelist_tags (self, plugin);
register_plugin_whitelist_vendor_ids (self, plugin);
register_plugin_whitelist_product_ids (self, plugin); register_plugin_whitelist_product_ids (self, plugin);
} }

View File

@@ -152,6 +152,12 @@ mm_plugin_get_allowed_udev_tags (MMPlugin *self)
return (const gchar **) self->priv->udev_tags; return (const gchar **) self->priv->udev_tags;
} }
const guint16 *
mm_plugin_get_allowed_vendor_ids (MMPlugin *self)
{
return self->priv->vendor_ids;
}
const mm_uint16_pair * const mm_uint16_pair *
mm_plugin_get_allowed_product_ids (MMPlugin *self) mm_plugin_get_allowed_product_ids (MMPlugin *self)
{ {

View File

@@ -126,6 +126,7 @@ GType mm_plugin_get_type (void);
const gchar *mm_plugin_get_name (MMPlugin *self); const gchar *mm_plugin_get_name (MMPlugin *self);
const gchar **mm_plugin_get_allowed_udev_tags (MMPlugin *self); const gchar **mm_plugin_get_allowed_udev_tags (MMPlugin *self);
const guint16 *mm_plugin_get_allowed_vendor_ids (MMPlugin *self);
const mm_uint16_pair *mm_plugin_get_allowed_product_ids (MMPlugin *self); const mm_uint16_pair *mm_plugin_get_allowed_product_ids (MMPlugin *self);
gboolean mm_plugin_is_generic (MMPlugin *self); gboolean mm_plugin_is_generic (MMPlugin *self);