git: 625835c8b5e8 - main - tcp: fix the initial CWND when a SYN retransmission happened

2024-11-05 Thread Michael Tuexen
The branch main has been updated by tuexen:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=625835c8b5e897e54a1a023788a3a9c3b16631c9

commit 625835c8b5e897e54a1a023788a3a9c3b16631c9
Author: Michael Tuexen 
AuthorDate: 2024-11-05 08:52:42 +
Commit: Michael Tuexen 
CommitDate: 2024-11-05 08:52:42 +

tcp: fix the initial CWND when a SYN retransmission happened

According to RFC 3390 the CWND should be set to one MSS if the
SYN or SYN-ACK has been retransmitted. This is handled in the
code by setting CWND to 1 and cc_conn_init() translates this
to MSS. Unfortunately, cc_cong_signal() was overwriting the
special value of 1 in case of a lost SYN, and therefore the
initial CWND was not as it was supposed to be.
Fix this by not overwriting the special value of 1.

Reviewed by:cc, rscheff
MFC after:  3 days
Sponsored by:   Netflix, Inc.
Differential Revision:  https://reviews.freebsd.org/D47439
---
 sys/netinet/tcp_timer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c
index c5c65dda5b1a..4d8dafaec31d 100644
--- a/sys/netinet/tcp_timer.c
+++ b/sys/netinet/tcp_timer.c
@@ -810,7 +810,9 @@ tcp_timer_rexmt(struct tcpcb *tp)
 */
tp->t_rtttime = 0;
 
-   cc_cong_signal(tp, NULL, CC_RTO);
+   /* Do not overwrite the snd_cwnd on SYN retransmissions. */
+   if (tp->t_state != TCPS_SYN_SENT)
+   cc_cong_signal(tp, NULL, CC_RTO);
NET_EPOCH_ENTER(et);
rv = tcp_output_locked(tp);
NET_EPOCH_EXIT(et);



git: 88dd0550920c - main - syslogd: Fix handling of unix socket modes

2024-11-05 Thread Mark Johnston
The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=88dd0550920c3dd378b2b761bda52339b5d860ec

commit 88dd0550920c3dd378b2b761bda52339b5d860ec
Author: Mark Johnston 
AuthorDate: 2024-11-05 17:48:37 +
Commit: Mark Johnston 
CommitDate: 2024-11-05 18:24:03 +

syslogd: Fix handling of unix socket modes

When bind() is called, the process umask is applied, so one has to
either clear the umask before binding or call chmod() to add permissions
after the fact.  Do the former here to ensure that the socket always has
the correct mode.

Reported by:Lexi Winter 
Fixes:  2b8c3a05e0a6 ("syslogd: Set unix socket modes atomically")
---
 usr.sbin/syslogd/syslogd.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 98ddb5d9158f..8fcf3f06cf95 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -3721,12 +3721,24 @@ socksetup(struct addrinfo *ai, const char *name, mode_t 
mode)
if (ai->ai_family == AF_LOCAL)
unlink(name);
if (ai->ai_family == AF_LOCAL || NoBind == 0 || name != NULL) {
+   mode_t mask;
+   int error;
+
if (ai->ai_family == AF_LOCAL && fchmod(s, mode) < 0) {
dprintf("fchmod %s: %s\n", name, strerror(errno));
close(s);
return (NULL);
}
-   if (bind(s, ai->ai_addr, ai->ai_addrlen) < 0) {
+
+   /*
+* For AF_LOCAL sockets, the process umask is applied to the
+* mode set above, so temporarily clear it to ensure that the
+* socket always has the correct permissions.
+*/
+   mask = umask(0);
+   error = bind(s, ai->ai_addr, ai->ai_addrlen);
+   (void)umask(mask);
+   if (error < 0) {
logerror("bind");
close(s);
return (NULL);



git: d14c38ceb8aa - main - sys: Avoid relying on pollution from refcount.h

2024-11-05 Thread Mark Johnston
The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d14c38ceb8aa10bd94913d0456ec0f726693379b

commit d14c38ceb8aa10bd94913d0456ec0f726693379b
Author: Mark Johnston 
AuthorDate: 2024-11-05 14:31:50 +
Commit: Mark Johnston 
CommitDate: 2024-11-05 18:22:20 +

sys: Avoid relying on pollution from refcount.h

Fix up headers which previously assumed that refcount.h includes
systm.h, and make them more self-contained.  Then, replace the systm.h
include in refcount with kassert.h.

Reviewed by:imp, kib
MFC after:  1 week
Differential Revision:  https://reviews.freebsd.org/D47450
---
 sys/powerpc/include/counter.h  |  2 ++
 sys/sys/_lock.h|  4 ++--
 sys/sys/_mutex.h   |  6 --
 sys/sys/_rmlock.h  | 10 --
 sys/sys/_rwlock.h  |  6 --
 sys/sys/_sx.h  |  5 -
 sys/sys/file.h |  7 +--
 sys/sys/ktls.h |  3 +++
 sys/sys/refcount.h |  7 ---
 sys/sys/sglist.h   |  1 +
 tools/build/test-includes/badfiles.inc |  1 -
 11 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/sys/powerpc/include/counter.h b/sys/powerpc/include/counter.h
index 68e292cde7f6..90e6400ad562 100644
--- a/sys/powerpc/include/counter.h
+++ b/sys/powerpc/include/counter.h
@@ -100,6 +100,8 @@ counter_u64_add(counter_u64_t c, int64_t inc)
 
 #else  /* !64bit */
 
+#include 
+
 #definecounter_enter() critical_enter()
 #definecounter_exit()  critical_exit()
 
diff --git a/sys/sys/_lock.h b/sys/sys/_lock.h
index ef167b9ab5ec..7057463fbde2 100644
--- a/sys/sys/_lock.h
+++ b/sys/sys/_lock.h
@@ -33,8 +33,8 @@
 
 struct lock_object {
const   char *lo_name;  /* Individual lock name. */
-   u_int   lo_flags;
-   u_int   lo_data;/* General class specific data. */
+   unsigned int lo_flags;
+   unsigned int lo_data;   /* General class specific data. */
struct  witness *lo_witness;/* Data for witness. */
 };
 
diff --git a/sys/sys/_mutex.h b/sys/sys/_mutex.h
index 0fcd5a2c2809..7241f9f1d31c 100644
--- a/sys/sys/_mutex.h
+++ b/sys/sys/_mutex.h
@@ -31,6 +31,8 @@
 #ifndef _SYS__MUTEX_H_
 #define_SYS__MUTEX_H_
 
+#include 
+#include 
 #include 
 
 /*
@@ -44,7 +46,7 @@
  */
 struct mtx {
struct lock_object  lock_object;/* Common lock properties. */
-   volatile uintptr_t  mtx_lock;   /* Owner and flags. */
+   volatile __uintptr_tmtx_lock;   /* Owner and flags. */
 };
 
 /*
@@ -58,7 +60,7 @@ struct mtx {
  */
 struct mtx_padalign {
struct lock_object  lock_object;/* Common lock properties. */
-   volatile uintptr_t  mtx_lock;   /* Owner and flags. */
+   volatile __uintptr_tmtx_lock;   /* Owner and flags. */
 } __aligned(CACHE_LINE_SIZE);
 
 #endif /* !_SYS__MUTEX_H_ */
diff --git a/sys/sys/_rmlock.h b/sys/sys/_rmlock.h
index 38375b623a65..9c8893efe19c 100644
--- a/sys/sys/_rmlock.h
+++ b/sys/sys/_rmlock.h
@@ -32,6 +32,14 @@
 #ifndef _SYS__RMLOCK_H_
 #define_SYS__RMLOCK_H_
 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct thread;
+
 /*
  * Mostly reader/occasional writer lock.
  */
@@ -66,8 +74,6 @@ struct rm_priotracker {
LIST_ENTRY(rm_priotracker) rmp_qentry;
 };
 
-#include 
-
 struct rmslock_pcpu;
 
 struct rmslock {
diff --git a/sys/sys/_rwlock.h b/sys/sys/_rwlock.h
index d360cfe2a4e9..8c15771cb172 100644
--- a/sys/sys/_rwlock.h
+++ b/sys/sys/_rwlock.h
@@ -28,6 +28,8 @@
 #ifndef _SYS__RWLOCK_H_
 #define_SYS__RWLOCK_H_
 
+#include 
+#include 
 #include 
 
 /*
@@ -41,7 +43,7 @@
  */
 struct rwlock {
struct lock_object  lock_object;
-   volatile uintptr_t  rw_lock;
+   volatile __uintptr_trw_lock;
 };
 
 /*
@@ -55,7 +57,7 @@ struct rwlock {
  */
 struct rwlock_padalign {
struct lock_object  lock_object;
-   volatile uintptr_t  rw_lock;
+   volatile __uintptr_trw_lock;
 } __aligned(CACHE_LINE_SIZE);
 
 #endif /* !_SYS__RWLOCK_H_ */
diff --git a/sys/sys/_sx.h b/sys/sys/_sx.h
index f70462c9a008..c6fd485620c6 100644
--- a/sys/sys/_sx.h
+++ b/sys/sys/_sx.h
@@ -31,12 +31,15 @@
 #ifndef_SYS__SX_H_
 #define_SYS__SX_H_
 
+#include 
+#include 
+
 /*
  * Shared/exclusive lock main structure definition.
  */
 struct sx {
struct lock_object  lock_object;
-   volatile uintptr_t  sx_lock;
+   volatile __uintptr_tsx_lock;
 };
 
 #endif /* !_SYS__SX_H_ */
diff --git a/sys/sys/file.h b/sys/sys/file.h
index 820ad1015573..a2dc02e523d8 100644
--- a/sys/sys/file.h
+++ b/sys/sys/file.h
@@ -37,13 +37,16 @@
 #include 
 #include 
 #else
-#include 
-#include 
+#include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 
 struct filedesc;
+stru

git: cdfd0600dc88 - main - release: Include -dbg files in dvd image

2024-11-05 Thread Colin Percival
The branch main has been updated by cperciva:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=cdfd0600dc8882f0a0d0e6d9a1cdcf926edba6d6

commit cdfd0600dc8882f0a0d0e6d9a1cdcf926edba6d6
Author: Colin Percival 
AuthorDate: 2024-11-05 21:35:17 +
Commit: Colin Percival 
CommitDate: 2024-11-05 21:39:38 +

release: Include -dbg files in dvd image

In 2016, commit 8834318685bc reworked the code for excluding -dbg
files from install media, and in the process accidentally broke it
for dvd images ('grep -v' should have been 'grep -vE').

FreeBSD Update builds later began to depend on this, and in any case
since DVD images are intended as "include everything" images there's
no point excluding those; so remove the (broken) filtering from DVD
image builds.

Sponsored by:   Amazon
MFC after:  2 days
---
 release/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/release/Makefile b/release/Makefile
index 6f59647ff5db..9f19b150ae65 100644
--- a/release/Makefile
+++ b/release/Makefile
@@ -241,12 +241,12 @@ dvd: packagesystem
-DDB_FROM_SRC )
 # Copy distfiles
mkdir -p ${.TARGET}/usr/freebsd-dist
-   for dist in MANIFEST $$(ls *.txz | grep -v -- '(${base 
${_ALL_libcompats}:L:ts|})-dbg'); \
+   for dist in MANIFEST $$(ls *.txz); \
do cp $${dist} ${.TARGET}/usr/freebsd-dist; \
done
 .if defined(NO_ROOT)
echo "./usr/freebsd-dist type=dir uname=root gname=wheel mode=0755" >> 
${.TARGET}/METALOG
-   for dist in MANIFEST $$(ls *.txz | grep -vE -- '(${base 
${_ALL_libcompats}:L:ts|})-dbg'); \
+   for dist in MANIFEST $$(ls *.txz); \
do echo "./usr/freebsd-dist/$${dist} type=file uname=root 
gname=wheel mode=0644" >> ${.TARGET}/METALOG; \
done
 .endif



Re: git: d2e7bb630b83 - main - rc.d/sendmail: Return non-zero if the daemon fails to start or is not running

2024-11-05 Thread Tijl Coosemans
On Mon, 21 Oct 2024 19:21:45 GMT Mateusz Piotrowski wrote:
> The branch main has been updated by 0mp:
> 
> URL: 
> https://cgit.FreeBSD.org/src/commit/?id=d2e7bb630b83848a774d8213014a9e0747775019
> 
> commit d2e7bb630b83848a774d8213014a9e0747775019
> Author: Mateusz Piotrowski <0...@freebsd.org>
> AuthorDate: 2024-10-21 10:10:52 +
> Commit: Mateusz Piotrowski <0...@freebsd.org>
> CommitDate: 2024-10-21 19:20:36 +
> 
> rc.d/sendmail: Return non-zero if the daemon fails to start or is not 
> running
> 
> If you have a mail server that is running sendmail daemon
> (sendmail_enable=YES) and sendmail queue runner (sendmail_msp_queue=YES)
> and the sendmail daemon dies, /etc/rc.d/sendmail status does see the
> daemon is not running but returns 0 as the exit code.  This prevents
> other programs (like puppet) from restarting sendmail to fix the issue.
> 
> Make sure that the exit code is propagated towards the end of the script
> if any of the sendmail services fail.
> 
> This patch does not call exit directly but instead just sets the exit
> status code by calling exit in a subshell. This way we do not exit the
> current shell in case the service script is sourced (e.g., when
> rc_fast_and_loose is active).
> 
> PR: 223132
> MFC after:  2 weeks
> Reported by:pirzyk
> Discussed with: jilles, eugen
> Reviewed by:christos, gshapiro (previous version), markj
> Approved by:christos (mentor), markj (mentor)
> Differential Revision:  https://reviews.freebsd.org/D46862
> Co-authored-by: Jim Pirzyk 
> ---
>  libexec/rc/rc.d/sendmail | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libexec/rc/rc.d/sendmail b/libexec/rc/rc.d/sendmail
> index af84c6d6b548..5a780e5b15a1 100755
> --- a/libexec/rc/rc.d/sendmail
> +++ b/libexec/rc/rc.d/sendmail
> @@ -206,6 +206,7 @@ sendmail_precmd()
>  }
>  
>  run_rc_command "$1"
> +_ret=$?
>  
>  required_files=
>  
> @@ -214,6 +215,7 @@ if checkyesno sendmail_submit_enable; then
>   rcvar="sendmail_submit_enable"
>   _rc_restart_done=false
>   run_rc_command "$1"
> + _ret=$(( _ret > $? ? _ret : $? ))
>  fi
>  
>  if checkyesno sendmail_outbound_enable; then
> @@ -221,6 +223,7 @@ if checkyesno sendmail_outbound_enable; then
>   rcvar="sendmail_outbound_enable"
>   _rc_restart_done=false
>   run_rc_command "$1"
> + _ret=$(( _ret > $? ? _ret : $? ))
>  fi
>  
>  name="sendmail_msp_queue"
> @@ -229,3 +232,6 @@ 
> pidfile="${sendmail_msp_queue_pidfile:-/var/spool/clientmqueue/sm-client.pid}"
>  required_files="/etc/mail/submit.cf"
>  _rc_restart_done=false
>  run_rc_command "$1"
> +_ret=$(( _ret > $? ? _ret : $? ))
> +
> +(exit "$_ret")

Running "make stop" in /etc/mail now produces an error with the
following config in /etc/rc.conf:

sendmail_enable="NO"
sendmail_msp_queue_enable="YES"
sendmail_outbound_enable="YES"
sendmail_submit_enable="YES"



git: f0c07fe3d000 - main - device_pager: rename the un_pager.devp.dev field to handle

2024-11-05 Thread Konstantin Belousov
The branch main has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f0c07fe3d0007a4499f81583a99598cd0a74d45b

commit f0c07fe3d0007a4499f81583a99598cd0a74d45b
Author: Konstantin Belousov 
AuthorDate: 2024-11-04 22:10:06 +
Commit: Konstantin Belousov 
CommitDate: 2024-11-06 00:10:59 +

device_pager: rename the un_pager.devp.dev field to handle

because it is not neccessary struct cdev *.

Reviewed by:markj
Sponsored by:   The FreeBSD Foundation
MFC after:  1 week
Differential revision:  https://reviews.freebsd.org/D47443
---
 sys/kern/kern_proc.c  |  2 +-
 sys/vm/device_pager.c | 20 ++--
 sys/vm/vm_object.c|  2 +-
 sys/vm/vm_object.h|  2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index f3ecaf4e2547..0d5b9a93d704 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -2719,7 +2719,7 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, 
ssize_t maxlen, int flags)
kve->kve_shadow_count = obj->shadow_count;
if (obj->type == OBJT_DEVICE ||
obj->type == OBJT_MGTDEVICE) {
-   cdev = obj->un_pager.devp.dev;
+   cdev = obj->un_pager.devp.handle;
if (cdev != NULL) {
csw = dev_refthread(cdev, &ref);
if (csw != NULL) {
diff --git a/sys/vm/device_pager.c b/sys/vm/device_pager.c
index a5be05efc6d9..a5fffbf629bd 100644
--- a/sys/vm/device_pager.c
+++ b/sys/vm/device_pager.c
@@ -118,8 +118,8 @@ cdev_pager_lookup(void *handle)
 again:
mtx_lock(&dev_pager_mtx);
object = vm_pager_object_lookup(&dev_pager_object_list, handle);
-   if (object != NULL && object->un_pager.devp.dev == NULL) {
-   msleep(&object->un_pager.devp.dev, &dev_pager_mtx,
+   if (object != NULL && object->un_pager.devp.handle == NULL) {
+   msleep(&object->un_pager.devp.handle, &dev_pager_mtx,
PVM | PDROP, "cdplkp", 0);
vm_object_deallocate(object);
goto again;
@@ -183,8 +183,8 @@ again:
object1->type = OBJT_DEAD;
vm_object_deallocate(object1);
object1 = NULL;
-   if (object->un_pager.devp.dev == NULL) {
-   msleep(&object->un_pager.devp.dev,
+   if (object->un_pager.devp.handle == NULL) {
+   msleep(&object->un_pager.devp.handle,
&dev_pager_mtx, PVM | PDROP, "cdplkp", 0);
vm_object_deallocate(object);
goto again;
@@ -218,7 +218,7 @@ again:
mtx_lock(&dev_pager_mtx);
TAILQ_REMOVE(&dev_pager_object_list, object,
pager_object_list);
-   wakeup(&object->un_pager.devp.dev);
+   wakeup(&object->un_pager.devp.handle);
mtx_unlock(&dev_pager_mtx);
object->type = OBJT_DEAD;
vm_object_deallocate(object);
@@ -228,14 +228,14 @@ again:
mtx_lock(&dev_pager_mtx);
object->flags |= OBJ_COLORED;
object->pg_color = color;
-   object->un_pager.devp.dev = handle;
-   wakeup(&object->un_pager.devp.dev);
+   object->un_pager.devp.handle = handle;
+   wakeup(&object->un_pager.devp.handle);
}
}
MPASS(object1 == NULL);
} else {
-   if (object->un_pager.devp.dev == NULL) {
-   msleep(&object->un_pager.devp.dev,
+   if (object->un_pager.devp.handle == NULL) {
+   msleep(&object->un_pager.devp.handle,
&dev_pager_mtx, PVM | PDROP, "cdplkp", 0);
vm_object_deallocate(object);
goto again;
@@ -301,7 +301,7 @@ dev_pager_dealloc(vm_object_t object)
vm_page_t m;
 
VM_OBJECT_WUNLOCK(object);
-   object->un_pager.devp.ops->cdev_pg_dtor(object->un_pager.devp.dev);
+   object->un_pager.devp.ops->cdev_pg_dtor(object->un_pager.devp.handle);
 
mtx_lock(&dev_pager_mtx);
TAILQ_REMOVE(&dev_pager_object_list, object, pager_object_list);
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 996f7557ea9b..6d29ddf71f19 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -2516,7 +2516,7 @@ vm_object_list_handler(struct sysctl_r

git: 580340dbdaaf - main - vm_object: do not assume that un_pager.devp.dev is cdev

2024-11-05 Thread Konstantin Belousov
The branch main has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=580340dbdaaf372867e9ed3dd257430982753e5e

commit 580340dbdaaf372867e9ed3dd257430982753e5e
Author: Konstantin Belousov 
AuthorDate: 2024-11-04 21:54:30 +
Commit: Konstantin Belousov 
CommitDate: 2024-11-06 00:11:00 +

vm_object: do not assume that un_pager.devp.dev is cdev

It is subtype-specific handle.  Mark OBJT_DEVICE that do fill cdev into
the handle, with a new object flag OBJ_CDEVH.

PR: 282533
Reviewed by:markj
Sponsored by:   The FreeBSD Foundation
MFC after:  1 week
Differential revision:  https://reviews.freebsd.org/D47443
---
 sys/kern/kern_proc.c | 5 +++--
 sys/vm/vm_mmap.c | 3 +++
 sys/vm/vm_object.c   | 3 ++-
 sys/vm/vm_object.h   | 1 +
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 0d5b9a93d704..4cd13234a10b 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -2717,8 +2717,9 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, 
ssize_t maxlen, int flags)
 
kve->kve_ref_count = obj->ref_count;
kve->kve_shadow_count = obj->shadow_count;
-   if (obj->type == OBJT_DEVICE ||
-   obj->type == OBJT_MGTDEVICE) {
+   if ((obj->type == OBJT_DEVICE ||
+   obj->type == OBJT_MGTDEVICE) &&
+   (obj->flags & OBJ_CDEVH) != 0) {
cdev = obj->un_pager.devp.handle;
if (cdev != NULL) {
csw = dev_refthread(cdev, &ref);
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index 4f709b1b74e1..028175b88b4f 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -1407,6 +1407,9 @@ vm_mmap_cdev(struct thread *td, vm_size_t objsize, 
vm_prot_t prot,
td->td_ucred);
if (obj == NULL)
return (EINVAL);
+   VM_OBJECT_WLOCK(obj);
+   vm_object_set_flag(obj, OBJ_CDEVH);
+   VM_OBJECT_WUNLOCK(obj);
*objp = obj;
*flagsp = flags;
return (0);
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 6d29ddf71f19..e6324647e29e 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -2515,7 +2515,8 @@ vm_object_list_handler(struct sysctl_req *req, bool 
swap_only)
sp = swap_pager_swapped_pages(obj);
kvo->kvo_swapped = sp > UINT32_MAX ? UINT32_MAX : sp;
}
-   if (obj->type == OBJT_DEVICE || obj->type == OBJT_MGTDEVICE) {
+   if ((obj->type == OBJT_DEVICE || obj->type == OBJT_MGTDEVICE) &&
+   (obj->flags & OBJ_CDEVH) != 0) {
cdev = obj->un_pager.devp.handle;
if (cdev != NULL) {
csw = dev_refthread(cdev, &ref);
diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h
index 596f67b46e6f..fc39041d02d6 100644
--- a/sys/vm/vm_object.h
+++ b/sys/vm/vm_object.h
@@ -204,6 +204,7 @@ struct vm_object {
 #defineOBJ_PAGERPRIV2  0x8000  /* Pager private */
 #defineOBJ_SYSVSHM 0x0001  /* SysV SHM */
 #defineOBJ_POSIXSHM0x0002  /* Posix SHM */
+#defineOBJ_CDEVH   0x0004  /* OBJT_DEVICE handle is cdev */
 
 /*
  * Helpers to perform conversion between vm_object page indexes and offsets.