]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agofusefs: updated cached attributes during VOP_LINK.
asomers [Wed, 8 May 2019 18:12:38 +0000 (18:12 +0000)]
fusefs: updated cached attributes during VOP_LINK.

FUSE_LINK returns a new set of attributes.  fusefs should cache them just
like it does during other VOPs.  This is not only a matter of performance
but of correctness too; without caching the new attributes the vnode's nlink
value would be out-of-date.

Reported by: pjdfstest
Sponsored by: The FreeBSD Foundation

5 years agofusefs: drop suid after a successful chown by a non-root user
asomers [Tue, 7 May 2019 22:38:13 +0000 (22:38 +0000)]
fusefs: drop suid after a successful chown by a non-root user

Drop sgid too.  Also, drop them after a successful chgrp.

Reported by: pjdfstest
Sponsored by: The FreeBSD Foundation

5 years agofusefs: allow the null chown and null chgrp
asomers [Tue, 7 May 2019 01:27:23 +0000 (01:27 +0000)]
fusefs: allow the null chown and null chgrp

Even an unprivileged user should be able to chown a file to its current
owner, or chgrp it to its current group.  Those are no-ops.

Reported by: pjdfstest
Sponsored by: The FreeBSD Foundation

5 years agofusefs: disable posix_fallocate
asomers [Tue, 7 May 2019 00:03:05 +0000 (00:03 +0000)]
fusefs: disable posix_fallocate

fuse file systems have far too much variability for the standard
posix_fallocate implementation to work.  A future protocol revision (7.19)
adds a FUSE_FALLOCATE operation, but we don't support that yet.  Better to
simply return EINVAL until then.

Reported by: pjdfstest
Sponsored by: The FreeBSD Foundation

5 years agofusefs: allow ftruncate on files without write permission
asomers [Mon, 6 May 2019 20:46:58 +0000 (20:46 +0000)]
fusefs: allow ftruncate on files without write permission

ftruncate should succeed as long as the file descriptor is writable, even if
the file doesn't have write permission.  This is important when combined
with O_CREAT.

Reported by: pjdfstest
Sponsored by: The FreeBSD Foundation

5 years agofusefs: Fix another obscure permission handling bug
asomers [Mon, 6 May 2019 16:54:35 +0000 (16:54 +0000)]
fusefs: Fix another obscure permission handling bug

Don't allow unprivileged users to set SGID on files to whose group they
don't belong.  This is slightly different than what POSIX says we should do
(clear sgid on return from a successful chmod), but it matches what UFS
currently does.

Reported by: pjdfstest
Sponsored by: The FreeBSD Foundation

5 years agofusefs: clear SUID & SGID after a successful write by a non-owner
asomers [Mon, 6 May 2019 16:17:55 +0000 (16:17 +0000)]
fusefs: clear SUID & SGID after a successful write by a non-owner

Reported by: pjdfstest
Sponsored by: The FreeBSD Foundation

5 years agofusefs: don't allow truncating irregular files on an read-only mount
asomers [Mon, 6 May 2019 15:20:18 +0000 (15:20 +0000)]
fusefs: don't allow truncating irregular files on an read-only mount

The readonly mount check had a special case allowing the sizes of files to
be changed if they weren't regular files.  I don't know why.  Neither UFS,
ZFS, nor ext2 have such a special case, and I don't know when you would ever
change the size of a non-regular file anyway.

Sponsored by: The FreeBSD Foundation

5 years agofusefs: only root may set the sticky bit on a non-directory
asomers [Sat, 4 May 2019 16:27:58 +0000 (16:27 +0000)]
fusefs: only root may set the sticky bit on a non-directory

PR: 216391
Reported by: pjdfstest
Sponsored by: The FreeBSD Foundation

5 years agofusefs: use effective gid, not real gid, for FUSE operations
asomers [Sat, 4 May 2019 02:11:28 +0000 (02:11 +0000)]
fusefs: use effective gid, not real gid, for FUSE operations

This is the gid used for stuff like setting the group of a newly created
file.

Reported by: pjdfstest
Sponsored by: The FreeBSD Foundation

5 years agofusefs: fix "returning with lock held" panics in fuse_vnode_alloc
asomers [Wed, 1 May 2019 17:27:04 +0000 (17:27 +0000)]
fusefs: fix "returning with lock held" panics in fuse_vnode_alloc

These panics all lie in the error path.  The only one I've hit is caused by
a buggy FUSE server unexpectedly changing the type of a vnode.

Sponsored by: The FreeBSD Foundation

5 years agofusefs: fix a memory leak from r346979
asomers [Wed, 1 May 2019 17:24:53 +0000 (17:24 +0000)]
fusefs: fix a memory leak from r346979

PR: 216391
Sponsored by: The FreeBSD Foundation

5 years agofusefs: fix some permission checks with -o default_permissions
asomers [Wed, 1 May 2019 00:00:49 +0000 (00:00 +0000)]
fusefs: fix some permission checks with -o default_permissions

When mounted with -o default_permissions fusefs is supposed to validate all
permissions in the kernel, not the file system.  This commit fixes two
permissions that I had previously overlooked.

* Only root may chown a file
* Non-root users may only chgrp a file to a group to which they belong

PR: 216391
Sponsored by: The FreeBSD Foundation

5 years agofusefs: support unix-domain sockets
asomers [Mon, 29 Apr 2019 16:24:51 +0000 (16:24 +0000)]
fusefs: support unix-domain sockets

Also, fix the teardown of the Fifo.read_write test

Sponsored by: The FreeBSD Foundation

5 years agofusefs: remove an obsolete fifo test
asomers [Mon, 29 Apr 2019 16:23:29 +0000 (16:23 +0000)]
fusefs: remove an obsolete fifo test

This should've been part of r346868

Sponsored by: The FreeBSD Foundation

5 years agofusefs: FIFO support
asomers [Mon, 29 Apr 2019 01:40:35 +0000 (01:40 +0000)]
fusefs: FIFO support

Sponsored by: The FreeBSD Foundation

5 years agofusefs: enable the Write.mmap test
asomers [Fri, 26 Apr 2019 19:54:46 +0000 (19:54 +0000)]
fusefs: enable the Write.mmap test

This test had been disabled because it was designed to check protocol
7.9-specific functionality.  Enable it without the 7.9-specific bit.

Sponsored by: The FreeBSD Foundation

5 years agofusefs: fix a deadlock in VOP_PUTPAGES
asomers [Fri, 26 Apr 2019 19:47:43 +0000 (19:47 +0000)]
fusefs: fix a deadlock in VOP_PUTPAGES

As of r346162 fuse now invalidates the cache during writes.  But it can't do
that when writing from VOP_PUTPAGES, because the write is coming _from_ the
cache.  Trying to invalidate the cache in that situation causes a deadlock
in vm_object_page_remove, because the pages in question have already been
busied by the same thread.

PR: 235774
Sponsored by: The FreeBSD Foundation

5 years agofusefs: fix cache invalidation error from r346162
asomers [Fri, 26 Apr 2019 17:09:26 +0000 (17:09 +0000)]
fusefs: fix cache invalidation error from r346162

An off-by-one error led to the last page of a write not being removed from
its object, even though that page's buffer was marked as invalid.

PR: 235774
Sponsored by: The FreeBSD Foundation

5 years agofusefs: handle ENOSYS for FUSE_INTERRUPT
asomers [Wed, 24 Apr 2019 17:30:50 +0000 (17:30 +0000)]
fusefs: handle ENOSYS for FUSE_INTERRUPT

Though it's not documented, Linux will interpret a FUSE_INTERRUPT response
of ENOSYS as "the file system does not support FUSE_INTERRUPT".
Subsequently it will never send FUSE_INTERRUPT again to the same mount
point.  This change matches Linux's behavior.

PR: 346357
Sponsored by: The FreeBSD Foundation

5 years agofusefs: interruptibility improvements suggested by kib
asomers [Wed, 24 Apr 2019 15:54:18 +0000 (15:54 +0000)]
fusefs: interruptibility improvements suggested by kib

* Block stop signals in fticket_wait_answer
* Hold ps_mtx while checking signal disposition
* style(9) changes

PR: 346357
Reported by: kib
Sponsored by: The FreeBSD Foundation

5 years agofusefs: fix the FUSE_INTERRUPT tests when data_cache_mode==2
asomers [Wed, 24 Apr 2019 14:25:35 +0000 (14:25 +0000)]
fusefs: fix the FUSE_INTERRUPT tests when data_cache_mode==2

Replace most write operations with mkdir so they won't be affected by the
setting of vfs.fusefs.data_cache_mode.

Sponsored by: The FreeBSD Foundation

5 years agofusefs: diff reduction between fuse_read_biobackend and ext_read
asomers [Tue, 23 Apr 2019 22:34:32 +0000 (22:34 +0000)]
fusefs: diff reduction between fuse_read_biobackend and ext_read

The main difference is to replace some custom logic with bread.  No
functional change at this point, but this is one step towards adding
readahead.

Sponsored by: The FreeBSD Foundation

5 years agoSlightly simplify vnode_pager_setsize
asomers [Tue, 23 Apr 2019 22:26:55 +0000 (22:26 +0000)]
Slightly simplify vnode_pager_setsize

No functional change intended.

Sponsored by: The FreeBSD Foundation

5 years agofusefs: use vfs_bio_clrbuf in fuse_vnode_setsize
asomers [Tue, 23 Apr 2019 22:25:50 +0000 (22:25 +0000)]
fusefs: use vfs_bio_clrbuf in fuse_vnode_setsize

Reuse fuse_vnode_setsize instead of reinventing the wheel.  This is what
ext2_ind_truncate does.

PR: 233783
Sponsored by: The FreeBSD Foundation

5 years agoFix bug in vtruncbuf introduced by r346162
asomers [Tue, 23 Apr 2019 22:22:46 +0000 (22:22 +0000)]
Fix bug in vtruncbuf introduced by r346162

r346162 factored out v_inval_buf_range from vtruncbuf, but it made an error
in the interface between the two.  The result was a failure to remove
buffers past the first.  Surprisingly, I couldn't reproduce the failure with
file systems other than fuse.

Also, modify fusefs's truncate_discards_cached_data test to catch this bug.

PR: 346162
Sponsored by: The FreeBSD Foundation

5 years agofusefs: commit missing files from r346387
asomers [Sun, 21 Apr 2019 23:04:06 +0000 (23:04 +0000)]
fusefs: commit missing files from r346387

PR: 346357
Sponsored by: The FreeBSD Foundation

5 years agofusefs: rename the SDT probes from "fuse" to "fusefs"
asomers [Sat, 20 Apr 2019 00:04:31 +0000 (00:04 +0000)]
fusefs: rename the SDT probes from "fuse" to "fusefs"

This matches the new name of the kld.

Sponsored by: The FreeBSD Foundation

5 years agofusefs: reap dead code
asomers [Fri, 19 Apr 2019 23:04:07 +0000 (23:04 +0000)]
fusefs: reap dead code

Sponsored by: The FreeBSD Foundation

5 years agofusefs: give priority to FUSE_INTERRUPT operations
asomers [Fri, 19 Apr 2019 21:50:23 +0000 (21:50 +0000)]
fusefs: give priority to FUSE_INTERRUPT operations

When interrupting a FUSE operation, send the FUSE_INTERRUPT op to the daemon
ASAP, ahead of other unrelated operations.

PR: 236530
Sponsored by: The FreeBSD Foundation

5 years agofusefs: fix interrupting FUSE_SETXATTR
asomers [Fri, 19 Apr 2019 20:31:12 +0000 (20:31 +0000)]
fusefs: fix interrupting FUSE_SETXATTR

fusefs's VOP_SETEXTATTR calls uiomove(9) before blocking, so it can't be
restarted.  It must be interrupted instead.

PR: 236530
Sponsored by: The FreeBSD Foundation

5 years agofusefs: don't send FUSE_INTERRUPT for ops that are still in-kernel
asomers [Fri, 19 Apr 2019 15:05:32 +0000 (15:05 +0000)]
fusefs: don't send FUSE_INTERRUPT for ops that are still in-kernel

If a pending FUSE operation hasn't yet been sent to the daemon, then there's
no reason to inform the daemon that it's been interrupted.  Instead, simply
remove it from the fuse message queue and set its status to EINTR or
ERESTART as appropriate.

PR: 346357
Sponsored by: The FreeBSD Foundation

5 years agofusefs: improvements to interruptibility
asomers [Thu, 18 Apr 2019 19:16:34 +0000 (19:16 +0000)]
fusefs: improvements to interruptibility

* If a process receives a fatal signal while blocked on a fuse operation,
  return ASAP without waiting for the operation to complete.  But still send
  the FUSE_INTERRUPT op to the daemon.
* Plug memory leaks from r346339

Interruptibility is now fully functional, but it could be better:
* Operations that haven't been sent to the server yet should be aborted
  without sending FUSE_INTERRUPT.
* It would be great if write operations could be made restartable.
  That would require delaying uiomove until the last possible moment, which
  would be sometime during fuse_device_read.
* It would be nice if we didn't have to guess which EAGAIN responses were
  for FUSE_INTERRUPT operations.

PR: 236530
Sponsored by: The FreeBSD Foundation

5 years agofusefs: WIP making FUSE operations interruptible
asomers [Wed, 17 Apr 2019 23:32:38 +0000 (23:32 +0000)]
fusefs: WIP making FUSE operations interruptible

The fuse protocol includes a FUSE_INTERRUPT operation that the client can
send to the server to indicate that it wants to abort an in-progress
operation.  It's required to interrupt any syscall that is blocking on a
fuse operation.

This commit adds basic FUSE_INTERRUPT support.  If a process receives any
signal while it's blocking on a FUSE operation, it will send a
FUSE_INTERRUPT and wait for the original operation to complete.  But there
is still much to do:

* The current code will leak memory if the server ignores FUSE_INTERRUPT,
  which many do.  It will also leak memory if the server completes the
  original operation before it receives the FUSE_INTERRUPT.
* An interrupted read(2) will incorrectly appear to be successful.
* fusefs should return immediately for fatal signals.
* Operations that haven't been sent to the server yet should be aborted
  without sending FUSE_INTERRUPT.
* Test coverage should be better.
* It would be great if write operations could be made restartable.
  That would require delaying uiomove until the last possible moment, which
  would be sometime during fuse_device_read.

PR: 236530
Sponsored by: The FreeBSD Foundation

5 years agofusefs: implement VOP_ADVLOCK
asomers [Fri, 12 Apr 2019 23:22:27 +0000 (23:22 +0000)]
fusefs: implement VOP_ADVLOCK

PR: 234581
Sponsored by: The FreeBSD Foundation

5 years agofusefs: evict invalidated cache contents during write-through
asomers [Fri, 12 Apr 2019 19:05:06 +0000 (19:05 +0000)]
fusefs: evict invalidated cache contents during write-through

fusefs's default cache mode is "writethrough", although it currently works
more like "write-around"; writes bypass the cache completely.  Since writes
bypass the cache, they were leaving stale previously-read data in the cache.
This commit invalidates that stale data.  It also adds a new global
v_inval_buf_range method, like vtruncbuf but for a range of a file.

PR: 235774
Reported by: cem
Sponsored by: The FreeBSD Foundation

5 years agofusefs: Handle ENOSYS for all remaining opcodes
asomers [Fri, 12 Apr 2019 00:15:36 +0000 (00:15 +0000)]
fusefs: Handle ENOSYS for all remaining opcodes

For many FUSE opcodes, an error of ENOSYS has special meaning.  fusefs
already handled some of those; this commit adds handling for the remainder:

* FUSE_FSYNC, FUSE_FSYNCDIR: ENOSYS means "success, and automatically return
  success without calling the daemon from now on"
* All extattr operations: ENOSYS means "fail EOPNOTSUPP, and automatically
  do it without calling the daemon from now on"

PR: 236557
Sponsored by: The FreeBSD Foundation

5 years agofusefs: add a test for setattr with UTIME_NOW
asomers [Thu, 11 Apr 2019 23:15:37 +0000 (23:15 +0000)]
fusefs: add a test for setattr with UTIME_NOW

The test is disabled ATM; it requires protocol version 7.9.

PR: 237181
Sponsored by: The FreeBSD Foundation

5 years agofusefs: /dev/fuse should be 0666
asomers [Thu, 11 Apr 2019 22:43:19 +0000 (22:43 +0000)]
fusefs: /dev/fuse should be 0666

The fuse protocol is designed with security in mind.  It prevents users from
spying on each others' activities.  And it doesn't grant users any
privileges that they didn't already have.  So it's appropriate to make it
available to everyone.  Plus, it's necessary in order for kyua to run tests
as an unprivileged user.

Sponsored by: The FreeBSD Foundation

5 years agofusefs: test that we reparent a vnode during rename
asomers [Thu, 11 Apr 2019 22:34:28 +0000 (22:34 +0000)]
fusefs: test that we reparent a vnode during rename

fusefs tracks each vnode's parent.  The rename code was already correctly
updating it.  Delete a comment that said otherwise, and add a regression
test for it.

Sponsored by: The FreeBSD Foundation

5 years agofusefs: fix a panic in a stale vnode situation
asomers [Thu, 11 Apr 2019 22:32:34 +0000 (22:32 +0000)]
fusefs: fix a panic in a stale vnode situation

Don't panic if the server changes the file type of a file without us first
deleting it.  That could indicate a buggy server, but it could also be the
result of one of several race conditions.  Return EAGAIN as we do elsewhere.

Sponsored by: The FreeBSD Foundation

5 years agofusefs: don't disappear a vnode on entry cache expiration
asomers [Thu, 11 Apr 2019 21:13:54 +0000 (21:13 +0000)]
fusefs: don't disappear a vnode on entry cache expiration

When the entry cache expires, it's only necessary to purge the cache.
Disappearing a vnode also purges the attribute cache, which is unnecessary,
and invalidates the data cache, which could be harmful.

Sponsored by: The FreeBSD Foundation

5 years agofusefs: Finish supporting -o default_permissions
asomers [Thu, 11 Apr 2019 21:00:40 +0000 (21:00 +0000)]
fusefs: Finish supporting -o default_permissions

I got most of -o default_permissions working in r346088.  This commit adds
sticky bit checks.  One downside is that sometimes there will be an extra
FUSE_GETATTR call for the parent directory during unlink or rename.  But in
actual use I think those attributes will almost always be cached.

PR: 216391
Sponsored by: The FreeBSD Foundation

5 years agofusefs: use vn_vget_ino_gen in fuse_vnop_lookup
asomers [Thu, 11 Apr 2019 17:20:15 +0000 (17:20 +0000)]
fusefs: use vn_vget_ino_gen in fuse_vnop_lookup

vn_vget_ino_gen is a helper function added in r268606 to simplify cases just
like this.

Sponsored by: The FreeBSD Foundation

5 years agofusefs: eliminate a superfluous FUSE_GETATTR from VOP_LOOKUP
asomers [Thu, 11 Apr 2019 05:11:02 +0000 (05:11 +0000)]
fusefs: eliminate a superfluous FUSE_GETATTR from VOP_LOOKUP

fuse_vnop_lookup was using a FUSE_GETATTR operation when looking up "." and
"..", even though the only information it needed was the file type and file
size.  "." and ".." are obviously always going to be directories; there's no
need to double check.

Sponsored by: The FreeBSD Foundation

5 years agofusefs: remove "early permission check hack"
asomers [Wed, 10 Apr 2019 21:46:59 +0000 (21:46 +0000)]
fusefs: remove "early permission check hack"

fuse_vnop_lookup contained an awkward hack meant to reduce daemon activity
during long lookup chains.  However, the hack is no longer necessary now
that we properly cache file attributes.  Also, I'm 99% certain that it
could've bypassed permission checks when using openat to open a file
relative to a directory that lacks execute permission.

Sponsored by: The FreeBSD Foundation

5 years agofusefs: various cleanups
asomers [Wed, 10 Apr 2019 21:10:21 +0000 (21:10 +0000)]
fusefs: various cleanups

* Eliminate fuse_access_param.  Whatever it was supposed to do, it seems
  like it was never complete.  The only real function it ever seems to have
  had was a minor performance optimization, which I've already eliminated.
* Make extended attribute operations obey the allow_other mount option.
* Allow unprivileged access to the SYSTEM extattr namespace when
  -o default_permissions is not in use.
* Disallow setextattr and deleteextattr on read-only mounts.
* Add tests for a few more error cases.

Sponsored by: The FreeBSD Foundation

5 years agofusefs: WIP supporting -o default_permissions
asomers [Wed, 10 Apr 2019 17:31:00 +0000 (17:31 +0000)]
fusefs: WIP supporting -o default_permissions

Normally all permission checking is done in the fuse server.  But when -o
default_permissions is used, it should be done in the kernel instead.  This
commit adds appropriate permission checks through fusefs when -o
default_permissions is used.  However, sticky bit checks aren't working yet.
I'll handle those in a follow-up commit.

There are no checks for file flags, because those aren't supported by our
version of the FUSE protocol.  Nor is there any support for ACLs, though
that could be added if there were any demand.

PR: 216391
Reported by: hiyorin@gmail.com
Sponsored by: The FreeBSD Foundation

5 years agofusefs: skip the Read.keep_cache test when cache is disabled
asomers [Tue, 9 Apr 2019 21:38:20 +0000 (21:38 +0000)]
fusefs: skip the Read.keep_cache test when cache is disabled

This should've been part of r345892

PR: 236560
Sponsored by: The FreeBSD Foundation

5 years agofusefs: cache negative lookups
asomers [Tue, 9 Apr 2019 21:22:02 +0000 (21:22 +0000)]
fusefs: cache negative lookups

The FUSE protocol includes a way for a server to tell the client that a
negative lookup response is cacheable for a certain amount of time.

PR: 236226
Sponsored by: The FreeBSD Foundation

5 years agofusefs: implement entry cache timeouts
asomers [Tue, 9 Apr 2019 17:23:34 +0000 (17:23 +0000)]
fusefs: implement entry cache timeouts

Follow-up to r346046.  These two commits implement fuse cache timeouts for
both entries and attributes.  They also remove the vfs.fusefs.lookup_cache
enable sysctl, which is no longer needed now that cache timeouts are
honored.

PR: 235773
Sponsored by: The FreeBSD Foundation

5 years agofusefs: implement attribute cache timeouts
asomers [Tue, 9 Apr 2019 00:47:38 +0000 (00:47 +0000)]
fusefs: implement attribute cache timeouts

The FUSE protocol allows the server to specify the timeout period for the
client's attribute and entry caches.  This commit implements the timeout
period for the attribute cache.  The entry cache's timeout period is
currently disabled because it panics, and is guarded by the
vfs.fusefs.lookup_cache_expire sysctl.

PR: 235773
Reported by: cem
Sponsored by: The FreeBSD Foundation

5 years agofusefs: cache file attributes
asomers [Mon, 8 Apr 2019 18:45:41 +0000 (18:45 +0000)]
fusefs: cache file attributes

FUSE_LOOKUP, FUSE_GETATTR, FUSE_SETATTR, FUSE_MKDIR, FUSE_LINK,
FUSE_SYMLINK, FUSE_MKNOD, and FUSE_CREATE all return file attributes with a
cache validity period.  fusefs will now cache the attributes, if the server
returns a non-zero cache validity period.

This change does _not_ implement finite attr cache timeouts.  That will
follow as part of PR 235773.

PR: 235775
Reported by: cem
Sponsored by: The FreeBSD Foundation

5 years agofusefs: implement VOP_ACCESS
asomers [Fri, 5 Apr 2019 18:37:48 +0000 (18:37 +0000)]
fusefs: implement VOP_ACCESS

VOP_ACCESS was never fully implemented in fusefs.  This change:
* Removes the FACCESS_DO_ACCESS flag, which pretty much disabled the whole
  vop.
* Removes a quixotic special case for VEXEC on regular files.  I don't know
  why that was in there.
* Removes another confusing special case for VADMIN.
* Removes the FACCESS_NOCHECKSPY flag.  It seemed to be a performance
  optimization, but I'm unconvinced that it was a net positive.
* Updates test cases.

This change does NOT implement -o default_permissions.  That will be handled
separately.

PR: 236291
Sponsored by: The FreeBSD Foundation

5 years agofusefs: enforce -onoallow_other even beneath the mountpoint
asomers [Fri, 5 Apr 2019 17:21:23 +0000 (17:21 +0000)]
fusefs: enforce -onoallow_other even beneath the mountpoint

When -o allow_other is not in use, fusefs is supposed to prevent access to
the filesystem by any user other than the one who owns the daemon.  Our
fusefs implementation was only enforcing that restriction at the mountpoint
itself.  That was usually good enough because lookup usually descends from
the mountpoint.  However, there are cases when it doesn't, such as when
using openat relative to a file beneath the mountpoint.

PR: 237052
Sponsored by: The FreeBSD Foundation

5 years agofusefs: correctly return EROFS from VOP_ACCESS
asomers [Fri, 5 Apr 2019 15:33:43 +0000 (15:33 +0000)]
fusefs: correctly return EROFS from VOP_ACCESS

Sponsored by: The FreeBSD Foundation

5 years agofusefs: reenable some fsyncdir tests
asomers [Fri, 5 Apr 2019 15:04:25 +0000 (15:04 +0000)]
fusefs: reenable some fsyncdir tests

These tests were actually fixed by r345398, r345390 and r345392, but I
neglected to reenable them.  Too bad googletest doesn't have the notion of
an Expected Failure like ATF does.

PR: 236474, 236473
Sponsored by: The FreeBSD Foundation

5 years agoFix the branch build
ngie [Fri, 5 Apr 2019 03:35:40 +0000 (03:35 +0000)]
Fix the branch build

Copy gtest_skip_in_environment_setup_test.cc (added in r345770) from ^/head .

5 years agoAdd mpr, mps, mpt to NOTES file
imp [Fri, 5 Apr 2019 02:54:02 +0000 (02:54 +0000)]
Add mpr, mps, mpt to NOTES file

Add these to all the architectures that these are in the GENERIC
kernel.

5 years agoFix build.
delphij [Fri, 5 Apr 2019 02:37:10 +0000 (02:37 +0000)]
Fix build.

MFC after: 2 weeks
X-MFC-With: r345900

5 years agoImplement checking of `.' and `..' entries of subdirectory.
delphij [Fri, 5 Apr 2019 02:21:16 +0000 (02:21 +0000)]
Implement checking of `.' and `..' entries of subdirectory.

Reviewed by: pfg
Obtained from: Android https://android.googlesource.com/platform/external/fsck_msdos/+/b6ee08aadb580341a4d80943741b80de16a88b5d%5E%21/
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19824

5 years agoAdd an entry to UPDATING for r345895, which affects the use of nfsuserd daemons
rmacklem [Thu, 4 Apr 2019 23:40:30 +0000 (23:40 +0000)]
Add an entry to UPDATING for r345895, which affects the use of nfsuserd daemons
built from head sources between July 6, 2017 and Aug. 22, 2018.

5 years agoRestore lfcl when LOSTDIR's chain was corrupted and overwritten
delphij [Thu, 4 Apr 2019 23:34:03 +0000 (23:34 +0000)]
Restore lfcl when LOSTDIR's chain was corrupted and overwritten
with invalid value.

Obtained from: Android https://android.googlesource.com/platform/external/fsck_msdos/+/4d6d6f8a3674ad67f970e2ae908d34f64e4854cf%5E%21/
MFC after: 2 weeks

5 years agosort(1): randomcoll: Skip the memory allocation entirely
cem [Thu, 4 Apr 2019 23:32:27 +0000 (23:32 +0000)]
sort(1): randomcoll: Skip the memory allocation entirely

There's no reason to order based on strcmp of ASCII digests instead of
memcmp of the raw digests.

While here, remove collision fallback.  If you collide two MD5s, they're
probably the same string anyway.  If robustness against MD5 collisions is
desired, maybe we shouldn't use MD5.

None of the behavior of sort -R is specified by POSIX, so we're free to
implement this however we like.  E.g., using a 128-bit counter and block cipher
to generate unique indices for each line of input.

PR: 230792 (2/many)
Relnotes: This will change the sort order for a given dataset with a
given seed.  Other similarly breaking changes are planned.
Sponsored by: Dell EMC Isilon

5 years agoRevert r320698, since the related userland changes were reverted by r338192.
rmacklem [Thu, 4 Apr 2019 23:30:27 +0000 (23:30 +0000)]
Revert r320698, since the related userland changes were reverted by r338192.

r338192 reverted the changes to nfsuserd so that it could use an AF_LOCAL
socket, since it resulted in a vnode locking panic().
Post r338192 nfsuserd daemons use the old AF_INET socket for upcalls and
do not use these kernel changes.
I left them in for a while, so that nfsuserd daemons built from head sources
between r320757 (Jul. 6, 2017) and r338192 (Aug. 22, 2018) would need them
by default.
This only affects head, since the changes were never MFC'd.
I will add an UPDATING entry, since an nfsuserd daemon built from head
sources between r320757 and r338192 will not run unless the "-use-udpsock"
option is specified. (This command line option is only in the affected
revisions of the nfsuserd daemon.)

I suspect few will be affected by this, since most who run systems built
from head sources (not stable or releases) will have rebuilt their nfsuserd
daemon from sources post r338192 (Aug. 22, 2018)

This is being reverted in preparation for an update to include AF_INET6
support to the code.

5 years agoRestore the ability of checking and fixing next free
delphij [Thu, 4 Apr 2019 23:16:36 +0000 (23:16 +0000)]
Restore the ability of checking and fixing next free
cluster in FSINFO that was lost in r203872.

Obtained from: NetBSD
MFC after: 2 weeks

5 years agoAdd requiered programs (cc and c++) for some lib/atf regression tests
olivier [Thu, 4 Apr 2019 20:34:17 +0000 (20:34 +0000)]
Add requiered programs (cc and c++) for some lib/atf regression tests

PR: 236889
Reviewed by: ngie
Approved by: emaste (on IRC)
MFC after: 1 month
Sponsored by: Netflix

5 years agofusefs: properly handle FOPEN_KEEP_CACHE
asomers [Thu, 4 Apr 2019 20:30:14 +0000 (20:30 +0000)]
fusefs: properly handle FOPEN_KEEP_CACHE

If a fuse file system returne FOPEN_KEEP_CACHE in the open or create
response, then the client is supposed to _not_ clear its caches for that
file.  I don't know why clearing the caches would be the default given that
there's a separate flag to bypass the cache altogether, but that's the way
it is.  fusefs(5) will now honor this flag.

Our behavior is slightly different than Linux's because we reuse file
handles.  That means that open(2) wont't clear the cache if there's a
reusable file handle, even if the file server wouldn't have sent
FOPEN_KEEP_CACHE had we opened a new file handle like Linux does.

PR: 236560
Sponsored by: The FreeBSD Foundation

5 years agosort(1): randomcoll: Don't sort on ENOMEM
cem [Thu, 4 Apr 2019 20:27:13 +0000 (20:27 +0000)]
sort(1): randomcoll: Don't sort on ENOMEM

PR: 230792 (1/many)
Sponsored by: Dell EMC Isilon

5 years agofusefs: fix some uninitialized memory references
asomers [Thu, 4 Apr 2019 20:24:58 +0000 (20:24 +0000)]
fusefs: fix some uninitialized memory references

This bug was long present, but was exacerbated by r345876.

The problem is that fiov_refresh was bzero()ing a buffer _before_ it
reallocated that buffer.  That's obviously the wrong order.  I fixed the
order in r345876, which exposed the main problem.  Previously, the first 160
bytes of the buffer were getting bzero()ed when it was first allocated in
fiov_init.  Subsequently, as that buffer got recycled between callers, the
portion used by the _previous_ caller was getting bzero()ed by the current
caller in fiov_refresh.  The problem was never visible simply because no
caller was trying to use more than 160 bytes.

Now the buffer gets properly bzero()ed both at initialization time and any
time it gets enlarged or reallocated.

Sponsored by: The FreeBSD Foundation

5 years agoif_muge: use NULL not 0 for DRIVER_MODULE pointer args
emaste [Thu, 4 Apr 2019 19:59:31 +0000 (19:59 +0000)]
if_muge: use NULL not 0 for DRIVER_MODULE pointer args

Sponsored by: The FreeBSD Foundation

5 years agoUse IN_foo() macros from sys/netinet/in.h inplace of handcrafted code
rgrimes [Thu, 4 Apr 2019 19:01:13 +0000 (19:01 +0000)]
Use IN_foo() macros from sys/netinet/in.h inplace of handcrafted code

There are a few places that use hand crafted versions of the macros
from sys/netinet/in.h making it difficult to actually alter the
values in use by these macros.  Correct that by replacing handcrafted
code with proper macro usage.

Reviewed by: karels, kristof
Approved by: bde (mentor)
MFC after: 3 weeks
Sponsored by: John Gilmore
Differential Revision: https://reviews.freebsd.org/D19317

5 years agoRewrite intro(4) man page.
ygy [Thu, 4 Apr 2019 18:52:03 +0000 (18:52 +0000)]
Rewrite intro(4) man page.

- Remove issues that no longer apply thanks to devfs
- Add language pointing out devfs's role and referencing its config
- Add a "historical notes" section and move discussion of block vs character devs to it, including pointing out the removal of block devs
- Modernize some examples

MFC after: 1 week
PR: 236970
Submitted by: andrew@tao173.riddles.org.uk
Reviewed by: 0mp
Differential Revision: https://reviews.freebsd.org/D19799

5 years agoMFHead@r345880
asomers [Thu, 4 Apr 2019 18:26:32 +0000 (18:26 +0000)]
MFHead@r345880

5 years agofusefs: correctly handle short writes
asomers [Thu, 4 Apr 2019 16:51:34 +0000 (16:51 +0000)]
fusefs: correctly handle short writes

If a FUSE daemon returns FOPEN_DIRECT_IO when a file is opened, then it's
allowed to write less data than was requested during a FUSE_WRITE operation
on that file handle.  fusefs should simply return a short write to userland.

The old code attempted to resend the unsent data.  Not only was that
incorrect behavior, but it did it in an ineffective way, by attempting to
"rewind" the uio and uiomove the unsent data again.

This commit correctly handles short writes by returning directly to
userland if FOPEN_DIRECT_IO was set.  If it wasn't set (making the short
write technically a protocol violation), then we resend the unsent data.
But instead of rewinding the uio, just resend the data that's already in the
kernel.

That necessitated a few changes to fuse_ipc.c to reduce the amount of bzero
activity.  fusefs may be marginally faster as a result.

PR: 236381
Sponsored by: The FreeBSD Foundation

5 years agostrings: capsicumize it
oshogbo [Thu, 4 Apr 2019 16:32:27 +0000 (16:32 +0000)]
strings: capsicumize it

Reviewed by: cem
Discussed with: emaste
Differential Revision: https://reviews.freebsd.org/D18038

5 years agoAdd cap_fileargs.h to -legacy if needed.
oshogbo [Thu, 4 Apr 2019 04:14:20 +0000 (04:14 +0000)]
Add cap_fileargs.h to -legacy if needed.

Reviewed by: arichardson
Differential Revision: https://reviews.freebsd.org/D19685

5 years agoFix malloc stats for the RPCSEC_GSS server code when DEBUG is enabled.
rmacklem [Thu, 4 Apr 2019 01:23:06 +0000 (01:23 +0000)]
Fix malloc stats for the RPCSEC_GSS server code when DEBUG is enabled.

The code enabled when "DEBUG" is defined uses mem_alloc(), which is a
malloc(.., M_RPC, M_WAITOK | M_ZERO), but then calls gss_release_buffer()
which does a free(.., M_GSSAPI) to free the memory.
This patch fixes the problem by replacing mem_alloc() with a
malloc(.., M_GSSAPI, M_WAITOK | M_ZERO).
This bug affects almost no one, since the sources are not normally built
with "DEBUG" defined.

Submitted by: peter@ifm.liu.se
MFC after: 2 weeks

5 years agoReplace read_random(9) with more appropriate arc4rand(9) KPIs
cem [Thu, 4 Apr 2019 01:02:50 +0000 (01:02 +0000)]
Replace read_random(9) with more appropriate arc4rand(9) KPIs

Reviewed by: ae, delphij
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19760

5 years agoImplement tests for online expansion:
pjd [Thu, 4 Apr 2019 00:05:36 +0000 (00:05 +0000)]
Implement tests for online expansion:
- init, init -R
- onetime, onetime -R
- 512 and 4k sectors
- encryption only
- encryption and authentication
- configure -r/-R for detached providers
- configure -r/-R for attached providers
- all keys allocated (10, 20 and 30MB provider sizes)
- keys allocated on demand (10, 20 and 30PB provider sizes)
- reading and writing to provider after expansion (10-30MB only)
- checking if metadata in old location is cleared.

Obtained from: Fudo Security

5 years agoUpdate configure tests after addition of the online expansion.
pjd [Wed, 3 Apr 2019 23:58:58 +0000 (23:58 +0000)]
Update configure tests after addition of the online expansion.

Obtained from: Fudo Security

5 years agoImplement automatic online expansion of GELI providers - if the underlying
pjd [Wed, 3 Apr 2019 23:57:37 +0000 (23:57 +0000)]
Implement automatic online expansion of GELI providers - if the underlying
provider grows, GELI will expand automatically and will move the metadata
to the new location of the last sector.

This functionality is turned on by default. It can be turned off with the
-R flag, but it is not recommended - if the underlying provider grows and
automatic expansion is turned off, it won't be possible to attach this
provider again, as the metadata is no longer located in the last sector.

If the automatic expansion is turned off and the underlying provider grows,
GELI will only log a message with the previous size of the provider, so
recovery can be easier.

Obtained from: Fudo Security

5 years ago- Add missing -T (notrim) option to the label subcommand.
pjd [Wed, 3 Apr 2019 23:50:52 +0000 (23:50 +0000)]
- Add missing -T (notrim) option to the label subcommand.
- Add missing -T option in the onetime subcommand comment.

Obtained from: Fudo Security

5 years agoImport libxo-1.0.2
phil [Wed, 3 Apr 2019 21:55:39 +0000 (21:55 +0000)]
Import libxo-1.0.2

from 1.0.0:
    Add "continuation" flag, to allow multiple "xo" invocations in a single line of output (#58)
    Add --top-wrap to make top-level JSON wrappers
    Add --{open,close}-{list,instace} options
    Add xo_xml_leader(), to detect use of some bogus XML tags. It's still bad form, but it's a little safer now
    Avoid call to xo_write before xo_flush, since the latter calls the former
    Check return code from xo_flush_h properly (<0) (FreeBSD Bug 236935)
    For JSON output, avoid newline before a container's close brace (#62)
    Merge branch 'text_only' of https://github.com/zvr/libxo into zvr-text_only
    Use XO_USE_INT_RETURN_CODES, not USE_INT_RETURN_CODES
    add docs for --continuation
    add docs for --not-first
    call xo_state_set_flags before values and close containers; add XOIF_MADE_OUTPUT flag to track state; make proper empty JSON objects in xo_finish
    color_map code has to be #ifdef'd out, since the struct definition
    correct xo_flush_func_t (doesn't use xo_ssize_t)
    make depth change for --top-wrap only for JSON
    fix to handle --top-wrap in "xo" by being more consistent with handling trailing newlines
    fix to handle text-only version #64 (from zvr)
    fix xo_buf_has_room for round up to the next XO_BUFSIZ, not just add XO_BUFSIZ to the size (FreeBSD Bug 236937)
    update docs for new "xo" options
    update functions to use xo_ssize_t
    update test cases
from 1.0.1:
    Add EINTEGRITY to .pot files under test/gettext/ (fix from FreeBSD)
from 1.0.2:
    handle failure from xo_vnsprintf; don't add -1 to "rc"

PR: 236937, 236935
Submitted by: phil
Reported by: Alfonso S. Siciliano <alfix86@gmail.com>
MFC after: 2 weeks

5 years agoAdd support for cross-building cloudware images.
cperciva [Wed, 3 Apr 2019 21:54:47 +0000 (21:54 +0000)]
Add support for cross-building cloudware images.

If MACHINE_ARCH doesn't match TARGET_ARCH, and we're not in the special
case of building i386 images on an amd64 host, we need to pull in the
qemu-user-static package; this allows us to run some commands inside
the VM disk image chroot, most notably to install packages.

Reviewed by: gjb
MFC after: 2 weeks
Sponsored by: FreeBSD/EC2 patreon (https://www.patreon.com/cperciva)

5 years agoTag libxo 1.0.2
phil [Wed, 3 Apr 2019 21:48:09 +0000 (21:48 +0000)]
Tag libxo 1.0.2

5 years agoImport libxo 1.0.2
phil [Wed, 3 Apr 2019 21:47:19 +0000 (21:47 +0000)]
Import libxo 1.0.2

5 years agocpsw: use `phy-handle` in FDT to find PHY address
emaste [Wed, 3 Apr 2019 21:01:53 +0000 (21:01 +0000)]
cpsw: use `phy-handle` in FDT to find PHY address

In r337703 DTS files were updated to Linux 4.18, including Linux commit
4d8b032d3c03f4e9788a18bbb51b10e6c9e8a56b which removed the `phy_id`
property from am335x-bone-common (as the property was deprecated).

Use `phy-handle` via fdt_get_phyaddr, keeping the existing code as a
fallback for old DTBs.

PR: 236624
Submitted by: manu, Gerald Aryeetey <aryeeteygerald_rogers.com>
Reported by: Gerald Aryeetey
Reviewed by: manu
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19814

5 years agofusefs: fix a panic in VOP_READDIR
asomers [Wed, 3 Apr 2019 20:57:43 +0000 (20:57 +0000)]
fusefs: fix a panic in VOP_READDIR

The original fusefs import, r238402, contained a bug in fuse_vnop_close that
could close a directory's file handle while there were still other open file
descriptors.  The code looks deliberate, but there is no explanation for it.
This necessitated a workaround in fuse_vnop_readdir that would open a new
file handle if, "for some mysterious reason", that vnode didn't have any
open file handles.  r345781 had the effect of causing the workaround to
panic, making the problem more visible.

This commit removes the workaround and the original bug, which also fixes
the panic.

Sponsored by: The FreeBSD Foundation

5 years agorctl: fix sysctl kern.racct.enable use after r341182
mjg [Wed, 3 Apr 2019 20:37:14 +0000 (20:37 +0000)]
rctl: fix sysctl kern.racct.enable use after r341182

The value was changed from int to bool. Since the new type
is smaller, the rest of the variable in the caller was left
unitialized.

PR: 236714
Reported by: trasz
Diagnosed by: markj
Sponsored by: The FreeBSD Foundation

5 years agofusefs: send FUSE_FLUSH during VOP_CLOSE
asomers [Wed, 3 Apr 2019 19:59:45 +0000 (19:59 +0000)]
fusefs: send FUSE_FLUSH during VOP_CLOSE

The FUSE protocol says that FUSE_FLUSH should be send every time a file
descriptor is closed.  That's not quite possible in FreeBSD because multiple
file descriptors can share a single struct file, and closef doesn't call
fo_close until the last close.  However, we can still send FUSE_FLUSH on
every VOP_CLOSE, which is probably good enough.

There are two purposes for FUSE_FLUSH.  One is to allow file systems to
return EIO if they have an error when writing data that's cached
server-side.  The other is to release POSIX file locks (which fusefs(5) does
not yet support).

PR: 236405, 236327
Sponsored by: The FreeBSD Foundation

5 years agoUndo my previous erroneous commit changing the tcp_output kassert.
rrs [Wed, 3 Apr 2019 19:35:07 +0000 (19:35 +0000)]
Undo my previous erroneous commit changing the tcp_output kassert.
Hmm now the question is where did the tcp_log_id change go :o

5 years agoFix typos in r345849.
mav [Wed, 3 Apr 2019 18:35:13 +0000 (18:35 +0000)]
Fix typos in r345849.

MFC after: 1 week

5 years agoList few more ATA commands.
mav [Wed, 3 Apr 2019 18:27:54 +0000 (18:27 +0000)]
List few more ATA commands.

MFC after: 1 week

5 years agolibbe(3): Add a serial to the generated snapshot names
kevans [Wed, 3 Apr 2019 17:04:38 +0000 (17:04 +0000)]
libbe(3): Add a serial to the generated snapshot names

To use bectl in an example, when one creates a new boot environment with
either `bectl create <be>` or `bectl create -e <otherbe> <be>`, libbe will
take a snapshot of the original boot environment to clone. Previously, this
used %F-%T date format as the snapshot name, but this has some limitations-
attempting to create multiple boot environments in quick succession may
collide if done within the same second.

Tack a serial onto it to reduce the chances of a collision... we could still
collide if multiple processes/threads are creating boot environments at the
same time, but this is likely not a big concern as this has only been
reported as occurring in freebsd-ci setup.

MFC after: 3 days

5 years agomsdosfs: zero tail of the last block on truncation for VREG vnodes as well.
kib [Wed, 3 Apr 2019 17:02:18 +0000 (17:02 +0000)]
msdosfs: zero tail of the last block on truncation for VREG vnodes as well.

Despite the call to vtruncbuf() from detrunc(), which results in
zeroing part of the partial page after EOF, there still is a
possibility to retain the stale data which is revived on file
enlargement.  If the filesystem block size is greater than the page
size, partial block might keep other after-EOF pages wired and they
get reused then.  Fix it by zeroing whole part of the partial buffer
after EOF, not relying on vnode_pager_setsize().

PR: 236977
Reported by: asomers
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agobectl.8: Bump date after r345845
0mp [Wed, 3 Apr 2019 13:59:35 +0000 (13:59 +0000)]
bectl.8: Bump date after r345845

Approved by: kevans

5 years agobectl.8: Clean up & clarify the create subcommand
0mp [Wed, 3 Apr 2019 13:46:43 +0000 (13:46 +0000)]
bectl.8: Clean up & clarify the create subcommand

- Improve formatting
- Use consistent variable names
- Improve the description of the create subcommand (1)

PR: 235850 (1)
Submitted by: kevans (1)
Reported by: ler (1)
Reviewed by: kevans
Approved by: src (kevans)
Differential Revision: https://reviews.freebsd.org/D19666

5 years agoFollow the declared behaviour that specifies server string format in
ae [Wed, 3 Apr 2019 12:47:49 +0000 (12:47 +0000)]
Follow the declared behaviour that specifies server string format in
bsnmpclient(3).

snmp_parse_server() function accepts string where some fields can be
omitted: [trans::][community@][server][:port]

"trans" field can be "udp", "udp6", "dgram" and "stream".
"community" can be empty string, if it is omitted, the default value
will be used. For read_community it is "public", for write_comminity
it is "private". "server" field can be hostname, IPv4 address or IPv6
address. IPv6 address should be specified in brackets "[]".
If port is omitted, the default value "snmp" will be used for "udp"
and "udp6" transports. So, now for bsnmpget(1) and bsnmwalk(1) it is
not required to specify all fields in argument of '-s' option. E.g.

  # bsnmpget -s 127.1 sysName.0
  # bsnmpget -s "udp::127.1" sysName.0
  # bsnmpget -s "udp::public@127.1" sysName.0
  # bsnmpget -s "udp::public@127.1:161" sysName.0
  # bsnmpget -s "udp::[::1]" sysName.0
  # bsnmpget -s "udp6::[::1]" sysName.0
  # bsnmpget -s "[fe80::1%lo0]" sysName.0

PR: 236664
Reported by: olivier
MFC after: 1 month

5 years agoAdd a cv_wait to the TPM2.0 harvesting function
mw [Wed, 3 Apr 2019 08:22:58 +0000 (08:22 +0000)]
Add a cv_wait to the TPM2.0 harvesting function

Harvesting has to compete for the TPM chip with userspace.
Before this change the callout could hijack an unread buffer
causing a userspace call to the TPM to fail.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: delphij
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D19712