Closed Bug 947599 Opened 10 years ago Closed 10 years ago

Set up DLL blocklist before LoadAppInitDlls (Port Bug 932100 to SeaMonkey)

Categories

(SeaMonkey :: Startup & Profiles, defect)

x86
Windows 7
defect
Not set
normal

Tracking

(seamonkey2.25 affected, seamonkey2.26 fixed, seamonkey2.27 fixed)

RESOLVED FIXED
seamonkey2.27
Tracking Status
seamonkey2.25 --- affected
seamonkey2.26 --- fixed
seamonkey2.27 --- fixed

People

(Reporter: philip.chee, Assigned: philip.chee)

References

Details

Attachments

(1 file, 1 obsolete file)

From: Bug 932100 - Set up DLL blocklist before LoadAppInitDlls

> The DLL blocklist is ineffective against AppInit DLLs because they get
> loaded before the DLL blocklist is initialized. Bug 925459 is an example.
> 
> kernel32!LoadAppInitDlls is called during user32's DLL_PROCESS_ATTACH. In
> order to intercept AppInit DLLs, we would need to hook LdrLoadDll before
> user32 gets loaded.
> 
> Currently, firefox.exe has a load-time link to user32.dll, which means we do
> LoadAppInitDlls before any Mozilla code is executed. It turns out that this
> link to user32 is only used by one call to MessageBoxW from an error handler
> in nsBrowserApp.cpp. Given the rarity of that codepath, we could easily turn
> it into a runtime dynamic link.
> 
> That would at least let us run firefox!wmain before user32, but the
> blocklist is implemented in xul.dll, and by the time we load that,
> InitXPCOMGlue has already loaded a ton of stuff, including user32.
> 
> Some potential options:
> 1) Have a separate blocklist in firefox.exe for AppInit DLLs
> 2) Move the blocklist from xul.dll to firefox.exe
> 3) Disentangle things and try to get xul!XRE_SetupDllBlocklist available
> before InitXPCOMGlue preloads the world
Attached patch Bug947599DLLBlocklist10.diff (obsolete) — Splinter Review
>  #elif defined(XP_WIN)
> -  // GetProcessIoCounters().ReadOperationCount seems to have little to
> -  // do with actual read operations. It reports 0 or 1 at this stage
> -  // in the program. Luckily 1 coincides with when prefetch is
> -  // enabled. If Windows prefetch didn't happen we can do our own
> -  // faster dll preloading.
>    IO_COUNTERS ioCounters;
>    gotCounters = GetProcessIoCounters(GetCurrentProcess(), &ioCounters);
> -  if (gotCounters && !ioCounters.ReadOperationCount)
>  #endif

Removed in Bug 770911 - Remove all prefetch clearing code.

> +#ifdef HAS_DLL_BLOCKLIST
> +  DllBlocklist_Initialize();
> +
> +#ifdef DEBUG
> +  // In order to be effective against AppInit DLLs, the blocklist must be
> +  // initialized before user32.dll is loaded into the process (bug 932100).

> +  if (GetModuleHandleA("user32.dll")) {
> +    fprintf(stderr, "DLL blocklist was unable to intercept AppInit DLLs.\n");

From Bug 939043 - Downgrade the user32 assertion to a warning message.

> Turns out we can't use NS_WARNING this early because the XPCOM debug stuff
> isn't hooked up yet.

> use #ifdef DEBUG printf(stderr) instead.
Assignee: nobody → philip.chee
Attachment #8344183 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #8344184 - Flags: review?(neil)
Attachment #8344184 - Flags: review?(neil) → review+
Pushed to comm-central
http://hg.mozilla.org/comm-central/rev/3f8b45a79dca
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → seamonkey2.27
Should this still land on comm-beta for 2.26? Per bug 990676, the crash reporter didn't launch for Thunderbird because of bug 982077, but it appears that SeaMonkey still had Windows crash reports for aurora (2.26a2). There is a recent crash report for 2.26b1, thus it appears it isn't affected anyway:

https://crash-stats.mozilla.com/query/?product=SeaMonkey&version=SeaMonkey:2.26b1&platform=win&range_value=14&range_unit=days&date=04/11/2014+13:00:00&query_search=signature&query_type=contains&query=&reason=&release_channels=&build_id=&process_type=any&hang_type=any
Are there any sharp drop-offs in SeaMonkey/Windows crashes? If no then we'll ride the trains.
I see TB has backported to comm-aurora and comm-beta. Let's see if the patch sticks there, then we can decide if we want to backport our version as well.
Blocks: 1018792
Landed on comm-release for SeaMonkey 2.26.1

$ hg tip
changeset:   20177:ff1ec742d4c0
branch:      SEA_2_26_1_RELBRANCH
tag:         tip
user:        Philip Chee <philip.chee@gmail.com>
date:        Sat Nov 30 14:11:44 2013 +0800
summary:     Bug 947599 Set up DLL blocklist before LoadAppInitDlls (Port Bug 932100 to SeaMonkey) r=Neil
You need to log in before you can comment on or make changes to this bug.