Commit Graph

1085 Commits

Author SHA1 Message Date
Andriy Gapon
16454bee3a linux_getdents, linux_readdir: fix mismatch between malloc and free tags
MFC after:	3 days
2017-06-26 09:13:25 +00:00
Ed Maste
dbaa9ebf1b Add ZFS to Linux statfs ftype
PR:		220086
Reviewed by:	cem
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D11252
2017-06-18 11:51:03 +00:00
Dmitry Chagin
12bbbbb254 Remove the outdated definition.
MFC after:	1 week
2017-06-12 07:48:51 +00:00
Dmitry Chagin
ac1082e590 Since r318735 (ino64 project) the size of the native struct dirent is
equal or greater than the size of Linux struct dirent or struct dirent64.
So, remove LINUX_RECLEN_RATIO magic as useless.
2017-06-12 07:35:59 +00:00
Dmitry Chagin
51d93426d9 On success, getrandom() Linux system call returns the number of bytes that
were copied to the buffer supplied by the user.

PR:           219464
Submitted by: Maciej Pasternacki
Reported by:  Maciej Pasternacki
MFC after:    1 week
2017-06-04 18:35:30 +00:00
Dmitry Chagin
e2e6a2a1b6 Revert r319053 due to lack of sence. As pointed out by kib@ opt_global.h
contains such fundamental settings as e.g. SMP option and fake
opt_global.h almost never match real configured kernels.

Reported by:	kib@
2017-06-04 18:24:41 +00:00
Dmitry Chagin
9ecc1abca3 On success, getrandom() Linux system call returns the number of bytes that
were copied to the buffer supplied by the user.

Also fix getrandom() if Linuxulator modules are built without the kernel.

PR:		219464
Submitted by:	Maciej Pasternacki
Reported by:	Maciej Pasternacki
MFC after:	1 week
2017-05-28 07:40:09 +00:00
Konstantin Belousov
6992112349 Commit the 64-bit inode project.
Extend the ino_t, dev_t, nlink_t types to 64-bit ints.  Modify
struct dirent layout to add d_off, increase the size of d_fileno
to 64-bits, increase the size of d_namlen to 16-bits, and change
the required alignment.  Increase struct statfs f_mntfromname[] and
f_mntonname[] array length MNAMELEN to 1024.

ABI breakage is mitigated by providing compatibility using versioned
symbols, ingenious use of the existing padding in structures, and
by employing other tricks.  Unfortunately, not everything can be
fixed, especially outside the base system.  For instance, third-party
APIs which pass struct stat around are broken in backward and
forward incompatible ways.

Kinfo sysctl MIBs ABI is changed in backward-compatible way, but
there is no general mechanism to handle other sysctl MIBS which
return structures where the layout has changed. It was considered
that the breakage is either in the management interfaces, where we
usually allow ABI slip, or is not important.

Struct xvnode changed layout, no compat shims are provided.

For struct xtty, dev_t tty device member was reduced to uint32_t.
It was decided that keeping ABI compat in this case is more useful
than reporting 64-bit dev_t, for the sake of pstat.

Update note: strictly follow the instructions in UPDATING.  Build
and install the new kernel with COMPAT_FREEBSD11 option enabled,
then reboot, and only then install new world.

Credits: The 64-bit inode project, also known as ino64, started life
many years ago as a project by Gleb Kurtsou (gleb).  Kirk McKusick
(mckusick) then picked up and updated the patch, and acted as a
flag-waver.  Feedback, suggestions, and discussions were carried
by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles),
and Rick Macklem (rmacklem).  Kris Moore (kris) performed an initial
ports investigation followed by an exp-run by Antoine Brodin (antoine).
Essential and all-embracing testing was done by Peter Holm (pho).
The heavy lifting of coordinating all these efforts and bringing the
project to completion were done by Konstantin Belousov (kib).

Sponsored by:	The FreeBSD Foundation (emaste, kib)
Differential revision:	https://reviews.freebsd.org/D10439
2017-05-23 09:29:05 +00:00
Dmitry Chagin
2ca5d34d20 Fix NULL pointer dereference in futex_wake_op() in case when the same
address specified for arguments uaddr and uaddr2.

PR:		218987
Reported by:	luke.tw gmail
MFC after:	1 week
2017-05-01 12:25:37 +00:00
Dmitry Chagin
c4f2941e0b Fix symlinkat() which use the newdfd argument to look up the old path,
while it should use it for the new path instead.

Reported by:	trasz@
MFC after:	1 month
2017-04-30 05:56:57 +00:00
Dmitry Chagin
25ada63736 Map Linux CLOCK_BOOTTIME to native CLOCK_UPTIME.
MFC after:	1 week
2017-04-23 07:57:30 +00:00
Dmitry Chagin
6e1d05bbd7 Add Evdev ioctl handler to the Linuxulator.
PR:		218627
Submitted by:	Jan Kokemüller
Reported by:	Jan Kokemüller
MFC after:	1 week
2017-04-23 07:43:50 +00:00
Conrad Meyer
c6943f3abc linux_ioctl: Refactor some v4l2 struct converters
According to the C standard, it is invalid to copy beyond the end of an
object, even if that object is obviously a member of a larger object (a
struct, in this case).

Appease the standard and Coverity by refactoring the copy in a
straightforward way.  No functional change.

Reported by:	Coverity (CWE-120)
CIDs:		1007819, 1007820, 1007821, 1007822, 1009668, 1009669
Security:	no (false positive detection)
Sponsored by:	Dell EMC Isilon
2017-04-13 17:34:51 +00:00
Tai-hwa Liang
113bb55f71 Adding SIOCGIFNAME support in Linuxulator. This should silence the console warning associated
with linux-opera:
	linux: pid 23492 (opera): ioctl fd=5, cmd=0x8910 ('\M^I',16) is not implemented
	linux: pid 23492 (opera): ioctl fd=28, cmd=0x8910 ('\M^I',16) is not implemented
	...

Reviewed by:	kib, marcel, dchagin
Tested with:	linux-opera-12.16_3
MFC after:	1 month
2017-04-09 15:27:04 +00:00
Dmitry Chagin
c695024348 Prevent ushort values overflow when convert new Linux 64-bit ipc
struct to the old Linux ipc struct.

Reported by:	PVS-Studio
XMFC with:	r314866

MFC after:	3 days
2017-04-07 05:37:08 +00:00
Dmitry Chagin
f0f583842e Use the kern_clock_nanosleep() to implement Linux clock_nanosleep() with
the proper handling of the TIMER_ABSTIME flag.

XMFC after:	r315526

MFC after:	1 month
2017-04-02 18:16:00 +00:00
Dmitry Chagin
0aecedaa83 Remove excess tv_nsec test as this is done by linux_to_native_timespec().
MFC after:	1 week
2017-04-02 07:49:05 +00:00
Dmitry Chagin
2ac9dced18 The value in the tv_nsec field should be in the range 0 to 999999999.
Pointed out by:	bde@

MFC after:	1 week
2017-04-02 07:47:28 +00:00
Dmitry Chagin
71b50d0872 As noted by bde@ negative tv_sec values are not checked for overflow,
so overflow can still occur. Fix that. Also remove the extra check for
tv_sec size as under COMPAT_LINUX32 it is always true.

Pointed out by:	bde@

MFC after:	1 week
2017-04-02 07:46:13 +00:00
Dmitry Chagin
faa9679e24 Use kern_mincore() helper instead of abusing syscall entry.
Suggested by:	kib@
Reviewed by:	kib@
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D10143
2017-03-30 19:45:07 +00:00
Dmitry Chagin
6c2a934b79 Implement Linux mincore() system call.
This is necessary for the upcoming drm-next.

Suggested by:	hselasky@
MFC after:	1 month
2017-03-25 15:47:29 +00:00
Eric van Gyzen
4cf66812ea nanosleep: plug a kernel memory disclosure
nanosleep() updates rmtp on EINVAL.  In that case, kern_nanosleep()
has not updated rmt, so sys_nanosleep() updates the user-space rmtp
by copying garbage from its stack frame.  This is not only a kernel
memory disclosure, it's also not POSIX-compliant.  Fix it to update
rmtp only on EINTR.

Reviewed by:	jilles (via D10020), dchagin
MFC after:	3 days
Security:	possibly
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D10044
2017-03-18 20:16:23 +00:00
Dmitry Chagin
b1ba0846f1 Implement getrandom() syscall.
Note. GRND_RANDOM option is not supported for now.

MFC after:	1 month
2017-03-18 18:34:29 +00:00
Dmitry Chagin
cd92d27e16 As noted by Roel Bouwman Linux allows a large buffer size than the
struct ucred size. Fix this.

PR:		102956
Reported by:	Roel Bouwman <roel at qsp nl>
MFC after:	1 week
2017-03-18 18:31:04 +00:00
Dmitry Chagin
857129394d To reduce code duplication move socket defines to the MI path.
MFC after:	1 week
2017-03-18 18:23:30 +00:00
Dmitry Chagin
54ec725bf3 Remove superflous break statment.
MFC after:	1 week
2017-03-18 18:19:31 +00:00
Dmitry Chagin
bd597911b2 Check for negative nanoseconds.
Linux do that in timespec_valid().

Reported by:	vangyzen@
MFC after:	1 week
2017-03-18 18:14:17 +00:00
Dmitry Chagin
5bb676adf7 Fix usage of the same 'i' variable in the external and nested loops.
Submitted by: Svyatoslav <razmyslov at viva64.com>
Sponsored by: PVS-Studio

MFC after:	1 week
2017-03-14 18:29:23 +00:00
Dmitry Chagin
b8bec5a415 Linux semop system call return EINVAL in case when the invalid nsops
or semid values specified.

MFC after:	1 month
2017-03-07 17:12:22 +00:00
Dmitry Chagin
c10e04f5a0 Linux kernel does not export to the user space ipc_perm.mode values
other than S_IRWXUGO (0777).

MFC after:	1 month
2017-03-07 17:09:12 +00:00
Dmitry Chagin
ab60bc8488 Reduce code duplication between MD Linux code by moving SYSV IPC 64-bit
related struct definitions out into the MI path.

Invert the native ipc structs to the Linux ipc structs convesion logic.
Since 64-bit variant of ipc structs has more precision convert native ipc
structs to the 64-bit Linux ipc structs and then truncate 64-bit values
into the non 64-bit if needed. Unlike Linux, return EOVERFLOW if the
values do not fit.

Fix SYSV IPC for 64-bit Linuxulator which never sets IPC_64 bit.

MFC after:	1 month
2017-03-07 17:07:16 +00:00
Mahdi Mokhtari
8049c6bfb8 Add UNIMPLEMENTED() placeholder macro for
the syscalls that are not implemented in Linux kernel itself.
Cleanup DUMMY() macros.

Reviewed by:	dchagin, trasz
Approved by:	dchagin
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D9804
2017-03-06 18:11:38 +00:00
Dmitry Chagin
8042c504f5 Style(9).
MFC after:	1 month
2017-03-04 08:59:21 +00:00
Dmitry Chagin
e45e3698ae Remove attribute __packed from some IPC struct definition since
Linuxulator is x86 only.
The only notable differences in algnment for an LP64 64-bit system
when compared to a 32-bit system is an eight or large byte types
alignment.

MFC after:	1 month
2017-03-04 08:57:39 +00:00
Dmitry Chagin
c1c8a12139 Hide Linux socketcall constants under corresponding #ifdef since
they are used only in i386 Linuxulator.

MFC after:	1 week
2017-03-04 06:54:05 +00:00
Dmitry Chagin
0633df29be Linux epoll return EEXIST on case when op is EPOLL_CTL_ADD, and the supplied
file descriptor fd is already registered with this epoll instance.

MFC after:	1 month
2017-02-28 19:55:16 +00:00
Dmitry Chagin
8bc4edfd75 Linux epoll return ENOENT error in case when op is EPOLL_CTL_MOD or
EPOLL_CTL_DEL, and fd is not registered with this epoll instance.

MFC after:	1 month
2017-02-28 19:54:22 +00:00
Dmitry Chagin
29b1ecbe01 FreeBSD does not have analgue for epill EPOLLPRI event type.
So, do not set EPOLLPRI event acidently.
Also, do not set EPOLLWRNORM and EPOLLRDNORM events as epoll
do not set this events.

MFC after:	1 month
2017-02-28 19:49:21 +00:00
Dmitry Chagin
281afc595f Return EINVAL when an invalid file descriptor specified.
MFC after:	1 month
2017-02-27 16:55:09 +00:00
Dmitry Chagin
ed211c40f4 Unify eventfd ioctl method and use it for other similar interfaces.
MFC after:	1 month
2017-02-27 16:53:52 +00:00
Dmitry Chagin
2fa6d2fe84 Return EINVAL in case when an invalid size of signal mask specified.
MFC after:	1 month
2017-02-26 20:01:58 +00:00
Dmitry Chagin
80c7315d17 Restore signal mask in epoll_pwait.
MFC after:	1 month
2017-02-26 19:54:17 +00:00
Dmitry Chagin
e0a254f6df Return EINVAL when an invalid file descriptor is specified.
MFC after:	1 month
2017-02-26 19:51:44 +00:00
Dmitry Chagin
dd93b628e9 Implement timerfd family syscalls.
MFC after:	1 month
2017-02-26 09:48:18 +00:00
Dmitry Chagin
01d4a346c2 Nostly style(9) changes, replace unused eventfd_truncate()
by default invfo_truncate() method.

MFC after:	1 month
2017-02-26 09:42:34 +00:00
Dmitry Chagin
0670e972e3 Return EOVERFLOW error in case then the size of tv_sec field of struct timespec
in COMPAT_LINUX32 Linuxulator's not equal to the size of native tv_sec.

MFC after:	1 month
2017-02-26 09:40:42 +00:00
Edward Tomasz Napierala
e801ac7852 Fix linux_fstatfs() to return proper value for f_frsize. Without it,
linux df(1) binary from Xenial shows garbage.

Reviewed by:	dchagin
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D9692
2017-02-25 20:32:37 +00:00
Mahdi Mokhtari
bd911530b7 Add linux_preadv() and linux_pwritev() syscalls to Linuxulator.
Reviewed by:	dchagin
Approved by:	dchagin, trasz (src committers)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D9722
2017-02-24 20:04:02 +00:00
Dmitry Chagin
8665c4d9cd Revert r314217. Commit is not match that I have approved. 2017-02-24 19:47:27 +00:00
Mahdi Mokhtari
21d23e3249 Add linux_preadv() and linux_pwritev() syscalls to Linuxulator.
Reviewed by:	dchagin
Approved by:	dchagin, trasz (src committers)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D9722
2017-02-24 19:22:17 +00:00