Commit Graph

7517 Commits

Author SHA1 Message Date
Colin Percival
eb51316b50 Adjust wording slightly to emphasize that random(3) should not be used for
any applications which need unpredictable random numbers, not merely those
which are cryptographic in nature.

If you work for a lottery and you're using random(3) to select the winning
numbers, please let me know.
2015-02-25 07:49:15 +00:00
Pedro F. Giffuni
e382e86bb4 setmode(3): Make sure that setmode sets errno on failure.
Our man page already documented this partially but now
we have some consistent behavior.

PR:		136669
Obtained from:	NetBSD (CVS rev. 1.31, 1.33)
Relnotes:	yes
MFC after:	3 weeks
2015-02-22 20:16:44 +00:00
Jilles Tjoelker
e220ce08ef nice(): Correct return value and [EPERM] error.
PR:		189821
Obtained from:	NetBSD
Relnotes:	yes
2015-02-22 13:36:44 +00:00
Pedro F. Giffuni
cc3a001f1c Prevent NULL pointer de-reference.
As a follow up to r279090, if dp hasn't been defined, we
shouldn't attempt to do an optimization here.
2015-02-21 15:02:27 +00:00
Pedro F. Giffuni
d58abbfe0f regex(3): Fix uninitialized pointer values.
CID:	405582	(also clang static checker)
CID:	1018724
2015-02-20 21:21:38 +00:00
Pedro F. Giffuni
0b7361b3e3 tab vs spaces. 2015-02-20 20:27:53 +00:00
Pedro F. Giffuni
a9a4a706eb dbm_delete(3) correct man page to match current behaviour.
"The dbm_store() and dbm_delete() functions shall return 0 when they
succeed and a negative value when they fail."

Reference:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/dbm_clearerr.html

PR:		42422
Suggested by:	delphij
MFC after:	3 days
2015-02-20 01:31:10 +00:00
Pedro F. Giffuni
a69a20fa13 Fix small memleaks in nis_passwd() and nis_group().
These only occur upon error.

Code Review:	https://reviews.freebsd.org/D1849
Reviewed by:	delphij

CID:	1016715
CID:	1016717
2015-02-20 01:02:32 +00:00
John-Mark Gurney
b759b8aa44 fix spelling, add comma and remove BUGS section.. it provided no useful
information, and is not really bugs, but limitations for other reasons...
2015-02-19 01:51:17 +00:00
Pedro F. Giffuni
2b1474fdde libc: clean some set-but-not-used errors.
These were found by gcc 5.0 on Dragonfly BSD, however I
made no attempt to silence the false positives.

Obtained from:	DragonFly (cf515c3a6f3a8964ad592e524442bc628f8ed63b)
2015-02-18 03:33:17 +00:00
Pedro F. Giffuni
d2f783303b ulimit(3): simplify.
rlim_t is at least as large as long, so we don't need the
extra variable to keep the intermediate step. We don't
need the volatile either.

The code was tested on i386 and amd64.

Suggested by:	bde
X-MFC with:	r278803
2015-02-17 16:01:00 +00:00
Konstantin Belousov
5aed3effa4 Restore the extern qualifier on __cleanup.
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2015-02-17 08:54:03 +00:00
Marius Strobl
aed116911d Unbreak sparc64 after r276630 by calling __sparc_sigtramp_setup signal
trampoline as part of the MD __sys_sigaction again.

Submitted by:	kib (initial versions)
MFC after:	3 days
2015-02-16 22:13:03 +00:00
Pedro F. Giffuni
78a452c36e Replace strcpy() with strlcpy()
The risk of an overrun here is very low but check the
length, JIC.

CID:	1019039
2015-02-15 21:11:07 +00:00
Pedro F. Giffuni
1a4161a15d Reverse one of the initializations from r278804.
It does no harm but this is not needed after the
correction in r278805 and I prefer to keep this
code very similar to it's original state.
2015-02-15 21:03:49 +00:00
Pedro F. Giffuni
b78ceb0a58 Mismatch in r278804. 2015-02-15 18:02:05 +00:00
Pedro F. Giffuni
09cc2762fa More tidy-ups on uninitialized scalar variable
As a followup to r278363, there is one more case where
stayopen can be accessed uninitialized, but even after
swapping arguments, access is possible in some other
cases so prevent it completely by initializing stayopen.

CID:	1018729
CID:	1018732
2015-02-15 16:50:21 +00:00
Pedro F. Giffuni
e291429c5b ulimit(3): Fix broken check.
The existing implementation had a broken comparison that could
overflow and return confusing values.  Replace this with a check
that avoids the overflow before it happens.

Consistently return a maximum value also on the case of negative
arguments since negative is considered an overflow and means
infinity for our current setrlimit().

New revamped version is credited to Bruce Evans.

CID:		1199295
MFC after:	1 week
2015-02-15 14:31:50 +00:00
Tijl Coosemans
dac0a53840 The ld(1) flag is -Bsymbolic not -Wsymbolic. 2015-02-14 15:14:41 +00:00
Konstantin Belousov
45468c5356 Properly interpose libc spinlocks, was missed in r276630. In
particular, stdio locking was affected.

Reported and tested by:	"Matthew D. Fuller" <fullermd@over-yonder.net>
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2015-02-14 11:47:40 +00:00
Xin LI
a89629abd9 Disallow pattern spaces which would cause intermediate calculations to
overflow size_t.

Obtained from:	DragonFly (2841837793bd095a82f477e9c370cfe6cfb3862c dillon)
Security:	CERT VU#695940
MFC after:	3 days
2015-02-14 00:23:53 +00:00
Pedro F. Giffuni
09d73a0662 Revert 278634: This broke the build due to the compiler being too clever.
Will be back, with proper compiler workarounds.
2015-02-13 00:21:54 +00:00
Pedro F. Giffuni
0b44c6cc6e ulimit(3): Fix broken check.
The existing implementation had a broken comparison that could overflow.
Replace this with a check that avoids the overflow before it happens.

Consistently return a maximum value also on the case of negative
arguments since negative is considered an overflow and means
infinity for our current setrlimit().

Discussed with:	bde (rather extensively)

CID:		1199295
MFC after:	1 week
2015-02-12 21:07:42 +00:00
Bryan Drewery
1bb3a25f07 When catopen(3) returns an error, it caches the result of that error
from r202992. The refcount on the cache entry is not initialized, so
any attempt to clean the cache will skip over this item since it likely
has a >0 value.

This change is currently a NOP. There is work in progress to support
freeing the cache which requires this change to avoid a memory leak.

MFC after:	2 weeks
Sponsored by:	EMC / Isilon Storage Division
2015-02-10 20:45:40 +00:00
Pedro F. Giffuni
eb77fbdcec Protect uninitialized scalar variable from being accessed
In a couple of cases a variable "stayopen" can be checked
unitialized. This is of no danger as the complementary
condition is false but prevent the access by switching
the checks.

CID:	1018729
CID:	1018732
2015-02-07 19:51:34 +00:00
Edward Tomasz Napierala
6c316535e2 Remove useless comment.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-02-07 13:11:45 +00:00
Pedro F. Giffuni
02aa7d7b57 Update comment and NetBSD ID tag.
The NetBSD revisions correspond to changes we have already done
like __P() removal and ANSI-fication of definitions.
2015-02-06 14:22:00 +00:00
Pedro F. Giffuni
24ef1d7ab6 Drop cgetclose() from getdiskbyname().
This was a local addition to the original change from NetBSD.
Being this libc there is some chance for it to interfere with
user's cget*() functions usage. The memory leak was finely
plugged by r278300.

Pointed out by:	ache
2015-02-06 14:07:01 +00:00
Pedro F. Giffuni
b20592de1b tdelete(3): don't delete the node we are about to return.
CID:		272528
Obtained from:	NetBSD (CVS rev. 1.4)
MFC after:	2 weeks
2015-02-05 23:02:43 +00:00
Pedro F. Giffuni
5262b957d4 getdiskbyname(): plug resource leak
Variable cq going out of scope leaks the storage it points to.

CID:		270511
Phabric:	D1775
Reviewed by:	imp
Obtained from:	NetBSD (CVS rev. 1.34)
MFC after:	2 weeks
2015-02-05 22:54:31 +00:00
Pedro F. Giffuni
e742fdff32 rpc: Uninitialized pointer read
Initialize *xprt to avoid exposing a random value
in cleanup_svc_vc_create.

CID:		1018723
Phabric:	D1749
Reviewed by:	alfred
2015-02-02 00:21:34 +00:00
Pedro F. Giffuni
81cb3b156b Resource leak
CID:	1016703
Reviewed by:	alfred
2015-02-01 23:19:06 +00:00
Jilles Tjoelker
424c16b2ce ttyname_r(): Return actual error, not always [ENOTTY].
Adjust the test that used to fail because of this bug.

PR:		191936
MFC after:	1 week
2015-02-01 22:50:33 +00:00
Ed Maste
7a47d65d5d Use zero register instead of immediate 0x0 in MIPS assembly
It seems GAS makes the substitution automatically, but Clang's
integrated assembler does not (yet). It fails with "invalid operand for
instruction."

Reported by:	sbruno
2015-01-29 15:30:04 +00:00
Jilles Tjoelker
49ba8a68f0 sem_post(): Fix and document semaphore value overflow error.
The error code is per Austin Group issue #315.

I provided different wording for the manual page change.

Submitted by:	pluknet
MFC after:	1 week
2015-01-28 22:42:56 +00:00
Jilles Tjoelker
8dd985befe Enable utimensat tests from NetBSD.
As with other tests from c063, a required #include <sys/stat.h> was missing.
2015-01-24 15:49:40 +00:00
Jilles Tjoelker
2205e0d1bd Add futimens and utimensat system calls.
The core kernel part is patch file utimes.2008.4.diff from
pluknet@FreeBSD.org. I updated the code for API changes, added the manual
page and added compatibility code for old kernels. There is also audit and
Capsicum support.

A new UTIME_* constant might allow setting birthtimes in future.

Differential Revision:	https://reviews.freebsd.org/D1426
Submitted by:	pluknet (partially)
Reviewed by:	delphij, pluknet, rwatson
Relnotes:	yes
2015-01-23 21:07:08 +00:00
Konstantin Belousov
677258f7e7 Add procctl(2) PROC_TRACE_CTL command to enable or disable debugger
attachment to the process.  Note that the command is not intended to
be a security measure, rather it is an obfuscation feature,
implemented for parity with other operating systems.

Discussed with:	jilles, rwatson
Man page fixes by:	rwatson
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2015-01-18 15:13:11 +00:00
Will Andrews
7a37b5fc17 Add a ${CP} alias for copying files in the build.
Some users build FreeBSD as non-root in Perforce workspaces.  By default,
Perforce sets files read-only unless they're explicitly being edited.
As a result, the -f argument must be used to cp in order to override the
read-only flag when copying source files to object directories.  Bare use of
'cp' should be avoided in the future.

Update all current users of 'cp' in the src tree.

Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	Spectra Logic
2015-01-16 21:39:08 +00:00
Ed Maste
4b12fb6103 Remove duplicate copies of trivial getcontextx.c
Only i386 and amd64 provide a non-trivial __getcontextx(). Use a common
trivial implementation in gen/ for other architectures, rather than
copying the file to each MD subdirectory.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D1472
2015-01-12 18:13:38 +00:00
Konstantin Belousov
397d851d66 Reduce the size of the interposing table and amount of
cancellation-handling code in the libthr.  Translate some syscalls
into their more generic counterpart, and remove translated syscalls
from the table.

List of the affected syscalls:
creat, open -> openat
raise -> thr_kill
sleep, usleep -> nanosleep
pause -> sigsuspend
wait, wait3, waitpid -> wait4

Suggested and reviewed by:	jilles (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2015-01-11 22:16:31 +00:00
Dimitry Andric
18ecc14c78 Apparently more Makefiles use stuff from compiler-rt, so fix them up
too.  (This did not show during a make universe, strangely.)
2015-01-08 20:11:38 +00:00
John Baldwin
e275993995 Document CPU_WHICH_DOMAIN and bump Dd for cpuset.1.
Missed in:	r276829
2015-01-08 18:53:11 +00:00
Craig Rodrigues
9cebfb86a7 Clarify text to be consistent with nanosleep(2),
since sleep(3) is implemented in terms of nanosleep(2).

This is similar to the sleep(3) man page for Darwin.
2015-01-08 01:27:43 +00:00
Justin Hibbits
85eda151ff Avoid use of register variables. Clang 3.5 treats this as undefined behavior,
and bad things happen.

MFC after:	1 week
2015-01-06 03:50:43 +00:00
Konstantin Belousov
1a744fefc2 Avoid calling internal libc function through PLT or accessing data
though GOT, by staticizing and hiding.  Add setter for
__error_selector to hide it as well.

Suggested and reviewed by:	jilles
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2015-01-05 01:06:54 +00:00
Joel Dahl
f636caf195 mdoc: paragraph improvements. 2015-01-04 12:49:24 +00:00
Konstantin Belousov
8495e8b1e9 Fix known issues which blow up the process after dlopen("libthr.so")
(or loading a dso linked to libthr.so into process which was not
linked against threading library).

- Remove libthr interposers of the libc functions, including
  __error(). Instead, functions calls are indirected through the
  interposing table, similar to how pthread stubs in libc are already
  done.  Libc by default points either to syscall trampolines or to
  existing libc implementations.  On libthr load, libthr rewrites the
  pointers to the cancellable implementations already in libthr.  The
  interposition table is separate from pthreads stubs indirection
  table to not pull pthreads stubs into static binaries.

- Postpone the malloc(3) internal mutexes initialization until libthr
  is loaded.  This avoids recursion between calloc(3) and static
  pthread_mutex_t initialization.

- Reinstall signal handlers with wrapper on libthr load.  The
  _rtld_is_dlopened(3) is used to avoid useless calls to sigaction(2)
  when libthr is statically referenced from the main binary.

In the process, fix openat(2), swapcontext(2) and setcontext(2)
interposing.  The libc symbols were exported at different versions
than libthr interposers.  Export both libc and libthr versions from
libc now, with default set to the higher version from libthr.

Remove unused and disconnected swapcontext(3) userspace implementation
from libc/gen.

No objections from:	deischen
Tested by:	pho, antoine (exp-run) (previous versions)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2015-01-03 18:38:46 +00:00
Konstantin Belousov
0e521992a4 Add rtld private interface for dso to detect dynamic loading
vs. static linking.

Tested by:	pho, antoine (exp-run)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2015-01-03 18:09:53 +00:00
Jilles Tjoelker
d79f904ad2 Link lib/libc/c063 tests to the build.
Some files lack required #include <sys/stat.h>. The #ifdef is per ngie's
request; the includes are clearly necessary for struct stat.

The faccessat test fails because it tries to use AT_SYMLINK_NOFOLLOW with
faccessat(), which is not specified by POSIX.1-2008.

Differential Revision:	https://reviews.freebsd.org/D1411
Reviewed by:	ngie
2015-01-02 22:49:05 +00:00