Commit Graph

1602 Commits

Author SHA1 Message Date
Joel Dahl
c2965cd185 mdoc: terminate quoted strings.
Reviewed by:	brueffer
2012-03-26 15:18:14 +00:00
Ed Schouten
126b6df920 Make utmpx(3) thread safe if we support TLS.
Because the utmpx interface is generally not required to be thread-safe,
but it is nice to have, if easy to do so. Therefore don't make a mess
out of the code and only use it if __NO_TLS is not defined.
2012-03-23 08:26:31 +00:00
Sergey Kandaurov
3daaaabdb8 Fix style. Somehow I managed to lost a space when copy&paste.
Pointed out by:	stefanf
2012-03-22 09:51:31 +00:00
Sergey Kandaurov
130b343048 Prevent fs_file NULL pointer dereference in fixfsfile() uncovered after r1.5
when passing damaged user-supplied fstab file data.

MFC after:	1 week
2012-03-22 09:42:27 +00:00
David Xu
4e2158bf53 Revert previous change. It is an incomplete change from old branch. :-( 2012-03-21 07:16:58 +00:00
David Xu
cc583082f4 Use version 2 of semaphore provided by kernel umtx code, now if there is
no waiters, we still increase and decrease count in user mode without
entering kernel, once there is a waiter, sem_post will enter kernel to
increase count and wake thread up, this is atomicy and allow us to
gracefully destroy semaphore after sem_wait returned.
2012-03-21 07:12:52 +00:00
Jilles Tjoelker
012df2856c fts(3): Mention that FTS_NOCHDIR imposes {PATH_MAX} limits on the returned
pathnames.

With the current API (no *at functions), FTS_NOCHDIR requires that the
fts_accpath start with the original path passed to fts_open(); therefore,
the depth that can be reached is limited by the {PATH_MAX} constraint on
this pathname.

MFC after:	1 week
2012-03-18 21:46:27 +00:00
Jilles Tjoelker
145c674dbd fts(3): Document cases where FTS_NOCHDIR is set implicitly.
PR:		docs/166091
Submitted by:	Matthew Story
MFC after:	1 week
2012-03-18 20:34:01 +00:00
Oleksandr Tymoshenko
54da2fb8f2 - Switch ARM and MIPS to TLS Variant I
- Fix TLS allocation  for Variant I: both rtld and libc allocators
    assume that tls_static_space includes space for TLS structure.
    So increment calculated static size by the size of it.
2012-03-06 03:42:54 +00:00
Ruslan Ermilov
e5fb99b712 Removed excessive _seekdir() call in closedir(). This saves one lseek()
syscall.  Before r5958, seekdir() was called for its side effect of
freeing memory allocated by opendir() for rewinddir(), but that revision
added _reclaim_telldir() that frees all memory allocated by telldir()
calls, making this call redundant.

This introduces a slight change.  If an application duplicated the descriptor
obtained through dirfd(), it can no longer rely on file position to be
reset to the start of file after a call to closedir().  It's believed to
be safe because neither POSIX, nor any other OS I've tested (NetBSD, Linux,
OS X) rewind the file offset pointer on closedir().

Reported by:	Igor Sysoev
2012-03-02 14:05:50 +00:00
Konstantin Belousov
2cfd3f86b0 Belatedly add dl_iterate_phdr(3) to the list of installed manpages.
MFC after:	3 days
2012-03-02 13:19:56 +00:00
Ruslan Ermilov
01e4939740 Finally removed the stat() and fstat() calls from the opendir() code.
They were made excessive in r205424 by opening with O_DIRECTORY.
Also eliminated the fcntl() call used to set FD_CLOEXEC by opening
with O_CLOEXEC.

(fdopendir() still checks that the passed descriptor is a directory,
and sets FD_CLOEXEC on it.)

Reviewed by:	ed
2012-03-02 10:03:38 +00:00
David Xu
df1f1bae9e In revision 231989, we pass a 16-bit clock ID into kernel, however
according to POSIX document, the clock ID may be dynamically allocated,
it unlikely will be in 64K forever. To make it future compatible, we
pack all timeout information into a new structure called _umtx_time, and
use fourth argument as a size indication, a zero means it is old code
using timespec as timeout value, but the new structure also includes flags
and a clock ID, so the size argument is different than before, and it is
non-zero. With this change, it is possible that a thread can sleep
on any supported clock, though current kernel code does not have such a
POSIX clock driver system.
2012-02-25 02:12:17 +00:00
Jilles Tjoelker
8b34578da7 libc: Eliminate some relative relocations in fmtmsg(). 2012-02-22 21:47:50 +00:00
Pawel Jakub Dawidek
57a82ba4d9 Document the fact that getgrouplist(3) returns 0 on success.
MFC after:	3 days
2012-02-20 20:46:27 +00:00
Xin LI
3a12c0461b Use ANSI prototypes. 2012-02-18 00:55:54 +00:00
Konstantin Belousov
1c90f07c45 Fix cross-references.
Submitted by:	pluknet
MFC after:  2 weeks
2012-02-17 12:40:27 +00:00
Konstantin Belousov
ab8f652cd7 Document dl_iterate_phdr(3).
Man page is based on the OpenBSD version, extended and corrected for
the FreeBSD implementation.

MFC after:  2 weeks
2012-02-17 10:51:40 +00:00
Konstantin Belousov
a7d61fc17d Fetch the aux vector for the static libc, and use the entries to
initialize the cache of the system information as it was done for the
dynamic libc. This removes several sysctls from the static binary
startup.

Use the aux vector to fill the single struct dl_phdr_info describing
the static binary itself, to implement dl_iterate_phdr(3) for the
static binaries. [1]

Based on the submission by:	John Marino <draco marino st> [1]
Tested by:   flo (sparc64)
MFC after:	2 weeks
2012-02-17 10:49:29 +00:00
Ed Schouten
6b99842ada Globally replace u_int*_t from (non-contributed) man pages.
The reasoning behind this, is that if we are consistent in our
documentation about the uint*_t stuff, people will be less tempted to
write new code that uses the non-standard types.

I am not going to bump the man page dates, as these changes can be
considered style nits. The meaning of the man pages is unaffected.

MFC after:	1 month
2012-02-12 18:29:56 +00:00
Ed Schouten
71d8432f98 Replace utxrm(8) by utx(8).
At first, I added a utility called utxrm(8) to remove stale entries from
the user accounting database. It seems there are cases in which we need
to perform different operations on the database as well. Simply rename
utxrm(8) to utx(8) and place the old code under the "rm" command.

In addition to "rm", this tool supports "boot" and "shutdown", which are
going to be used by an rc-script which I am going to commit separately.
2012-02-11 20:28:42 +00:00
Ed Schouten
a8f77c1f66 Set read buffer size to multiple of sizeof(struct futx).
If the utmpx database gets updated while an application is reading it,
there is a chance the reading application processes partially
overwritten entries. To solve this, make sure we always read a multiple
of sizeof(struct futx) at a time.

MFC after:	2 weeks
2012-02-11 11:11:13 +00:00
Bjoern A. Zeeb
6d076ae8f7 Introduce a new NET_RT_IFLISTL API to query the address list. It works
on extended and extensible structs if_msghdrl and ifa_msghdrl.  This
will allow us to extend both the msghdrl structs and eventually if_data
in the future without breaking the ABI.

Bump __FreeBSD_version to allow ports to more easily detect the new API.

Reviewed by:	glebius, brooks
MFC after:	3 days
2012-02-11 06:02:16 +00:00
Eitan Adler
7c88c0d0e1 More accurately document what happens on error.
PR:		docs/127908
Submitted by:	Matthew D. Fuller <fullermd@over-yonder.net>
Approved by:	cperciva
MFC after:	1 week
2012-02-09 20:49:03 +00:00
Konstantin Belousov
2b1de0afd1 Add API for obtaining extended machine context states that cannot be
fit into existing mcontext_t.

On i386 and amd64 do return the extended FPU states using
getcontextx(3). For other architectures, getcontextx(3) returns the
same information as getcontext(2).

Tested by:  pho
MFC after:  1 month
2012-01-21 18:00:28 +00:00
David Xu
d22d46ce27 Insert read memory barriers. 2012-01-16 06:15:14 +00:00
Ed Schouten
f9d9bcd45e Remove wtmpcvt(1).
The wtmpcvt(1) utility converts wtmp files to the new format used by
utmpx(3). Now that HEAD has been branched to stable/9 and 9.0 is
released, there is no need for it in HEAD.

MFC after:	never
2012-01-13 15:40:49 +00:00
Guy Helmer
9a2611585e Revert unintentional commit of changes to getnetgrent.c. 2012-01-10 19:54:53 +00:00
Guy Helmer
f295618d06 Add pidfile_fileno() to obtain the file descriptor for an open
pidfile.
2012-01-10 19:53:25 +00:00
Konstantin Belousov
5d8aec9c02 Implement fdlopen(3), an rtld interface to load shared object by file
descriptor.

Requested and tested by:	des (previous version)
Reviewed by:  des, kan (previous version)
MFC after:    2 weeks
2012-01-07 10:33:01 +00:00
Ed Schouten
b3608ae18f Replace index() and rindex() calls with strchr() and strrchr().
The index() and rindex() functions were marked LEGACY in the 2001
revision of POSIX and were subsequently removed from the 2008 revision.
The strchr() and strrchr() functions are part of the C standard.

This makes the source code a lot more consistent, as most of these C
files also call into other str*() routines. In fact, about a dozen
already perform strchr() calls.
2012-01-03 18:51:58 +00:00
Dimitry Andric
b9b670e347 Add some additional const poison after r228972. The 'mapping' array in
lib/libc/gen/strtofflags.c became const, but gcc did not warn about
assigning its members to non-const pointers.  Clang warned about this
with:

lib/libc/gen/strtofflags.c:98:12: error: assigning to 'char *' from 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types]
                        for (sp = mapping[i].invert ? mapping[i].name :
                                ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reviewed by:	jilles
2011-12-30 20:41:24 +00:00
Jilles Tjoelker
8c87e0405a libc: Eliminate some relative relocations in file flags table. 2011-12-29 22:15:18 +00:00
Jilles Tjoelker
5b7aa0fc6e libc: Eliminate some relative relocations in getusershell(). 2011-12-27 23:35:10 +00:00
Colin Percival
3e65b9c6e6 Fix a problem whereby a corrupt DNS record can cause named to crash. [11:06]
Add an API for alerting internal libc routines to the presence of
"unsafe" paths post-chroot, and use it in ftpd. [11:07]

Fix a buffer overflow in telnetd. [11:08]

Make pam_ssh ignore unpassphrased keys unless the "nullok" option is
specified. [11:09]

Add sanity checking of service names in pam_start. [11:10]

Approved by:    so (cperciva)
Approved by:    re (bz)
Security:       FreeBSD-SA-11:06.bind
Security:       FreeBSD-SA-11:07.chroot
Security:       FreeBSD-SA-11:08.telnetd
Security:       FreeBSD-SA-11:09.pam_ssh
Security:       FreeBSD-SA-11:10.pam
2011-12-23 15:00:37 +00:00
Eitan Adler
855291741d - Fix style(9) bugs in glob.c
Approved by:	jilles
2011-12-20 22:56:44 +00:00
Eitan Adler
0d6d372c03 - Add restrict keyword to glob(3)
PR:		kern/161958
Submitted by:	Henning Petersen <henning.petersen@t-online.de>
Approved by:	jilles
MFC after:	3 days
2011-12-20 22:56:13 +00:00
Ruslan Ermilov
e26e60ee36 Clean up includes; the prototype for getosreldate() has moved to
<unistd.h> in r183390.
2011-12-14 08:35:08 +00:00
David E. O'Brien
0582474525 Tweak the r137233 fix to r136283 -- Code was making two send() attempts
vs. the comment documented "If we are working with a privileged socket,
then take only one attempt".  Make the code match.

Furthermore, critical privileged applications that [over] log a vast amount
can look like a DoS to this code.  Given it's unlikely the single reattempted
send() will succeeded, avoid usurping the scheduler in a library API for a
single non-critical facility in critical applications.

Obtained from:	Juniper Networks
Discussed with:	glebius
2011-12-02 01:06:33 +00:00
David Chisnall
5bf69a4b16 style(9) fix.
Approved by:	dim (mentor)
2011-11-26 16:49:25 +00:00
David Chisnall
48cb9786e1 Return not-implemented from pthread_once and pthread_key_create, rather
than silently failing and returning success.

Without this, code calls pthread_once(), receives a return value of
success, and thinks that the passed function has been called.

Approved by:	dim (mentor)
2011-11-26 15:57:09 +00:00
Jilles Tjoelker
38574aa8df fdopendir(): Do not close the passed file descriptor on failure.
Reviewed by:	delphij
2011-11-22 23:46:56 +00:00
David Chisnall
3c87aa1d3d Implement xlocale APIs from Darwin, mainly for use by libc++. This adds a
load of _l suffixed versions of various standard library functions that use
the global locale, making them take an explicit locale parameter.  Also
adds support for per-thread locales.  This work was funded by the FreeBSD
Foundation.

Please test any code you have that uses the C standard locale functions!

Reviewed by:    das (gdtoa changes)
Approved by:    dim (mentor)
2011-11-20 14:45:42 +00:00
David Schultz
7a0789b485 Further reduce diffs with OpenBSD's arc4random. The main functional
change here is to ensure that when a process forks after arc4random
is seeded, the parent and child don't observe the same random sequence.
OpenBSD's fix introduces some additional overhead in the form of a
getpid() call.  This could be improved upon, e.g., by setting a flag
in fork(), if it proves to be a problem.

This was discussed with secteam (simon, csjp, rwatson) in 2008, shortly
prior to my going out of town and forgetting all about it.  The conclusion
was that the problem with forks is worrisome, but it doesn't appear to
have introduced an actual vulnerability for any known programs.

The only significant remaining difference between our arc4random and
OpenBSD's is in how we seed the generator in arc4_stir().
2011-11-15 05:49:24 +00:00
David Schultz
c0b4847030 Sync the style, comments, and variable names of arc4random.c with
OpenBSD's version (r1.22).  While some of our style changes were
indeed small improvements, being able to easily track functionality
changes in OpenBSD seems more useful.

Also fix style bugs in the FreeBSD-specific parts of this file.

No functional changes, as verified with md5.
2011-11-15 05:45:46 +00:00
Ed Schouten
ad033677ea Don't forget to kick the man page date. 2011-10-27 17:21:41 +00:00
Ed Schouten
c5cf53fc3e Make our utmpx more like System V.
When booting the system, truncate the utx.active file, but do write the
BOOT_TIME record into it afterwards. This allows one to obtain the boot
time of the system as follows:

	struct utmpx u1 = { .ut_type = BOOT_TIME }, *u2;

	setutxent();
	u2 = getutxid(&u1);

Now, the boot time is stored in u2->ut_tv, just like on Linux and other
systems.

We don't open the utx.active file with O_EXLOCK. It's rather unlikely
that other applications use this database at the same time and I want to
prevent the possibility of deadlocks in init(8).

Discussed with:	pluknet
2011-10-27 17:05:18 +00:00
Sergey Kandaurov
7112398c93 Fix the manual section number for a cross-reference to open(2) and sort it.
Reviewed by:	ed
MFC after:	3 days
2011-10-27 13:17:42 +00:00
David Schultz
6232589aeb Replace a proliferation of buggy MD implementations of modf() with a
working MI one.  The MI one only needs to be overridden on machines
with non-IEEE754 arithmetic.  (The last supported one was the VAX.)
It can also be overridden if someone comes up with a faster one that
actually passes the regression tests -- but this is harder than it sounds.
2011-10-21 06:40:36 +00:00
Eitan Adler
36daf0495a - change "is is" to "is" or "it is"
- change "the the" to "the"

Approved by:	lstewart
Approved by:	sahil (mentor)
MFC after:	3 days
2011-10-16 14:30:28 +00:00