pluart(4): hardware console baudrate

2022-06-14 Thread Anton Lindqvist
Hi,
pluart(4) does not report the correct baudrate for the hardware console
but instead defaults to 38400. This in turn causes the same baudrate to
end up in /etc/ttys during installation. Note that this is not a problem
as of now since pluart does not support changing the baudrate just yet,
I have another subsequent diff for that.

Instead, honor and propagate the baudrate given to pluartcnattach()
while attaching the hardware console. Similar to what com(4) already
does.

Comments? OK?

diff --git sys/dev/ic/pluart.c sys/dev/ic/pluart.c
index be7d4483646..03acab832a9 100644
--- sys/dev/ic/pluart.c
+++ sys/dev/ic/pluart.c
@@ -153,11 +153,12 @@ struct cfdriver pluart_cd = {
NULL, "pluart", DV_TTY
 };
 
+intpluartdefaultrate = B38400;
+intpluartconsrate = B38400;
 bus_space_tag_tpluartconsiot;
 bus_space_handle_t pluartconsioh;
 bus_addr_t pluartconsaddr;
 tcflag_t   pluartconscflag = TTYDEF_CFLAG;
-intpluartdefaultrate = B38400;
 
 struct cdevsw pluartdev =
cdev_tty_init(3/*XXX NUART */ ,pluart); /* 12: serial port */
@@ -563,7 +564,10 @@ pluartopen(dev_t dev, int flag, int mode, struct proc *p)
if (ISSET(sc->sc_swflags, COM_SW_MDMBUF))
SET(tp->t_cflag, MDMBUF);
tp->t_lflag = TTYDEF_LFLAG;
-   tp->t_ispeed = tp->t_ospeed = pluartdefaultrate;
+   if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE))
+   tp->t_ispeed = tp->t_ospeed = pluartconsrate;
+   else
+   tp->t_ispeed = tp->t_ospeed = pluartdefaultrate;
 
s = spltty();
 
@@ -837,6 +841,7 @@ pluartcnattach(bus_space_tag_t iot, bus_addr_t iobase, int 
rate, tcflag_t cflag)
pluartconsiot = iot;
pluartconsaddr = iobase;
pluartconscflag = cflag;
+   pluartconsrate = rate;
 
return 0;
 }



[PATCH 1/1] drm/fb-helper: Fix clip rectangle height

2022-06-14 Thread Xiaohui Zhang
Computing the clip rectangle is prone to off-by-one errors when writes
happen near the end of a memory page. Point the end of the memory area
to the first trailing byte, so that (end - start) returns the area's
length.

Signed-off-by: Xiaohui Zhang 
---
 sys/dev/pci/drm/drm_fb_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/pci/drm/drm_fb_helper.c b/sys/dev/pci/drm/drm_fb_helper.c
index d56b9c66e..358680902 100644
--- a/sys/dev/pci/drm/drm_fb_helper.c
+++ b/sys/dev/pci/drm/drm_fb_helper.c
@@ -715,7 +715,7 @@ void drm_fb_helper_deferred_io(struct fb_info *info,
max = 0;
list_for_each_entry(page, pagelist, lru) {
start = page->index << PAGE_SHIFT;
-   end = start + PAGE_SIZE - 1;
+   end = start + PAGE_SIZE;
min = min(min, start);
max = max(max, end);
}
-- 
2.17.1



Re: [PATCH 1/1] drm/amd/display: Fix memory leak reported by coverity

2022-06-14 Thread Greg Steuck
Thanks for sending this fix Xiaohui.

The upstream patch is more complete
https://github.com/torvalds/linux/commit/7b89bf83181363a84f86da787159ddbbef505b8c

I believe the fixes will arrive via a normal update process unless
somebody knows a reason to apply this one specifically out of schedule.

Xiaohui Zhang  writes:

> Free memory allocated if any of the previous allocations failed.
>
> Signed-off-by: Xiaohui Zhang 
> ---
>  sys/dev/pci/drm/amd/display/dc/dcn302/dcn302_resource.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/sys/dev/pci/drm/amd/display/dc/dcn302/dcn302_resource.c 
> b/sys/dev/pci/drm/amd/display/dc/dcn302/dcn302_resource.c
> index 2292bb820..7f04042d2 100644
> --- a/sys/dev/pci/drm/amd/display/dc/dcn302/dcn302_resource.c
> +++ b/sys/dev/pci/drm/amd/display/dc/dcn302/dcn302_resource.c
> @@ -542,8 +542,12 @@ static struct stream_encoder 
> *dcn302_stream_encoder_create(enum engine_id eng_id
>   vpg = dcn302_vpg_create(ctx, vpg_inst);
>   afmt = dcn302_afmt_create(ctx, afmt_inst);
>  
> - if (!enc1 || !vpg || !afmt)
> + if (!enc1 || !vpg || !afmt) {
> + kfree(enc1);
> + kfree(vpg);
> + kfree(afmt);
>   return NULL;
> + }
>  
>   dcn30_dio_stream_encoder_construct(enc1, ctx, ctx->dc_bios, eng_id, 
> vpg, afmt, &stream_enc_regs[eng_id],
>   &se_shift, &se_mask);



pfctl reports back a table as being always created/added

2022-06-14 Thread Alexandr Nedvedicky
Hello,

Jason Mc Intyre (jmc@) reported a bug earlier today reaching me
by email off-list. Let me quote from Jason's email:

i already have a pf table, adding an address tells me i have created a
table. even though the table already existed:

# pfctl -tbrutes -Tshow | wc
89  89  501
# pfctl -tbrutes -Tadd 1.1.1.1
1 table created.
1/1 addresses added.

The bug has been introduced by my commit to pf_table.c:
$OpenBSD: pf_ioctl.c,v 1.381 2022/05/10 23:12:25 sashan Exp $

pfr_table_add() currently always increases 'xadd' counter while it
should increase 'xadd' if and only if we are going to create a table.
diff below fixes that.

OK to commit?


thanks and
regards
sashan

8<---8<---8<--8<
diff --git a/sys/net/pf_table.c b/sys/net/pf_table.c
index f261baef963..6c47e11f604 100644
--- a/sys/net/pf_table.c
+++ b/sys/net/pf_table.c
@@ -1562,13 +1562,13 @@ pfr_add_tables(struct pfr_table *tbl, int size, int 
*nadd, int flags)
if (p == NULL) {
SLIST_REMOVE(&auxq, n, pfr_ktable, pfrkt_workq);
SLIST_INSERT_HEAD(&addq, n, pfrkt_workq);
+   xadd++;
} else if (!(flags & PFR_FLAG_DUMMY) &&
!(p->pfrkt_flags & PFR_TFLAG_ACTIVE)) {
p->pfrkt_nflags = (p->pfrkt_flags &
~PFR_TFLAG_USRMASK) | key.pfrkt_flags;
SLIST_INSERT_HEAD(&changeq, p, pfrkt_workq);
}
-   xadd++;
}
 
if (!(flags & PFR_FLAG_DUMMY)) {



Re: ipsec acquire refcount fix

2022-06-14 Thread Vitaliy Makkoveev
> On 14 Jun 2022, at 15:47, Alexander Bluhm  wrote:
> 
> Hi,
> 
> I made a little mistake when adding acquire refcount.  The timeout
> does not decrement the counter to 0 properly.
> 
> We have one reference count for the lists, and one for the timeout
> handler.  When the timout fires, it has to decrement the referenc
> to itself.  Then the ipa is removed from the lists and decremented
> again.
> 
> ok?
> 
> bluhm
> 

ok mvs@

> Index: netinet/ip_spd.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_spd.c,v
> retrieving revision 1.116
> diff -u -p -r1.116 ip_spd.c
> --- netinet/ip_spd.c  4 May 2022 15:29:58 -   1.116
> +++ netinet/ip_spd.c  14 Jun 2022 12:08:37 -
> @@ -714,7 +714,10 @@ ipsp_delete_acquire_timer(void *v)
> {
>   struct ipsec_acquire *ipa = v;
> 
> - ipsp_delete_acquire(ipa);
> + mtx_enter(&ipsec_acquire_mtx);
> + refcnt_rele(&ipa->ipa_refcnt);
> + ipsp_delete_acquire_locked(ipa);
> + mtx_leave(&ipsec_acquire_mtx);
> }
> 
> /*
> 



Re: bgpd more kroute cleanup

2022-06-14 Thread Theo Buehler
On Tue, Jun 14, 2022 at 06:36:13PM +0200, Claudio Jeker wrote:
> This diff does introduce a new flag for routes that have been inserted
> into the FIB. Now I actually renamed the F_BGPD_INSERTED flag to F_BGPD
> and reused F_BGPD_INSERTED as this new flag.
> Adjust and use the send_rtmsg() return value to set F_BGPD_INSERTED if the
> route message was successfully sent.
> 
> Additionally this removes F_DYNAMIC and tracking of dynamic routes (routes
> generated by the kernel because of PMTU or some other event). A routing
> protocol does not need to work with them so just filter them out like ARP
> and ND routes.
> 
> While there also just remove protect_lo() it is a function that is not
> really making anything better. There are other checks in place for
> 127.0.0.1 and ::1.

Would it not be cleaner to set or unset the F_BGPD_INSERTED flag
inside send_rt{,6}msg() depending on action instead of doing that
after inspecting the return code?

ok tb

> 
> -- 
> :wq Claudio
> 
> Index: bgpctl/bgpctl.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.c,v
> retrieving revision 1.276
> diff -u -p -r1.276 bgpctl.c
> --- bgpctl/bgpctl.c   21 Mar 2022 10:16:23 -  1.276
> +++ bgpctl/bgpctl.c   14 Jun 2022 15:31:59 -
> @@ -633,14 +633,12 @@ fmt_fib_flags(uint16_t flags)
>   else
>   strlcpy(buf, "*", sizeof(buf));
>  
> - if (flags & F_BGPD_INSERTED)
> + if (flags & F_BGPD)
>   strlcat(buf, "B", sizeof(buf));
>   else if (flags & F_CONNECTED)
>   strlcat(buf, "C", sizeof(buf));
>   else if (flags & F_STATIC)
>   strlcat(buf, "S", sizeof(buf));
> - else if (flags & F_DYNAMIC)
> - strlcat(buf, "D", sizeof(buf));
>   else
>   strlcat(buf, " ", sizeof(buf));
>  
> Index: bgpctl/output.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpctl/output.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 output.c
> --- bgpctl/output.c   6 Feb 2022 09:52:32 -   1.20
> +++ bgpctl/output.c   14 Jun 2022 15:51:49 -
> @@ -46,7 +46,7 @@ show_head(struct parse_result *res)
>   break;
>   case SHOW_FIB:
>   printf("flags: * = valid, B = BGP, C = Connected, "
> - "S = Static, D = Dynamic\n");
> + "S = Static\n");
>   printf("   "
>   "N = BGP Nexthop reachable via this route\n");
>   printf("   r = reject route, b = blackhole route\n\n");
> Index: bgpctl/output_json.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpctl/output_json.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 output_json.c
> --- bgpctl/output_json.c  21 Mar 2022 10:16:23 -  1.14
> +++ bgpctl/output_json.c  14 Jun 2022 15:32:05 -
> @@ -357,14 +357,12 @@ json_fib(struct kroute_full *kf)
>   json_do_printf("prefix", "%s/%u", log_addr(&kf->prefix), kf->prefixlen);
>   json_do_uint("priority", kf->priority);
>   json_do_bool("up", !(kf->flags & F_DOWN));
> - if (kf->flags & F_BGPD_INSERTED)
> + if (kf->flags & F_BGPD)
>   origin = "bgp";
>   else if (kf->flags & F_CONNECTED)
>   origin = "connected";
>   else if (kf->flags & F_STATIC)
>   origin = "static";
> - else if (kf->flags & F_DYNAMIC)
> - origin = "dynamic";
>   else
>   origin = "unknown";
>   json_do_printf("origin", "%s", origin);
> Index: bgpctl/parser.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpctl/parser.c,v
> retrieving revision 1.109
> diff -u -p -r1.109 parser.c
> --- bgpctl/parser.c   21 Mar 2022 10:16:23 -  1.109
> +++ bgpctl/parser.c   14 Jun 2022 15:29:05 -
> @@ -151,15 +151,15 @@ static const struct token t_show_summary
>  };
>  
>  static const struct token t_show_fib[] = {
> - { NOTOKEN,  "", NONE,NULL},
> - { FLAG, "connected",F_CONNECTED, t_show_fib},
> - { FLAG, "static",   F_STATIC,t_show_fib},
> - { FLAG, "bgp",  F_BGPD_INSERTED, t_show_fib},
> - { FLAG, "nexthop",  F_NEXTHOP,   t_show_fib},
> - { KEYWORD,  "table",NONE,t_show_fib_table},
> - { FAMILY,   "", NONE,t_show_fib},
> - { ADDRESS,  "", NONE,NULL},
> - { ENDTOKEN, "", NONE,NULL}
> + { NOTOKEN,  "", NONE,   NULL},
> + { FLAG, "connected",F_CONNECTED,t_show_fib},
> + { FLAG, "static",   F_STATIC,   t_show_fib},
> + { FLAG, "bgp",  F_BGPD, t_show_fib},
> + { FLAG, "nexthop",  F_NEXTHOP,  t_show_fib},
> +

bgpd more kroute cleanup

2022-06-14 Thread Claudio Jeker
This diff does introduce a new flag for routes that have been inserted
into the FIB. Now I actually renamed the F_BGPD_INSERTED flag to F_BGPD
and reused F_BGPD_INSERTED as this new flag.
Adjust and use the send_rtmsg() return value to set F_BGPD_INSERTED if the
route message was successfully sent.

Additionally this removes F_DYNAMIC and tracking of dynamic routes (routes
generated by the kernel because of PMTU or some other event). A routing
protocol does not need to work with them so just filter them out like ARP
and ND routes.

While there also just remove protect_lo() it is a function that is not
really making anything better. There are other checks in place for
127.0.0.1 and ::1.

-- 
:wq Claudio

Index: bgpctl/bgpctl.c
===
RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.c,v
retrieving revision 1.276
diff -u -p -r1.276 bgpctl.c
--- bgpctl/bgpctl.c 21 Mar 2022 10:16:23 -  1.276
+++ bgpctl/bgpctl.c 14 Jun 2022 15:31:59 -
@@ -633,14 +633,12 @@ fmt_fib_flags(uint16_t flags)
else
strlcpy(buf, "*", sizeof(buf));
 
-   if (flags & F_BGPD_INSERTED)
+   if (flags & F_BGPD)
strlcat(buf, "B", sizeof(buf));
else if (flags & F_CONNECTED)
strlcat(buf, "C", sizeof(buf));
else if (flags & F_STATIC)
strlcat(buf, "S", sizeof(buf));
-   else if (flags & F_DYNAMIC)
-   strlcat(buf, "D", sizeof(buf));
else
strlcat(buf, " ", sizeof(buf));
 
Index: bgpctl/output.c
===
RCS file: /cvs/src/usr.sbin/bgpctl/output.c,v
retrieving revision 1.20
diff -u -p -r1.20 output.c
--- bgpctl/output.c 6 Feb 2022 09:52:32 -   1.20
+++ bgpctl/output.c 14 Jun 2022 15:51:49 -
@@ -46,7 +46,7 @@ show_head(struct parse_result *res)
break;
case SHOW_FIB:
printf("flags: * = valid, B = BGP, C = Connected, "
-   "S = Static, D = Dynamic\n");
+   "S = Static\n");
printf("   "
"N = BGP Nexthop reachable via this route\n");
printf("   r = reject route, b = blackhole route\n\n");
Index: bgpctl/output_json.c
===
RCS file: /cvs/src/usr.sbin/bgpctl/output_json.c,v
retrieving revision 1.14
diff -u -p -r1.14 output_json.c
--- bgpctl/output_json.c21 Mar 2022 10:16:23 -  1.14
+++ bgpctl/output_json.c14 Jun 2022 15:32:05 -
@@ -357,14 +357,12 @@ json_fib(struct kroute_full *kf)
json_do_printf("prefix", "%s/%u", log_addr(&kf->prefix), kf->prefixlen);
json_do_uint("priority", kf->priority);
json_do_bool("up", !(kf->flags & F_DOWN));
-   if (kf->flags & F_BGPD_INSERTED)
+   if (kf->flags & F_BGPD)
origin = "bgp";
else if (kf->flags & F_CONNECTED)
origin = "connected";
else if (kf->flags & F_STATIC)
origin = "static";
-   else if (kf->flags & F_DYNAMIC)
-   origin = "dynamic";
else
origin = "unknown";
json_do_printf("origin", "%s", origin);
Index: bgpctl/parser.c
===
RCS file: /cvs/src/usr.sbin/bgpctl/parser.c,v
retrieving revision 1.109
diff -u -p -r1.109 parser.c
--- bgpctl/parser.c 21 Mar 2022 10:16:23 -  1.109
+++ bgpctl/parser.c 14 Jun 2022 15:29:05 -
@@ -151,15 +151,15 @@ static const struct token t_show_summary
 };
 
 static const struct token t_show_fib[] = {
-   { NOTOKEN,  "", NONE,NULL},
-   { FLAG, "connected",F_CONNECTED, t_show_fib},
-   { FLAG, "static",   F_STATIC,t_show_fib},
-   { FLAG, "bgp",  F_BGPD_INSERTED, t_show_fib},
-   { FLAG, "nexthop",  F_NEXTHOP,   t_show_fib},
-   { KEYWORD,  "table",NONE,t_show_fib_table},
-   { FAMILY,   "", NONE,t_show_fib},
-   { ADDRESS,  "", NONE,NULL},
-   { ENDTOKEN, "", NONE,NULL}
+   { NOTOKEN,  "", NONE,   NULL},
+   { FLAG, "connected",F_CONNECTED,t_show_fib},
+   { FLAG, "static",   F_STATIC,   t_show_fib},
+   { FLAG, "bgp",  F_BGPD, t_show_fib},
+   { FLAG, "nexthop",  F_NEXTHOP,  t_show_fib},
+   { KEYWORD,  "table",NONE,   t_show_fib_table},
+   { FAMILY,   "", NONE,   t_show_fib},
+   { ADDRESS,  "", NONE,   NULL},
+   { ENDTOKEN, "", NONE,   NULL}
 };
 
 static const struct token t_show_rib[] = {
Index: bgpd/bgp

OpenBGPD 7.4 released

2022-06-14 Thread Claudio Jeker
We have released OpenBGPD 7.4, which will be arriving in the
OpenBGPD directory of your local OpenBSD mirror soon.

This release includes the following changes to the previous release:

* Implement max-communities filter to limit the number of allowed
  communities, ext-communities and large-communities.

* Fix TCP-MD5 support on Linux systems. The TCP-MD5 keys were not
  correctly loaded on the listening sockets, which allowed unprotected
  connections in. 

* Fix insertion of additional non-transitive extended communities when
  sending out prefixes.

* Relax IP address limitation by allowing prefixes in 240/4.

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.



ipsec acquire refcount fix

2022-06-14 Thread Alexander Bluhm
Hi,

I made a little mistake when adding acquire refcount.  The timeout
does not decrement the counter to 0 properly.

We have one reference count for the lists, and one for the timeout
handler.  When the timout fires, it has to decrement the referenc
to itself.  Then the ipa is removed from the lists and decremented
again.

ok?

bluhm

Index: netinet/ip_spd.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_spd.c,v
retrieving revision 1.116
diff -u -p -r1.116 ip_spd.c
--- netinet/ip_spd.c4 May 2022 15:29:58 -   1.116
+++ netinet/ip_spd.c14 Jun 2022 12:08:37 -
@@ -714,7 +714,10 @@ ipsp_delete_acquire_timer(void *v)
 {
struct ipsec_acquire *ipa = v;
 
-   ipsp_delete_acquire(ipa);
+   mtx_enter(&ipsec_acquire_mtx);
+   refcnt_rele(&ipa->ipa_refcnt);
+   ipsp_delete_acquire_locked(ipa);
+   mtx_leave(&ipsec_acquire_mtx);
 }
 
 /*