Re: PATCH: add more malloc.conf details to malloc.3

2014-07-11 Thread Otto Moerbeek
On Fri, Jul 11, 2014 at 01:38:23AM -0600, Theo de Raadt wrote:

> I am a bit concerned.  The description is trying too hard to be overly
> precise, and may be cumbersome for the typical reader of this page.

indeed, and I also dislike putting too much implementation details
into a man page. Things might change and if you are really interested,
read the code. 

-Otto

> 
> > Index: lib/libc/stdlib/malloc.3
> > ===
> > RCS file: /cvs/src/lib/libc/stdlib/malloc.3,v
> > retrieving revision 1.78
> > diff -u -p -d -r1.78 malloc.3
> > --- lib/libc/stdlib/malloc.31 May 2014 18:41:59 -   1.78
> > +++ lib/libc/stdlib/malloc.311 Jul 2014 07:19:27 -
> > @@ -220,10 +220,23 @@ Malloc will first look for a symbolic li
> >  .Pa /etc/malloc.conf
> >  and next check the environment for a variable called
> >  .Ev MALLOC_OPTIONS
> > +(if not
> > +.Xr issetugid 2 )
> >  and finally for the global variable
> >  .Va malloc_options
> >  and scan them for flags in that order.
> >  Flags are single letters, uppercase means on, lowercase means off.
> > +.Pp
> > +The default flags are
> > +.Cm A
> > +and
> > +.Cm P ,
> > +small chunks are always junked, and the first
> > +part of the pages is junked after free.
> > +The default junk behavior does not correspond to
> > +.Cm j
> > +or
> > +.Cm J .
> >  .Bl -tag -width indent
> >  .It Cm A
> >  .Dq Abort .
> > @@ -271,6 +284,7 @@ Currently junk is bytes of 0xd0 when all
> >  .Dq Duh .
> >  \&:-)
> >  Freed chunks are filled with 0xdf.
> > +This performs more junking than by default.
> >  .It Cm j
> >  .Dq Don't Junk .
> >  By default, small chunks are always junked, and the first part of pages
> > @@ -297,6 +311,11 @@ This can substantially aid in compacting
> >  .\"Consult the source for this one.
> >  .It Cm S
> >  Enable all options suitable for security auditing.
> > +This currently enables flags
> > +.Cm U ,
> > +.Cm J ,
> > +.Cm G
> > +and sets the free cache page size to 0.
> >  .It Cm U
> >  .Dq Free unmap .
> >  Enable use after free protection for larger allocations.
> > 



Re: PATCH: add more malloc.conf details to malloc.3

2014-07-11 Thread Jason McIntyre
On Fri, Jul 11, 2014 at 07:25:06AM +, Doug Hogan wrote:
> On Fri, Jul 11, 2014 at 01:03:54AM -0600, Anthony J. Bentley wrote:
> > In addition to what jmc said, if you document these flags they need to
> > be marked up with the Cm macro instead of ASCII single quotes.
> 
> My mistake.  Fixed version:
> 
> 
> Index: lib/libc/stdlib/malloc.3
> ===
> RCS file: /cvs/src/lib/libc/stdlib/malloc.3,v
> retrieving revision 1.78
> diff -u -p -d -r1.78 malloc.3
> --- lib/libc/stdlib/malloc.3  1 May 2014 18:41:59 -   1.78
> +++ lib/libc/stdlib/malloc.3  11 Jul 2014 07:19:27 -
> @@ -220,10 +220,23 @@ Malloc will first look for a symbolic li
>  .Pa /etc/malloc.conf
>  and next check the environment for a variable called
>  .Ev MALLOC_OPTIONS
> +(if not
> +.Xr issetugid 2 )
>  and finally for the global variable
>  .Va malloc_options
>  and scan them for flags in that order.
>  Flags are single letters, uppercase means on, lowercase means off.
> +.Pp
> +The default flags are
> +.Cm A
> +and
> +.Cm P ,

you could keep that briefer by using:

...are
.Cm AP ,

> +small chunks are always junked, and the first
> +part of the pages is junked after free.
> +The default junk behavior does not correspond to
> +.Cm j
> +or
> +.Cm J .
>  .Bl -tag -width indent
>  .It Cm A
>  .Dq Abort .
> @@ -271,6 +284,7 @@ Currently junk is bytes of 0xd0 when all
>  .Dq Duh .
>  \&:-)
>  Freed chunks are filled with 0xdf.
> +This performs more junking than by default.
>  .It Cm j
>  .Dq Don't Junk .
>  By default, small chunks are always junked, and the first part of pages
> @@ -297,6 +311,11 @@ This can substantially aid in compacting
>  .\"Consult the source for this one.
>  .It Cm S
>  Enable all options suitable for security auditing.
> +This currently enables flags
> +.Cm U ,
> +.Cm J ,
> +.Cm G

here too.

> +and sets the free cache page size to 0.
>  .It Cm U
>  .Dq Free unmap .
>  Enable use after free protection for larger allocations.
> 

jmc



Re: PATCH: add more malloc.conf details to malloc.3

2014-07-11 Thread Theo de Raadt
I am a bit concerned.  The description is trying too hard to be overly
precise, and may be cumbersome for the typical reader of this page.

> Index: lib/libc/stdlib/malloc.3
> ===
> RCS file: /cvs/src/lib/libc/stdlib/malloc.3,v
> retrieving revision 1.78
> diff -u -p -d -r1.78 malloc.3
> --- lib/libc/stdlib/malloc.3  1 May 2014 18:41:59 -   1.78
> +++ lib/libc/stdlib/malloc.3  11 Jul 2014 07:19:27 -
> @@ -220,10 +220,23 @@ Malloc will first look for a symbolic li
>  .Pa /etc/malloc.conf
>  and next check the environment for a variable called
>  .Ev MALLOC_OPTIONS
> +(if not
> +.Xr issetugid 2 )
>  and finally for the global variable
>  .Va malloc_options
>  and scan them for flags in that order.
>  Flags are single letters, uppercase means on, lowercase means off.
> +.Pp
> +The default flags are
> +.Cm A
> +and
> +.Cm P ,
> +small chunks are always junked, and the first
> +part of the pages is junked after free.
> +The default junk behavior does not correspond to
> +.Cm j
> +or
> +.Cm J .
>  .Bl -tag -width indent
>  .It Cm A
>  .Dq Abort .
> @@ -271,6 +284,7 @@ Currently junk is bytes of 0xd0 when all
>  .Dq Duh .
>  \&:-)
>  Freed chunks are filled with 0xdf.
> +This performs more junking than by default.
>  .It Cm j
>  .Dq Don't Junk .
>  By default, small chunks are always junked, and the first part of pages
> @@ -297,6 +311,11 @@ This can substantially aid in compacting
>  .\"Consult the source for this one.
>  .It Cm S
>  Enable all options suitable for security auditing.
> +This currently enables flags
> +.Cm U ,
> +.Cm J ,
> +.Cm G
> +and sets the free cache page size to 0.
>  .It Cm U
>  .Dq Free unmap .
>  Enable use after free protection for larger allocations.
> 



Re: PATCH: add more malloc.conf details to malloc.3

2014-07-11 Thread Doug Hogan
On Fri, Jul 11, 2014 at 01:03:54AM -0600, Anthony J. Bentley wrote:
> In addition to what jmc said, if you document these flags they need to
> be marked up with the Cm macro instead of ASCII single quotes.

My mistake.  Fixed version:


Index: lib/libc/stdlib/malloc.3
===
RCS file: /cvs/src/lib/libc/stdlib/malloc.3,v
retrieving revision 1.78
diff -u -p -d -r1.78 malloc.3
--- lib/libc/stdlib/malloc.31 May 2014 18:41:59 -   1.78
+++ lib/libc/stdlib/malloc.311 Jul 2014 07:19:27 -
@@ -220,10 +220,23 @@ Malloc will first look for a symbolic li
 .Pa /etc/malloc.conf
 and next check the environment for a variable called
 .Ev MALLOC_OPTIONS
+(if not
+.Xr issetugid 2 )
 and finally for the global variable
 .Va malloc_options
 and scan them for flags in that order.
 Flags are single letters, uppercase means on, lowercase means off.
+.Pp
+The default flags are
+.Cm A
+and
+.Cm P ,
+small chunks are always junked, and the first
+part of the pages is junked after free.
+The default junk behavior does not correspond to
+.Cm j
+or
+.Cm J .
 .Bl -tag -width indent
 .It Cm A
 .Dq Abort .
@@ -271,6 +284,7 @@ Currently junk is bytes of 0xd0 when all
 .Dq Duh .
 \&:-)
 Freed chunks are filled with 0xdf.
+This performs more junking than by default.
 .It Cm j
 .Dq Don't Junk .
 By default, small chunks are always junked, and the first part of pages
@@ -297,6 +311,11 @@ This can substantially aid in compacting
 .\"Consult the source for this one.
 .It Cm S
 Enable all options suitable for security auditing.
+This currently enables flags
+.Cm U ,
+.Cm J ,
+.Cm G
+and sets the free cache page size to 0.
 .It Cm U
 .Dq Free unmap .
 Enable use after free protection for larger allocations.



Re: PATCH: add more malloc.conf details to malloc.3

2014-07-11 Thread Anthony J. Bentley
On Fri, Jul 11, 2014 at 12:50 AM, Jason McIntyre  wrote:
> On Fri, Jul 11, 2014 at 05:46:15AM +, Doug Hogan wrote:
>>  .It Cm j
>>  .Dq Don't Junk .
>>  By default, small chunks are always junked, and the first part of pages
>> @@ -297,6 +303,7 @@ This can substantially aid in compacting
>>  .\"Consult the source for this one.
>>  .It Cm S
>>  Enable all options suitable for security auditing.
>> +This currently enables flags 'UJG' and sets the free cache page size to 0.
>>  .It Cm U
>>  .Dq Free unmap .
>>  Enable use after free protection for larger allocations.

In addition to what jmc said, if you document these flags they need to
be marked up with the Cm macro instead of ASCII single quotes.

-- 
Anthony J. Bentley



Re: PATCH: add more malloc.conf details to malloc.3

2014-07-10 Thread Jason McIntyre
On Fri, Jul 11, 2014 at 05:46:15AM +, Doug Hogan wrote:
> I don't think the current man page has enough detail for what the
> malloc.conf settings do.
> 
> 
> Index: lib/libc/stdlib/malloc.3
> ===
> RCS file: /cvs/src/lib/libc/stdlib/malloc.3,v
> retrieving revision 1.78
> diff -u -p -d -r1.78 malloc.3
> --- lib/libc/stdlib/malloc.3  1 May 2014 18:41:59 -   1.78
> +++ lib/libc/stdlib/malloc.3  11 Jul 2014 04:30:37 -
> @@ -220,10 +220,16 @@ Malloc will first look for a symbolic li
>  .Pa /etc/malloc.conf
>  and next check the environment for a variable called
>  .Ev MALLOC_OPTIONS
> +(if not
> +.Xr issetugid 2 )
>  and finally for the global variable
>  .Va malloc_options
>  and scan them for flags in that order.
>  Flags are single letters, uppercase means on, lowercase means off.
> +

you want .Pp instead of a blank line

> +The default flags are 'AP', small chunks are always junked, and the first
> +part of the pages is junked after free.  The default junk behavior does not

new sentences start on new lines

> +correspond to 'j' or 'J'.
>  .Bl -tag -width indent
>  .It Cm A
>  .Dq Abort .
> @@ -270,7 +276,7 @@ Fill some junk into the area allocated.
>  Currently junk is bytes of 0xd0 when allocating; this is pronounced
>  .Dq Duh .
>  \&:-)
> -Freed chunks are filled with 0xdf.
> +Freed chunks are filled with 0xdf.  This performs more junking than by 
> default.

ditto

>  .It Cm j
>  .Dq Don't Junk .
>  By default, small chunks are always junked, and the first part of pages
> @@ -297,6 +303,7 @@ This can substantially aid in compacting
>  .\"Consult the source for this one.
>  .It Cm S
>  Enable all options suitable for security auditing.
> +This currently enables flags 'UJG' and sets the free cache page size to 0.
>  .It Cm U
>  .Dq Free unmap .
>  Enable use after free protection for larger allocations.
> 

if another developer wants to pick this up, i'm ok with it.

jmc



PATCH: add more malloc.conf details to malloc.3

2014-07-10 Thread Doug Hogan
I don't think the current man page has enough detail for what the
malloc.conf settings do.


Index: lib/libc/stdlib/malloc.3
===
RCS file: /cvs/src/lib/libc/stdlib/malloc.3,v
retrieving revision 1.78
diff -u -p -d -r1.78 malloc.3
--- lib/libc/stdlib/malloc.31 May 2014 18:41:59 -   1.78
+++ lib/libc/stdlib/malloc.311 Jul 2014 04:30:37 -
@@ -220,10 +220,16 @@ Malloc will first look for a symbolic li
 .Pa /etc/malloc.conf
 and next check the environment for a variable called
 .Ev MALLOC_OPTIONS
+(if not
+.Xr issetugid 2 )
 and finally for the global variable
 .Va malloc_options
 and scan them for flags in that order.
 Flags are single letters, uppercase means on, lowercase means off.
+
+The default flags are 'AP', small chunks are always junked, and the first
+part of the pages is junked after free.  The default junk behavior does not
+correspond to 'j' or 'J'.
 .Bl -tag -width indent
 .It Cm A
 .Dq Abort .
@@ -270,7 +276,7 @@ Fill some junk into the area allocated.
 Currently junk is bytes of 0xd0 when allocating; this is pronounced
 .Dq Duh .
 \&:-)
-Freed chunks are filled with 0xdf.
+Freed chunks are filled with 0xdf.  This performs more junking than by default.
 .It Cm j
 .Dq Don't Junk .
 By default, small chunks are always junked, and the first part of pages
@@ -297,6 +303,7 @@ This can substantially aid in compacting
 .\"Consult the source for this one.
 .It Cm S
 Enable all options suitable for security auditing.
+This currently enables flags 'UJG' and sets the free cache page size to 0.
 .It Cm U
 .Dq Free unmap .
 Enable use after free protection for larger allocations.