Commit Graph

2576 Commits

Author SHA1 Message Date
jdolecek
bb9b067782 put back UFS_WAPBL_JUNLOCK_ASSERT(), the underlying rw_write_held() check
doesn't actually have a race since it checks if the rwlock is held by
current lwp
2018-12-10 20:48:34 +00:00
jdolecek
19787ecf98 make UFS_WAPBL_JLOCK_ASSERT() #ifdef DIAGNOSTIC, same as the underlying
function KASSERT(), so that it actually does something; fix code using
it to actually pass correct params, so that it compiles

remove UFS_WAPBL_JUNLOCK_ASSERT(), as that is inherently racy (it's
okay on those places if the rwlock is held by other lwp); depend
on the RW_ASSERT()/LOCKDEBUG inside rw_enter() to catch the case
with wapbl rwlock held by current lwp
2018-12-10 19:29:41 +00:00
maxv
9cd5bec30f Remove unused mbuf.h includes. 2018-12-10 14:46:24 +00:00
riastradh
d1579b2d70 Rename min/max -> uimin/uimax for better honesty.
These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

	#define min(a, b)	((a) < (b) ? (a) : (b))
	#define max(a, b)	((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX.  Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)
2018-09-03 16:29:22 +00:00
msaitoh
61e1eb0d0b - Cleanup for dynamic sysctl:
- Remove unused *_NAMES macros for sysctl.
  - Remove unused *_MAXID for sysctls.
- Move CTL_MACHDEP sysctl definitions for m68k into m68k/include/cpu.h and
  use them on all m68k machines.
2018-08-22 01:05:21 +00:00
zafer
ccaf6aff2d In lfs_mkdir fix wrong return path in case of EMLINK which causes a panic. Also, check earlier before setting up dirop. 2018-08-11 20:16:21 +00:00
ozaki-r
eb1f432ad6 Avoid using magic numbers for arguments of workqueue_create (NFC) 2018-07-19 05:09:34 +00:00
uwe
39b3d27f91 ffs_superblock_validate - check fs_old_size too.
Now I can mount OpenWindows Version 3 CD from 1991.
2018-07-18 22:40:56 +00:00
kamil
646ced3028 Avoid Undefined Behavior in ffs_clusteracct()
Change the type of 'bit' variable from int to unsigned int and use unsigned
values consistently.

sys/ufs/ffs/ffs_subr.c:336:10, shift exponent -1 is negative

Detected with Kernel Undefined Behavior Sanitizer.

Reported by <Harry Pantazis>
2018-07-04 02:02:15 +00:00
zafer
cf3761a94c Add missing b_cflags and b_oflags.
Ok dholland@
Addresses PR kern/42342 by Yoshihiro Nakajima
2018-06-09 18:48:31 +00:00
maya
a50c06709e Remove duplicate ; 2018-06-06 01:49:07 +00:00
chs
e406c140eb add a genfs method to allow a file system to limit the range of pages
that are given to a single GOP_WRITE() call.  needed by ZFS.
2018-05-28 21:04:37 +00:00
christos
87fd18f8e5 s/static inline/static __inline/g for consistency. 2018-04-19 21:50:06 +00:00
ozaki-r
a208e7b3be Remove unnecessary assertions
KASSERT(!rw_lock_held()) just before rw_destroy() is useless because
rw_destroy does more strict check and provides better information on
failure.
2018-02-07 08:50:13 +00:00
sevan
9663b966f1 Drop commended out include to a hardcoded path in root's home directory. 2018-01-29 15:48:50 +00:00
hannken
67070b1e36 Prevent use-after-free where genfs_node_destroy() would destroy
a lock residing in the just freed inode data.
2018-01-28 10:02:00 +00:00
hannken
4c6335f141 Make sure inode blocks and size are zero when VOP_INACTIVE()
finalises a now unlinked inode.
Counterpart of the check in ffs_newvnode().
2018-01-28 10:01:18 +00:00
chs
dfb50bb7f4 fix the UVM_PAGE_TRKOWN page-locking assertion at the top of ffs_alloc()
to work right for multi-threaded processes.
2017-12-07 21:53:41 +00:00
christos
c0d12e4603 PR/52728: Izumi Tsutsui: "mount -u /dev/ /" triggers kernel panic
Simplify the control flow of the mount code and make sure that the
mountfrom argument can be converted to a block device in the update
case.
XXX: pullup-8
2017-11-15 21:21:18 +00:00
riastradh
81f0ddf5e8 Fix up chfs_mountfs error branches. 2017-11-14 22:06:40 +00:00
christos
913317c461 use PR_WAITOK everywhere. 2017-11-09 22:16:38 +00:00
pgoyette
cb32a134a5 Update the kernhist(9) kernel history code to address issues identified
in PR kern/52639, as well as some general cleaning-up...

(As proposed on tech-kern@ with additional changes and enhancements.)

Details of changes:

* All history arguments are now stored as uintmax_t values[1], both in
  the kernel and in the structures used for exporting the history data
  to userland via sysctl(9).  This avoids problems on some architectures
  where passing a 64-bit (or larger) value to printf(3) can cause it to
  process the value as multiple arguments.  (This can be particularly
  problematic when printf()'s format string is not a literal, since in
  that case the compiler cannot know how large each argument should be.)

* Update the data structures used for exporting kernel history data to
  include a version number as well as the length of history arguments.

* All [2] existing users of kernhist(9) have had their format strings
  updated.  Each format specifier now includes an explicit length
  modifier 'j' to refer to numeric values of the size of uintmax_t.

* All [2] existing users of kernhist(9) have had their format strings
  updated to replace uses of "%p" with "%#jx", and the pointer
  arguments are now cast to (uintptr_t) before being subsequently cast
  to (uintmax_t).  This is needed to avoid compiler warnings about
  casting "pointer to integer of a different size."

* All [2] existing users of kernhist(9) have had instances of "%s" or
  "%c" format strings replaced with numeric formats; several instances
  of mis-match between format string and argument list have been fixed.

* vmstat(1) has been modified to handle the new size of arguments in the
  history data as exported by sysctl(9).

* vmstat(1) now provides a warning message if the history requested with
  the -u option does not exist (previously, this condition was silently
  ignored, with only a single blank line being printed).

* vmstat(1) now checks the version and argument length included in the
  data exported via sysctl(9) and exits if they do not match the values
  with which vmstat was built.

* The kernhist(9) man-page has been updated to note the additional
  requirements imposed on the format strings, along with several other
  minor changes and enhancements.

[1] It would have been possible to use an explicit length (for example,
    uint64_t) for the history arguments.  But that would require another
    "rototill" of all the users in the future when we add support for an
    architecture that supports a larger size.  Also, the printf(3) format
    specifiers for explicitly-sized values, such as "%"PRIu64, are much
    more verbose (and less aesthetically appealing, IMHO) than simply
    using "%ju".

[2] I've tried very hard to find "all [the] existing users of kernhist(9)"
    but it is possible that I've missed some of them.  I would be glad to
    update any stragglers that anyone identifies.
2017-10-28 00:37:11 +00:00
joerg
e64612f440 Revert printf return value change. 2017-10-27 12:25:14 +00:00
utkarsh009
eba4ddef5b [syzkaller] Cast all the printf's to (void *)
> as a result of new printf(9) declaration.
2017-10-27 09:59:17 +00:00
jdolecek
a2ca97c085 fix tyop, PR kern/52653 by Edgar Fuss 2017-10-25 18:06:01 +00:00
maya
7948a10963 print mode as octal for readability 2017-08-20 12:51:38 +00:00
maya
3884179483 update the comment to the current IFMT/permissions location 2017-08-20 12:09:06 +00:00
maya
c3b9b8abce Fix typo in comment 2017-08-20 05:37:03 +00:00
maya
cb6c7420bb XXX question our double-flushing of dirops 2017-08-20 00:03:12 +00:00
maya
650aa898f5 Ask some question about the code in a XXX comment 2017-08-19 14:22:49 +00:00
maya
2731853b39 Not much point doing anything after a panic call 2017-08-19 12:01:08 +00:00
maya
c3a3e06e27 Consistently use {,UN}MARK_VNODE macros rather than function calls. 2017-08-19 11:27:42 +00:00
mlelstv
0bbad10443 Don't time out the discard work queue here. Either destroying a work queue
with pending work items panics or accessing freed resources from the work
item will crash. The timeout needs to be handled gracefully by the driver
that implements the discard operation.

Fixes parts of PR 50725.
2017-08-13 21:00:58 +00:00
dholland
db6ae02331 Tidy up ufs_readdir. First step only; there's plenty more that could be
done to improve this code.
2017-08-07 06:53:48 +00:00
maya
c8856768e5 fix buffer overflow/KASSERT when cookies are supplied
lfs no longer uses the ffs-style struct direct, use the correct minimum
size

from dholland
XXX more wrong
2017-08-04 07:27:42 +00:00
riastradh
d87eb92313 kmem_xyz(sizeof(struct foo)) --> kmem_xyz(sizeof(*foo))
No change to amd64 binary.
2017-07-30 14:23:54 +00:00
maya
8f5758dbf8 change lfs_nextsegsleep and lfs_allclean_wakeup to use condvar
XXX had to use lfs_lock in lfs_segwait, removed kernel_lock, is this
appropriate?
2017-07-26 16:42:37 +00:00
maya
79b200096d Revert r1.272 fix to PR kern/52301, the performance hit is making things
unusable.
2017-07-26 15:07:27 +00:00
maya
d1a0c6fbef Deduplicate sanity check that seglock is held on segunlock 2017-07-26 14:38:59 +00:00
hannken
ef20bebb39 When initializing more inodes make sure to write them to disk
before writing the cylinder group with updated cg_initediblk.
2017-07-12 09:30:16 +00:00
maya
0bf92910be Ifdef out KDASSERT which fires on my machine. 2017-06-19 12:09:37 +00:00
maya
34f7c17843 It isn't safe to drain dirops with seglock held, it'll deadlock if there
are any dirops. drain before grabbing seglock.

lfs_dirops == 0 is always true (as we already drained dirops), so omit
that part of the comparison.

Fixes a lot of LFS deadlocks. PR kern/52301

Many thanks to dholland for help analyzing coredumps
2017-06-15 14:37:30 +00:00
maya
4cf1b10115 Use continue to denote the no-op loop to match netbsd style
newline for extra clarity.
2017-06-12 15:02:32 +00:00
maya
8f063ba0d0 Rename i_flag to i_state.
The similarity to i_flags has previously caused errors.
2017-06-10 05:29:36 +00:00
chs
ec5ea71a90 move some buffer cache internals declarations from buf.h to vfs_bio.c.
this is needed to avoid name conflicts with ZFS and also
makes it clearer that other code shouldn't be messing with these.
remove the LFS debug code that poked around in bufqueues and
remove the BQ_EMPTY bufqueue since nothing uses it anymore.
provide a function to let LFS and wapbl read the value of nbuf for now.
2017-06-08 01:23:01 +00:00
maya
01329061eb Add an XXX about the missing flags so it's not buried in a commit
message.

now the XXX count for LFS is 260
2017-06-05 07:47:32 +00:00
maya
3648207f6f Correct confusion between i_flag and i_flags
These will have to be renamed.

Spotted by Riastradh, thanks!
2017-06-05 01:29:21 +00:00
maya
5ad9db10cd Move definition of IN_ALLMOD near the flag it's a mask for.
Now we can see that it doesn't match all the flags, but changing that will
require more careful thought.
2017-06-05 01:01:42 +00:00
hannken
287643b0da Operations fstrans_start() and fstrans_start_nowait() now always
use FSTRANS_SHARED as lock type so remove the lock type argument.

File system state FSTRANS_SUSPENDING is now unused so remove it.

Regen vnode_if files.

Ride 8.99.1 less than a hour ago.
2017-06-04 08:05:41 +00:00
chs
fd34ea77eb remove checks for failure after memory allocation calls that cannot fail:
kmem_alloc() with KM_SLEEP
  kmem_zalloc() with KM_SLEEP
  percpu_alloc()
  pserialize_create()
  psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
2017-06-01 02:45:05 +00:00