ftp(1): anonymous login and .netrc

2017-01-04 Thread Anton Lindqvist
I'm running a script as root which drops privileges while fetching files
using ftp(1) with anonymous login enabled:

# doas -u unpriv ftp -a URL

... and was surprised to see the following error:

ftp: /root/.netrc: Permission denied

I'm not sure if the .netrc file should be considered when anonymous
login is enabled. If not, here's a patch:

Index: util.c
===
RCS file: /cvs/src/usr.bin/ftp/util.c,v
retrieving revision 1.81
diff -u -p -r1.81 util.c
--- util.c  20 Aug 2016 20:18:42 -  1.81
+++ util.c  3 Jan 2017 20:19:16 -
@@ -221,7 +221,7 @@ ftp_login(const char *host, char *user, 
struct passwd *pw;
 
 #ifndef SMALL
-   if (user == NULL) {
+   if (user == NULL && !anonftp) {
if (ruserpass(host, &user, &pass, &acctname) < 0) {
code = -1;
return (0);



[patch] fix typo in pf.conf(5)

2017-01-04 Thread Dimitris Papastamos
Hi,

Typo fix, below.

diff --git a/share/man/man5/pf.conf.5 b/share/man/man5/pf.conf.5
index 3559803..955539b 100644
--- a/share/man/man5/pf.conf.5
+++ b/share/man/man5/pf.conf.5
@@ -368,7 +368,7 @@ Translates to the point-to-point interface's peer 
address(es).
 .Pp
 Host names may also have the
 .Cm :0
-modfier appended to restrict the name resolution to the first of each
+modifier appended to restrict the name resolution to the first of each
 v4 and v6 address found.
 .Pp
 Host name resolution and interface to address translation are done at



Re: [patch] fix typo in pf.conf(5)

2017-01-04 Thread Theo Buehler
On Wed, Jan 04, 2017 at 09:52:46AM +, Dimitris Papastamos wrote:
> Hi,
> 
> Typo fix, below.

committed, thanks!

> 
> diff --git a/share/man/man5/pf.conf.5 b/share/man/man5/pf.conf.5
> index 3559803..955539b 100644
> --- a/share/man/man5/pf.conf.5
> +++ b/share/man/man5/pf.conf.5
> @@ -368,7 +368,7 @@ Translates to the point-to-point interface's peer 
> address(es).
>  .Pp
>  Host names may also have the
>  .Cm :0
> -modfier appended to restrict the name resolution to the first of each
> +modifier appended to restrict the name resolution to the first of each
>  v4 and v6 address found.
>  .Pp
>  Host name resolution and interface to address translation are done at
> 



Re: libcrypto: fix assembly for clang

2017-01-04 Thread Patrick Wildt
On Tue, Jan 03, 2017 at 02:16:25PM -0500, Ted Unangst wrote:
> Patrick Wildt wrote:
> > 
> > Maybe they want to support older binutils that do not support the unified 
> > syntax?
> > What's our policy there?
> 
> OpenBSD is just about the oldest binutils around. I wouldn't worry about
> anything older than what we have in base.

Considering that, I'm going to ask for OKs then.

ok?



Re: libcrypto: fix assembly for clang

2017-01-04 Thread Mark Kettenis
> Date: Wed, 4 Jan 2017 11:04:43 +0100
> From: Patrick Wildt 
> 
> On Tue, Jan 03, 2017 at 02:16:25PM -0500, Ted Unangst wrote:
> > Patrick Wildt wrote:
> > > 
> > > Maybe they want to support older binutils that do not support the unified 
> > > syntax?
> > > What's our policy there?
> > 
> > OpenBSD is just about the oldest binutils around. I wouldn't worry about
> > anything older than what we have in base.
> 
> Considering that, I'm going to ask for OKs then.
> 
> ok?

ok kettenis@, but lets give the LibreSSL people a chance to raise any
portability concerns as they might have a better idea about LibreSSL
portable deployment on ARM.



sort(1): fix segfault with -m flag

2017-01-04 Thread Julien Ramseier
sort segfaults when using the -m flag and no files.
It should default to stdin instead.

Easily reproducible with a simple:
sort -m

Index: sort.c
===
RCS file: /cvs/src/usr.bin/sort/sort.c,v
retrieving revision 1.86
diff -u -r1.86 sort.c
--- sort.c  14 Jul 2016 08:31:18 -  1.86
+++ sort.c  4 Jan 2017 11:19:49 -
@@ -1224,7 +1224,10 @@
struct file_list fl;

file_list_init(&fl, false);
-   file_list_populate(&fl, argc, argv, true);
+   if (argc < 1)
+   file_list_add(&fl, "-", true);
+   else
+   file_list_populate(&fl, argc, argv, true);
merge_files(&fl, outfile);
file_list_clean(&fl);
}



xenocara fontconfig: make slight hinting the default

2017-01-04 Thread Nils Reuße
Dear all,

fontconfig made slight hinting the default in version 2.11.95 (see commit at 
[1]).

xenocara currently ships, but does not install the new hinting conf files:

  $ cd /usr/xenocara/dist/fontconfig/conf.d/
  $ for file in *conf; do if ! test -f /etc/fonts/conf.avail/$file; then echo 
"$file not found"; fi; done
  10-hinting-full.conf not found
  10-hinting-medium.conf not found
  10-hinting-none.conf not found
  10-hinting-slight.conf not found

The patch below installs the missing files and makes slight hinting the default.

Any comments?

Kind regards
Nils

[1] 
https://cgit.freedesktop.org/fontconfig/commit/?id=98434b3392172233094cac25ade7225c93da9f1c


Index: distrib/sets/lists/xetc/mi
===
RCS file: /cvs/xenocara/distrib/sets/lists/xetc/mi,v
retrieving revision 1.31
diff -u -p -u -r1.31 mi
--- distrib/sets/lists/xetc/mi  28 Oct 2015 00:46:31 -  1.31
+++ distrib/sets/lists/xetc/mi  4 Jan 2017 11:21:03 -
@@ -12,6 +12,7 @@
 ./etc/X11/xdm/xdm-config
 ./etc/X11/xinit/xinitrc
 ./etc/X11/xsm/system.xsm
+./etc/fonts/conf.d/10-hinting-slight.conf
 ./etc/fonts/conf.d/10-scale-bitmap-fonts.conf
 ./etc/fonts/conf.d/20-unhint-small-dejavu-sans-mono.conf
 ./etc/fonts/conf.d/20-unhint-small-dejavu-sans.conf
Index: lib/fontconfig/conf.d/Makefile
===
RCS file: /cvs/xenocara/lib/fontconfig/conf.d/Makefile,v
retrieving revision 1.10
diff -u -p -u -r1.10 Makefile
--- lib/fontconfig/conf.d/Makefile  19 Nov 2016 08:45:51 -  1.10
+++ lib/fontconfig/conf.d/Makefile  4 Jan 2017 11:21:03 -
@@ -9,6 +9,7 @@ DOC_FILES= \
README

 CONF_LINKS = \
+   10-hinting-slight.conf \
10-scale-bitmap-fonts.conf \
20-unhint-small-vera.conf \
30-lucida-aliases.conf \
@@ -29,6 +30,10 @@ CONF_LINKS = \

 AVAIL_FILES =  \
10-autohint.conf\
+   10-hinting-full.conf\
+   10-hinting-medium.conf  \
+   10-hinting-none.conf\
+   10-hinting-slight.conf  \
10-no-sub-pixel.conf\
10-scale-bitmap-fonts.conf  \
10-sub-pixel-bgr.conf   \



Re: libcrypto: fix assembly for clang

2017-01-04 Thread Brent Cook
On Wed, Jan 4, 2017 at 5:12 AM, Mark Kettenis 
wrote:

> > Date: Wed, 4 Jan 2017 11:04:43 +0100
> > From: Patrick Wildt 
> >
> > On Tue, Jan 03, 2017 at 02:16:25PM -0500, Ted Unangst wrote:
> > > Patrick Wildt wrote:
> > > >
> > > > Maybe they want to support older binutils that do not support the
> unified syntax?
> > > > What's our policy there?
> > >
> > > OpenBSD is just about the oldest binutils around. I wouldn't worry
> about
> > > anything older than what we have in base.
> >
> > Considering that, I'm going to ask for OKs then.
> >
> > ok?
>
> ok kettenis@, but lets give the LibreSSL people a chance to raise any
> portability concerns as they might have a better idea about LibreSSL
> portable deployment on ARM.
>
> ​
ok bcook@ - we don't even enable assembly on ARM in portable. Happy if
someone wants to help change that.


less(1): carefully handle null in strchr arguments

2017-01-04 Thread Julien Ramseier
The environment variable LESSBINFMT is not properly validated. If it is
set to "*", less will perform an out of boundary access.

This happens because strchr can be called with '\0' as second argument.
Such a call won't return NULL but the address of the '\0' in the string.
Therefore, the checkfmt function won't notice that the environment
variable is invalid.
--
The file line.c has the same issue but I'm not sure if '\0' is a valid
code in an ANSI sequence or not.

Patch from Tobias Stoeckmann
https://github.com/gdamore/less-fork/commit/c4eae4da7b51ec0125dcc40df2523c8c8e5387d2

Index: charset.c
===
RCS file: /cvs/src/usr.bin/less/charset.c,v
retrieving revision 1.19
diff -u -r1.19 charset.c
--- charset.c   17 Sep 2016 15:06:41 -  1.19
+++ charset.c   4 Jan 2017 14:48:46 -
@@ -37,7 +37,7 @@

if (*s == '*') {/* skip leading attribute if there */
s++;
-   if (strchr("dksu", *s) == NULL) {
+   if (*s == '\0' || strchr("dksu", *s) == NULL) {
return (-1);
}
s++;
@@ -57,7 +57,8 @@
if (seen) {
return (-1);/* 2nd % format item! */
}
-   while (strchr(" '+-0#", *s) != NULL) {  /* skip flags */
+   /* skip flags */
+   while (*s != '\0' && strchr(" '+-0#", *s) != NULL) {
s++;
}
while (isdigit(*s)) {   /* skip width */
@@ -78,7 +79,7 @@
s++;
}

-   if (strchr("cCdiouxX", *s) == NULL) {
+   if (*s == '\0' || strchr("cCdiouxX", *s) == NULL) {
/* bad or evil format character (%s, %n, etc.) */
return (-1);
}



Re: less(1): carefully handle null in strchr arguments

2017-01-04 Thread Theo Buehler
On Wed, Jan 04, 2017 at 03:55:20PM +0100, Julien Ramseier wrote:
> The environment variable LESSBINFMT is not properly validated. If it is
> set to "*", less will perform an out of boundary access.
> 
> This happens because strchr can be called with '\0' as second argument.
> Such a call won't return NULL but the address of the '\0' in the string.
> Therefore, the checkfmt function won't notice that the environment
> variable is invalid.
> --
> The file line.c has the same issue but I'm not sure if '\0' is a valid
> code in an ANSI sequence or not.
> 
> Patch from Tobias Stoeckmann
> https://github.com/gdamore/less-fork/commit/c4eae4da7b51ec0125dcc40df2523c8c8e5387d2

ok tb

> 
> Index: charset.c
> ===
> RCS file: /cvs/src/usr.bin/less/charset.c,v
> retrieving revision 1.19
> diff -u -r1.19 charset.c
> --- charset.c 17 Sep 2016 15:06:41 -  1.19
> +++ charset.c 4 Jan 2017 14:48:46 -
> @@ -37,7 +37,7 @@
> 
>   if (*s == '*') {/* skip leading attribute if there */
>   s++;
> - if (strchr("dksu", *s) == NULL) {
> + if (*s == '\0' || strchr("dksu", *s) == NULL) {
>   return (-1);
>   }
>   s++;
> @@ -57,7 +57,8 @@
>   if (seen) {
>   return (-1);/* 2nd % format item! */
>   }
> - while (strchr(" '+-0#", *s) != NULL) {  /* skip flags */
> + /* skip flags */
> + while (*s != '\0' && strchr(" '+-0#", *s) != NULL) {
>   s++;
>   }
>   while (isdigit(*s)) {   /* skip width */
> @@ -78,7 +79,7 @@
>   s++;
>   }
> 
> - if (strchr("cCdiouxX", *s) == NULL) {
> + if (*s == '\0' || strchr("cCdiouxX", *s) == NULL) {
>   /* bad or evil format character (%s, %n, etc.) */
>   return (-1);
>   }
> 



Re: sort(1): fix segfault with -m flag

2017-01-04 Thread Todd C. Miller
On Wed, 04 Jan 2017 12:24:15 +0100, Julien Ramseier wrote:

> sort segfaults when using the -m flag and no files.
> It should default to stdin instead.

Committed, thanks.

 - todd



libcrypto: another ARM assembly change

2017-01-04 Thread Patrick Wildt
Hi,

with our base clang targeting armv7 by default, this enables the NEON
assembly in libcrypto as well.  Note that is only used if NEON is
actually available.

Clang doesn't like the extra size definition ".32" on vmov which is not
needed, so simply remove it.

ok?

Patrick

diff --git a/lib/libcrypto/bn/asm/armv4-gf2m.pl 
b/lib/libcrypto/bn/asm/armv4-gf2m.pl
index c52e0b75b5b..89159246413 100644
--- a/lib/libcrypto/bn/asm/armv4-gf2m.pl
+++ b/lib/libcrypto/bn/asm/armv4-gf2m.pl
@@ -174,7 +174,7 @@ bn_GF2m_mul_2x2:
beq .Lialu
 
veor$A1,$A1
-   vmov.32 $B1,r3,r3   @ two copies of b1
+   vmov$B1,r3,r3   @ two copies of b1
vmov.32 ${A1}[0],r1 @ a1
 
veor$A0,$A0



Re: libcrypto: another ARM assembly change

2017-01-04 Thread Mark Kettenis
> Date: Wed, 4 Jan 2017 16:56:08 +0100
> From: Patrick Wildt 
> 
> Hi,
> 
> with our base clang targeting armv7 by default, this enables the NEON
> assembly in libcrypto as well.  Note that is only used if NEON is
> actually available.
> 
> Clang doesn't like the extra size definition ".32" on vmov which is not
> needed, so simply remove it.
> 
> ok?

ok kettenis@

> diff --git a/lib/libcrypto/bn/asm/armv4-gf2m.pl 
> b/lib/libcrypto/bn/asm/armv4-gf2m.pl
> index c52e0b75b5b..89159246413 100644
> --- a/lib/libcrypto/bn/asm/armv4-gf2m.pl
> +++ b/lib/libcrypto/bn/asm/armv4-gf2m.pl
> @@ -174,7 +174,7 @@ bn_GF2m_mul_2x2:
>   beq .Lialu
>  
>   veor$A1,$A1
> - vmov.32 $B1,r3,r3   @ two copies of b1
> + vmov$B1,r3,r3   @ two copies of b1
>   vmov.32 ${A1}[0],r1 @ a1
>  
>   veor$A0,$A0
> 
> 



llvm: pass library paths for cross-build

2017-01-04 Thread Patrick Wildt
Hi,

with GCC as cross-compiler the PREFIX define (which is set to the
CROSSDIR) makes sure that the linker includes the correct dirs.
Otherwise the cross-build will only find the host libraries, which
does not really work well.

Our clang doesn't do this so far.  The changes in clang make sure that

  * the library paths are passed to ld(1) and
  * the library path /usr/lib is prefixed with the sysroot.

Then we need to make sure to invoke our cross-clang with --sysroot
${CROSSDIR}.  For this, simply replace the cc and c++ binary with
a wrapper that calls clang with the correct mode and options.

Comments?

Patrick

diff --git a/Makefile.cross b/Makefile.cross
index 01c1c843953..9c5dbe8b5a5 100644
--- a/Makefile.cross
+++ b/Makefile.cross
@@ -238,10 +238,13 @@ ${CROSSGCC}:  ${CROSSBINUTILS}
${MAKE} install)
mv ${CROSSDIR}/usr/bin/clang ${CROSSDIR}/usr/bin/${TARGET_CANON}-clang
mv ${CROSSDIR}/usr/bin/clang++ 
${CROSSDIR}/usr/bin/${TARGET_CANON}-clang++
-   cp -f ${CROSSDIR}/usr/bin/${TARGET_CANON}-clang 
${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc
-   cp -f ${CROSSDIR}/usr/bin/${TARGET_CANON}-clang++ 
${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-c++
+   cp -f ${CROSSDIR}/usr/bin/${TARGET_CANON}-clang 
${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-clang
ln -sf ${TARGET_CANON}-cc ${CROSSDIR}/usr/${TARGET_CANON}/bin/cc
ln -sf ${TARGET_CANON}-c++ ${CROSSDIR}/usr/${TARGET_CANON}/bin/c++
+   echo  
"#!/bin/sh\n${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-clang --sysroot 
${CROSSDIR} \"$$""@\"" > 
${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc; \
+   chmod +x ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc;
+   echo  
"#!/bin/sh\n${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-clang 
--driver-mode=g++ --sysroot ${CROSSDIR} \"$$""@\"" > 
${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-c++; \
+   chmod +x ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-c++;
 .elif ${COMPILER_VERSION:L} == "gcc3"
(cd ${.CURDIR}/gnu/usr.bin/gcc; \
MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
diff --git a/gnu/llvm/tools/clang/lib/Driver/ToolChains.cpp 
b/gnu/llvm/tools/clang/lib/Driver/ToolChains.cpp
index 45622b22ab5..7ba8f25efdd 100644
--- a/gnu/llvm/tools/clang/lib/Driver/ToolChains.cpp
+++ b/gnu/llvm/tools/clang/lib/Driver/ToolChains.cpp
@@ -2977,7 +2977,7 @@ OpenBSD::OpenBSD(const Driver &D, const llvm::Triple 
&Triple,
  const ArgList &Args)
 : Generic_ELF(D, Triple, Args) {
   getFilePaths().push_back(getDriver().Dir + "/../lib");
-  getFilePaths().push_back("/usr/lib");
+  getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
 }
 
 Tool *OpenBSD::buildAssembler() const {
diff --git a/gnu/llvm/tools/clang/lib/Driver/Tools.cpp 
b/gnu/llvm/tools/clang/lib/Driver/Tools.cpp
index 656a8fbbdaf..34cbd620b4b 100644
--- a/gnu/llvm/tools/clang/lib/Driver/Tools.cpp
+++ b/gnu/llvm/tools/clang/lib/Driver/Tools.cpp
@@ -7623,8 +7623,10 @@ void openbsd::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 }
   }
 
-  Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
-options::OPT_e, options::OPT_s, options::OPT_t,
+  Args.AddAllArgs(CmdArgs, options::OPT_L);
+  getToolChain().AddFilePathLibArgs(Args, CmdArgs);
+  Args.AddAllArgs(CmdArgs, {options::OPT_T_Group, options::OPT_e,
+options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});
 
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);



Re: llvm: pass library paths for cross-build

2017-01-04 Thread Mark Kettenis
> Date: Wed, 4 Jan 2017 17:46:23 +0100
> From: Patrick Wildt 
> 
> Hi,
> 
> with GCC as cross-compiler the PREFIX define (which is set to the
> CROSSDIR) makes sure that the linker includes the correct dirs.
> Otherwise the cross-build will only find the host libraries, which
> does not really work well.
> 
> Our clang doesn't do this so far.  The changes in clang make sure that
> 
>   * the library paths are passed to ld(1) and
>   * the library path /usr/lib is prefixed with the sysroot.

This will also help aoption of lld, so ok kettenis@

> Then we need to make sure to invoke our cross-clang with --sysroot
> ${CROSSDIR}.  For this, simply replace the cc and c++ binary with
> a wrapper that calls clang with the correct mode and options.

I think that's a reasonable thing to do.

ok kettenis@

> diff --git a/Makefile.cross b/Makefile.cross
> index 01c1c843953..9c5dbe8b5a5 100644
> --- a/Makefile.cross
> +++ b/Makefile.cross
> @@ -238,10 +238,13 @@ ${CROSSGCC}:${CROSSBINUTILS}
>   ${MAKE} install)
>   mv ${CROSSDIR}/usr/bin/clang ${CROSSDIR}/usr/bin/${TARGET_CANON}-clang
>   mv ${CROSSDIR}/usr/bin/clang++ 
> ${CROSSDIR}/usr/bin/${TARGET_CANON}-clang++
> - cp -f ${CROSSDIR}/usr/bin/${TARGET_CANON}-clang 
> ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc
> - cp -f ${CROSSDIR}/usr/bin/${TARGET_CANON}-clang++ 
> ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-c++
> + cp -f ${CROSSDIR}/usr/bin/${TARGET_CANON}-clang 
> ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-clang
>   ln -sf ${TARGET_CANON}-cc ${CROSSDIR}/usr/${TARGET_CANON}/bin/cc
>   ln -sf ${TARGET_CANON}-c++ ${CROSSDIR}/usr/${TARGET_CANON}/bin/c++
> + echo  
> "#!/bin/sh\n${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-clang 
> --sysroot ${CROSSDIR} \"$$""@\"" > 
> ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc; \
> + chmod +x ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc;
> + echo  
> "#!/bin/sh\n${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-clang 
> --driver-mode=g++ --sysroot ${CROSSDIR} \"$$""@\"" > 
> ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-c++; \
> + chmod +x ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-c++;
>  .elif ${COMPILER_VERSION:L} == "gcc3"
>   (cd ${.CURDIR}/gnu/usr.bin/gcc; \
>   MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
> diff --git a/gnu/llvm/tools/clang/lib/Driver/ToolChains.cpp 
> b/gnu/llvm/tools/clang/lib/Driver/ToolChains.cpp
> index 45622b22ab5..7ba8f25efdd 100644
> --- a/gnu/llvm/tools/clang/lib/Driver/ToolChains.cpp
> +++ b/gnu/llvm/tools/clang/lib/Driver/ToolChains.cpp
> @@ -2977,7 +2977,7 @@ OpenBSD::OpenBSD(const Driver &D, const llvm::Triple 
> &Triple,
>   const ArgList &Args)
>  : Generic_ELF(D, Triple, Args) {
>getFilePaths().push_back(getDriver().Dir + "/../lib");
> -  getFilePaths().push_back("/usr/lib");
> +  getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
>  }
>  
>  Tool *OpenBSD::buildAssembler() const {
> diff --git a/gnu/llvm/tools/clang/lib/Driver/Tools.cpp 
> b/gnu/llvm/tools/clang/lib/Driver/Tools.cpp
> index 656a8fbbdaf..34cbd620b4b 100644
> --- a/gnu/llvm/tools/clang/lib/Driver/Tools.cpp
> +++ b/gnu/llvm/tools/clang/lib/Driver/Tools.cpp
> @@ -7623,8 +7623,10 @@ void openbsd::Linker::ConstructJob(Compilation &C, 
> const JobAction &JA,
>  }
>}
>  
> -  Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
> -options::OPT_e, options::OPT_s, options::OPT_t,
> +  Args.AddAllArgs(CmdArgs, options::OPT_L);
> +  getToolChain().AddFilePathLibArgs(Args, CmdArgs);
> +  Args.AddAllArgs(CmdArgs, {options::OPT_T_Group, options::OPT_e,
> +options::OPT_s, options::OPT_t,
>  options::OPT_Z_Flag, options::OPT_r});
>  
>AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
> 
> 



less(1): fix some memory leaks

2017-01-04 Thread Julien Ramseier
This does not fix all "leaks" that may be detected.  In particular
during program initialization copies of a few strings and such are made
and those copies may persist.  However, those are benign as the program
does not continuously leak memory.  Furthermore, fixing all of them would
be substantially more effort than its worth -- in fact the code to "fix"
this would grow the text size of the program by more than the couple of
bytes of leaked memory!

Patch from Garrett D'Amore
https://github.com/gdamore/less-fork/commit/b2f362eb4dea171265ab2aff059cbbeca075664e


Index: screen.c
===
RCS file: /cvs/src/usr.bin/less/screen.c,v
retrieving revision 1.24
diff -u -r1.24 screen.c
--- screen.c8 Jul 2016 15:23:44 -   1.24
+++ screen.c4 Jan 2017 17:36:00 -
@@ -396,9 +396,9 @@
if (*sc_move == '\0') {
t2 = "";
} else {
-   t2 = estrdup(tparm(sc_move, 0, 0, 0, 0, 0, 0, 0, 0, 0));
+   t2 = tparm(sc_move, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
-   sc_home = cheaper(t1, t2, "|\b^");
+   sc_home = estrdup(cheaper(t1, t2, "|\b^"));

/*
 * Choose between using "ll" and "cm"  ("lower left" and "cursor move")
@@ -410,10 +410,9 @@
if (*sc_move == '\0') {
t2 = "";
} else {
-   t2 = estrdup(tparm(sc_move, sc_height-1,
-   0, 0, 0, 0, 0, 0, 0, 0));
+   t2 = tparm(sc_move, sc_height-1, 0, 0, 0, 0, 0, 0, 0, 0);
}
-   sc_lower_left = cheaper(t1, t2, "\r");
+   sc_lower_left = estrdup(cheaper(t1, t2, "\r"));

/*
 * Get carriage return string.
Index: search.c
===
RCS file: /cvs/src/usr.bin/less/search.c,v
retrieving revision 1.18
diff -u -r1.18 search.c
--- search.c17 Sep 2016 15:06:41 -  1.18
+++ search.c4 Jan 2017 17:36:00 -
@@ -92,9 +92,10 @@
 static int
 set_pattern(struct pattern_info *info, char *pattern, int search_type)
 {
-   if (pattern == NULL)
+   if (pattern == NULL) {
+   uncompile_pattern(&info->compiled);
info->compiled = NULL;
-   else if (compile_pattern(pattern, search_type, &info->compiled) < 0)
+   } else if (compile_pattern(pattern, search_type, &info->compiled) < 0)
return (-1);
/* Pattern compiled successfully; save the text too. */
free(info->text);



Re: Unable to boot since latest installer HTTPS changes

2017-01-04 Thread Leo Unglaub

Hey,

On 01/03/17 17:26, Leo Unglaub wrote:

Hey tech@
i wanted to upgrade to the latest snapshot (as i always do, every week)
but since you added the HTTPS support to the installer i am unable to
boot my system or the install.fs from a flash drive.

I get to the MBR and then into the PBR but after probing all discs the
system restarts instantly. No debug prompt or something else. I tryed it
with the latest 3 install.fs or so. But i am unable to boot at all.

This only happens in MBR mode, i am able to boot in UEFI mode from the
install.fs.

I also tryed a 4 weeks old install.fs and in there it works fine. So its
not a hardware issue.

This started to happend around the same time you added HTTPS support to
the installer.

I am on AMD64. I cannot provide a dmesg of that machine because i am
unable to boot it at all.

There is someone else on Reddit having the exact same problem.
Thanks and greetings
Leo


i just tried the latest snapshot from today (04-Jan-2017 11:27) and the 
problem still exists. Would it be helpful for debugging if i tested it 
with the install.iso as well? Or should be install.fs and install.iso be 
the same in that regard?


Greetings
Leo



Re: Recursive NET_LOCK()

2017-01-04 Thread Alexander Bluhm
On Tue, Jan 03, 2017 at 08:21:58PM +0100, Martin Pieuchot wrote:
> I am also looking for more feedbacks and/or inputs so I appreciate your
> email on the matter.

Together with a coworker Zaur Molotnikov we are using static code
analysis to find places where a netlock is needed.  We try to create
possible reverse stack traces:

 |- if_linkstate
|- if_down
   |- pppoe_ioctl
   |- if_clone_destroy
   |- if_downall
   |- if_setrdomain
  |- if_clone_create
  |- ifioctl
 |- soo_ioctl
 |- nfs_boot_init
   |- ifioctl
  |- soo_ioctl
  |- nfs_boot_init
   |- sppp_lcp_down
   |- sppp_keepalive
   |- pppdealloc
  |- pppclose
   |- trunk_port_destroy
  |- trunk_clone_destroy
  |- trunk_port_ifdetach
  |- trunk_ioctl
|- if_up
   |- pppoe_ioctl
   |- ifioctl
  |- soo_ioctl
  |- nfs_boot_init
   |- sppp_ioctl
  |- pppoe_ioctl
   |- sppp_lcp_tlu
   |- loioctl
   |- mpeioctl
   |- gif_ioctl
|- if_linkstate_task

We tell the system if_linkstate() needs the lock, then leaves have
to provide it somehow.  As our implementation is in an early stage,
analysis stops at function pointers.

At the end it prints traces where it cannot find where the netlock
is taken.

Analyzing Locks
Lock not found:  [Node: if_linkstate, Node: if_down, Node: pppoe_ioctl]
Lock not found:  [Node: if_linkstate, Node: if_down, Node: sppp_lcp_down]
Lock not found:  [Node: if_linkstate, Node: if_down, Node: sppp_keepalive]
Lock not found:  [Node: if_linkstate, Node: if_down, Node: pppdealloc, Node: 
pppclose]
Lock not found:  [Node: if_linkstate, Node: if_down, Node: trunk_port_destroy, 
Node: trunk_clone_destroy]
Lock not found:  [Node: if_linkstate, Node: if_down, Node: trunk_port_destroy, 
Node: trunk_port_ifdetach]
Lock not found:  [Node: if_linkstate, Node: if_down, Node: trunk_port_destroy, 
Node: trunk_ioctl]
Lock not found:  [Node: if_linkstate, Node: if_up, Node: pppoe_ioctl]
Lock not found:  [Node: if_linkstate, Node: if_up, Node: sppp_ioctl, Node: 
pppoe_ioctl]
Lock not found:  [Node: if_linkstate, Node: if_up, Node: sppp_lcp_tlu]
Lock not found:  [Node: if_linkstate, Node: if_up, Node: loioctl]
Lock not found:  [Node: if_linkstate, Node: if_up, Node: mpeioctl]
Lock not found:  [Node: if_linkstate, Node: if_up, Node: gif_ioctl]
Done

This is work in progress, I am not sure wether it will work in the
end.  Now we are concentrating on missing locks, but it could also
find recursive locks.

bluhm



Re: ld.so diff that needs testing on landisk

2017-01-04 Thread Philip Guenther
On Tue, Jan 3, 2017 at 2:13 PM, Mark Kettenis  wrote:
> The diff below (partly by guenther@) removes ld.so's dependency on the
> __got_{start,end} symbols by looking at PT_GNU_RELRO instead.  On some
> platforms (hppa and perhaps a few others) this leads to even less
> writable pages.  However, we're not sure if this will work correctly
> on landisk.  So if somebody with a fairly up-to-date landisk could
> give this a spin for us, it would be highly appreciated.

Looks like one change got lost in the back-and-forth...


> --- libexec/ld.so/boot.c13 Aug 2016 20:57:04 -  1.14
> +++ libexec/ld.so/boot.c2 Jan 2017 15:55:52 -
...
> @@ -189,4 +191,30 @@ _dl_boot_bind(const long sp, long *dl_da
>  * we have been fully relocated here, so most things no longer
>  * need the loff adjustment
>  */
> +
> +   /*
> +* No further changes to the PLT and/or GOT are needed so make
> +* them read-only.
> +*/
> +
> +   /* do any RWX -> RX fixups for executable PLTs and apply GNU_RELRO */
> +   ehdp = (Elf_Ehdr *)loff;
> +   phdp = (Elf_Phdr *)(loff + ehdp->e_phoff);
> +   for (i = 0; i < dl_data[AUX_phnum]; i++, phdp++) {

I believe this line should be:
+   for (i = 0; i < ehdp->e_phnum; i++, phdp++) {


Philip Guenther