RE: [hackers] [dwm][PATCH] move config data to read-only sections

2017-09-06 Thread Joachim.Henke
From: Anselm R Garbe [garb...@gmail.com]
Sent: Wednesday, September 6, 2017 7:38 PM
To: hackers mail list
Subject: Re: [hackers] [dwm][PATCH] move config data to read-only sections

On 6 September 2017 at 19:03,   wrote:
> From: Hiltjo Posthuma [hil...@codemadness.org]
> Sent: Wednesday, September 6, 2017 5:32 PM
> To: hackers mail list
> Subject: Re: [hackers] [dwm][PATCH] move config data to read-only sections
>
> On Wed, Sep 06, 2017 at 05:07:06PM +0200, Anselm R Garbe wrote:
>> Hi Joachim,
>>
>> On 6 September 2017 at 17:02,   wrote:
>> > commit 6a5056d4c919bb5ae0222b2fde0ed787d50092cf
>> > Author: Joachim Henke 
>> > AuthorDate: Wed, 6 Sep 2017 16:26:42 +0200
>> >
>> > The configuration data is just used read-only. So making it immutable
>> > might improve security. Testing on x86_64 showed that the .data section
>> > shrunk considerably: by ~2500 bytes.
>> >
>> > diff --git a/config.def.h b/config.def.h
>> > index a9ac303..a43a03c 100644
>> > --- a/config.def.h
>> > +++ b/config.def.h
>> > @@ -5,14 +5,14 @@ static const unsigned int borderpx  = 1;/* 
>> > border pixel of windows */
>> >  static const unsigned int snap  = 32;   /* snap pixel */
>> >  static const int showbar= 1;/* 0 means no bar */
>> >  static const int topbar = 1;/* 0 means bottom bar */
>> > -static const char *fonts[]  = { "monospace:size=10" };
>> > +static const char *const fonts[]= { "monospace:size=10" };
>> >  static const char dmenufont[]   = "monospace:size=10";
>> >  static const char col_gray1[]   = "#22";
>> >  static const char col_gray2[]   = "#44";
>> >  static const char col_gray3[]   = "#bb";
>> >  static const char col_gray4[]   = "#ee";
>> >  static const char col_cyan[]= "#005577";
>> > -static const char *colors[][3]  = {
>> > +static const char *const colors[][3] = {
>> > /*   fg bg border   */
>> > [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
>> > [SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
>> > @@ -56,10 +56,10 @@ static const Layout layouts[] = {
>> >
>> >  /* commands */
>> >  static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in 
>> > spawn() */
>> > -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", 
>> > dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", 
>> > col_gray4, NULL };
>> > -static const char *termcmd[]  = { "st", NULL };
>> > +static const char *const dmenucmd[] = { "dmenu_run", "-m", dmenumon, 
>> > "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, 
>> > "-sf", col_gray4, NULL };
>> > +static const char *const termcmd[]  = { "st", NULL };
>> >
>> > -static Key keys[] = {
>> > +static const Key keys[] = {
>> > /* modifier keyfunction
>> > argument */
>> > { MODKEY,   XK_p,  spawn,  {.v = 
>> > dmenucmd } },
>> > { MODKEY|ShiftMask, XK_Return, spawn,  {.v = 
>> > termcmd } },
>> > @@ -98,7 +98,7 @@ static Key keys[] = {
>> >
>> >  /* button definitions */
>> >  /* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or 
>> > ClkRootWin */
>> > -static Button buttons[] = {
>> > +static const Button buttons[] = {
>> > /* clickevent mask  button  function   
>> >  argument */
>> > { ClkLtSymbol,  0,  Button1,setlayout, 
>> >  {0} },
>> > { ClkLtSymbol,  0,  Button3,setlayout, 
>> >  {.v = [2]} },
>> > diff --git a/drw.c b/drw.c
>> > index 319eb6b..902976f 100644
>> > --- a/drw.c
>> > +++ b/drw.c
>> > @@ -153,7 +153,7 @@ xfont_free(Fnt *font)
>> >  }
>> >
>> >  Fnt*
>> > -drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
>> > +drw_fontset_create(Drw* drw, const char *const fonts[], size_t fontcount)
>> >  {
>> > Fnt *cur, *ret = NULL;
>> > size_t i;
>> > @@ -194,7 +194,7 @@ drw_clr_create(Drw *drw, XftColor *dest, const char 
>> > *clrname)
>> >  /* Wrapper to create color schemes. The caller has to call free(3) on the
>> >   * returned color scheme when done using it. */
>> >  Scm
>> > -drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
>> > +drw_scm_create(Drw *drw, const char *const clrnames[], size_t clrcount)
>> >  {
>> > size_t i;
>> > Scm ret;
>> > diff --git a/drw.h b/drw.h
>> > index ff4355b..2de6a6f 100644
>> > --- a/drw.h
>> > +++ b/drw.h
>> > @@ -32,14 +32,14 @@ void drw_resize(Drw *drw, unsigned int w, unsigned int 
>> > h);
>> >  void drw_free(Drw *drw);
>> >
>> >  /* Fnt abstraction */
>> > -Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
>> > +Fnt *drw_fontset_create(Drw* drw, const char *const fonts[], 

[hackers] Re: [ubase] dd doesn't handle reading from high latency files well

2017-09-06 Thread Eric Pruitt
On Tue, Sep 05, 2017 at 09:31:04PM -0700, Eric Pruitt wrote:
> The amount of sys time spent by ubase's dd is always a lot higher than
> coreutil's even when the wall-clock time of the runs is comparable. I
> haven't spent a lot of time looking into this yet, so I don't have a
> patch prepared, but glancing at strace showed rapid invocations of
> select(2) which often alternated between succeeding and ENOSYS:

The GNU implementation just uses read(2)
(https://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/dd.c;h=ddeeb4f).
I also looked at the dd implementations in:

- OpenBSD: https://github.com/openbsd/src/blob/master/bin/dd/dd.c
- FreeBSD: https://github.com/freebsd/freebsd/blob/master/bin/dd/dd.c
- BusyBox: https://git.busybox.net/busybox/tree/coreutils/dd.c

Assuming I didn't overlook something, they all use read(2) and write(2)
without select(2). My inclination would be to revert ubase commit
0ca8e52 which introduced select(2) and avoid splice(2) since getting rid
of the Linux-specific function might make it possible to move dd from
ubase to sbase.

Eric




Re: [hackers] [dwm][PATCH] move config data to read-only sections

2017-09-06 Thread Anselm R Garbe
On 6 September 2017 at 19:03,   wrote:
> From: Hiltjo Posthuma [hil...@codemadness.org]
> Sent: Wednesday, September 6, 2017 5:32 PM
> To: hackers mail list
> Subject: Re: [hackers] [dwm][PATCH] move config data to read-only sections
>
> On Wed, Sep 06, 2017 at 05:07:06PM +0200, Anselm R Garbe wrote:
>> Hi Joachim,
>>
>> On 6 September 2017 at 17:02,   wrote:
>> > commit 6a5056d4c919bb5ae0222b2fde0ed787d50092cf
>> > Author: Joachim Henke 
>> > AuthorDate: Wed, 6 Sep 2017 16:26:42 +0200
>> >
>> > The configuration data is just used read-only. So making it immutable
>> > might improve security. Testing on x86_64 showed that the .data section
>> > shrunk considerably: by ~2500 bytes.
>> >
>> > diff --git a/config.def.h b/config.def.h
>> > index a9ac303..a43a03c 100644
>> > --- a/config.def.h
>> > +++ b/config.def.h
>> > @@ -5,14 +5,14 @@ static const unsigned int borderpx  = 1;/* 
>> > border pixel of windows */
>> >  static const unsigned int snap  = 32;   /* snap pixel */
>> >  static const int showbar= 1;/* 0 means no bar */
>> >  static const int topbar = 1;/* 0 means bottom bar */
>> > -static const char *fonts[]  = { "monospace:size=10" };
>> > +static const char *const fonts[]= { "monospace:size=10" };
>> >  static const char dmenufont[]   = "monospace:size=10";
>> >  static const char col_gray1[]   = "#22";
>> >  static const char col_gray2[]   = "#44";
>> >  static const char col_gray3[]   = "#bb";
>> >  static const char col_gray4[]   = "#ee";
>> >  static const char col_cyan[]= "#005577";
>> > -static const char *colors[][3]  = {
>> > +static const char *const colors[][3] = {
>> > /*   fg bg border   */
>> > [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
>> > [SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
>> > @@ -56,10 +56,10 @@ static const Layout layouts[] = {
>> >
>> >  /* commands */
>> >  static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in 
>> > spawn() */
>> > -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", 
>> > dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", 
>> > col_gray4, NULL };
>> > -static const char *termcmd[]  = { "st", NULL };
>> > +static const char *const dmenucmd[] = { "dmenu_run", "-m", dmenumon, 
>> > "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, 
>> > "-sf", col_gray4, NULL };
>> > +static const char *const termcmd[]  = { "st", NULL };
>> >
>> > -static Key keys[] = {
>> > +static const Key keys[] = {
>> > /* modifier keyfunction
>> > argument */
>> > { MODKEY,   XK_p,  spawn,  {.v = 
>> > dmenucmd } },
>> > { MODKEY|ShiftMask, XK_Return, spawn,  {.v = 
>> > termcmd } },
>> > @@ -98,7 +98,7 @@ static Key keys[] = {
>> >
>> >  /* button definitions */
>> >  /* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or 
>> > ClkRootWin */
>> > -static Button buttons[] = {
>> > +static const Button buttons[] = {
>> > /* clickevent mask  button  function   
>> >  argument */
>> > { ClkLtSymbol,  0,  Button1,setlayout, 
>> >  {0} },
>> > { ClkLtSymbol,  0,  Button3,setlayout, 
>> >  {.v = [2]} },
>> > diff --git a/drw.c b/drw.c
>> > index 319eb6b..902976f 100644
>> > --- a/drw.c
>> > +++ b/drw.c
>> > @@ -153,7 +153,7 @@ xfont_free(Fnt *font)
>> >  }
>> >
>> >  Fnt*
>> > -drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
>> > +drw_fontset_create(Drw* drw, const char *const fonts[], size_t fontcount)
>> >  {
>> > Fnt *cur, *ret = NULL;
>> > size_t i;
>> > @@ -194,7 +194,7 @@ drw_clr_create(Drw *drw, XftColor *dest, const char 
>> > *clrname)
>> >  /* Wrapper to create color schemes. The caller has to call free(3) on the
>> >   * returned color scheme when done using it. */
>> >  Scm
>> > -drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
>> > +drw_scm_create(Drw *drw, const char *const clrnames[], size_t clrcount)
>> >  {
>> > size_t i;
>> > Scm ret;
>> > diff --git a/drw.h b/drw.h
>> > index ff4355b..2de6a6f 100644
>> > --- a/drw.h
>> > +++ b/drw.h
>> > @@ -32,14 +32,14 @@ void drw_resize(Drw *drw, unsigned int w, unsigned int 
>> > h);
>> >  void drw_free(Drw *drw);
>> >
>> >  /* Fnt abstraction */
>> > -Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
>> > +Fnt *drw_fontset_create(Drw* drw, const char *const fonts[], size_t 
>> > fontcount);
>> >  void drw_fontset_free(Fnt* set);
>> >  unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
>> >  void drw_font_getexts(Fnt *font, const char 

RE: [hackers] [dwm][PATCH] move config data to read-only sections

2017-09-06 Thread Joachim.Henke
From: Hiltjo Posthuma [hil...@codemadness.org]
Sent: Wednesday, September 6, 2017 5:32 PM
To: hackers mail list
Subject: Re: [hackers] [dwm][PATCH] move config data to read-only sections

On Wed, Sep 06, 2017 at 05:07:06PM +0200, Anselm R Garbe wrote:
> Hi Joachim,
>
> On 6 September 2017 at 17:02,   wrote:
> > commit 6a5056d4c919bb5ae0222b2fde0ed787d50092cf
> > Author: Joachim Henke 
> > AuthorDate: Wed, 6 Sep 2017 16:26:42 +0200
> >
> > The configuration data is just used read-only. So making it immutable
> > might improve security. Testing on x86_64 showed that the .data section
> > shrunk considerably: by ~2500 bytes.
> >
> > diff --git a/config.def.h b/config.def.h
> > index a9ac303..a43a03c 100644
> > --- a/config.def.h
> > +++ b/config.def.h
> > @@ -5,14 +5,14 @@ static const unsigned int borderpx  = 1;/* border 
> > pixel of windows */
> >  static const unsigned int snap  = 32;   /* snap pixel */
> >  static const int showbar= 1;/* 0 means no bar */
> >  static const int topbar = 1;/* 0 means bottom bar */
> > -static const char *fonts[]  = { "monospace:size=10" };
> > +static const char *const fonts[]= { "monospace:size=10" };
> >  static const char dmenufont[]   = "monospace:size=10";
> >  static const char col_gray1[]   = "#22";
> >  static const char col_gray2[]   = "#44";
> >  static const char col_gray3[]   = "#bb";
> >  static const char col_gray4[]   = "#ee";
> >  static const char col_cyan[]= "#005577";
> > -static const char *colors[][3]  = {
> > +static const char *const colors[][3] = {
> > /*   fg bg border   */
> > [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
> > [SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
> > @@ -56,10 +56,10 @@ static const Layout layouts[] = {
> >
> >  /* commands */
> >  static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in 
> > spawn() */
> > -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", 
> > dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", 
> > col_gray4, NULL };
> > -static const char *termcmd[]  = { "st", NULL };
> > +static const char *const dmenucmd[] = { "dmenu_run", "-m", dmenumon, 
> > "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, 
> > "-sf", col_gray4, NULL };
> > +static const char *const termcmd[]  = { "st", NULL };
> >
> > -static Key keys[] = {
> > +static const Key keys[] = {
> > /* modifier keyfunctionargument 
> > */
> > { MODKEY,   XK_p,  spawn,  {.v = 
> > dmenucmd } },
> > { MODKEY|ShiftMask, XK_Return, spawn,  {.v = 
> > termcmd } },
> > @@ -98,7 +98,7 @@ static Key keys[] = {
> >
> >  /* button definitions */
> >  /* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or 
> > ClkRootWin */
> > -static Button buttons[] = {
> > +static const Button buttons[] = {
> > /* clickevent mask  button  function
> > argument */
> > { ClkLtSymbol,  0,  Button1,setlayout,  
> > {0} },
> > { ClkLtSymbol,  0,  Button3,setlayout,  
> > {.v = [2]} },
> > diff --git a/drw.c b/drw.c
> > index 319eb6b..902976f 100644
> > --- a/drw.c
> > +++ b/drw.c
> > @@ -153,7 +153,7 @@ xfont_free(Fnt *font)
> >  }
> >
> >  Fnt*
> > -drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
> > +drw_fontset_create(Drw* drw, const char *const fonts[], size_t fontcount)
> >  {
> > Fnt *cur, *ret = NULL;
> > size_t i;
> > @@ -194,7 +194,7 @@ drw_clr_create(Drw *drw, XftColor *dest, const char 
> > *clrname)
> >  /* Wrapper to create color schemes. The caller has to call free(3) on the
> >   * returned color scheme when done using it. */
> >  Scm
> > -drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
> > +drw_scm_create(Drw *drw, const char *const clrnames[], size_t clrcount)
> >  {
> > size_t i;
> > Scm ret;
> > diff --git a/drw.h b/drw.h
> > index ff4355b..2de6a6f 100644
> > --- a/drw.h
> > +++ b/drw.h
> > @@ -32,14 +32,14 @@ void drw_resize(Drw *drw, unsigned int w, unsigned int 
> > h);
> >  void drw_free(Drw *drw);
> >
> >  /* Fnt abstraction */
> > -Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
> > +Fnt *drw_fontset_create(Drw* drw, const char *const fonts[], size_t 
> > fontcount);
> >  void drw_fontset_free(Fnt* set);
> >  unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
> >  void drw_font_getexts(Fnt *font, const char *text, unsigned int len, 
> > unsigned int *w, unsigned int *h);
> >
> >  /* Colorscheme abstraction */
> >  void drw_clr_create(Drw *drw, XftColor *dest, const char *clrname);
> > -Scm 

Re: [hackers] [dwm][PATCH] move config data to read-only sections

2017-09-06 Thread Hiltjo Posthuma
On Wed, Sep 06, 2017 at 05:07:06PM +0200, Anselm R Garbe wrote:
> Hi Joachim,
> 
> On 6 September 2017 at 17:02,   wrote:
> > commit 6a5056d4c919bb5ae0222b2fde0ed787d50092cf
> > Author: Joachim Henke 
> > AuthorDate: Wed, 6 Sep 2017 16:26:42 +0200
> >
> > The configuration data is just used read-only. So making it immutable
> > might improve security. Testing on x86_64 showed that the .data section
> > shrunk considerably: by ~2500 bytes.
> >
> > diff --git a/config.def.h b/config.def.h
> > index a9ac303..a43a03c 100644
> > --- a/config.def.h
> > +++ b/config.def.h
> > @@ -5,14 +5,14 @@ static const unsigned int borderpx  = 1;/* border 
> > pixel of windows */
> >  static const unsigned int snap  = 32;   /* snap pixel */
> >  static const int showbar= 1;/* 0 means no bar */
> >  static const int topbar = 1;/* 0 means bottom bar */
> > -static const char *fonts[]  = { "monospace:size=10" };
> > +static const char *const fonts[]= { "monospace:size=10" };
> >  static const char dmenufont[]   = "monospace:size=10";
> >  static const char col_gray1[]   = "#22";
> >  static const char col_gray2[]   = "#44";
> >  static const char col_gray3[]   = "#bb";
> >  static const char col_gray4[]   = "#ee";
> >  static const char col_cyan[]= "#005577";
> > -static const char *colors[][3]  = {
> > +static const char *const colors[][3] = {
> > /*   fg bg border   */
> > [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
> > [SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
> > @@ -56,10 +56,10 @@ static const Layout layouts[] = {
> >
> >  /* commands */
> >  static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in 
> > spawn() */
> > -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", 
> > dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", 
> > col_gray4, NULL };
> > -static const char *termcmd[]  = { "st", NULL };
> > +static const char *const dmenucmd[] = { "dmenu_run", "-m", dmenumon, 
> > "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, 
> > "-sf", col_gray4, NULL };
> > +static const char *const termcmd[]  = { "st", NULL };
> >
> > -static Key keys[] = {
> > +static const Key keys[] = {
> > /* modifier keyfunctionargument 
> > */
> > { MODKEY,   XK_p,  spawn,  {.v = 
> > dmenucmd } },
> > { MODKEY|ShiftMask, XK_Return, spawn,  {.v = 
> > termcmd } },
> > @@ -98,7 +98,7 @@ static Key keys[] = {
> >
> >  /* button definitions */
> >  /* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or 
> > ClkRootWin */
> > -static Button buttons[] = {
> > +static const Button buttons[] = {
> > /* clickevent mask  button  function
> > argument */
> > { ClkLtSymbol,  0,  Button1,setlayout,  
> > {0} },
> > { ClkLtSymbol,  0,  Button3,setlayout,  
> > {.v = [2]} },
> > diff --git a/drw.c b/drw.c
> > index 319eb6b..902976f 100644
> > --- a/drw.c
> > +++ b/drw.c
> > @@ -153,7 +153,7 @@ xfont_free(Fnt *font)
> >  }
> >
> >  Fnt*
> > -drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
> > +drw_fontset_create(Drw* drw, const char *const fonts[], size_t fontcount)
> >  {
> > Fnt *cur, *ret = NULL;
> > size_t i;
> > @@ -194,7 +194,7 @@ drw_clr_create(Drw *drw, XftColor *dest, const char 
> > *clrname)
> >  /* Wrapper to create color schemes. The caller has to call free(3) on the
> >   * returned color scheme when done using it. */
> >  Scm
> > -drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
> > +drw_scm_create(Drw *drw, const char *const clrnames[], size_t clrcount)
> >  {
> > size_t i;
> > Scm ret;
> > diff --git a/drw.h b/drw.h
> > index ff4355b..2de6a6f 100644
> > --- a/drw.h
> > +++ b/drw.h
> > @@ -32,14 +32,14 @@ void drw_resize(Drw *drw, unsigned int w, unsigned int 
> > h);
> >  void drw_free(Drw *drw);
> >
> >  /* Fnt abstraction */
> > -Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
> > +Fnt *drw_fontset_create(Drw* drw, const char *const fonts[], size_t 
> > fontcount);
> >  void drw_fontset_free(Fnt* set);
> >  unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
> >  void drw_font_getexts(Fnt *font, const char *text, unsigned int len, 
> > unsigned int *w, unsigned int *h);
> >
> >  /* Colorscheme abstraction */
> >  void drw_clr_create(Drw *drw, XftColor *dest, const char *clrname);
> > -Scm drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
> > +Scm drw_scm_create(Drw *drw, const char *const clrnames[], size_t 
> > clrcount);
> >
> >  /* Cursor abstraction */
> 

Re: [hackers] [dwm][PATCH] move config data to read-only sections

2017-09-06 Thread Anselm R Garbe
Hi Joachim,

On 6 September 2017 at 17:02,   wrote:
> commit 6a5056d4c919bb5ae0222b2fde0ed787d50092cf
> Author: Joachim Henke 
> AuthorDate: Wed, 6 Sep 2017 16:26:42 +0200
>
> The configuration data is just used read-only. So making it immutable
> might improve security. Testing on x86_64 showed that the .data section
> shrunk considerably: by ~2500 bytes.
>
> diff --git a/config.def.h b/config.def.h
> index a9ac303..a43a03c 100644
> --- a/config.def.h
> +++ b/config.def.h
> @@ -5,14 +5,14 @@ static const unsigned int borderpx  = 1;/* border 
> pixel of windows */
>  static const unsigned int snap  = 32;   /* snap pixel */
>  static const int showbar= 1;/* 0 means no bar */
>  static const int topbar = 1;/* 0 means bottom bar */
> -static const char *fonts[]  = { "monospace:size=10" };
> +static const char *const fonts[]= { "monospace:size=10" };
>  static const char dmenufont[]   = "monospace:size=10";
>  static const char col_gray1[]   = "#22";
>  static const char col_gray2[]   = "#44";
>  static const char col_gray3[]   = "#bb";
>  static const char col_gray4[]   = "#ee";
>  static const char col_cyan[]= "#005577";
> -static const char *colors[][3]  = {
> +static const char *const colors[][3] = {
> /*   fg bg border   */
> [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
> [SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
> @@ -56,10 +56,10 @@ static const Layout layouts[] = {
>
>  /* commands */
>  static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in 
> spawn() */
> -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", 
> dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", 
> col_gray4, NULL };
> -static const char *termcmd[]  = { "st", NULL };
> +static const char *const dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", 
> dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", 
> col_gray4, NULL };
> +static const char *const termcmd[]  = { "st", NULL };
>
> -static Key keys[] = {
> +static const Key keys[] = {
> /* modifier keyfunctionargument */
> { MODKEY,   XK_p,  spawn,  {.v = 
> dmenucmd } },
> { MODKEY|ShiftMask, XK_Return, spawn,  {.v = 
> termcmd } },
> @@ -98,7 +98,7 @@ static Key keys[] = {
>
>  /* button definitions */
>  /* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or 
> ClkRootWin */
> -static Button buttons[] = {
> +static const Button buttons[] = {
> /* clickevent mask  button  function  
>   argument */
> { ClkLtSymbol,  0,  Button1,setlayout,
>   {0} },
> { ClkLtSymbol,  0,  Button3,setlayout,
>   {.v = [2]} },
> diff --git a/drw.c b/drw.c
> index 319eb6b..902976f 100644
> --- a/drw.c
> +++ b/drw.c
> @@ -153,7 +153,7 @@ xfont_free(Fnt *font)
>  }
>
>  Fnt*
> -drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
> +drw_fontset_create(Drw* drw, const char *const fonts[], size_t fontcount)
>  {
> Fnt *cur, *ret = NULL;
> size_t i;
> @@ -194,7 +194,7 @@ drw_clr_create(Drw *drw, XftColor *dest, const char 
> *clrname)
>  /* Wrapper to create color schemes. The caller has to call free(3) on the
>   * returned color scheme when done using it. */
>  Scm
> -drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
> +drw_scm_create(Drw *drw, const char *const clrnames[], size_t clrcount)
>  {
> size_t i;
> Scm ret;
> diff --git a/drw.h b/drw.h
> index ff4355b..2de6a6f 100644
> --- a/drw.h
> +++ b/drw.h
> @@ -32,14 +32,14 @@ void drw_resize(Drw *drw, unsigned int w, unsigned int h);
>  void drw_free(Drw *drw);
>
>  /* Fnt abstraction */
> -Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
> +Fnt *drw_fontset_create(Drw* drw, const char *const fonts[], size_t 
> fontcount);
>  void drw_fontset_free(Fnt* set);
>  unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
>  void drw_font_getexts(Fnt *font, const char *text, unsigned int len, 
> unsigned int *w, unsigned int *h);
>
>  /* Colorscheme abstraction */
>  void drw_clr_create(Drw *drw, XftColor *dest, const char *clrname);
> -Scm drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
> +Scm drw_scm_create(Drw *drw, const char *const clrnames[], size_t clrcount);
>
>  /* Cursor abstraction */
>  Cur *drw_cur_create(Drw *drw, int shape);

I like your patch, at first glance it makes config.h more consistent
with the other const declarations, however I need to browse through
the patches if there were any places, where the non-const declaration
was on purpose for some reason prior to accepting 

[hackers] [dwm][PATCH] move config data to read-only sections

2017-09-06 Thread Joachim.Henke
commit 6a5056d4c919bb5ae0222b2fde0ed787d50092cf
Author: Joachim Henke 
AuthorDate: Wed, 6 Sep 2017 16:26:42 +0200

The configuration data is just used read-only. So making it immutable
might improve security. Testing on x86_64 showed that the .data section
shrunk considerably: by ~2500 bytes.

diff --git a/config.def.h b/config.def.h
index a9ac303..a43a03c 100644
--- a/config.def.h
+++ b/config.def.h
@@ -5,14 +5,14 @@ static const unsigned int borderpx  = 1;/* border 
pixel of windows */
 static const unsigned int snap  = 32;   /* snap pixel */
 static const int showbar= 1;/* 0 means no bar */
 static const int topbar = 1;/* 0 means bottom bar */
-static const char *fonts[]  = { "monospace:size=10" };
+static const char *const fonts[]= { "monospace:size=10" };
 static const char dmenufont[]   = "monospace:size=10";
 static const char col_gray1[]   = "#22";
 static const char col_gray2[]   = "#44";
 static const char col_gray3[]   = "#bb";
 static const char col_gray4[]   = "#ee";
 static const char col_cyan[]= "#005577";
-static const char *colors[][3]  = {
+static const char *const colors[][3] = {
/*   fg bg border   */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
@@ -56,10 +56,10 @@ static const Layout layouts[] = {
 
 /* commands */
 static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in 
spawn() */
-static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", 
dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", 
col_gray4, NULL };
-static const char *termcmd[]  = { "st", NULL };
+static const char *const dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", 
dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", 
col_gray4, NULL };
+static const char *const termcmd[]  = { "st", NULL };
 
-static Key keys[] = {
+static const Key keys[] = {
/* modifier keyfunctionargument */
{ MODKEY,   XK_p,  spawn,  {.v = 
dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn,  {.v = 
termcmd } },
@@ -98,7 +98,7 @@ static Key keys[] = {
 
 /* button definitions */
 /* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or 
ClkRootWin */
-static Button buttons[] = {
+static const Button buttons[] = {
/* clickevent mask  button  function
argument */
{ ClkLtSymbol,  0,  Button1,setlayout,  
{0} },
{ ClkLtSymbol,  0,  Button3,setlayout,  
{.v = [2]} },
diff --git a/drw.c b/drw.c
index 319eb6b..902976f 100644
--- a/drw.c
+++ b/drw.c
@@ -153,7 +153,7 @@ xfont_free(Fnt *font)
 }
 
 Fnt*
-drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
+drw_fontset_create(Drw* drw, const char *const fonts[], size_t fontcount)
 {
Fnt *cur, *ret = NULL;
size_t i;
@@ -194,7 +194,7 @@ drw_clr_create(Drw *drw, XftColor *dest, const char 
*clrname)
 /* Wrapper to create color schemes. The caller has to call free(3) on the
  * returned color scheme when done using it. */
 Scm
-drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
+drw_scm_create(Drw *drw, const char *const clrnames[], size_t clrcount)
 {
size_t i;
Scm ret;
diff --git a/drw.h b/drw.h
index ff4355b..2de6a6f 100644
--- a/drw.h
+++ b/drw.h
@@ -32,14 +32,14 @@ void drw_resize(Drw *drw, unsigned int w, unsigned int h);
 void drw_free(Drw *drw);
 
 /* Fnt abstraction */
-Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
+Fnt *drw_fontset_create(Drw* drw, const char *const fonts[], size_t fontcount);
 void drw_fontset_free(Fnt* set);
 unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
 void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned 
int *w, unsigned int *h);
 
 /* Colorscheme abstraction */
 void drw_clr_create(Drw *drw, XftColor *dest, const char *clrname);
-Scm drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
+Scm drw_scm_create(Drw *drw, const char *const clrnames[], size_t clrcount);
 
 /* Cursor abstraction */
 Cur *drw_cur_create(Drw *drw, int shape);
-- 
2.14.1



Re: [hackers] [sbase] [PATCH] Add missing getconf.h dependency to sbase-box

2017-09-06 Thread Michael Forney
On 2017-09-05, Eric Pruitt  wrote:
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git Makefile Makefile
> index 1c39fef..0e421e7 100644
> --- Makefile
> +++ Makefile
> @@ -233,7 +233,7 @@ dist: clean
>   gzip sbase-$(VERSION).tar
>   rm -rf sbase-$(VERSION)
>
> -sbase-box: $(LIB) $(SRC)
> +sbase-box: $(LIB) $(SRC) getconf.h
>   mkdir -p build
>   cp $(HDR) build
>   cp getconf.h build
> --
> 2.11.0

Thanks, applied.



[hackers] [sbase] Add missing getconf.h dependency to sbase-box || Eric Pruitt

2017-09-06 Thread git
commit fb936d5ba5ae6831dcf42c89ad1a0dce1e338f88
Author: Eric Pruitt 
AuthorDate: Tue Sep 5 18:13:16 2017 -0700
Commit: Michael Forney 
CommitDate: Tue Sep 5 23:00:42 2017 -0700

Add missing getconf.h dependency to sbase-box

diff --git a/Makefile b/Makefile
index 1c39fef..0e421e7 100644
--- a/Makefile
+++ b/Makefile
@@ -233,7 +233,7 @@ dist: clean
gzip sbase-$(VERSION).tar
rm -rf sbase-$(VERSION)
 
-sbase-box: $(LIB) $(SRC)
+sbase-box: $(LIB) $(SRC) getconf.h
mkdir -p build
cp $(HDR) build
cp getconf.h build