git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] mingw: enable DEP and ASLR

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 8, 2019, 11:27 UTC
Message-ID
<nycvar.QRO.7.76.6.1905081319570.44@tvgsbejvaqbjf.bet>
In-Reply-To
<20190501220219.GA42435@google.com>
Hi Jonathan & Peff,
On Wed, 1 May 2019, Jonathan Nieder wrote:
Show 44 quoted lines
> Jeff King wrote:
>
> > I wonder if this points to this patch touching the wrong level. These
> > compiler flags are a thing that _some_ builds want (i.e., production
> > builds where people care most about security and not about debugging),
> > but not necessarily all.
> >
> > I'd have expected this to be tweakable by a Makefile knob (either a
> > specific knob, or just the caller setting the right CFLAGS etc), and
> > then for the builds of Git for Windows to turn those knobs when making a
> > package to distribute.
> >
> > Our internal package builds at GitHub all have this in their config.mak
> > (for Linux, of course):
> >
> >   CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
> >   CFLAGS += -fstack-protector-strong
> >
> >   CFLAGS += -fpie
> >   LDFLAGS += -z relro -z now
> >   LDFLAGS += -pie
> >
> > and I wouldn't be surprised if other binary distributors (like the
> > Debian package) do something similar.
>
> Yes, the Debian package uses
>
> 	CFLAGS := -Wall \
> 		$(shell dpkg-buildflags --get CFLAGS) \
> 		$(shell dpkg-buildflags --get CPPFLAGS)
>
> and then passes CFLAGS='$(CFLAGS)' to "make".
>
> That means we're using
>
> 	-g -O2 -fstack-protector-strong -Wformat -Werror=format-security
> 	-Wdate-time -D_FORTIFY_SOURCE=2
>
> Dscho's suggestion for the Windows build sounds fine to me (if
> checking for -Og, too).  Maybe it would make sense to factor out a
> makefile variable for this, that could be used for builds on other
> platforms, too.  That way, the autodetection can be in one place, and
> there is a standard way to override it when the user wants something
> else.

Indeed, if I was to add a generic "are we building for production?" function, this would be incorrect.

But this is not the case here, we are doing something very specific, Windows-only here, and for the sole reason to keep debuggability (for which the presence of the `-g` option indeed would not be a good indicator: in Git for Windows, we build `.pdb` files so that stackdumps can be more meaningful, but we do not want to have full debug information in those executables).

In the long run, I think we need to become more explicit about this, by adding a "FOR_PRODUCTION" flag. It's really no good if we use implementation details such as CFLAGS to deduce intent.

That's for another patch series, though, as it is pretty clear-cut here: If you build with optimization flags using Git for Windows' SDK, you cannot use gdb for single-stepping, likewise if you use ASLR, so we can totally piggyback the latter onto the former.

Ciao, Dscho

Previous: Jonathan NiederNext: İsmail Dönmez via GitGitGadget
Message 12 of 16 in “Enable Data Execution Protection and Address Space Layout Randomization on Windows”
  1. 0/2 Enable Data Execution Protection and Address Space Layout Randomization on WindowsJohannes Schindelin via GitGitGadget, Apr 29, 2019
  2. 2/2 mingw: enable DEP and ASLRİsmail Dönmez via GitGitGadget, Apr 29, 2019
  3. Johannes SixtApr 30, 2019
  4. Johannes SchindelinApr 30, 2019
  5. Johannes SixtApr 30, 2019
  6. Alban GruinMay 1, 2019
  7. brian m. carlsonMay 1, 2019
  8. Johannes SchindelinMay 8, 2019
  9. Johannes SchindelinMay 8, 2019
  10. Jeff KingMay 1, 2019
  11. Jonathan NiederMay 1, 2019
  12. Johannes SchindelinMay 8, 2019
  13. 1/2 mingw: do not let ld strip relocationsİsmail Dönmez via GitGitGadget, Apr 29, 2019
  14. 0/2 Enable Data Execution Protection and Address Space Layout Randomization on WindowsJohannes Schindelin via GitGitGadget, May 8, 2019
  15. 2/2 mingw: enable DEP and ASLRİsmail Dönmez via GitGitGadget, May 8, 2019
  16. 1/2 mingw: do not let ld strip relocationsİsmail Dönmez via GitGitGadget, May 8, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.