Page MenuHomeFreeBSD

mmc_sim: fix setting of the mutex name
ClosedPublic

Authored by avg on Dec 13 2021, 11:45 AM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 30 2024, 7:12 AM
Unknown Object (File)
Jan 17 2024, 5:01 AM
Unknown Object (File)
Jan 15 2024, 7:35 PM
Unknown Object (File)
Jan 12 2024, 7:44 AM
Unknown Object (File)
Dec 24 2023, 11:14 AM
Unknown Object (File)
Dec 20 2023, 7:57 AM
Unknown Object (File)
Dec 18 2023, 6:33 AM
Unknown Object (File)
Nov 25 2023, 2:17 PM
Subscribers

Details

Summary

To quote the manual:
The pointer passed in as name and type is saved rather than the data
it points to. The data pointed to must remain stable until the mutex
is destroyed.

It seems that the type is actually copied, but the name is stored as
a pointer indeed.
mmc_cam_sim_alloc used a name stored on stack.
So, a corrupt mutex name would be reported.
For example:

lock order reversal: (sleepable after non-sleepable)
1st 0xd7285b20 <8A><C0><C0>P@<C1><D0>P@<C1>^D^A (aw_mmc_sim, sleep mutex) @ /usr/devel/git/orange/sys/cam/cam_xpt.c:2804

This change moves the name to struct mmc_sim.
Also, that name is used as the sim name as well.
Unused mtx_name variable is removed too.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

avg requested review of this revision.Dec 13 2021, 11:45 AM
This revision was not accepted when it landed; it landed in state Needs Review.Dec 13 2021, 11:52 AM
This revision was automatically updated to reflect the committed changes.
manu accepted this revision.
This revision is now accepted and ready to land.Dec 13 2021, 12:25 PM

In case you re-open it, I'd accept it. Scrolling through it looks sane. Probably wasn't worth backing it out.

I think the only question I'd have is-- do we actually need 64 characters for a mutex name and the SIM name? I think in a lot of places we used 16 for the mutex; probably also because some tools will truncate when printing?

In D33412#755309, @bz wrote:

I think the only question I'd have is-- do we actually need 64 characters for a mutex name and the SIM name? I think in a lot of places we used 16 for the mutex; probably also because some tools will truncate when printing?

Good question and I am not sure.
I kept what the original code used, but that was on the stack.
I think that 16 should be enough.
I wonder if we have any constants for conventional mutex and SIM name lengths.

This revision was automatically updated to reflect the committed changes.