summaryrefslogtreecommitdiff
path: root/lib/libc
AgeCommit message (Collapse)Author
2021-02-04Referece trpt(8) from the SO_DEBUG section of getsockopt(2).Alexander Bluhm
OK claudio@ visa@
2021-02-03Adding a hard-trap instruction after the __threxit syscall instructionKurt Miller
broke pthreads on hppa. Reverting. Ok deraadt@
2021-02-02article fixes; from eddie yousephJason McIntyre
2021-01-26When checking for available address family for AI_ADDRCONFIG considerFlorian Obser
the routing domain we are currently in. Otherwise we might end up with address families that are not available in the current rdomain but in others since getifaddrs(3) gives us all interface addresses in the system. Clue-bat & OK claudio, input & OK eric, OK kn
2021-01-20Missing return value; ok jmc@Otto Moerbeek
2021-01-19Prevent an overflow in inet_net_pton(3) when the passed in buffer isFlorian Obser
too small in the AF_INET6 case. Spotted by Brad House (brad AT brad-house.com) with the c-ares regression test. The man page says Caution: The dst field should be zeroed before calling inet_net_pton() as the function will only fill the number of bytes necessary to encode the network number in network byte order. Which seems to suggest that the function should work if the passed in storage is big enough to hold the prefix, which might be smaller than sizeof(in6_addr). Input & OK tb
2021-01-13kernel, sysctl(8): remove dead variable: tickadjcheloha
The global "tickadj" variable is a remnant of the old NTP adjustment code we used in the kernel before the current timecounter subsystem was imported from FreeBSD circa 2004 or 2005. Fifteen years hence it is completely vestigial and we can remove it. We probably should have removed it long ago but I guess it slipped through the cracks. FreeBSD removed it in 2002: https://cgit.freebsd.org/src/commit/?id=e1d970f1811e5e1e9c912c032acdcec6521b2a6d NetBSD and DragonflyBSD can probably remove it, too. We export tickadj via the kern.clockrate sysctl(2), so update sysctl.2 and sysctl(8) accordingly. Hypothetically this change could break someone's sysctl(8) parsing script. I don't think that's very likely. ok mvs@
2021-01-08Make fts_{alloc,safe_changed}() const correctTheo Buehler
Previously, this code was passing string constants to functions that did not declare their parameters as const. After this patch, the functions now declare that they do not modify these arguments, making it safe to pass string constants. Fixes -Wincompatible-pointer-types-discards-qualifiers. From Adam Barth <abarth google com> ok millert
2021-01-07sleep(3): don't bypass nanosleep(2) if seconds is zerocheloha
sleep(3) does not call nanosleep(2) if seconds is zero. This is bad. As a simplified interface to nanosleep(2), sleep(3) should delegate all decisions about whether or not to yield the CPU to nanosleep(2). This patch removes the nanosleep(2) bypass from sleep(3). This means that this code: sleep(0); will block for up to 1 tick, just like the equivalent nanosleep(2) call. Neither FreeBSD nor NetBSD bypass nanosleep(2) in the zero case, so this commit brings our sleep(3) closer to theirs in behavior. As an added bonus, sleep(3) will now *always* appear in a ktrace(1) as a call to nanosleep(2). ok millert@
2021-01-06Fix two issues related to thread private data in asr.Otto Moerbeek
- setting up asr in single thread mode and then starting threads using asr would lead to multiple threads sharing the same resolver. - destruction of a thread that has been using asr would leak data. Problem originally reported by Alexey Sokolov and Uli Schlachter. ok kettenis@
2021-01-03Make consistent reference to pathname.rob
OK schwarze@, jmc@, deraadt@
2021-01-03Make CHIN() Boolean-valued and use this to turn an expression with aTheo Buehler
quintuple negation into one with a simple negation. From miod, ok millert
2021-01-03Turn macros into inline functions so that there is no need to document inTheo Buehler
comments that they will evaluate their arguments multiple times. From miod, ok millert
2021-01-02Remove two now-unused functions; a result of the categories removal.Todd C. Miller
From miod@, OK tb@
2020-12-31More regular error handling with the REQUIRE macro.Todd C. Miller
Changing it from ((condition) || function call) to an if() wrapped in a do/while is easier to read and more stylistically consistent. The seterr() function no longer needs to return a value. From miod@, OK tb@
2020-12-31Remove unused categories in re_guts; they are written to but never read.Todd C. Miller
From miod@, OK tb@
2020-12-31Strings in struct parse can be const, they are never modified.Todd C. Miller
Also, the temporary array in nonnewline() can be made static const. From miod@, OK tb@
2020-12-30getifaddrs() can return entries where ifa_addr is NULL. Check for thisSebastian Benoit
before accessing anything in ifa_addr. ok claudio@
2020-12-30regcomp.c uses the "start + count < end" idiom to check that there areTheo Buehler
"count" bytes available in an array of char "start" and "end" both point to. This is fine, unless "start + count" goes beyond the last element of the array. In this case, pedantic interpretation of the C standard makes the comparison of such a pointer against "end" undefined, and optimizers from hell will happily remove as much code as possible because of this. An example of this occurs in regcomp.c's bothcases(), which defines bracket[3], sets "next" to "bracket" and "end" to "bracket + 2". Then it invokes p_bracket(), which starts with "if (p->next + 5 < p->end)"... Because bothcases() and p_bracket() are static functions in regcomp.c, there is a real risk of miscompilation if aggressive inlining happens. The following diff rewrites the "start + count < end" constructs into "end - start > count". Assuming "end" and "start" are always pointing in the array (such as "bracket[3]" above), "end - start" is well-defined and can be compared without trouble. As a bonus, MORE2() implies MORE() therefore SEETWO() can be simplified a bit. from miod, ok millert
2020-12-30Constify the strings in regerror.c and make use of the strlcpy()Theo Buehler
return value to avoid a redundant strlen() call. from miod, ok millert
2020-12-30cclasses[] multis field is always an empty string. Remove it and codeTheo Buehler
dealing with it. This code was incomplete anyway. from miod, ok millert
2020-12-30Constify the strings in cnames[]. No functional change.Theo Buehler
from miod, ok millert
2020-12-29Document kern.video.record.Marcus Glocker
With help/input from jmc@ and kn@. ok jmc@
2020-12-28Fix an off-by-one error in the marking of the O_CH operator followingTodd C. Miller
an OOR2 operator. Also includes a regress test for the issue. From FreeBSD via miod@
2020-12-21Always call endservent_r() after getservbyport_r().Eric Faurot
Fix a memory leak when no entry is matched. ok florian
2020-12-13Geode CPU does not support SSE, so MXCSR does not exists there. AsAlexander Bluhm
our i386 compiler does not generate SSE instructions by default, it is not strictly necessary to save MXCSR content between setjmp(3) and longjmp(3). We do not want to end supporting such old processors now. Remove the stmxcsr and ldmxcsr instructions from libc. reported by Johan Huldtgren; OK jsg@ kettenis@
2020-12-06On i386 setjmp(3) should store the FPU state and longjmp(3) restoreAlexander Bluhm
it. There is enough space in jmp_buf to save MXCSR and CW register. Idea taken from amd64. This fixes regress/lib/libc/setjmp-fpu . OK kettenis@
2020-12-06Introduce constants to access the setjmp(3) jmp_buf fields fromAlexander Bluhm
i386 libc. The assembler code is more readable than with magic numbers. This brings i386 in line with amd64. No change in object file. OK kettenis@
2020-12-03grammar fixes from Varik "The Genuine Article!!!" Valefor;Jason McIntyre
2020-12-01Set type to DB_RECNO in __rec_open() for consistency with other db types.Todd C. Miller
From Boudewijn Dijkstra
2020-11-28Add retguard to macppc kernel locore.S, ofwreal.S, setjmp.Sgkoehler
This changes RETGUARD_SETUP(ffs) to RETGUARD_SETUP(ffs, %r11, %r12) and RETGUARD_CHECK(ffs) to RETGUARD_CHECK(ffs, %r11, %r12) to show that r11 and r12 are in use between setup and check, and to pick registers other than r11 and r12 in some kernel functions. ok mortimer@ deraadt@
2020-11-23mapalign() only handles allocations >= a page; problem found by and ok semarie@Otto Moerbeek
2020-11-14Constify dktypenames and fstypenames in libc.Philip Guenther
Adjust variable declaration in disklabel to match. ok millert@ deraadt@
2020-11-14remove macro instances from arbitrary string width specifiers. for exampleJason McIntyre
-width ".Dv BOB" -> -width "BOB" although they are not errors, they are misleading and probably should not get pasted around
2020-11-14EVFILT_EXCEPT operates on sockets (emil engler)Jason McIntyre
or pseudo terminals (visa); ok mpi visa
2020-11-07Actually m88k assembler can not handle 'nop' mnemonic, use a macro instead.Kenji Aoyama
ok deraadt@
2020-11-05double word fixes;Jason McIntyre
2020-10-27The printf format string component %n is a nearly turning-complete gadget.Theo de Raadt
Largely considered attack surface nowadays. The benefit provided by %n is completely overshadowed by the risk. New uses of %n don't seem to be entering the C ecosystem, as static tools flag them. And everyone points fingers at those people.... The list of programs (and libraries) which use %n is therefore finite and shrinking. Most of the %n use comes out of the GNU ecosystem. jca@ has convinced gnulib to fix their code (so we need to wait for software including gnulib to make new releases). A few libraries have moved ahead of us and become more strict. Some n longer permit %n (for instance, andriod bionic). Others log the occurance. Some log and abort if the output location is W|X (MacOS). Our base tree is clean. The ports tree contains a handful during build time, and unknown count (more) during runtime. We would like to abort programs on any occurance of %n. Or we could be like MacOS, aborting for W|X pages (but would need a system call which can check that condition, and that introduces addressspace knowledge we don't want attackers to know, and may be a poor tradeoff). For now, we can syslog, to increase awareness, and involve more people in the greater community to remove %n uses. [If %n is at the end, use the *printf return value. If it occurs in the middle, split the printf calls into multiples] Hopefully one day, we can just abort() when %n happens. Help us get there? ok jca, plus naddy for ports team
2020-10-26Retguard asm macros for powerpc libc, ld.sogkoehler
Add retguard to some, but not all, asm functions in libc. Edit SYS.h in libc to remove the PREFIX macros and add SYSENTRY (more like aarch64 and powerpc64), so we can insert RETGUARD_SETUP after SYSENTRY. Some .S files in this commit don't get retguard, but do stop using the old prefix macros. Tested by deraadt@, who put this diff in a macppc snap.
2020-10-25clock_gettime.2: overhaul manpagecheloha
The clock_gettime.2 page is clumsy. It will be easier to use if it is reorganized to emphasize clock_gettime(2), a general and widely used interface, over clock_settime(2), a special-purpose and rarely used interface. While doing that I found a bunch of other things I wanted to tweak or improve: - Simplify the NAME summary. No need to mention "calibration" or "date". - "now", "res", and "clock" are better argument names than "tp" and "clock_id". - The CLOCK_* list is a bunch of fragments. Rewrite the list to make it easier to understand what the clocks represent and how they behave. - Mention clock_settime(2) *after* the list of clocks. Almost nobody needs to use it. It shouldn't lead the page alongside clock_gettime(2). - Drop the adjtime(2) reference. We could mention it in a CAVEATS section but it definitely doesn't belong here in the DESCRIPTION. - Drop the useless init(8) reference. - Add a bunch of EXAMPLES demonstrating how to actually use each clock. - Clean up the ERRORS. - Update the cross references. - Add a HISTORY for the interfaces and each clock. High-level structural ideas from jmc@ and schwarze@. Edited by jmc@. ok jmc@, probably ok schwarze@
2020-10-21Save and restore the MXCSR register and the FPU control word such thatMark Kettenis
floating-point control modes are properly restored by longjmp(3). ok guenther@
2020-10-20Align the basename(3) and dirname(3) prototypes with the POSIX spec:Christian Weisgerber
Both functions take a non-const parameter. Implementations may modify the passed string, even though ours do not. ok stsp@ deraadt@ millert@
2020-10-20Use a trap instruction that unconditionally terminates the process.Visa Hankala
OK deraadt@
2020-10-19Retguard sigsetjmp on powerpc64.mortimer
ok deraadt@
2020-10-19replace ad-hoc illegal instruction with the architecturally defined oneChristian Weisgerber
("permanently undefined") ok deraadt@ kettenis@
2020-10-19add retguard prologue/epilogueTheo de Raadt
ok mortimer
2020-10-19Save and restore the FPCR register such that floating-point control modesMark Kettenis
are properly restored by longjmp(3).
2020-10-18Add powerpc64 retguard macros for setjmp / longjmp.mortimer
ok deraadt@
2020-10-18SYS___threxit cannot fail, but this integration looks like a gadget.Theo de Raadt
Put a hard-trap instruction after the syscall instruction. ok kettenis mortimer
2020-10-16Adapt SYS.h to use retguard macros from asm.h, so that generated systemTheo de Raadt
calls are guarded. Adapt the first few hand-written functions to this model (a few remain) ok kettenis mortimer