Commit Graph

3429 Commits

Author SHA1 Message Date
maya 53dcb847d9 $ORIGIN support is now enabled.
Thanks martin for the heads up.
2019-04-15 10:17:01 +00:00
abhinav 55eec9d71a Typo: s/a indirection/an indirection/ 2019-04-15 06:42:06 +00:00
wiz a30bc70869 Use more Dv. 2019-04-14 22:09:50 +00:00
maya 9a04775cfa Note that we now search DT_RUNPATH paths as well. 2019-04-14 20:27:02 +00:00
christos fb007af046 undo previous unlock/relock; it is not needed now that we added the tls model
declaration to all externs in jemalloc (suggested by joerg@)
2019-04-14 19:21:37 +00:00
christos 15018ca013 Fix c++ exceptions on arm; jemalloc calls _rtld_tls_get_addr from inside
dl_iterate_phdr, so we need to unlock and relock.
2019-04-13 03:15:25 +00:00
rin e66054b66e Do not compile __tls_get_addr() into ldd(1), which fixes ldd(1) crashing
on arm after switching to new jemalloc.

jemalloc invokes __tls_get_addr() under some condition. If anything other
than ld.elf_so nor libc exports it, inconsistency arises as a result.
2019-04-13 00:23:32 +00:00
christos 39fadeea40 Disable optimization for rtld.c on the vax with gcc-7. 2019-04-03 21:37:58 +00:00
martin 9e275c0f36 Account for cgihandler being set when counting the number of CGI environment
headers we are about to set. Avoids an assertion failure (and overruninng
the array) later.
2019-03-29 14:46:44 +00:00
mrg 58a223ca24 add $NetBSD$ 2019-03-27 04:50:30 +00:00
mrg 8b21018e17 on m68010 set BOZO_WRSZ to 16k and BOZO_WRSZ to 64k. 2019-03-08 03:12:28 +00:00
mrg 767fb2605a call this bozohttpd 20190228, and merge the CHANGES entries from the
previous release.
2019-02-28 09:16:42 +00:00
mrg 08dbfa234a add ssl specific timeout value (30s). if SSL_accept() doesn't
work with in this timeout value, ssl setup now fails.

mostly different from, but inspired from the patch in PR 50655
2019-02-28 08:28:21 +00:00
mrg f0885992ce - bump buffer sizes to avoid potential truncation issues 2019-02-04 04:36:41 +00:00
mrg fbffadb9f8 - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
  this case, and thus can't be marked __dead easily
2019-02-03 03:19:25 +00:00
lukem fc9234654d clarify the fd used for blacklisting.
Use STDIN_FILENO instead of 0 as the fd to blacklist_r(),
since we use the former in ftpd.c
2019-01-29 23:19:30 +00:00
lukem 086f834b20 NetBSD-ftpd 20180428
Update version to "NetBSD-ftpd 20180428" for changes:
- Fix violations of the sequence point rule.
- Check that stat and fstat succeed.
- Support blacklistd(8) hooks.
- Clear utmpx struct before writing it to wtmpx files.
- Fix directory stream leaks.
- Use explicit_memset(3) instead of memset(3) to clear password.
- Fix scope of variable. PR misc/50665.
- Ensure that closing socket exists. CID 603440.
- Add -f option to ftpd to stay in foreground with -D. PR bin/53221.
2019-01-29 11:51:05 +00:00
dholland ad8aa774f5 fix duplicated chunk from merge 2019-01-27 04:33:29 +00:00
pgoyette d91f98a871 Merge the [pgoyette-compat] branch 2019-01-27 02:08:33 +00:00
mrg 00e064adab o don't display special files in the directory index. they aren't
served, but links to them are generated.
2019-01-22 05:32:57 +00:00
skrll 69e8dca2e5 Adapt https://svnweb.freebsd.org/base?view=revision&revision=342113 to
NetBSD.

This brings us resolving for dynamically loaded libraries and makes
tests/libexec/ld.elf_so/t_thread_local_dtor pass.

With suggestions from joerg@
2019-01-18 11:59:03 +00:00
mrg 8f49d6e252 rework size_arrays():
- avoid calloc, use bozomalloc
- minor CSE
- fix bozoprefs->size setting when increasing the size (new total was
  being added to the prior total.)  found by clang static analyzer
  from rajeev_v_pillai.

pass httpd to size_arrays() now.
free(NULL) is legal.
2019-01-18 06:04:10 +00:00
mrg 5335936687 fix a few problems pointed out by clang static analyzer, from rajeev_v_pillai:
- bozostrnsep() may return with "in = NULL", so check for it.
- nul terminating in bozo_escape_rfc3986() can be simpler
- don't use uniinit variables in check_remap()
- don't use re-used freed data in check_virtual().  this one is tricky as
  the original code was:
	free(request->hr_file);
	request->hr_file = bozostrdup(httpd, request, s ? s : "/");
  however, bozostrdup() may reference request->hr_file.
2019-01-18 05:48:31 +00:00
mrg 9b91523ebd - call this 20190116
- adjust the directory indexing again:
  - don't include "index.html" in html headers
  - additional escaping of names
  - re-add top/bottom borders
  - adds an aquamarine table header
  - Zebra-stripes table rows using CSS instead of code
  all from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>
2019-01-17 07:46:16 +00:00
mrg d1eeb82409 add 'check' target to toplevel makefile.
fix the t11.out output now that CGI parsing works better.
2019-01-17 07:39:00 +00:00
mrg 9c0805993a - fix CGI '+' param and error handling.
- remove unused parameter to daemon_poll_err().

both from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>
2019-01-17 07:34:06 +00:00
christos d17b8a0ea7 print the program name when we don't find a library.
XXX: really most _rtld_error() should do that, and most do.
2019-01-12 18:58:10 +00:00
uwe 62a27ee607 Spell "occurrence" correctly. 2019-01-09 17:19:08 +00:00
mrg 4aff0e8a96 remove reference to deleted -r option. fixes PR#53840 from J. Lewis Muir. 2019-01-08 06:04:29 +00:00
joerg 06c9aa1116 When loading a non-PIE main binary, the virtual address must match.
Use MAP_TRYFIXED and verify that the result matches the expectation.
2019-01-06 19:44:54 +00:00
joerg 08e505b543 MAP_ALIGNED has existed for years, just assume it exists. 2019-01-04 19:54:56 +00:00
martin e4d02a93c7 Add support for DT_RUNPATH - it is just the same as we always have treated
DT_RPATH.  Approved by core.
2018-12-30 11:55:15 +00:00
christos d30b19ef3d - fix wrong reloc name in assert
- fix uninitialized
2018-12-30 03:23:46 +00:00
christos 61268f23da binutils 2.31.1 can put copy relocations in the relro segment. Delay
protecting the relro segment for the main object until copy relocations
are done.
2018-12-30 01:48:37 +00:00
christos 2c62c57fa6 initfini array support for everyone. 2018-12-27 18:58:14 +00:00
christos ba044c6310 explain why we skip objmain. 2018-12-27 18:57:43 +00:00
mrg 48003606bd minor rewording. fix alphabeta ordering of contributors. 2018-12-19 12:40:32 +00:00
mrg ff386e5b59 fix an old spell-o and a new format-o. 2018-12-18 23:11:40 +00:00
maya 79d3071f0c Remove mention of SPX. 2018-12-15 23:23:51 +00:00
leot 6816df1bc3 Document last changes and bump version to 20181215
Suggested by <mrg>, thanks! (Possible mistakes are mine though!)
2018-12-15 12:52:36 +00:00
leot 9644d25eb4 Fix handling of bozo_set_timeout() timeouts (and `-T' option parsing) 2018-12-15 12:43:24 +00:00
leot 6c2202365c Avoid .htpasswd exposure to authenticated users when .htpasswd is
in the slashdir too.

Problem reported by JP via tech-security@ and discussed with <mrg>, thanks!
2018-12-15 12:39:22 +00:00
leot 1f52a22c8c Avoid possible NULL dereference when sending a big request that timeout.
Problem reported by <maya> and reviewed by <maya> and <mrg>, thanks!
2018-12-15 09:28:27 +00:00
maya d6e51063d8 strings.h for strcasecmp (on linux) 2018-12-15 02:03:24 +00:00
maya 69e8cec185 Check against BOZO_HEADERS_MAX_SIZE in a way that isn't prone to overflow.
Note that this isn't reachable in practice as big requests time out.
2018-12-15 01:02:34 +00:00
maya 6807b854c1 Don't pass ${HOST} to test scripts.
htnl_cmp compares against the output of `hostname`.

This makes the tests pass on my machine.
2018-12-14 23:57:22 +00:00
sborrill 35d580002c IPFilter 5 requires you to specify IPv4 or IPv6 2018-12-13 13:11:28 +00:00
maya cd6150e9ad Remove unused macros. 2018-12-13 04:29:18 +00:00
mrg 34ece249a9 use html tables for directory index.
from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>

call this bozohttpd 20181204.
2018-12-04 02:52:42 +00:00
mrg 3d201ca797 avoid sign extension in % handling (and printing 0xFFFFFF before
wanted values.)  from Rajeev V. Pillai.
2018-12-04 00:26:15 +00:00
skrll 66b7511afb Fix typos 2018-12-01 13:01:57 +00:00
joerg 335f313f07 Now that lib/csu no longer uses the object handle, drop the magic and
version field from the internal object. It is kept in the legacy version
of the main object.
2018-11-26 17:40:26 +00:00
mrg a0c45e363d normalise some messages. 2018-11-25 23:48:14 +00:00
mrg cd79b847e8 add option fixes here. 2018-11-25 23:37:09 +00:00
mrg c53bc78857 fix -X option parsing. noted by Rajeev V. Pillai. 2018-11-25 07:37:20 +00:00
mrg ac81556715 avoid c99ism. 2018-11-24 18:38:59 +00:00
christos 201b0ce72c - add FALLTHROUGH comment
- one return is usually enough.
2018-11-24 13:08:10 +00:00
christos 47273da74b appease lint 2018-11-24 13:03:15 +00:00
christos 9034ab8ec4 one semicolon is usually enough. 2018-11-24 13:02:46 +00:00
mrg de8fdd6045 call this bozohttpd 20181124. 2018-11-24 02:35:13 +00:00
mrg 0e9761c130 fix a bug in the rework for -i option: move the real code in place.
for some reason gcc does not warn about this:

   case 'x':
     stuff_here();
     break;

     other_stuff_here();
     break;

and the other_stuff_here() was what was mis-placed.


should fix atf failures in networking.
2018-11-24 02:30:56 +00:00
mrg a49dff0c2c s/time/val/ to avoid shadowing a global indentifier. 2018-11-24 00:47:51 +00:00
skrll c7af211bee Fix RTLD_DEBUG_RELOC build 2018-11-23 11:26:05 +00:00
skrll 0d71550e67 Trailing whitespace 2018-11-23 10:59:20 +00:00
mrg ed71d0d525 minor style fixes. simplify bozo_match_content_map(). 2018-11-23 08:11:20 +00:00
mrg 7cb0de5ddc add an assert() check on array bounds. 2018-11-22 18:42:06 +00:00
mrg b0d9cf700a alpha sort the option switch. 2018-11-22 18:21:59 +00:00
mrg 4cfb2183d3 many clean ups:
- keep a list of special files and their human names
- remove (void) casts on bozo_http_error()
- fix a few more misuses of bozo_http_error()
- rename check_mapping() to check_remap() and perform some CSE
- switch away from ``%s'' to '%s'
- remove a bunch of #ifdef using new have_feature defines
2018-11-22 08:54:08 +00:00
mrg 32fa179b6e use MAP_SHARED for the bzremap file. avoids netbsd kernel complaining:
WARNING: defaulted mmap() share type to MAP_PRIVATE (pid 15478 command bozohttpd)
2018-11-21 17:39:19 +00:00
mrg b4624ca902 two fixes reported by mouse:
- don't check contents of 'st' if stat(2) failed.
- round up instead of truncate.  now 10000 byte files say 10kB not 9kB.
2018-11-21 10:25:17 +00:00
mrg a3912675bc - move special files defines into bozohttpd.h, so we can ...
- consolidate all the special file checks into
  bozo_check_special_files() so that all builds check the same
  list of special files, regardless of build options.
- convert "(void)bozo_http_error(...); return -1;" into plain
  "return bozo_http_error(...);"
- fix the call to bozo_check_special_files() to be used on all
  input types.  part of the fixes for failure to reject access
  to /.htpasswd as reported by JP on tech-security.
- use warn_unused_result attribute on bozo_check_special_files(),
  and fix the failures to return failure.  second part of the
  htpasswd access fix.
- update testsuite to use a fixed fake hostname.

call this bozohttpd 20181121.
2018-11-21 09:37:02 +00:00
mrg b091ab062f also fix have_dynamic_content from the previous previous. re-order
the debug and dynamic content to match the same pattern as everything
else so similar problems are less likely in the future.
2018-11-20 01:23:06 +00:00
mrg 75e07df53f fix previous: have_debug was reversed. 2018-11-20 01:19:51 +00:00
mrg cbabfa751a move some #if support into bozohttpd.h. 2018-11-20 01:15:50 +00:00
mrg 3230a9a3d5 from CHANGES:
o  reduce default timeouts, and add expand timeouts to handle the
   initial line, each header, and the total time spent
o  add -T option to expose new timeout settings
o  minor RFC fixes related to timeout handling responses

old timeouts:
60 seconds for initial request like, 60 seconds per header line,
and no whole timeout (though the recent total header size changes
do introduce one that would be about 11 hours.)
new timeouts:
30 seconds for initial request like, 10 seconds per header line,
and a total request time of 600 seconds.


the new global timeout is implemented using CLOCK_MONOTONIC, with
a fallback to CLOCK_REALTIME if monotonic time is unavailable.


reject multiple Host: headers.  besides being protocol standard,
this closes one additional memory leak found by JP.  add a simple
test to check this.


clean up option and usage handling some.
2018-11-20 01:06:46 +00:00
mrg 1520b40a61 note the changes present in bozohttpd 20181118:
o  add url remap support via .bzremap file, from martin@netbsd.org
o  handle redirections for any protocol, not just http:
o  fix a denial of service attack against header contents, which
   is now bounded at 16KiB.  reported by JP.
2018-11-19 04:14:59 +00:00
mrg 7b01d57a61 avoid memory leak in sending multiple auth headers.
mostly mitigated by previous patch to limit total header size,
but still a real problem here.
2018-11-19 04:13:09 +00:00
mrg 0ccc27dc69 fix a denial of service attack against header contents, which
is now bounded at 16KiB.  reported by JP.
2018-11-19 04:12:22 +00:00
mrg e2c37278b9 use __func__ in debug(). 2018-11-18 11:22:11 +00:00
kre 3e9d705017 sysctl(KERN_BOOTTIME) is a struct timespec, not struct timeval
and has eben since 2009.    Adapt.

NFCI - while the tv_usec (now tv_nsec) field is used, we will
keep its uses to microsecond precision to avoid any compat issues.
2018-10-30 21:18:39 +00:00
joerg 4312beab4f Move compatibility for pre-2.0 ELF binaries into separate file.
Early ELF binaries defined dlopen and friends in crt0.o by
using function pointers in the object handle passed from rtld.
This contract wastes space when many shared objects are allocated
and ties dynamic linker and rest of the system tightly together.
Fake the entry points in a static object and restrict them to the
platforms that had working ELF support at the time. Keep the magic and
version field used by modern crt0.o for all architectures. The checks
will be removed from crt0.o in a follow-up step.
2018-10-17 23:36:58 +00:00
rmind 39013e66c1 NPF: Major rework -- migrate NPF to the libnv library.
- This conversion significantly simplifies the code and moves NPF to
  a binary serialisation format (replacing the XML-like format).
- Fix some memory/reference leaks and possibly use-after-free bugs.
- Bump NPF_VERSION as this change makes libnpf incompatible with the
  previous versions.  Also, different serialisation format means NPF
  connection/config saving and loading is not compatible with the
  previous versions either.

Thanks to christos@ for extra testing.
2018-09-29 14:41:35 +00:00
jakllsch 3c05430e55 Revise previous to not deadlock. 2018-09-20 19:02:22 +00:00
jakllsch df54aa978e Improve support for R_AARCH64_TLSDESC relocations.
In large part from FreeBSD.
2018-09-20 18:41:05 +00:00
wiz 2aa6701c2b Remove trailing whitespace. 2018-08-24 14:24:50 +00:00
martin 48f4f2396c Bump date 2018-08-24 11:43:13 +00:00
martin bf2f242dcd Add support for remapping requested paths via a .bzredirect file.
Fixes PR 52772. Ok: mrg@
2018-08-24 11:41:16 +00:00
mrg 05225295cb fix output since protocol agnostic change went in.
XXX: i thought someone hooked this into atf already, please do :)
2018-08-24 10:04:41 +00:00
joerg da0b29937f Apply relocbase for tlsinit of the executable itself. Fixes PIE where
relocbase typically is not zero.

PR bin/53465
2018-07-24 13:48:48 +00:00
christos 8de0d28182 Initialize new_value to account for bogus return from the function. 2018-07-16 00:29:37 +00:00
gson 4828bdca7d No semicolon after macro do ... while (0) wrapper. 2018-06-23 07:21:00 +00:00
christos 64715b9aa8 We can't build those three with MKSANITIZER, they are used too early. 2018-06-09 22:41:55 +00:00
christos b5fd6cb2a8 rename flag to the official name. 2018-05-24 17:05:54 +00:00
sevan 658d9240b5 remove definition of LUA_USE_APICHECK, it is a build time option for Lua
itself. Not for modules.
2018-05-11 20:19:25 +00:00
sevan 3186d74c3d Do not try and process empty requests. This resolves a crash when issuing a
carriage return to read_request() in foreground mode.
In the C daemon, a NULL check is performed on bozo_read_request in main.c
before moving on to bozo_process_request & bozo_clean_request. Here,
process_request & clean_request just return instead.
2018-05-04 19:45:27 +00:00
christos d9ca995a53 fix the rest of the compilers. 2018-05-04 18:07:23 +00:00
christos c1e5495798 fix lint 2018-05-04 18:06:44 +00:00
sevan 89bb3c6008 Unbreak script for Lua 5.3.
This change breaks support for older releases of Lua.
2018-05-02 00:03:27 +00:00
sevan f11f7afd13 Pass the expected httpd instance when calling set_pref()
process_request() only takes a single argument.
2018-05-02 00:00:30 +00:00
sevan babdc61a7b Enable checking arguments for validity.
Remove disabled code.
Fix function parameters.
Add support for Lua 5.3
2018-05-01 23:51:53 +00:00
riastradh 7bc66ed4ff Add -f option to ftpd to stay in foreground with -D.
From nia in PR bin/53221.
2018-04-28 13:38:00 +00:00
joerg f80c3669c3 Rework ifunc support to address a number of short comings:
- Move to a shared _rtld_call_ifunc for rel and rela architectures
- Architectures using rel format must patch IRELATIVE non-PLT
  relocations like RELATIVE in additition to the later ifunc handling
- Consistently record the delta to the end of the relocation group for
  non-PLT IRELATIVE relocations

Hidden ifunc is now supported on all ifunc platforms, even when using
-fno-plt. The combination of -fno-plt and relro is broken due to
incorrect GNU ld output though.
2018-04-03 21:10:27 +00:00
joerg 2d65afd272 Move the complex logic for dynamically writing branches from ld.elf_so
into a header for reuse in crt0.o for static ifunc support. Change the
existing logic for sparc64 to use the Bicc variant of ba,a as it allows
+-8MB displacement compared to the BPcc variant's +-1MB. Teach the sparc
variant the same trick for using ba,a and not sethi+jmp when possible.
2018-03-29 13:23:39 +00:00
joerg 033ffc4d89 Don't skip PLT processing for the main binary. It can still contain
ifunc references.
2018-03-25 18:56:01 +00:00
joerg 64156cbaf3 Like Sparc, PowerPC can use IRELATIVE relocations in non-PLT sections. 2018-03-09 20:19:11 +00:00
snj cb9b4ba530 delete now-irrelevant comment 2018-03-01 06:24:12 +00:00
snj 51521ab7d9 prune disabled XIDLE support. the required X server extension hasn't been
around for a couple decades now. even if someone wanted to modernize this,
it wouldn't be appropriate for NetBSD, since we don't want programs in base
to be linked against X libs.
2018-02-28 23:45:56 +00:00
mrg 2e19323388 add LIBKRB5_LDADD/LIBKRB5_DPADD and their static counterparts
to bsd.prog.mk.  use them instead of hard coding various lists
of libraries for krb5.

this fixes static builds.
2018-02-25 00:16:48 +00:00
jakllsch db546b38aa Wrap PowerPC #pragma goop in #if __GNUC_PREREQ__(6,0).
Our older GCC warns/errors on it.
2018-02-11 18:58:44 +00:00
christos 63224f5106 We need authentication || encryption even when we are not building
kerberos. They are needed for telnet_net_write() which is used in libtelnet.
2018-02-10 19:34:34 +00:00
mrg 1bf47496e9 update for GCC 6:
ignore -Wframe-address warnings for the ppc hack.
2018-02-07 06:17:45 +00:00
christos 5f8b254caf - need string.h
- cast options to long for OpenSSL-1.1
2018-02-06 15:48:46 +00:00
skrll e958e889a2 Various fixes / changes from Ryo Shimizu / Toru Nishimura to make this
work.

_rtld_call_ifunc copied from other rela platforms by me - not tested in
any way.
2018-02-04 21:49:51 +00:00
mrg 845c916a36 updates for GCC 6.4:
identd has aliasing violations, use -fno-strict-aliasing.

newfs_msdos's getbpbinfo() has missing {} issues.

sysctl's kern_cp_id() has missing {} issues.
2018-02-04 09:03:23 +00:00
maya 501cede865 Use a protocol-agnostic URL (don't degrade HTTPS->HTTP)
Suggested by Travis Paul in PR bin/52958.
2018-01-28 13:37:39 +00:00
christos 381da60e92 don't forget to eat the high bits. 2018-01-19 23:17:41 +00:00
joerg e5e34a6c86 Since GNU ld doesn't honor the PLT entry reservation, also compensate
for JMP_IREL relocations at the start of the PLT.
2017-12-25 17:00:15 +00:00
maya 0a4e3118cb Fix typo in comment
from freebsd
2017-12-25 05:29:27 +00:00
maya 6f158d565c fix debug build 2017-12-24 01:22:16 +00:00
wiz ffa84063eb Document script handler issues with httpd(8).
From martin@, addressing PR 52194.

While here, use American spelling consistently and upper-case some
abbreviations.

Bump date.
2017-11-28 12:22:27 +00:00
martin e9e7c8e344 PR bin/52194: bozohttpd fails to exec scripts via the -C mechanism
sometimes with EFAULT due to not NULL terminated environment.
2017-11-28 10:33:51 +00:00
joerg da03f1ef14 init/fini for the main program is handled by crt0.o, so ifunc handling
is skipped right now as it iterates the same list. Don't repeat that
mistake and explicitly take care of it in the dynamic linker.
2017-11-06 21:16:03 +00:00
ryo 9f03e9b6d3 fix to compile without USE_PAM. (unused variables) 2017-10-07 19:23:02 +00:00
mrg 803cb099d6 s/u_int/unsigned/.
from Jan Danielsson.  increases/fixes portability.
2017-10-05 04:22:41 +00:00
christos e771911261 make this compile. 2017-10-02 22:14:32 +00:00
joerg 42f0ecedd8 Include time.h for time.
XXX Doesn't build with newer zlib, remove?
2017-10-02 22:04:51 +00:00
nisimura dfab1def86 explain AARCH64 PLT design 2017-08-28 06:59:25 +00:00
nisimura 695ffc63ca - avoid caddr_t. use Elf_Addr instead.
- iron out rdbg() errors.
2017-08-23 09:17:48 +00:00
joerg 610e531ea3 Add sparc/sparc64 support for irelative relocations. 2017-08-12 09:03:27 +00:00
joerg e78cfb8eb8 Add IRELATIVE support for ARM, X86 and PowerPC. 2017-08-10 19:03:25 +00:00
joerg 493a7561e4 If a DF_1_NODELETE DSO has been removed from the DAG list, it still
needs to be able to resolve relocations against itself. As such, search
the referencing object explicitly last, if it hasn't been searched
before.
2017-08-09 18:44:32 +00:00
martin 806d1922a8 Fix thinko in previous: even if the address is an unsigned value and we
have verified the range before, we still need to mask the bit pattern
to the target instruction field.
2017-07-24 08:08:34 +00:00
martin 41cf8822e9 Simplify and fix the offset calculation when doing a %pc relative
branch from the PLT slot to the target.
2017-07-23 14:37:51 +00:00
joerg bde7a58ae6 Fix two bugs related to promotion of DSO TLS blocks into the static
thread allocation:
(1) Set the DTV vector up whenever an offset into the static allocation
is assigned, even if the block itself is not initialized. This has been
seen in libstdc++.
(2) Do not free a DTV block if it is part of the static thread
allocation.
2017-07-13 14:10:38 +00:00
christos 97c79d531d rename the macro 2017-07-12 17:55:24 +00:00
christos 15e7a34b21 make this compile with debug again (symnum uninitialized) 2017-07-12 17:54:23 +00:00
joerg e5678be828 Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
functions are used for destructors of thread_local objects.

If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.

Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
2017-07-11 15:21:31 +00:00
joerg 88b397335b Drop comments about symbol exporting, the relevant code is gone. 2017-07-09 17:57:59 +00:00
mrg 68bd8b44d6 fix ordering of a couple of words. from Edgar Pettijohn in PR#52375.
thanks!
2017-07-07 07:05:49 +00:00
wiz d2c81abc95 Add EXIT STATUS section. Use Ex. 2017-07-04 06:56:50 +00:00
wiz 01869ca4d2 Remove workaround for ancient HTML generation code. 2017-07-03 21:28:48 +00:00
joerg a7f7db4a1a Remove old assert that only two segments exist. The rest of the code has
been changed to cope with more and at least Go actively creates them.
Adjust the mapping size computation to use the maximum and not depend on
PT_LOAD segments to be in order.
2017-06-23 15:29:21 +00:00
joerg 3870ab1fa7 Replace last use of r_type. 2017-06-21 12:34:01 +00:00
joerg 152a0d21c4 Add back symnum, fix debug print. 2017-06-20 15:02:54 +00:00
joerg ddeaaf811f Add last_symnum, move up def and defobj. 2017-06-20 13:45:20 +00:00
joerg d5127e3ef7 Fix C&P bug. Deal with more MIPS hacks overriding def. 2017-06-20 13:24:03 +00:00
joerg 6d0511e34f Expand symnum, GCC's uninitialized used tracking is too imprecise. 2017-06-20 12:41:49 +00:00
joerg fd7c99c412 Drop symbol number from default branch diagnostic, it isn't set at this
point and most likely not valid either.
2017-06-20 11:01:18 +00:00
joerg e45d4ba084 Replace COMBREL with just-in-time check in _rtld_relocate_nonplt_objects.
The COMBREL logic predates thread-safety of the dynamic linker and
breaks the use of shared locks for the common symbol lookup case. It is
unlikely to provide any benefit for lazy binding or PLT lookups, so
provide equivalent functionality in the non-PLT relocation handling loop
by checking if the symbol used by the current relocation is the same as
the one used during the last lookup. No inter-object cachine is done as
it is also unlikely to be benefical.

Testing with Firefox startup on AMD64 shows a small performance gain by
the new method.
2017-06-19 11:57:01 +00:00
joerg 28b12dab1c Fix indentation. 2017-06-15 23:08:46 +00:00
joerg 130ea7cf18 Call _rtld_debug_state before running the global initialisers, so give
gdb a chance to set break points etc.
2017-06-08 18:24:39 +00:00
alnsn 9a921db489 Cosmetic changes to Lua binding in bozohttpd.
- Don't use negative indicies to read arguments of Lua functions.
- On error, return nil, "error string".
- Use ssize_t for return values from bozo_read() and bozo_write().
- Prefer lstring especially when if saves you from appending NUL and
  doing len + 1 which can potentially wraparound.
- Don't mix C allocations with Lua functions marked with "m" in the Lua
  manual. Those functions may throw (longjump) and leak data allocated
  by C function. In one case, I use luaL_Buffer, in the other case,
  I rearranged calls a bit.
2017-05-28 22:37:36 +00:00
riastradh ef315f7931 Remove MKCRYPTO option.
Originally, MKCRYPTO was introduced because the United States
classified cryptography as a munition and restricted its export.  The
export controls were substantially relaxed fifteen years ago, and are
essentially irrelevant for software with published source code.

In the intervening time, nobody bothered to remove the option after
its motivation -- the US export restriction -- was eliminated.  I'm
not aware of any other operating system that has a similar option; I
expect it is mainly out of apathy for churn that we still have it.
Today, cryptography is an essential part of modern computing -- you
can't use the internet responsibly without cryptography.

The position of the TNF board of directors is that TNF makes no
representation that MKCRYPTO=no satisfies any country's cryptography
regulations.

My personal position is that the availability of cryptography is a
basic human right; that any local laws restricting it to a privileged
few are fundamentally immoral; and that it is wrong for developers to
spend effort crippling cryptography to work around such laws.

As proposed on tech-crypto, tech-security, and tech-userlevel to no
objections:

https://mail-index.netbsd.org/tech-crypto/2017/05/06/msg000719.html
https://mail-index.netbsd.org/tech-security/2017/05/06/msg000928.html
https://mail-index.netbsd.org/tech-userlevel/2017/05/06/msg010547.html

P.S.  Reviewing all the uses of MKCRYPTO in src revealed a lot of
*bad* crypto that was conditional on it, e.g. DES in telnet...  That
should probably be removed too, but on the grounds that it is bad,
not on the grounds that it is (nominally) crypto.
2017-05-21 15:28:36 +00:00
uwe 672fc2f785 PR port-macppc/47464 - Old binutils generated bogus zero-sized COPY
relocations for _SDA_BASE_ and _SDA2_BASE_ that happened to work by
accident.  They no longer happen to work when old binaries are run on
newer systems.  Explicitly ignore these bogus relocations.
2017-04-27 08:37:15 +00:00
maya cfef4500d4 Revert to version 1.55 of map_object.c. This reverts:
"really unmap the gap between the text and data rather than just removing
all access with mprotect().  the latter results in the kernel having to
keep track of that range separately since the permissions are different.
avoid calling mmap() with a size of zero."

As per toolchain/52054: src/libexec/ld.elf_so update breaks everything,
this commit is very broken for some people (but not others). chs mentioned
he has a fix, but best not to leave -current broken in the meantime.
2017-03-10 09:13:49 +00:00
chs cf66c8999a really unmap the gap between the text and data rather than just removing
all access with mprotect().  the latter results in the kernel having to
keep track of that range separately since the permissions are different.
avoid calling mmap() with a size of zero.
2017-03-09 00:43:50 +00:00
chs 1c75bf6f84 tag the powerpc hackish_return_address() as __noinline. 2017-02-27 20:25:26 +00:00
mrg 002f468d50 uh, this is actually called 20170201 :-) 2017-02-05 01:55:03 +00:00
mrg 7dd016e517 fix the prototype for bozo_set_pref(). from cfkoch 2017-02-04 01:32:54 +00:00
mrg 630f2c0b49 call this bozohttpd 20170201. 2017-01-31 14:36:09 +00:00
mrg 2c19cec69e - fix a bug in cgi processing. from Dennis Lindroos.
- add a testcase for this, and expand test-simple to handle additional
  args to bozohttpd for eg, cgi-bin setting.
- fix objdir bugs in the testsuite.
2017-01-31 14:33:54 +00:00
christos 92838f1e37 kerberos needs sqlite3 2017-01-28 23:40:51 +00:00
abhinav b461520850 Fix typo: s/suport/support 2017-01-20 16:14:44 +00:00
christos a80110f6b6 need <sys/stat.h> 2017-01-10 21:08:48 +00:00
christos 7d85ef5c1f need <sys/stat.h> for chmod 2017-01-10 21:08:15 +00:00
christos 2c1d98b710 missing <sys/stat.h> include. 2017-01-10 20:29:48 +00:00
schmonz 10c3be53a3 When testing non-verbosely, show diff on failure. ok mrg@ 2016-12-27 12:09:19 +00:00
abhinav 96415509bf Fix a sentence. 2016-12-24 05:40:49 +00:00
abhinav c665c84ea5 We don't have any ``name'' program, so remove its reference
and use markup to refer finger(1).

ok wiz@
2016-12-22 12:42:24 +00:00
abhinav cad7fa138e Fix sentences at a couple of places. 2016-12-21 09:33:08 +00:00
abhinav ca3357623e s/users/user's
Also, add an xref to services(5)
2016-12-20 09:22:18 +00:00
maya 21cc7f1b6b acknowleg -> acknowledg, proceedure -> procedure.
only comments were changed.

from miod
2016-12-12 15:58:44 +00:00
wiz d8a6eb3c16 Whitespace. 2016-12-12 10:07:48 +00:00
mrg 48524f008b there was a bug fix in july. call this 20160720. 2016-12-11 20:40:41 +00:00
christos a106fb55e5 Add libprop for static linking 2016-12-11 15:43:48 +00:00
christos a363700a4c Fix the direction; ipf/pf seem to be wrong... 2016-12-10 22:09:18 +00:00
christos 4ce8846de5 Fix varargs. 2016-12-10 22:08:13 +00:00
christos b525cd90e0 add npf support. 2016-12-10 05:43:11 +00:00
christos c8c18415f0 n dl_iterate_phdr return the path not the name. 2016-12-01 18:21:39 +00:00
christos f9f702d000 Instead of using a function to resolve symbols that should be supplied by
the dynamic linker itself, use a version script that exposes them. From joerg@
2016-12-01 14:29:15 +00:00
christos 1abd6678f6 add missing newline in comment 2016-11-30 20:25:23 +00:00
christos d32757ced4 Emulate the standard symbol search order in dlsym() i.e. resolve weak or
not found symbols that are in the dynamic linker list of exported symbols
from the dynamic linker itself.
2016-11-30 19:43:32 +00:00
christos 07303da5f3 revert, I'll fix libc instead. 2016-10-07 19:10:03 +00:00
christos 94e616077b Mips o32 needs -lgcc for __udivdi3 in headers.c for fast_divide32_prepare(). 2016-10-07 17:12:59 +00:00
mrg da548da125 update the -V documentation to be more clear about what it does.
inspired by Swift Griggs on netbsd-users.
2016-10-04 18:33:00 +00:00
mrg 5261f4fbc4 add -V to the usage() list. noted by Swift Griggs on netbsd-users. 2016-10-04 18:26:47 +00:00
schmonz 7ec9a291e1 Missed in previous: exit 1 if html_cmp says no match. 2016-09-26 00:21:22 +00:00
schmonz 268438cada Add a VERBOSE knob to the testsuite ("yes" by default, producing
basically the same output as before). When turned off, tests run
silently except when there's a failure.

Reviewed by mrg@.
2016-09-23 16:55:56 +00:00
martin fee8b601f9 Despite the 10 in the name, the OLO10 relocation targets a 13 bit field,
the offset (O) providing the additional data.
2016-08-29 16:00:10 +00:00
mrg bfef5cee0b use netbsd rcsid 2016-08-20 00:36:41 +00:00
shm febbddea26 Fix error checks in open(2) calls. 2016-07-21 12:29:37 +00:00
shm ef0b7ea3b6 CID 976523: add FALLTHROUGH 2016-07-20 20:18:21 +00:00
shm 31d615acc3 CID 603440: ensure that closing socket exists 2016-07-19 21:25:38 +00:00
shm d3c94bcc3a Fix race condition in deliver(), fix resource leak. 2016-07-19 13:11:38 +00:00
shm 1202090c01 Do not send encoding header for compressed formats. 2016-07-19 09:27:40 +00:00
mrg 9d18868a64 avoid an impossible case the compiler can't quite tell. 2016-06-30 13:17:48 +00:00
martin 115160e654 Fix a few bounds and instruction sequences generated in the PLT; exercised
by ASLR and verified to work with the aslr fixed random debug sysctls.
2016-06-20 08:12:25 +00:00
christos 4910b5ce72 Move relro after we've computed out relocbase and re-enable it.
(Matthias Weckbecker)
2016-06-16 11:34:13 +00:00
christos 3ee1ef9906 Turn off GNU_RELRO for now. 2016-06-15 12:08:47 +00:00
christos 0e6265fc35 Add support for GNU RELRO headers from Matthias Weckbecker. 2016-06-14 13:06:41 +00:00
agc 205633288c As proposed in:
http://mail-index.netbsd.org/tech-userlevel/2016/05/18/msg009999.html

and

	https://www.netbsd.org/~agc/bozo-20160517.diff

add a patch to httpd to return the version string of httpd itself, and use the
-G option on the command line to enable this. This gives httpd the ability to
show, from the command line, what version is running.

	% /usr/build/obj/x86_64/usr/src/libexec/httpd/bozohttpd -G
	bozohttpd version bozohttpd/20160415
	%
2016-05-24 21:18:29 +00:00
christos 564475388a Put the name of the dynamic linker in allocated memory, so that it becomes
part of the core file link-map, so that gdb can find it.
2016-05-24 20:32:33 +00:00
joerg 6e49b77769 obj->phdr must be the absolute address, not the virtual offset from the
main binary. Historically, this has been the same. For PIE though,
relocbase can be pretty much anywhere. Fixes PR toolchain/51159.
2016-05-22 19:28:39 +00:00
christos f7945701d6 CID 1358679: Fix memory leak.
XXX: pullup 7
2016-04-24 18:24:47 +00:00
mrg 0a7cdc80ba use %zu instead of %lu for size_t. 2016-04-15 20:00:13 +00:00
mrg 27da98ff14 updates and bozohttpd 20160415:
o  add search-word support for CGI
o  fix a security issue in CGI suffix handler support which would
   allow remote code execution, from shm@netbsd.org
o  -C option supports now CGI scripts only
2016-04-15 17:57:21 +00:00
skrll 42fe483061 Remove duplicated __RCSIDs I added years ago - I blame CVS.
Spotted by Miod Vallat
2016-04-14 20:17:07 +00:00
christos 80c3d4eb2a - Print a warning for text relocations
- Don't remap the text segment executable while relocating
2016-04-12 19:10:48 +00:00
mrg 7bc3291858 move the compiler hack closer to the source of the fail 2016-03-18 10:10:21 +00:00
christos 43c3c3f74a Add volatile for gcc 5 2016-03-17 00:21:04 +00:00
christos f2192299b9 volatile for gcc 5 2016-03-17 00:17:58 +00:00
mrg 2dc66b067e make the GCC 4.8 specific hack for ci.clean being set GCC >= 4.8. 2016-03-16 18:58:34 +00:00
dholland d9047ae69b Use functions instead of preprocessor abuse. 2016-03-13 00:32:09 +00:00
christos 80fa2ce1a5 where is already void * 2016-02-20 15:20:23 +00:00
macallan 3709f36323 make debug code compile again
from christos
2016-02-19 22:09:09 +00:00
riastradh 9628679b27 Need <stdbool.h> for true/false. 2016-02-19 03:53:46 +00:00
skrll 19b4c45621 Actually, descsz should not contain the padding. The note still needs to
be padded out.
2016-02-09 10:20:03 +00:00
skrll a5b645efc7 Fix .note.netbsd.march by ensuring correct padding 2016-02-08 11:59:39 +00:00
christos a21e664447 we don't need <sys/mbuf.h> 2016-01-24 01:56:04 +00:00
christos ffeb8dbf4e Define _KERNTYPES for things that need it. 2016-01-23 21:22:45 +00:00
christos 8d60259f07 PR/50665: David Binderman: move "dir" to the outer scope so it stays alive
when the pointer is used later.
2016-01-17 14:46:07 +00:00
elric 591b978b80 Fix bug in cleanup of reply headers. 2016-01-02 20:35:59 +00:00
elric afe55bf842 Add the concept of ``reply headers'', that is a SIMPLEQ of headers that
will be included in the HTTP reply.  We define this as we are about to
add an authentication method that may need to have a conversation with
the client.
2016-01-02 18:40:13 +00:00
mrg 0841a79ea3 bump the version; we have real fixes now. 2015-12-31 04:58:43 +00:00
mrg 614a8b6713 redo the fix for rev 1.26 - instead of getting a new string wrong,
just delay the free until the parent has finished using them.
also, free query as well.

fixes PR#50374.
2015-12-31 04:39:16 +00:00
mrg 84411b5891 rewrite the redirection url generation code to use bozoasprintf(). 2015-12-29 04:30:33 +00:00
mrg c2e98309d5 - convert most asprintf() calls to bozoasprintf().
- don't call getpwuid(0) if we don't need to, or fail it it fails,
  and remove the 'username' member of bozohttpd_t since it is not
  used outside of bozo_setup().
2015-12-29 04:21:46 +00:00
mrg 881b8188de rename bozo_err/bozo_warn/bozo_asprintf to bozoerr/etc.
new rule is that function that mirror libc-style functions get no underscore.
2015-12-28 07:37:59 +00:00
mrg cff2d95613 several clean ups:
- bozostrdup() gains a request parameter, and uses it to determine
  what sort of error handling is required
- bozo_strdup() dies
- size_arrays() reduced slightly, pushing error handling into the caller
- convert to size_t for some array indices
- bozo_set_pref() and bozo_init_prefs() gain httpd parameters
- apply a bunch of manual CSE to vastly reduce the number of times the
  string "request->hr_httpd" appears.
- CGI parse_header() takes a request not httpd now

XXX: lua glue updated to call bozo_init_prefs() with htttpd parameter,
     but i'm only guessing here.
2015-12-27 10:21:35 +00:00
mrg 71e7babf6d fix running the testsuite from the build tree 2015-12-27 07:43:39 +00:00
christos f47ab3a37e Introduce bozo_strdup and bozo_asprintf to add error checking and reduce
code duplication.

Note that bozo_strdup is different that bozostrdup; the _ routines exit
loging error to syslog or stderr, whereas the non _ routines send error
responses to the http client.
2015-12-12 18:06:58 +00:00
christos 14ba256990 - restrict the default list of ciphers to something more secure
- restrict ssl options
From Travis Paul
2015-12-12 16:57:53 +00:00
kamil d3f055bfc7 Improve the httpd(8) printenv.lua Lua example
Stop using Lua builtin print function and replace them with http.* ones.
httpd.print and http.write wraps SSL support when needed.

Print http headers, without them browser may interpret page as raw text.

No need to hardcode prefix path in the form.

Add comments for a user with tips how to use this script.

Patch by Travis Paul

Closes PR misc/50502
2015-12-07 03:11:48 +00:00
kamil a2fa5fef62 Bump date for previous 2015-11-29 15:58:07 +00:00
kamil 1e3b6beb3f Synchronize SYNOPSIS with reality 2015-11-29 15:29:55 +00:00
kamil 55cd314790 Remove nonexistent option z: in the getopt(3) call 2015-11-29 15:26:10 +00:00
christos 59f3853f3e handle asprintf errors consistently. 2015-10-31 00:55:17 +00:00
christos e3e5f7f09b fix wrong variable 2015-10-30 23:45:31 +00:00
christos 1932f6942a simplify 2015-10-30 23:27:47 +00:00
christos b44c2ed92e - don't use alloca and then check if alloca returns null and then try to
free it. Allocating from the stack does not return null, and freeing it
  will have unpredictable results. use malloc instead.
- now we are using malloc remove -Wno-stack-protector kludge
2015-10-30 23:21:05 +00:00
tron 63d7176dc2 Fix build with "USE_SSP" set to "yes". 2015-10-30 18:53:26 +00:00
shm c4fe1fac22 * add CGI support for ~user translation (-E switch)
* add redirects to ~user translation
* fix bugs around ~user translation
* add schema detection for absolute redirects
* fixed few memory leaks
* bunch of minor tweaks
* removed -r support
* smarter redirects

OK mrg@
2015-10-28 09:20:15 +00:00
mrg ce12165d33 s/USE_NBUTIL/HAVE_NBUTIL_H/, to match the Makefile.
fixes a merge problem in introduced when merging the QNX patches.

from Jan Danielsson.
2015-10-25 19:06:49 +00:00
dholland fbd9d636b3 Enable lfs64 in the cleaner. 2015-10-15 06:25:04 +00:00
christos 029efed26d this is syslog-like 2015-10-14 15:53:50 +00:00
dholland 4f6e0f51f3 Use llabs(), not abs(), on the difference of daddr_t's.
Caught by clang, reported by joerg.

Turn off the clang-specific compiler flags that were making the report
nonfatal.
2015-10-10 22:34:46 +00:00
dholland c4e7149610 Use IINFO in the cleaner. 2015-10-03 08:28:30 +00:00
dholland 89fa7c41df Remove dead assignment; from Henning Petersen in PR 50196. 2015-09-03 08:16:36 +00:00
dholland ec175d5025 Add new accessors for the d_type and d_namlen fields of struct lfs_direct.
Napalm the old byteswap access logic for these.
2015-09-01 06:16:58 +00:00
dholland eb2560adae The ifile's inode number is constant. (it is always 1)
Therefore, storing the value in the superblock and reading it out
again is silly and offers the opportunity for it to become corrupted.
So, don't do that (most of the code already didn't) and use the
existing constant instead. Initialize new 32-bit superblocks with
the value for the sake of old userland programs, but don't keep the
value in the 64-bit superblock at all.

(approved by Margo Seltzer)
2015-09-01 06:12:04 +00:00