Skip to content

Conversation

@bneradt
Copy link
Contributor

@bneradt bneradt commented Dec 8, 2021

A plugin may have multiple user argument types. For instance, it may
have both TS_USER_ARGS_SSN and TS_USER_ARGS_TXN plugin data. Due to a
coding error, it is possible that it may accidentally use the wrong
index type while retrieving one or the other user data types. For
instance, if it uses its transaction index to retrieve its session data,
this may result in them getting the transaction data for another plugin.
In these situations, the plugin will either read what looks like garbage
data to it (because it is casting incorrect memory to its data type), or
it may write to that data and thus corrupt the other plugin's data, or
both.

This change updates the core to segment off the plugin user data ids by
category. This allows the core to verify that the plugin passes the
correct id type per the data type (session, transaction, etc.) and
fails an assertion if there is a mismatch.


Note: autests for this PR will fail until a couple plugins with indexing issues uncovered by this patch are merged in:

@bneradt bneradt added the Plugins label Dec 8, 2021
@bneradt bneradt added this to the 10.0.0 milestone Dec 8, 2021
@bneradt bneradt requested a review from zwoop December 8, 2021 02:41
@bneradt bneradt self-assigned this Dec 8, 2021
@ywkaras
Copy link
Contributor

ywkaras commented Dec 8, 2021

Nitpick: seems like static constexpr items should be private members of PluginUserArgsMixin. But that's perhaps beyond the scope of this PR.

@bneradt
Copy link
Contributor Author

bneradt commented Dec 8, 2021

Nitpick: seems like static constexpr items should be private members of PluginUserArgsMixin. But that's perhaps beyond the scope of this PR.

I agree that it's good to keep stuff private if they can be, but these functions are both needed externally in the InkAPI.cc code. Here, for example:
https://github.com/apache/trafficserver/pull/8550/files#diff-e188d413739d07f1ad183ae5912ca435557809252154bdd5f2fcf625f95b9600R6331

@bneradt bneradt force-pushed the make_user_args_type_safer branch from b120782 to 24dcc2b Compare December 9, 2021 03:12
@bneradt bneradt requested a review from bryancall as a code owner December 9, 2021 03:12
ywkaras
ywkaras previously approved these changes Dec 9, 2021
@bneradt
Copy link
Contributor Author

bneradt commented Dec 9, 2021

[approve ci autest]

@ywkaras
Copy link
Contributor

ywkaras commented Dec 9, 2021

Unfortunately I think this is probably detecting errors in core plugins, that you'll need to fix in this PR to get Au test regression to pass. I suggest trying the failing cases in your own test environment, see what's going on.

@duke8253
Copy link
Contributor

duke8253 commented Dec 9, 2021

I like this

@bneradt
Copy link
Contributor Author

bneradt commented Dec 9, 2021

Unfortunately I think this is probably detecting errors in core plugins, that you'll need to fix in this PR to get Au test regression to pass. I suggest trying the failing cases in your own test environment, see what's going on.

Correct, there were issues with core plugins. But I think those are now both addressed and merged in via the PRs mentioned in the description. We'll see whether I missed any with this latest autest run.

A plugin may have multiple user argument types. For instance, it may
have both TS_USER_ARGS_SSN and TS_USER_ARGS_TXN plugin data. Due to a
coding error, it is possible that it may accidentally use the wrong
index type while retrieving one or the other user data types. For
instance, if it uses its transaction index to retrieve its session data,
this may result in them getting the transaction data for another plugin.
In these situations, the plugin will either read what looks like garbage
data to it (because it is casting incorrect memory to its data type), or
it may write to that data and thus corrupt the other plugin's data, or
both.

This change updates the core to segment off the plugin user data ids by
category. This allows the core to verify that the plugin passes the
correct id type per the data type (session, transaction, etc.) and
fails an assertion if there is a mismatch.
@bneradt bneradt force-pushed the make_user_args_type_safer branch from 50e66bb to 9a0da36 Compare December 11, 2021 04:03
@bneradt
Copy link
Contributor Author

bneradt commented Dec 14, 2021

@masaori335 has volunteered to review this.

@apache apache deleted a comment from masaori335 Dec 14, 2021
@bneradt bneradt merged commit 5774921 into apache:master Dec 14, 2021
@bneradt bneradt deleted the make_user_args_type_safer branch December 14, 2021 03:33
@zwoop
Copy link
Contributor

zwoop commented Jan 5, 2022

I'd like to leave this out of 9.1.x if ok with you.

zwoop pushed a commit that referenced this pull request Jan 5, 2022
A plugin may have multiple user argument types. For instance, it may
have both TS_USER_ARGS_SSN and TS_USER_ARGS_TXN plugin data. Due to a
coding error, it is possible that it may accidentally use the wrong
index type while retrieving one or the other user data types. For
instance, if it uses its transaction index to retrieve its session data,
this may result in them getting the transaction data for another plugin.
In these situations, the plugin will either read what looks like garbage
data to it (because it is casting incorrect memory to its data type), or
it may write to that data and thus corrupt the other plugin's data, or
both.

This change updates the core to segment off the plugin user data ids by
category. This allows the core to verify that the plugin passes the
correct id type per the data type (session, transaction, etc.) and
fails an assertion if there is a mismatch.

(cherry picked from commit 5774921)
@zwoop
Copy link
Contributor

zwoop commented Jan 5, 2022

Cherry-picked to v9.2.x

@zwoop zwoop modified the milestones: 10.0.0, 9.2.0 Jan 5, 2022
@bneradt
Copy link
Contributor Author

bneradt commented Jan 5, 2022

I'd like to leave this out of 9.1.x if ok with you.

Fine with me. I'll remove the 9.1.x project.

moonchen pushed a commit to moonchen/trafficserver that referenced this pull request Mar 17, 2022
* asf/9.2.x:
  Updated ChangeLog
  docs: fix fedora install notes and spelling issues (apache#8537)
  Docs: Fix default value of proxy.config.ssl.handshake_timeout_in (apache#8574)
  Partial of revert "Cleanup generated LDFLAGS for jemalloc (apache#8285)" (apache#8533)
  TSUserArg: add value type checking (apache#8550)
  Relax key validation of sni.yaml (apache#8549)
  Clear random header value by AIO read error (apache#8559)
  Fixes macOS arm64 builds (again) (apache#8556)
  Traffic Dump: Use the correct transaction user index (apache#8548)
  combo_handler: Initialize User Arg Index in TSRemapInit (apache#8551)
  backout down parent retry limiting in parent selection and nexthop (apache#8546)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants