You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by "Philippe M. Chiasson" <go...@ectoplasm.org> on 2004/06/16 01:36:34 UTC

[Patch] Prevent coredump when statically linked module tries to access ap_server_config_defines from register_hooks

The only moment where it's appropriate for a module to push Defines values into
ap_server_config_defines is during the register_hook phase. The problem is that
this phase is called earlier for compiled-in modules than for loaded modules.
So a module trying to add to it thru apr_array_push(ap_server_config_defines) at
that time will succeed, only if it's dynamically loaded, and most likely segfault
otherwise.

The following patches delays ap_setup_prelinked_modules to slightly later, after
ap_server_config_defines has been proprely initialized.

Index: server/main.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/main.c,v
retrieving revision 1.157
diff -u -I$Id -r1.157 main.c
--- server/main.c	25 Apr 2004 17:23:31 -0000	1.157
+++ server/main.c	15 Jun 2004 23:33:28 -0000
@@ -428,18 +428,18 @@
      }
  #endif

+    apr_pool_create(&pcommands, pglobal);
+    apr_pool_tag(pcommands, "pcommands");
+    ap_server_pre_read_config  = apr_array_make(pcommands, 1, sizeof(char *));
+    ap_server_post_read_config = apr_array_make(pcommands, 1, sizeof(char *));
+    ap_server_config_defines   = apr_array_make(pcommands, 1, sizeof(char *));
+
      error = ap_setup_prelinked_modules(process);
      if (error) {
          ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_EMERG, 0, NULL, "%s: %s",
                       ap_server_argv0, error);
          destroy_and_exit_process(process, 1);
      }
-
-    apr_pool_create(&pcommands, pglobal);
-    apr_pool_tag(pcommands, "pcommands");
-    ap_server_pre_read_config  = apr_array_make(pcommands, 1, sizeof(char *));
-    ap_server_post_read_config = apr_array_make(pcommands, 1, sizeof(char *));
-    ap_server_config_defines   = apr_array_make(pcommands, 1, sizeof(char *));

      ap_run_rewrite_args(process);



-- 
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Re: [Patch] Prevent coredump when statically linked module tries to access ap_server_config_defines from register_hooks

Posted by Stas Bekman <st...@stason.org>.
>>> Well, knowing httpd will simply segfault otherwise, I'd say, refuse 
>>> static
>>> build for Apache < 2.0.51 with a loud bang.
>>
>>
>>
>> +1
>>
>> but that also means that currently noone can use Apache 2.0.50 or 
>> lower with static build. But there is nothing we can do about it.
> 
> 
> Exactly, and since we _know_ that it will explode otherwise, I think it's
> reasonable to simply bail out of the configuration if static was specified
> and httpd < 2.0.50 (too bad it is an httpd problem we couldn't work around)

Make that < 2.0.51 :)

> Anyways, I'll rework my static build patch with that in mind and 
> resubmit something this week.

Just go ahead and commit it...

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Patch] Prevent coredump when statically linked module tries to access ap_server_config_defines from register_hooks

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>>> Well, knowing httpd will simply segfault otherwise, I'd say, refuse
>>> static
>>> build for Apache < 2.0.51 with a loud bang.
>>
>>
>>
>> +1
>>
>> but that also means that currently noone can use Apache 2.0.50 or
>> lower with static build. But there is nothing we can do about it.
> 
> 
> Exactly, and since we _know_ that it will explode otherwise, I think it's
> reasonable to simply bail out of the configuration if static was specified
> and httpd < 2.0.50 (too bad it is an httpd problem we couldn't work around)

yeah, since there is nothing that can be done about it we really have no
choice but to require 2.0.51.  but at least we know that it can be done with
2.0.51.  or at least we can take active steps to make sure that 2.0.51 has
everything we need so we can wipe this todo off.

--Geoff


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Patch] Prevent coredump when statically linked module tries to access ap_server_config_defines from register_hooks

Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.

Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> 
>>
>>Stas Bekman wrote:
>>
>>
>>>Geoffrey Young wrote:
>>>
>>>
>>>>Geoffrey Young wrote:
>>>>
>>>>
>>>>
>>>>>>>The following patches delays ap_setup_prelinked_modules to slightly
>>>>>>>later, after
>>>>>>>ap_server_config_defines has been proprely initialized.
>>>>>>
>>>>>>
>>>>>>
>>>>>>that all seems reasonable.  does anyone know of any historical (or 
>>>>>>other)
>>>>>>reasons why this shouldn't be shuffled a bit?
>>>>>
>>>>>
>>>>>
>>>>>this has been committed to 2.1 and proposed for backport to 2.0.  vote
>>>>>early, vote often.
>>>>
>>>>
>>>>
>>>>now part of 2.0.51-dev, to be released with 2.0.51.  thanks all :)
>>>
>>>
>>>
>>>So, should we refuse the static build for Apache < 2.0.51? Or at least 
>>>print a warning (which most won't see anyway?)
>>
>>
>>Well, knowing httpd will simply segfault otherwise, I'd say, refuse static
>>build for Apache < 2.0.51 with a loud bang.
> 
> 
> +1
> 
> but that also means that currently noone can use Apache 2.0.50 or lower with 
> static build. But there is nothing we can do about it.

Exactly, and since we _know_ that it will explode otherwise, I think it's
reasonable to simply bail out of the configuration if static was specified
and httpd < 2.0.50 (too bad it is an httpd problem we couldn't work around)

Anyways, I'll rework my static build patch with that in mind and resubmit something
this week.

-- 
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Re: [Patch] Prevent coredump when statically linked module tries to access ap_server_config_defines from register_hooks

Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
> 
> 
> Stas Bekman wrote:
> 
>> Geoffrey Young wrote:
>>
>>> Geoffrey Young wrote:
>>>
>>>
>>>>>> The following patches delays ap_setup_prelinked_modules to slightly
>>>>>> later, after
>>>>>> ap_server_config_defines has been proprely initialized.
>>>>>
>>>>>
>>>>>
>>>>> that all seems reasonable.  does anyone know of any historical (or 
>>>>> other)
>>>>> reasons why this shouldn't be shuffled a bit?
>>>>
>>>>
>>>>
>>>> this has been committed to 2.1 and proposed for backport to 2.0.  vote
>>>> early, vote often.
>>>
>>>
>>>
>>> now part of 2.0.51-dev, to be released with 2.0.51.  thanks all :)
>>
>>
>>
>> So, should we refuse the static build for Apache < 2.0.51? Or at least 
>> print a warning (which most won't see anyway?)
> 
> 
> Well, knowing httpd will simply segfault otherwise, I'd say, refuse static
> build for Apache < 2.0.51 with a loud bang.

+1

but that also means that currently noone can use Apache 2.0.50 or lower with 
static build. But there is nothing we can do about it.


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Patch] Prevent coredump when statically linked module tries to access ap_server_config_defines from register_hooks

Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.

Stas Bekman wrote:
> Geoffrey Young wrote:
> 
>>Geoffrey Young wrote:
>>
>>
>>>>>The following patches delays ap_setup_prelinked_modules to slightly
>>>>>later, after
>>>>>ap_server_config_defines has been proprely initialized.
>>>>
>>>>
>>>>that all seems reasonable.  does anyone know of any historical (or other)
>>>>reasons why this shouldn't be shuffled a bit?
>>>
>>>
>>>this has been committed to 2.1 and proposed for backport to 2.0.  vote
>>>early, vote often.
>>
>>
>>now part of 2.0.51-dev, to be released with 2.0.51.  thanks all :)
> 
> 
> So, should we refuse the static build for Apache < 2.0.51? Or at least print a 
> warning (which most won't see anyway?)

Well, knowing httpd will simply segfault otherwise, I'd say, refuse static
build for Apache < 2.0.51 with a loud bang.

> 

-- 
--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Re: [Patch] Prevent coredump when statically linked module tries to access ap_server_config_defines from register_hooks

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 
> Geoffrey Young wrote:
> 
>>>>The following patches delays ap_setup_prelinked_modules to slightly
>>>>later, after
>>>>ap_server_config_defines has been proprely initialized.
>>>
>>>
>>>that all seems reasonable.  does anyone know of any historical (or other)
>>>reasons why this shouldn't be shuffled a bit?
>>
>>
>>this has been committed to 2.1 and proposed for backport to 2.0.  vote
>>early, vote often.
> 
> 
> now part of 2.0.51-dev, to be released with 2.0.51.  thanks all :)

So, should we refuse the static build for Apache < 2.0.51? Or at least print a 
warning (which most won't see anyway?)


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Patch] Prevent coredump when statically linked module tries to access ap_server_config_defines from register_hooks

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Geoffrey Young wrote:
>>>The following patches delays ap_setup_prelinked_modules to slightly
>>>later, after
>>>ap_server_config_defines has been proprely initialized.
>>
>>
>>that all seems reasonable.  does anyone know of any historical (or other)
>>reasons why this shouldn't be shuffled a bit?
> 
> 
> this has been committed to 2.1 and proposed for backport to 2.0.  vote
> early, vote often.

now part of 2.0.51-dev, to be released with 2.0.51.  thanks all :)

--Geoff

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Patch] Prevent coredump when statically linked module tries to access ap_server_config_defines from register_hooks

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>>The following patches delays ap_setup_prelinked_modules to slightly
>>later, after
>>ap_server_config_defines has been proprely initialized.
> 
> 
> that all seems reasonable.  does anyone know of any historical (or other)
> reasons why this shouldn't be shuffled a bit?

this has been committed to 2.1 and proposed for backport to 2.0.  vote
early, vote often.

--Geoff

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Patch] Prevent coredump when statically linked module tries to access ap_server_config_defines from register_hooks

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Philippe M. Chiasson wrote:
> The only moment where it's appropriate for a module to push Defines
> values into
> ap_server_config_defines is during the register_hook phase. The problem
> is that
> this phase is called earlier for compiled-in modules than for loaded
> modules.
> So a module trying to add to it thru
> apr_array_push(ap_server_config_defines) at
> that time will succeed, only if it's dynamically loaded, and most likely
> segfault
> otherwise.
> 
> The following patches delays ap_setup_prelinked_modules to slightly
> later, after
> ap_server_config_defines has been proprely initialized.

that all seems reasonable.  does anyone know of any historical (or other)
reasons why this shouldn't be shuffled a bit?

--Geoff

Re: [Patch] Prevent coredump when statically linked module tries to access ap_server_config_defines from register_hooks

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Philippe M. Chiasson wrote:
> The only moment where it's appropriate for a module to push Defines
> values into
> ap_server_config_defines is during the register_hook phase. The problem
> is that
> this phase is called earlier for compiled-in modules than for loaded
> modules.
> So a module trying to add to it thru
> apr_array_push(ap_server_config_defines) at
> that time will succeed, only if it's dynamically loaded, and most likely
> segfault
> otherwise.
> 
> The following patches delays ap_setup_prelinked_modules to slightly
> later, after
> ap_server_config_defines has been proprely initialized.

that all seems reasonable.  does anyone know of any historical (or other)
reasons why this shouldn't be shuffled a bit?

--Geoff

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org