Skip to content

MDEV-39245-Check that plugin name is pure ASCII#4950

Draft
pranavktiwari wants to merge 1 commit into10.11from
10.11-MDEV-39245
Draft

MDEV-39245-Check that plugin name is pure ASCII#4950
pranavktiwari wants to merge 1 commit into10.11from
10.11-MDEV-39245

Conversation

@pranavktiwari
Copy link
Copy Markdown

@pranavktiwari pranavktiwari commented Apr 17, 2026

fixes MDEV-39245

Problem:

It is assumed plugin names are pure ASCII (e.g., uses my_casedn_str with latin1 charset) but never validates this at plugin registration time, allowing plugins with non-ASCII names to be installed, causing undefined behavior.

Fix

Added ASCII validation at two points using my_string_repertoire():

  1. Built-in plugins (plugin_init):
    A non-ASCII builtin name is a developer error. Added a check
    using my_string_repertoire() that prints an error via
    print_init_failed_error() and returns 1 to abort server startup.

  2. Dynamically loaded plugins (plugin_add):
    Added a pre-validation loop before the registration loop. If any
    plugin name in the .so is non-ASCII, the entire .so is rejected
    before any plugin is registered, preventing partial state where
    valid plugins from the same .so get left INACTIVE in the hash.

Added test plugins and MTR tests to verify both rejection of
non-ASCII named plugins and successful loading of ASCII named plugins.

@pranavktiwari pranavktiwari marked this pull request as draft April 17, 2026 07:58
@pranavktiwari pranavktiwari force-pushed the 10.11-MDEV-39245 branch 2 times, most recently from 3649181 to 2fab82e Compare April 17, 2026 08:03
@pranavktiwari pranavktiwari force-pushed the 10.11-MDEV-39245 branch 3 times, most recently from bba9d91 to 4b5e148 Compare April 21, 2026 07:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses MDEV-39245 by enforcing that server plugin names are pure ASCII at registration time, preventing undefined behavior caused by non-ASCII names being handled with ASCII/latin1-oriented routines.

Changes:

  • Added ASCII repertoire validation for plugin names during dynamic plugin registration (plugin_add) and built-in plugin registration (plugin_init).
  • Added new test plugins (one all-ASCII, one containing a non-ASCII plugin name) plus an MTR test verifying failure/success cases.
  • Updated Debian test packaging to include the new test plugin .so files.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
sql/sql_plugin.cc Adds ASCII-only validation for plugin names during plugin registration/initialization.
plugin/plugin_name_ascii_check/CMakeLists.txt Builds two new test plugin modules used by MTR.
plugin/plugin_name_ascii_check/plugin_name_ascii.cc Test plugin with only ASCII plugin names.
plugin/plugin_name_ascii_check/plugin_name_non_ascii.cc Test plugin that includes a non-ASCII plugin name to validate rejection behavior.
mysql-test/suite/plugins/t/plugin_name_ascii.test New MTR test covering INSTALL SONAME / INSTALL PLUGIN scenarios for ASCII vs non-ASCII names.
mysql-test/suite/plugins/t/plugin_name_ascii.opt Test options for plugin maturity.
mysql-test/suite/plugins/r/plugin_name_ascii.result Expected output for the new MTR test.
debian/mariadb-test.install Installs the new test plugin shared objects for Debian test packages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sql/sql_plugin.cc
Comment thread sql/sql_plugin.cc
Comment on lines +17 to +20
Test plugin: two plugins with ASCII names and one with a non-ASCII name.
Used by mysql-test/suite/plugins/t/plugin_name_ascii.test
The non-ASCII plugin name "plügïn_bad" is represented as UTF-8 hex bytes.
*/
{
MYSQL_DAEMON_PLUGIN,
&plugin3_descriptor,
"plügïn_non_ascii", /* "plügïn_non_ascii" in UTF-8 bytes */
Comment thread sql/sql_plugin.cc Outdated
Comment on lines +1152 to +1156
/* Pre-validation: ensure all plugin names are pure ASCII */
for (plugin= tmp.plugin_dl->plugins; plugin->info; plugin++)
{
tmp.name.str= (char *)plugin->name;
tmp.name.length= strlen(plugin->name);
if (skip_plugin(plugin))
continue;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is possible that name -> str is null- in that case all the plugins from .so should be installed only if all of them contains ascii plugin name.
But if name is passed from the argument, in that case only the name with that plugin needs to be installed only if the name is ascii character. What is wrong in that?

Comment thread sql/sql_plugin.cc Outdated
tmp.name.length))
{
print_init_failed_error(&tmp);
DBUG_RETURN(1);;
@pranavktiwari pranavktiwari force-pushed the 10.11-MDEV-39245 branch 2 times, most recently from 5829cc2 to 1194e8f Compare April 21, 2026 09:04
Copy link
Copy Markdown
Member

@sanja-byelkin sanja-byelkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix

Comment thread sql/sql_plugin.cc
plugin->name, strlen(plugin->name)))
{
my_error(ER_PLUGIN_IS_NOT_LOADED, MyFlags, plugin->name, ENOEXEC,
"invalid plugin name: non-ASCII characters are not supported");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where this text goes? have you checked the pattern? have you wrote it or AI?

tip: use my_printf_error

FROM information_schema.PLUGINS
WHERE PLUGIN_NAME = 'ascii_plugin_one';

UNINSTALL PLUGIN ascii_plugin_one; No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct line ends everywhere (setup your editor)

1. Built-in plugins (plugin_init):
   A non-ASCII builtin name is a developer error. Added a check
   using my_string_repertoire() that prints an error via
   print_init_failed_error() and returns 1 to abort server startup.

2. Dynamically loaded plugins (plugin_add):
   Added a pre-validation loop before the registration loop. If any
   plugin name in the .so is non-ASCII, the entire .so is rejected
   before any plugin is registered, preventing partial state where
   valid plugins from the same .so get left INACTIVE in the hash.

Added test plugins and MTR tests to verify both rejection of
non-ASCII named plugins and successful loading of ASCII named plugins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants