Re: Stop using direct syscall(2) from perl(1)

2023-07-12 Thread George Koehler
On Sun, 9 Jul 2023 13:29:58 -0700
Andrew Hewus Fresh  wrote:

> Here is a patch to replace perl(1)'s use of syscall(2) with a dispatcher
> that will call the libc function instead.

patch(1) didn't "chmod +x gen_syscall_emulator.pl", but I needed to
do so to get around this this error,

$ make -f Makefile.bsd-wrapper 
/usr/src/gnu/usr.bin/perl/gen_syscall_emulator.pl > syscall_emulator.c
/bin/sh: /usr/src/gnu/usr.bin/perl/gen_syscall_emulator.pl: cannot execute - 
Permission denied
*** Error 126 in /usr/src/gnu/usr.bin/perl (Makefile.bsd-wrapper:51 
'syscall_emulator.c')



Remove ENGINE use from relayd

2023-07-12 Thread Theo Buehler
This is analogous to the change that op committed to smtpd a few days
ago. Instead of using ENGINE to make RSA use privsep via imsg, create
an RSA method that has custom priv_enc/priv_dec methods, replace the
default RSA method. Ditch numerous wrappers that extract the default
methods on the fly only to add a log call.

This removes a lot of boilerplate and shows more clearly where the
actual magic happens. Regress exercises this code and passes.

Index: ca.c
===
RCS file: /cvs/src/usr.sbin/relayd/ca.c,v
retrieving revision 1.42
diff -u -p -r1.42 ca.c
--- ca.c11 Jun 2023 10:30:26 -  1.42
+++ ca.c11 Jul 2023 18:21:47 -
@@ -41,20 +41,8 @@ void  ca_launch(void);
 int ca_dispatch_parent(int, struct privsep_proc *, struct imsg *);
 int ca_dispatch_relay(int, struct privsep_proc *, struct imsg *);
 
-int rsae_pub_enc(int, const u_char *, u_char *, RSA *, int);
-int rsae_pub_dec(int,const u_char *, u_char *, RSA *, int);
 int rsae_priv_enc(int, const u_char *, u_char *, RSA *, int);
 int rsae_priv_dec(int, const u_char *, u_char *, RSA *, int);
-int rsae_mod_exp(BIGNUM *, const BIGNUM *, RSA *, BN_CTX *);
-int rsae_bn_mod_exp(BIGNUM *, const BIGNUM *, const BIGNUM *,
-   const BIGNUM *, BN_CTX *, BN_MONT_CTX *);
-int rsae_init(RSA *);
-int rsae_finish(RSA *);
-int rsae_sign(int, const u_char *, u_int, u_char *, u_int *,
-   const RSA *);
-int rsae_verify(int dtype, const u_char *m, u_int, const u_char *,
-   u_int, const RSA *);
-int rsae_keygen(RSA *, int, BIGNUM *, BN_GENCB *);
 
 static struct relayd *env = NULL;
 
@@ -301,7 +289,7 @@ ca_dispatch_relay(int fd, struct privsep
  * RSA privsep engine (called from unprivileged processes)
  */
 
-const RSA_METHOD *rsa_default = NULL;
+static const RSA_METHOD *rsa_default;
 static RSA_METHOD *rsae_method;
 
 static int
@@ -417,20 +405,6 @@ rsae_send_imsg(int flen, const u_char *f
 }
 
 int
-rsae_pub_enc(int flen,const u_char *from, u_char *to, RSA *rsa,int padding)
-{
-   DPRINTF("%s:%d", __func__, __LINE__);
-   return RSA_meth_get_pub_enc(rsa_default)(flen, from, to, rsa, padding);
-}
-
-int
-rsae_pub_dec(int flen,const u_char *from, u_char *to, RSA *rsa,int padding)
-{
-   DPRINTF("%s:%d", __func__, __LINE__);
-   return RSA_meth_get_pub_dec(rsa_default)(flen, from, to, rsa, padding);
-}
-
-int
 rsae_priv_enc(int flen, const u_char *from, u_char *to, RSA *rsa, int padding)
 {
DPRINTF("%s:%d", __func__, __LINE__);
@@ -444,69 +418,10 @@ rsae_priv_dec(int flen, const u_char *fr
return rsae_send_imsg(flen, from, to, rsa, padding, IMSG_CA_PRIVDEC);
 }
 
-int
-rsae_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
-{
-   DPRINTF("%s:%d", __func__, __LINE__);
-   return RSA_meth_get_mod_exp(rsa_default)(r0, I, rsa, ctx);
-}
-
-int
-rsae_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
-const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
-{
-   DPRINTF("%s:%d", __func__, __LINE__);
-   return RSA_meth_get_bn_mod_exp(rsa_default)(r, a, p, m, ctx, m_ctx);
-}
-
-int
-rsae_init(RSA *rsa)
-{
-   DPRINTF("%s:%d", __func__, __LINE__);
-   if (RSA_meth_get_init(rsa_default) == NULL)
-   return 1;
-   return RSA_meth_get_init(rsa_default)(rsa);
-}
-
-int
-rsae_finish(RSA *rsa)
-{
-   DPRINTF("%s:%d", __func__, __LINE__);
-   if (RSA_meth_get_finish(rsa_default) == NULL)
-   return 1;
-   return RSA_meth_get_finish(rsa_default)(rsa);
-}
-
-int
-rsae_sign(int type, const u_char *m, u_int m_length, u_char *sigret,
-u_int *siglen, const RSA *rsa)
-{
-   DPRINTF("%s:%d", __func__, __LINE__);
-   return RSA_meth_get_sign(rsa_default)(type, m, m_length,
-   sigret, siglen, rsa);
-}
-
-int
-rsae_verify(int dtype, const u_char *m, u_int m_length, const u_char *sigbuf,
-u_int siglen, const RSA *rsa)
-{
-   DPRINTF("%s:%d", __func__, __LINE__);
-   return RSA_meth_get_verify(rsa_default)(dtype, m, m_length,
-   sigbuf, siglen, rsa);
-}
-
-int
-rsae_keygen(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb)
-{
-   DPRINTF("%s:%d", __func__, __LINE__);
-   return RSA_meth_get_keygen(rsa_default)(rsa, bits, e, cb);
-}
-
 void
 ca_engine_init(struct relayd *x_env)
 {
-   ENGINE  *e = NULL;
-   const char  *errstr, *name;
+   const char  *errstr;
 
if (env == NULL)
env = x_env;
@@ -514,68 +429,25 @@ ca_engine_init(struct relayd *x_env)
if (rsa_default != NULL)
return;
 
-   if ((rsae_method = RSA_meth_new("RSA privsep engine", 0)) == NULL) {
-   errstr = "RSA_meth_new";
+   if ((rsa_default = RSA_get_default_method()) == NULL) {
+   errstr = "RSA_get_default_method";
goto fail;
}
 
-   RSA_meth_set_pub_enc(rsae_method, rsae_pub_enc);
-   

Move solock() down to sosetopt()

2023-07-12 Thread Vitaliy Makkoveev
This is a part of my standalone sblock() work. I need this movement
because buffers related SO_SND* and SO_RCV* socket options modification
should be protected with sblock(). However, standalone sblock() has
different lock orders with solock() for receive and send buffers. At
least sblock() for `so_snd' buffer will always be taken before solock()
in the sosend() path.

The switch() block was split by two. SO_DONTROUTE, SO_SPLICE, SO_SND*
and SO_RCV* cases do not require to call (*pr_ctloutput)(), so they were
moved to the first switch() block solock() was pushed into each case
individually. For SO_SND* and SO_RCV* cases solock() will be replaced by
sblock() in the future. SO_RTABLE case calls (*pr_ctloutput)(), but do
this in the special way, so it was placed to the first switch() block
too.

The second switch() block contains the cases which require to call
(*pr_ctloutput)(). solock() is taken around this block together with the
(*pr_ctloutput)() call to keep atomicy.

sys_setsockopt() is not the only sosetopt() caller. For such places
the solock() could be just dropped around sosetopt() call. Please note,
solock() protects only socket consistency so this doesn't brings any
atomicy loss.

I want to receive feedback, polish the diff if required, and then I'll
ask to test the final version with bulk builds and the snaps.

Index: sys/kern/uipc_socket.c
===
RCS file: /cvs/src/sys/kern/uipc_socket.c,v
retrieving revision 1.305
diff -u -p -r1.305 uipc_socket.c
--- sys/kern/uipc_socket.c  4 Jul 2023 22:28:24 -   1.305
+++ sys/kern/uipc_socket.c  12 Jul 2023 23:08:02 -
@@ -1789,57 +1789,23 @@ sosetopt(struct socket *so, int level, i
 {
int error = 0;
 
-   soassertlocked(so);
-
if (level != SOL_SOCKET) {
if (so->so_proto->pr_ctloutput) {
+   solock(so);
error = (*so->so_proto->pr_ctloutput)(PRCO_SETOPT, so,
level, optname, m);
+   sounlock(so);
return (error);
}
error = ENOPROTOOPT;
} else {
switch (optname) {
-   case SO_BINDANY:
-   if ((error = suser(curproc)) != 0)  /* XXX */
-   return (error);
-   break;
-   }
-
-   switch (optname) {
-
-   case SO_LINGER:
-   if (m == NULL || m->m_len != sizeof (struct linger) ||
-   mtod(m, struct linger *)->l_linger < 0 ||
-   mtod(m, struct linger *)->l_linger > SHRT_MAX)
-   return (EINVAL);
-   so->so_linger = mtod(m, struct linger *)->l_linger;
-   /* FALLTHROUGH */
-
-   case SO_BINDANY:
-   case SO_DEBUG:
-   case SO_KEEPALIVE:
-   case SO_USELOOPBACK:
-   case SO_BROADCAST:
-   case SO_REUSEADDR:
-   case SO_REUSEPORT:
-   case SO_OOBINLINE:
-   case SO_TIMESTAMP:
-   case SO_ZEROIZE:
-   if (m == NULL || m->m_len < sizeof (int))
-   return (EINVAL);
-   if (*mtod(m, int *))
-   so->so_options |= optname;
-   else
-   so->so_options &= ~optname;
-   break;
-
case SO_DONTROUTE:
if (m == NULL || m->m_len < sizeof (int))
return (EINVAL);
if (*mtod(m, int *))
-   error = EOPNOTSUPP;
-   break;
+   return (EOPNOTSUPP);
+   return (0);
 
case SO_SNDBUF:
case SO_RCVBUF:
@@ -1853,23 +1819,32 @@ sosetopt(struct socket *so, int level, i
cnt = *mtod(m, int *);
if ((long)cnt <= 0)
cnt = 1;
-   switch (optname) {
 
+   solock(so);
+   switch (optname) {
case SO_SNDBUF:
-   if (so->so_snd.sb_state & SS_CANTSENDMORE)
-   return (EINVAL);
+   if (so->so_snd.sb_state & SS_CANTSENDMORE) {
+   error = EINVAL;
+   break;
+   }
if (sbcheckreserve(cnt, so->so_snd.sb_wat) ||
-   sbreserve(so, >so_snd, cnt))
-   return (ENOBUFS);
+   sbreserve(so, >so_snd, cnt)) {
+

Re: refcnt_init(9): Add missing word

2023-07-12 Thread Jason McIntyre
On Wed, Jul 12, 2023 at 12:19:40PM +0200, thib4711 wrote:
> diff --git a/share/man/man9/refcnt_init.9 b/share/man/man9/refcnt_init.9
> index 96fa94e7e64..142c1e57d8d 100644
> --- a/share/man/man9/refcnt_init.9
> +++ b/share/man/man9/refcnt_init.9
> @@ -71,7 +71,7 @@ is used to release an existing reference.
>  is used to release an existing reference and wakes up a process
>  that is currently waiting in
>  .Fn refcnt_finalize
> -for all the references to released.
> +for all the references to be released.
>  .Pp
>  .Fn refcnt_finalize
>  releases the caller's reference and sleeps until all the other
> 

fixed, thanks.
jmc



vfs: drop a bunch of cast macros

2023-07-12 Thread thib4711
make it obvious in the vfsops assignment that an op isnt supported.

diff --git sys/isofs/cd9660/cd9660_extern.h sys/isofs/cd9660/cd9660_extern.h
index 2a5348e1768..bd8154a27bd 100644
--- sys/isofs/cd9660/cd9660_extern.h
+++ sys/isofs/cd9660/cd9660_extern.h
@@ -94,10 +94,8 @@ int cd9660_vptofh(struct vnode *, struct fid *);
 int cd9660_init(struct vfsconf *);
 int cd9660_check_export(struct mount *, struct mbuf *, int *,
  struct ucred **);
-#define cd9660_sysctl ((int (*)(int *, u_int, void *, size_t *, void *, \
-size_t, struct proc *))eopnotsupp)
 
-int cd9660_mountroot(void); 
+int cd9660_mountroot(void);
 
 extern const struct vops   cd9660_vops;
 extern const struct vops   cd9660_specvops;
diff --git sys/isofs/cd9660/cd9660_vfsops.c sys/isofs/cd9660/cd9660_vfsops.c
index ef0ffbbb152..b844a2ff709 100644
--- sys/isofs/cd9660/cd9660_vfsops.c
+++ sys/isofs/cd9660/cd9660_vfsops.c
@@ -72,7 +72,7 @@ const struct vfsops cd9660_vfsops = {
.vfs_fhtovp = cd9660_fhtovp,
.vfs_vptofh = cd9660_vptofh,
.vfs_init   = cd9660_init,
-   .vfs_sysctl = cd9660_sysctl,
+   .vfs_sysctl = (void *)eopnotsupp,
.vfs_checkexp   = cd9660_check_export,
 };
 
diff --git sys/msdosfs/msdosfs_vfsops.c sys/msdosfs/msdosfs_vfsops.c
index 0de37665dfd..6b90195b5e5 100644
--- sys/msdosfs/msdosfs_vfsops.c
+++ sys/msdosfs/msdosfs_vfsops.c
@@ -762,27 +762,18 @@ msdosfs_check_export(struct mount *mp, struct mbuf *nam, 
int *exflagsp,
return (0);
 }
 
-#define msdosfs_vget ((int (*)(struct mount *, ino_t, struct vnode **)) \
- eopnotsupp)
-
-#define msdosfs_quotactl ((int (*)(struct mount *, int, uid_t, caddr_t, \
-   struct proc *))eopnotsupp)
-
-#define msdosfs_sysctl ((int (*)(int *, u_int, void *, size_t *, void *, \
-size_t, struct proc *))eopnotsupp)
-
 const struct vfsops msdosfs_vfsops = {
.vfs_mount  = msdosfs_mount,
.vfs_start  = msdosfs_start,
.vfs_unmount= msdosfs_unmount,
.vfs_root   = msdosfs_root,
-   .vfs_quotactl   = msdosfs_quotactl,
+   .vfs_quotactl   = (void *)eopnotsupp,
.vfs_statfs = msdosfs_statfs,
.vfs_sync   = msdosfs_sync,
-   .vfs_vget   = msdosfs_vget,
+   .vfs_vget   = (void *)eopnotsupp,
.vfs_fhtovp = msdosfs_fhtovp,
.vfs_vptofh = msdosfs_vptofh,
.vfs_init   = msdosfs_init,
-   .vfs_sysctl = msdosfs_sysctl,
+   .vfs_sysctl = (void *)eopnotsupp,
.vfs_checkexp   = msdosfs_check_export,
 };



vnode: drop comment, nonsensical where it is

2023-07-12 Thread thib4711
The line comment in struct vnode is fine;

diff --git sys/sys/vnode.h sys/sys/vnode.h
index 30787afddd8..b2f0fa4b60c 100644
--- sys/sys/vnode.h
+++ sys/sys/vnode.h
@@ -74,12 +74,7 @@ enum vtagtype{
 "unused", "unused", "unused", "ISOFS", "unused",   \
 "EXT2FS", "VFS", "NTFS", "UDF", "FUSEFS", "TMPFS"
 
-/*
- * Each underlying filesystem allocates its own private area and hangs
- * it from v_data.  If non-null, this area is freed in getnewvnode().
- */
 LIST_HEAD(buflists, buf);
-
 RBT_HEAD(buf_rb_bufs, buf);
 
 struct namecache;



refcnt_init(9): Add missing word

2023-07-12 Thread thib4711
diff --git a/share/man/man9/refcnt_init.9 b/share/man/man9/refcnt_init.9
index 96fa94e7e64..142c1e57d8d 100644
--- a/share/man/man9/refcnt_init.9
+++ b/share/man/man9/refcnt_init.9
@@ -71,7 +71,7 @@ is used to release an existing reference.
 is used to release an existing reference and wakes up a process
 that is currently waiting in
 .Fn refcnt_finalize
-for all the references to released.
+for all the references to be released.
 .Pp
 .Fn refcnt_finalize
 releases the caller's reference and sleeps until all the other



OpenBGPD 8.1 released

2023-07-12 Thread Claudio Jeker
We have released OpenBGPD 8.1, which will be arriving in the
OpenBGPD directory of your local OpenBSD mirror soon.

This release includes the following changes to the previous release:

* Include OpenBSD 7.3 errata 002:
  Avoid fatal errors in bgpd(8) due to incorrect refcounting and
  mishandling of ASPA objects. Fix bgpctl(8) 'show rib in' by renaming
  'invalid' into 'disqualified'.

* Include OpenBSD 7.3 errata 006:
  Incorrect length handling of path attributes in bgpd(8) can lead to a
  session reset.

* Include OpenBSD 7.3 errata 009:
  When tracking nexthops over IPv6 multipath routes, or when receiving
  a NOTIFICATION while reaching an internal limit, bgpd(8) could crash.

  When checking the next hop for IPv6 multipath routes, or when receiving
  a NOTIFICATION while reaching an internal limit, bgpd(8) could crash.

* Add configure options to adjust WWW_USER and wwwrunstatedir.

* Fix 'ext-community * *' matching which also affects filters removing
  all ext-commuinites.

* Limit the socket buffer size to 64k for all sessions.
  Limiting the buffer size to a reasonable size ensures that not too many
  updates end up queued in the TCP stack.

OpenBGPD-portable is known to compile and run on FreeBSD and the
Linux distributions Alpine, Debian, Fedora, RHEL/CentOS and Ubuntu.
It is our hope that packagers take interest and help adapt OpenBGPD-portable
to more distributions.

We welcome feedback and improvements from the broader community.
Thanks to all of the contributors who helped make this release
possible.



OpenBSD Errata: July 12, 2023 (bgpd, httpd, elf, bgpd)

2023-07-12 Thread Theo Buehler
Errata patches for bgpd(8), httpd(8) and the kernel have been released
for OpenBSD 7.2 and 7.3.

Binary updates for the amd64, i386 and arm64 platform are available
via the syspatch utility.  Source code patches can be found on the
respective errata page:

  https://www.openbsd.org/errata72.html
  https://www.openbsd.org/errata73.html



Re: patch(1): don't run off the end in num_components.

2023-07-12 Thread Omar Polo
On 2023/07/12 12:54:54 +0200, Florian Obser  wrote:
> Found with afl, if path ends in '/', num_components will run off the end
> of the string.
> 
> OK?

ok op

> (this is on top of tb's fix on bugs but should be independent and not
> cause conflicts.)
> 
> diff --git pch.c pch.c
> index 63543a609fb..8c58dc9ffe5 100644
> --- pch.c
> +++ pch.c
> @@ -1484,7 +1484,8 @@ num_components(const char *path)
>   size_t n;
>   const char *cp;
>  
> - for (n = 0, cp = path; (cp = strchr(cp, '/')) != NULL; n++, cp++) {
> + for (n = 0, cp = path; (cp = strchr(cp, '/')) != NULL; n++) {
> + cp++;
>   while (*cp == '/')
>   cp++;   /* skip consecutive slashes */
>   }




Re: patch(1): basename(3) can fail

2023-07-12 Thread Theo Buehler
On Wed, Jul 12, 2023 at 12:53:10PM +0200, Florian Obser wrote:
> So I was sufficiently bored during breakfast and decided to run afl
> against patch...
> 
> basename(3) can fail thusly:
> ERRORS
>  The following error codes may be set in errno:
> 
>  [ENAMETOOLONG] The path component to be returned was larger than
> PATH_MAX.
> 
> and then strlen(3) segfaults.
> 
> OK?

ok

> (this is on top of tb's fix on bugs but should be independent and not
> cause conflicts.)

Go ahead. If it conflicts it's easy to redo anway.

> 
> diff --git pch.c pch.c
> index 4ae5f363393..63543a609fb 100644
> --- pch.c
> +++ pch.c
> @@ -1422,7 +1422,7 @@ compare_names(const struct file_name *names, bool 
> assume_exists)
>  {
>   size_t min_components, min_baselen, min_len, tmp;
>   char *best = NULL;
> - char *path;
> + char *path, *bn;
>   int i;
>  
>   /*
> @@ -1443,7 +1443,10 @@ compare_names(const struct file_name *names, bool 
> assume_exists)
>   min_components = tmp;
>   best = path;
>   }
> - if ((tmp = strlen(basename(path))) > min_baselen)
> + bn = basename(path);
> + if (bn == NULL)
> + continue;
> + if ((tmp = strlen(bn)) > min_baselen)
>   continue;
>   if (tmp < min_baselen) {
>   min_baselen = tmp;
> 
> -- 
> In my defence, I have been left unsupervised.
> 



patch(1): don't run off the end in num_components.

2023-07-12 Thread Florian Obser
Found with afl, if path ends in '/', num_components will run off the end
of the string.

OK?

(this is on top of tb's fix on bugs but should be independent and not
cause conflicts.)

diff --git pch.c pch.c
index 63543a609fb..8c58dc9ffe5 100644
--- pch.c
+++ pch.c
@@ -1484,7 +1484,8 @@ num_components(const char *path)
size_t n;
const char *cp;
 
-   for (n = 0, cp = path; (cp = strchr(cp, '/')) != NULL; n++, cp++) {
+   for (n = 0, cp = path; (cp = strchr(cp, '/')) != NULL; n++) {
+   cp++;
while (*cp == '/')
cp++;   /* skip consecutive slashes */
}

-- 
In my defence, I have been left unsupervised.



patch(1): basename(3) can fail

2023-07-12 Thread Florian Obser
So I was sufficiently bored during breakfast and decided to run afl
against patch...

basename(3) can fail thusly:
ERRORS
 The following error codes may be set in errno:

 [ENAMETOOLONG] The path component to be returned was larger than
PATH_MAX.

and then strlen(3) segfaults.

OK?

(this is on top of tb's fix on bugs but should be independent and not
cause conflicts.)

diff --git pch.c pch.c
index 4ae5f363393..63543a609fb 100644
--- pch.c
+++ pch.c
@@ -1422,7 +1422,7 @@ compare_names(const struct file_name *names, bool 
assume_exists)
 {
size_t min_components, min_baselen, min_len, tmp;
char *best = NULL;
-   char *path;
+   char *path, *bn;
int i;
 
/*
@@ -1443,7 +1443,10 @@ compare_names(const struct file_name *names, bool 
assume_exists)
min_components = tmp;
best = path;
}
-   if ((tmp = strlen(basename(path))) > min_baselen)
+   bn = basename(path);
+   if (bn == NULL)
+   continue;
+   if ((tmp = strlen(bn)) > min_baselen)
continue;
if (tmp < min_baselen) {
min_baselen = tmp;

-- 
In my defence, I have been left unsupervised.



Re: GPROF: sleep_state: disable _mcount() across suspend/resume

2023-07-12 Thread Theo de Raadt
> ok kettenis@

ok deraadt also



wscons shift+arrow keys terminal sequence support

2023-07-12 Thread jon
Hello. I have been missing the ability to have my Shift +
{up,down,left,right} arrows picked up and represented by the usual
character sequence in e.g. xterm's terminfo. Here is a diff I have
been using to that end, hoping that it will be of interest and
usefulness for others in this list.

P.S. I have also implemented ctrl+arrow keys support, but I'd like
to present them in a separate, incremental fashion, excited to share
this with the list.

Index: dev/pckbc/wskbdmap_mfii.c
===
RCS file: /cvs/src/sys/dev/pckbc/wskbdmap_mfii.c,v
retrieving revision 1.48
diff -u -p -r1.48 wskbdmap_mfii.c
--- dev/pckbc/wskbdmap_mfii.c   23 Jan 2023 09:36:40 -  1.48
+++ dev/pckbc/wskbdmap_mfii.c   9 Jul 2023 22:44:05 -
@@ -156,12 +156,12 @@ static const keysym_t pckbd_keydesc_us[]
 KC(198),  KS_Cmd_ResetClose, /* CTL-Break */
 #endif
 KC(199),   KS_Home,
-KC(200),   KS_Up,
+KC(200),   KS_Up, KS_ShiftUp,
 KC(201), KS_Cmd_ScrollBack,KS_Prior,
-KC(203),   KS_Left,
-KC(205),   KS_Right,
+KC(203),   KS_Left, KS_ShiftLeft,
+KC(205),   KS_Right, KS_ShiftRight,
 KC(207),   KS_End,
-KC(208),   KS_Down,
+KC(208),   KS_Down, KS_ShiftDown,
 KC(209), KS_Cmd_ScrollFwd, KS_Next,
 KC(210),   KS_Insert,
 KC(211), KS_Cmd_KbdReset,  KS_KP_Delete,
Index: dev/usb/ukbdmap.c
===
RCS file: /cvs/src/sys/dev/usb/ukbdmap.c,v
retrieving revision 1.47
diff -u -p -r1.47 ukbdmap.c
--- dev/usb/ukbdmap.c   23 Jan 2023 09:38:03 -  1.47
+++ dev/usb/ukbdmap.c   9 Jul 2023 22:44:28 -
@@ -128,10 +128,10 @@ static const keysym_t ukbd_keydesc_us[] 
 KC(76),KS_Cmd_KbdReset,KS_KP_Delete,
 KC(77),KS_End,
 KC(78),KS_Cmd_ScrollFwd,KS_Next,
-KC(79),KS_Right,
-KC(80),KS_Left,
-KC(81),KS_Down,
-KC(82),KS_Up,
+KC(79),KS_Right, KS_ShiftRight,
+KC(80),KS_Left, KS_ShiftLeft,
+KC(81),KS_Down, KS_ShiftDown,
+KC(82),KS_Up, KS_ShiftUp,
 KC(83),KS_Num_Lock,
 KC(84),KS_KP_Divide,
 KC(85),KS_KP_Multiply,
Index: dev/wscons/wsemul_vt100_keys.c
===
RCS file: /cvs/src/sys/dev/wscons/wsemul_vt100_keys.c,v
retrieving revision 1.9
diff -u -p -r1.9 wsemul_vt100_keys.c
--- dev/wscons/wsemul_vt100_keys.c  23 Jan 2023 09:36:40 -  1.9
+++ dev/wscons/wsemul_vt100_keys.c  9 Jul 2023 22:45:20 -
@@ -213,6 +229,18 @@ wsemul_vt100_translate(void *cookie, kbd
else
*out = "\033[C";
return (3);
+   case KS_ShiftUp:
+   *out = "\033[1;2A";
+   return (6);
+   case KS_ShiftDown:
+   *out = "\033[1;2B";
+   return (6);
+   case KS_ShiftLeft:
+   *out = "\033[1;2D";
+   return (6);
+   case KS_ShiftRight:
+   *out = "\033[1;2C";
+   return (6);
}
return (0);
 }
Index: dev/wscons/wsksymdef.h
===
RCS file: /cvs/src/sys/dev/wscons/wsksymdef.h,v
retrieving revision 1.40
diff -u -p -r1.40 wsksymdef.h
--- dev/wscons/wsksymdef.h  23 Jan 2023 09:36:40 -  1.40
+++ dev/wscons/wsksymdef.h  9 Jul 2023 22:45:38 -
@@ -627,6 +627,10 @@
 #define KS_Paste   0xf394
 #define KS_Cut 0xf395
 #define KS_Backtab 0xf396
+#define KS_ShiftUp 0xf397
+#define KS_ShiftDown   0xf398
+#define KS_ShiftLeft   0xf399
+#define KS_ShiftRight  0xf39a
 
 #define KS_Menu0xf3c0
 #define KS_Pause   0xf3c1