Re: [[patch]] /usr/src/regress/sys/ffs/ffs/Makefile

2021-11-26 Thread Theo de Raadt
That encourages people to setup unsafe doas.conf files.

Why don't we just create user accounts as uid 0 to make this easier
for everyone who wants to run regress?

Edgar Pettijohn  wrote:

> Allow running as non-root via ${SUDO}.
> 
> Thanks,
> 
> 
> Edgar



[[patch]] /usr/src/regress/sys/ffs/ffs/Makefile

2021-11-26 Thread Edgar Pettijohn

Allow running as non-root via ${SUDO}.

Thanks,


Edgar
Index: Makefile
===
RCS file: /cvs/src/regress/sys/ffs/ffs/Makefile,v
retrieving revision 1.5
diff -u -p -u -r1.5 Makefile
--- Makefile	16 Dec 2020 21:49:20 -	1.5
+++ Makefile	27 Nov 2021 01:10:25 -
@@ -8,23 +8,23 @@ CLEANFILES=	diskimage
 
 disk: unconfig
 	dd if=/dev/zero of=diskimage bs=512 count=4k
-	vnconfig vnd0 diskimage
-	newfs vnd0c
+	${SUDO} vnconfig vnd0 diskimage
+	${SUDO} newfs vnd0c
 
 REGRESS_SETUP_ONCE+=	mount
 mount: disk
-	mkdir -p /mnt/regress-ffs
-	mount /dev/vnd0c /mnt/regress-ffs
+	${SUDO} mkdir -p /mnt/regress-ffs
+	${SUDO} mount /dev/vnd0c /mnt/regress-ffs
 
 REGRESS_CLEANUP+=	umount
 umount:
-	umount /mnt/regress-ffs
+	${SUDO} umount /mnt/regress-ffs
 
 REGRESS_CLEANUP+=	unconfig
 unconfig:
-	-umount -f /dev/vnd0c 2>/dev/null || true
+	-${SUDO} umount -f /dev/vnd0c 2>/dev/null || true
 	-rmdir /mnt/regress-ffs 2>/dev/null || true
-	-vnconfig -u vnd0 2>/dev/null || true
+	-${SUDO} vnconfig -u vnd0 2>/dev/null || true
 	rm -f stamp-mount
 
 REGRESS_SETUP+=		${.OBJDIR}/../fstest


Re: Stop building the kernel with -Wno-uninitialized on clang archs

2021-11-26 Thread Jonathan Gray
On Fri, Nov 26, 2021 at 05:41:20PM +0100, Jan Stary wrote:
> > > Stop building the kernel with -Wno-uninitialized on clang archs.
> > > This hides real problems like the recently fixed uninitialised memory
> > > use in pf and igc.
> > > 
> > > [-Wsometimes-uninitialized] /sys/arch/arm/arm/cpu.c:352:6: warning: 
> > > variable 'ci' is used uninitialized whenever 'if' condition is false
> > > [-Wsometimes-uninitialized] /sys/arch/arm64/arm64/cpu.c:613:6: warning: 
> > > variable 'ci' is used uninitialized whenever 'if' condition is false
> > > [-Wsometimes-uninitialized] /sys/arch/riscv64/riscv64/cpu.c:169:6: 
> > > warning: variable 'ci' is used uninitialized whenever 'if' condition is 
> > > false
> > > [-Wsometimes-uninitialized] 
> > > /tmp/src/sys/arch/powerpc/powerpc/trap.c:467:7: error: variable 'offset' 
> > > is used uninitialized whenever 'if' condition is false
> > > [-Wuninitialized] /sys/arch/arm64/dev/acpiiort.c:174:28: warning: 
> > > variable 'rid' is uninitialized when used here
> > > 
> > > cpu.c warnings occur with MULTIPROCESSOR not defined
> > > powerpc trap.c occurs with DDB not defined
> > > 
> > > patch to address these and remove the flag below
> > > acpiiort part from patrick@
> 
> On each of the following platforms, the kernel builds fine for me
> with this patch and the compilation shows none of the above warnings.
> 
> i386   (ALIX.1E)
> amd64  (Thinkpad T400)
> arm64  (Raspberry Pi 3 and 4)
> armv7  (BeagleBone Black)
> macppc (Mac Mini 7447A)

thanks, committed with the i386 part changed to not remove -Werror

> 
> 
>   Jan
> 
> > > Index: arch/amd64/conf/Makefile.amd64
> > > ===
> > > RCS file: /cvs/src/sys/arch/amd64/conf/Makefile.amd64,v
> > > retrieving revision 1.121
> > > diff -u -p -r1.121 Makefile.amd64
> > > --- arch/amd64/conf/Makefile.amd6412 Jul 2021 06:07:33 -  
> > > 1.121
> > > +++ arch/amd64/conf/Makefile.amd6426 Nov 2021 04:54:10 -
> > > @@ -48,7 +48,7 @@ INCLUDES=   -nostdinc -I$S -I${.OBJDIR} -I
> > >  CPPFLAGS=${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -MD -MP \
> > >   -DCONFIG_DRM_AMD_DC_DCN3_0
> > >  CWARNFLAGS=  -Werror -Wall -Wimplicit-function-declaration \
> > > - -Wno-uninitialized -Wno-pointer-sign \
> > > + -Wno-pointer-sign \
> > >   -Wframe-larger-than=2047
> > >  
> > >  CMACHFLAGS=  -mcmodel=kernel -mno-red-zone -mno-sse2 -mno-sse 
> > > -mno-3dnow \
> > > Index: arch/arm/arm/cpu.c
> > > ===
> > > RCS file: /cvs/src/sys/arch/arm/arm/cpu.c,v
> > > retrieving revision 1.55
> > > diff -u -p -r1.55 cpu.c
> > > --- arch/arm/arm/cpu.c25 Mar 2021 04:12:00 -  1.55
> > > +++ arch/arm/arm/cpu.c23 Nov 2021 00:19:43 -
> > > @@ -349,14 +349,11 @@ cpu_attach(struct device *parent, struct
> > >   __asm volatile("mrc p15, 0, %0, c0, c0, 5" : "=r"(mpidr));
> > >   KASSERT(faa->fa_nreg > 0);
> > >  
> > > +#ifdef MULTIPROCESSOR
> > >   if (faa->fa_reg[0].addr == (mpidr & MPIDR_AFF)) {
> > >   ci = &cpu_info_primary;
> > > -#ifdef MULTIPROCESSOR
> > >   ci->ci_flags |= CPUF_RUNNING | CPUF_PRESENT | CPUF_PRIMARY;
> > > -#endif
> > > - }
> > > -#ifdef MULTIPROCESSOR
> > > - else {
> > > + } else {
> > >   ci = malloc(sizeof(*ci), M_DEVBUF, M_WAITOK | M_ZERO);
> > >   cpu_info[dev->dv_unit] = ci;
> > >   ci->ci_next = cpu_info_list->ci_next;
> > > @@ -364,6 +361,8 @@ cpu_attach(struct device *parent, struct
> > >   ci->ci_flags |= CPUF_AP;
> > >   ncpus++;
> > >   }
> > > +#else
> > > + ci = &cpu_info_primary;
> > >  #endif
> > >  
> > >   ci->ci_dev = dev;
> > > Index: arch/arm64/arm64/cpu.c
> > > ===
> > > RCS file: /cvs/src/sys/arch/arm64/arm64/cpu.c,v
> > > retrieving revision 1.58
> > > diff -u -p -r1.58 cpu.c
> > > --- arch/arm64/arm64/cpu.c23 Nov 2021 01:03:35 -  1.58
> > > +++ arch/arm64/arm64/cpu.c23 Nov 2021 01:28:26 -
> > > @@ -604,20 +604,19 @@ cpu_attach(struct device *parent, struct
> > >  {
> > >   struct fdt_attach_args *faa = aux;
> > >   struct cpu_info *ci;
> > > +#ifdef MULTIPROCESSOR
> > >   uint64_t mpidr = READ_SPECIALREG(mpidr_el1);
> > > +#endif
> > >   uint64_t id_aa64mmfr1, sctlr;
> > >   uint32_t opp;
> > >  
> > >   KASSERT(faa->fa_nreg > 0);
> > >  
> > > +#ifdef MULTIPROCESSOR
> > >   if (faa->fa_reg[0].addr == (mpidr & MPIDR_AFF)) {
> > >   ci = &cpu_info_primary;
> > > -#ifdef MULTIPROCESSOR
> > >   ci->ci_flags |= CPUF_RUNNING | CPUF_PRESENT | CPUF_PRIMARY;
> > > -#endif
> > > - }
> > > -#ifdef MULTIPROCESSOR
> > > - else {
> > > + } else {
> > >   ci = malloc(sizeof(*ci), M_DEVBUF, M_WAITOK | M_ZERO);
> > >   cpu_info[dev->dv_unit] = ci;
> > >   ci->ci_next = cpu_info_list->ci_next;
> > > @@ -625,6 +624,8 @@ cpu_attach(str

Re: [External] : Re: make 'set skip on ...' dynamic

2021-11-26 Thread Alexandr Nedvedicky
Hello,

On Fri, Nov 26, 2021 at 01:01:40PM +0100, Claudio Jeker wrote:
> 
> One more thing to consider, I think the following test in pfi_set_flags():
> 
> > +   if ((p->pfik_flags_new != p->pfik_flags) &&
> > +   (p->pfik_flagrefs == 0))
> > +   pfi_kif_ref(p, PFI_KIF_REF_FLAG);
> 
> should actually check for the PFI_IFLAG_SKIP flag and not any flag.
> 
>   if (ISSET(p->pfik_flags_new, PFI_IFLAG_SKIP) &&
>   p->pfik_flagrefs == 0)
>   pfi_kif_ref(p, PFI_KIF_REF_FLAG);
> 
> Same goes for pfi_clear_flags() just in reverse:
> 
> > +   if ((p->pfik_flags_new != p->pfik_flags) &&
> > +   (p->pfik_flagrefs == 1))
> > +   pfi_kif_unref(p, PFI_KIF_REF_FLAG);
> 
> Should be changed to:
>   if (!ISSET(p->pfik_flags_new, PFI_IFLAG_SKIP) &&
>   p->pfik_flagrefs == 1)
>   pfi_kif_unref(p, PFI_KIF_REF_FLAG);
> 
> We only want to track the PFI_IFLAG_SKIP flag but not any other flag like
> PFI_IFLAG_ANY. At least I think we want to do that, but then I guess
> pfi_set_flags() should only add a kif
>   if (found == 0 && ISSET(flags, PFI_IFLAG_SKIP))
> 

yes it makes sense.

> I don't really like pfi_set_flags() and pfi_clear_flags()
> and their ioctls DIOCSETIFFLAG and DIOCCLRIFFLAG. There are no checks for
> valid flag combinations. So anything goes for these functions.
> Also should the name check not happen in the ioctl handler and return
> EINVAL for bad input?
> 

the thing is that empty string acts as a kind of wildcard pfi_skip_if()
matches anything if 'name' is NULL or empty string. So I'm keeping sanity
check in pfi_set_flags().

But it it still worth to add test for io == NULL to DIOCSETIFFLAG
and to DIOCCLRIFFLAG to avoid NULL pointer dereference (NULL->pfiio_name)

updated diff is below.


thanks and
regards
sashan

8<---8<---8<--8<
diff --git a/share/man/man5/pf.conf.5 b/share/man/man5/pf.conf.5
index bff448aa8dc..4afe841651f 100644
--- a/share/man/man5/pf.conf.5
+++ b/share/man/man5/pf.conf.5
@@ -1383,9 +1383,6 @@ Packets passing in or out on such interfaces are passed 
as if pf was
 disabled, i.e. pf does not process them in any way.
 This can be useful on loopback and other virtual interfaces, when
 packet filtering is not desired and can have unexpected effects.
-.Ar ifspec
-is only evaluated when the ruleset is loaded; interfaces created
-later will not be skipped.
 PF filters traffic on all interfaces by default.
 .It Ic set Cm state-defaults Ar state-option , ...
 The
diff --git a/sys/net/if.c b/sys/net/if.c
index 2e9a968d7cc..a6d3cb4f4ac 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -2725,6 +2725,7 @@ if_addgroup(struct ifnet *ifp, const char *groupname)
 
 #if NPF > 0
pfi_group_addmember(groupname, ifp);
+   pfi_xcommit();
 #endif
 
return (0);
@@ -2757,7 +2758,7 @@ if_delgroup(struct ifnet *ifp, const char *groupname)
}
 
 #if NPF > 0
-   pfi_group_change(groupname);
+   pfi_group_delmember(groupname, ifp);
 #endif
 
KASSERT(ifgl->ifgl_group->ifg_refcnt != 0);
@@ -2769,6 +2770,10 @@ if_delgroup(struct ifnet *ifp, const char *groupname)
free(ifgl->ifgl_group, M_TEMP, sizeof(*ifgl->ifgl_group));
}
 
+#if NPF > 0
+   pfi_xcommit();
+#endif
+
free(ifgl, M_TEMP, sizeof(*ifgl));
 
return (0);
diff --git a/sys/net/pf_if.c b/sys/net/pf_if.c
index 8de37375ab4..22d5937ec1d 100644
--- a/sys/net/pf_if.c
+++ b/sys/net/pf_if.c
@@ -57,6 +57,10 @@
 #include 
 #endif /* INET6 */
 
+#define isupper(c) ((c) >= 'A' && (c) <= 'Z')
+#define islower(c) ((c) >= 'a' && (c) <= 'z')
+#define isalpha(c) (isupper(c)||islower(c))
+
 struct pfi_kif  *pfi_all = NULL;
 struct pool  pfi_addr_pl;
 struct pfi_ifheadpfi_ifs;
@@ -75,6 +79,7 @@ void   pfi_address_add(struct sockaddr *, 
sa_family_t, u_int8_t);
 int pfi_if_compare(struct pfi_kif *, struct pfi_kif *);
 int pfi_skip_if(const char *, struct pfi_kif *);
 int pfi_unmask(void *);
+voidpfi_group_change(const char *);
 
 RB_PROTOTYPE(pfi_ifhead, pfi_kif, pfik_tree, pfi_if_compare);
 RB_GENERATE(pfi_ifhead, pfi_kif, pfik_tree, pfi_if_compare);
@@ -187,6 +192,9 @@ pfi_kif_ref(struct pfi_kif *kif, enum pfi_kif_refs what)
case PFI_KIF_REF_SRCNODE:
kif->pfik_srcnodes++;
break;
+   case PFI_KIF_REF_FLAG:
+   kif->pfik_flagrefs++;
+   break;
default:
panic("pfi_kif_ref with unknown type");
}
@@ -204,7 +212,8 @@ pfi_kif_unref(struct pfi_kif *kif, enum pfi_kif_refs what)
case PFI_KIF_REF_RULE:
if (kif->pfik_rules <= 0) {
DPFPRINTF(LOG_ERR,
-   

Re: ksh: diff to add tab completion for '..'

2021-11-26 Thread Jeremy Evans
On Fri, Nov 26, 2021 at 5:57 AM Luís Henriques  wrote:

> On Sun, Nov 21, 2021 at 03:36:33PM +, Luís Henriques wrote:
> > Hi!
> >
> > I always found it annoying that, in ksh, doing:
> >
> >   $ ls ..
> >
> > followed by TAB doesn't allow me to list the options (i.e. show
> files/dirs
> > in '..').  I need to do add a trailing '/' to this 'ls' command in order
> > to have the completions listed.
>
> ping.  I'm just wondering if this is something worth pursuing or if people
> aren't simply interested and I should drop it.
>


`ls .` lists files in the current directory starting with `.`.  `ls
./` lists files in the current directory (other than files starting
with `.`, which are hidden). So I think it makes sense that `ls ..`
would list files in the current directory starting with `..`, which is what
it currently does.

Thanks,
Jeremy


Re: ixl cksum offloading sparc64 panic

2021-11-26 Thread Theo de Raadt
> That is hard for me, to decide.  My main motivation was, that It looks
> a bit odd to me, that we first assemble a complete packet for network.
> But, one step before sending it out, we have to parse it again, to get
> some values.

The packet has to be parsed because the values in the packet are
authoritative.

INSTEAD, with your proposal those values are now cached in a seperate
place, and if ever high-level code change forgets to keep them
syncronized, there will be problems, but only in a few drivers.

Rare-use caches are dangerous design.

I bet you it takes less than 5 years before someone developer forgets
to keep these variables syncronized.



Re: ixl cksum offloading sparc64 panic

2021-11-26 Thread Theo de Raadt
This consumes a bunch extra bytes per mbuf on _all systems_, regardless of
whether they have offload support or not.

How many bytes? the addition of ph_eth_type adds 2 bytes misaligned before
the int, so padding happens there.  Everything misaligns oddly because of
the struct pkthdr_pf containing a pointer, which that object pointer align.
On amd64, this goes from 64 to 72.  So 8 extra bytes.

Is the size a fair tradeoff???

Is setting fields when majority of drivers don't look at them a fair
tradeoff?

Is there a possibility that in the future someone will make code
changes and forget to update these "cached" fields, because 99% of
drivers work fine without the fields, and introduce a problem only
observable in 1 driver?

All those things together... I don't think this is the right way.





Re: Pass -U to pgrep and pkill in rc.subr(8)

2021-11-26 Thread Vincent Lee


Stuart Henderson  writes:

> Yes that will break a lot of existing scripts, also it is probably not needed 
> - rc.subr uses the process name *and arguments*, if you're
> using default top options you'll only see the name, use top -C or ps to check 
> as there is probably more that you can match on.

Great, thanks for the info.



pfkey tdb_unref error case

2021-11-26 Thread Alexander Bluhm
Hi,

Using void* for temporary allocated TDB in pfkeyv2 does not make
sense.  It looks like this is from a time before we had TDB pools.

Do not use the freeme pointer for TDB in pfkeyv2_send().  The pattern
is tdb_alloc() and tdb_unref() in case of error.  Replace tdb_free()
in reserve_spi() with tdb_unref() to keep this pattern consistent.
Only tdb_unref() should call tdb_free().

No functional change.

ok?

bluhm

Index: net/pfkeyv2.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/net/pfkeyv2.c,v
retrieving revision 1.222
diff -u -p -r1.222 pfkeyv2.c
--- net/pfkeyv2.c   25 Nov 2021 13:46:02 -  1.222
+++ net/pfkeyv2.c   25 Nov 2021 22:43:04 -
@@ -1327,22 +1327,18 @@ pfkeyv2_send(struct socket *so, void *me
int alg;
 
/* Create new TDB */
-   freeme_sz = 0;
-   freeme = tdb_alloc(rdomain);
-   bzero(&ii, sizeof(struct ipsecinit));
-
-   newsa = (struct tdb *) freeme;
+   newsa = tdb_alloc(rdomain);
newsa->tdb_satype = smsg->sadb_msg_satype;
 
if ((rval = pfkeyv2_get_proto_alg(newsa->tdb_satype,
&newsa->tdb_sproto, &alg))) {
-   tdb_unref(freeme);
-   freeme = NULL;
+   tdb_unref(newsa);
NET_UNLOCK();
goto ret;
}
 
/* Initialize SA */
+   bzero(&ii, sizeof(struct ipsecinit));
import_sa(newsa, headers[SADB_EXT_SA], &ii);
import_address(&newsa->tdb_src.sa,
headers[SADB_EXT_ADDRESS_SRC]);
@@ -1372,8 +1368,7 @@ pfkeyv2_send(struct socket *so, void *me
headers[SADB_X_EXT_DST_MASK],
headers[SADB_X_EXT_PROTOCOL],
headers[SADB_X_EXT_FLOW_TYPE]))) {
-   tdb_unref(freeme);
-   freeme = NULL;
+   tdb_unref(newsa);
NET_UNLOCK();
goto ret;
}
@@ -1395,8 +1390,7 @@ pfkeyv2_send(struct socket *so, void *me
rval = tdb_init(newsa, alg, &ii);
if (rval) {
rval = EINVAL;
-   tdb_unref(freeme);
-   freeme = NULL;
+   tdb_unref(newsa);
NET_UNLOCK();
goto ret;
}
@@ -1405,8 +1399,7 @@ pfkeyv2_send(struct socket *so, void *me
 
/* Delete old version of the SA, insert new one */
tdb_delete(sa2);
-   puttdb((struct tdb *) freeme);
-   freeme = NULL;
+   puttdb(newsa);
} else {
/*
 * The SA is already initialized, so we're only allowed 
to
@@ -1498,26 +1491,24 @@ pfkeyv2_send(struct socket *so, void *me
goto ret;
}
 
-   /* Allocate and initialize new TDB */
-   freeme_sz = 0;
-   freeme = tdb_alloc(rdomain);
-
{
-   struct tdb *newsa = (struct tdb *) freeme;
+   struct tdb *newsa;
struct ipsecinit ii;
int alg;
 
-   bzero(&ii, sizeof(struct ipsecinit));
-
+   /* Create new TDB */
+   newsa = tdb_alloc(rdomain);
newsa->tdb_satype = smsg->sadb_msg_satype;
+
if ((rval = pfkeyv2_get_proto_alg(newsa->tdb_satype,
&newsa->tdb_sproto, &alg))) {
-   tdb_unref(freeme);
-   freeme = NULL;
+   tdb_unref(newsa);
NET_UNLOCK();
goto ret;
}
 
+   /* Initialize SA */
+   bzero(&ii, sizeof(struct ipsecinit));
import_sa(newsa, headers[SADB_EXT_SA], &ii);
import_address(&newsa->tdb_src.sa,
headers[SADB_EXT_ADDRESS_SRC]);
@@ -1550,8 +1541,7 @@ pfkeyv2_send(struct socket *so, void *me
headers[SADB_X_EXT_DST_MASK],
headers[SADB_X_EXT_PROTOCOL],
headers[SADB_X_EXT_FLOW_TYPE]))) {
-   tdb_unref(freeme

Re: Stop building the kernel with -Wno-uninitialized on clang archs

2021-11-26 Thread Jan Stary
> > Stop building the kernel with -Wno-uninitialized on clang archs.
> > This hides real problems like the recently fixed uninitialised memory
> > use in pf and igc.
> > 
> > [-Wsometimes-uninitialized] /sys/arch/arm/arm/cpu.c:352:6: warning: 
> > variable 'ci' is used uninitialized whenever 'if' condition is false
> > [-Wsometimes-uninitialized] /sys/arch/arm64/arm64/cpu.c:613:6: warning: 
> > variable 'ci' is used uninitialized whenever 'if' condition is false
> > [-Wsometimes-uninitialized] /sys/arch/riscv64/riscv64/cpu.c:169:6: warning: 
> > variable 'ci' is used uninitialized whenever 'if' condition is false
> > [-Wsometimes-uninitialized] /tmp/src/sys/arch/powerpc/powerpc/trap.c:467:7: 
> > error: variable 'offset' is used uninitialized whenever 'if' condition is 
> > false
> > [-Wuninitialized] /sys/arch/arm64/dev/acpiiort.c:174:28: warning: variable 
> > 'rid' is uninitialized when used here
> > 
> > cpu.c warnings occur with MULTIPROCESSOR not defined
> > powerpc trap.c occurs with DDB not defined
> > 
> > patch to address these and remove the flag below
> > acpiiort part from patrick@

On each of the following platforms, the kernel builds fine for me
with this patch and the compilation shows none of the above warnings.

i386   (ALIX.1E)
amd64  (Thinkpad T400)
arm64  (Raspberry Pi 3 and 4)
armv7  (BeagleBone Black)
macppc (Mac Mini 7447A)


Jan

> > Index: arch/amd64/conf/Makefile.amd64
> > ===
> > RCS file: /cvs/src/sys/arch/amd64/conf/Makefile.amd64,v
> > retrieving revision 1.121
> > diff -u -p -r1.121 Makefile.amd64
> > --- arch/amd64/conf/Makefile.amd64  12 Jul 2021 06:07:33 -  1.121
> > +++ arch/amd64/conf/Makefile.amd64  26 Nov 2021 04:54:10 -
> > @@ -48,7 +48,7 @@ INCLUDES= -nostdinc -I$S -I${.OBJDIR} -I
> >  CPPFLAGS=  ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -MD -MP \
> > -DCONFIG_DRM_AMD_DC_DCN3_0
> >  CWARNFLAGS=-Werror -Wall -Wimplicit-function-declaration \
> > -   -Wno-uninitialized -Wno-pointer-sign \
> > +   -Wno-pointer-sign \
> > -Wframe-larger-than=2047
> >  
> >  CMACHFLAGS=-mcmodel=kernel -mno-red-zone -mno-sse2 -mno-sse 
> > -mno-3dnow \
> > Index: arch/arm/arm/cpu.c
> > ===
> > RCS file: /cvs/src/sys/arch/arm/arm/cpu.c,v
> > retrieving revision 1.55
> > diff -u -p -r1.55 cpu.c
> > --- arch/arm/arm/cpu.c  25 Mar 2021 04:12:00 -  1.55
> > +++ arch/arm/arm/cpu.c  23 Nov 2021 00:19:43 -
> > @@ -349,14 +349,11 @@ cpu_attach(struct device *parent, struct
> > __asm volatile("mrc p15, 0, %0, c0, c0, 5" : "=r"(mpidr));
> > KASSERT(faa->fa_nreg > 0);
> >  
> > +#ifdef MULTIPROCESSOR
> > if (faa->fa_reg[0].addr == (mpidr & MPIDR_AFF)) {
> > ci = &cpu_info_primary;
> > -#ifdef MULTIPROCESSOR
> > ci->ci_flags |= CPUF_RUNNING | CPUF_PRESENT | CPUF_PRIMARY;
> > -#endif
> > -   }
> > -#ifdef MULTIPROCESSOR
> > -   else {
> > +   } else {
> > ci = malloc(sizeof(*ci), M_DEVBUF, M_WAITOK | M_ZERO);
> > cpu_info[dev->dv_unit] = ci;
> > ci->ci_next = cpu_info_list->ci_next;
> > @@ -364,6 +361,8 @@ cpu_attach(struct device *parent, struct
> > ci->ci_flags |= CPUF_AP;
> > ncpus++;
> > }
> > +#else
> > +   ci = &cpu_info_primary;
> >  #endif
> >  
> > ci->ci_dev = dev;
> > Index: arch/arm64/arm64/cpu.c
> > ===
> > RCS file: /cvs/src/sys/arch/arm64/arm64/cpu.c,v
> > retrieving revision 1.58
> > diff -u -p -r1.58 cpu.c
> > --- arch/arm64/arm64/cpu.c  23 Nov 2021 01:03:35 -  1.58
> > +++ arch/arm64/arm64/cpu.c  23 Nov 2021 01:28:26 -
> > @@ -604,20 +604,19 @@ cpu_attach(struct device *parent, struct
> >  {
> > struct fdt_attach_args *faa = aux;
> > struct cpu_info *ci;
> > +#ifdef MULTIPROCESSOR
> > uint64_t mpidr = READ_SPECIALREG(mpidr_el1);
> > +#endif
> > uint64_t id_aa64mmfr1, sctlr;
> > uint32_t opp;
> >  
> > KASSERT(faa->fa_nreg > 0);
> >  
> > +#ifdef MULTIPROCESSOR
> > if (faa->fa_reg[0].addr == (mpidr & MPIDR_AFF)) {
> > ci = &cpu_info_primary;
> > -#ifdef MULTIPROCESSOR
> > ci->ci_flags |= CPUF_RUNNING | CPUF_PRESENT | CPUF_PRIMARY;
> > -#endif
> > -   }
> > -#ifdef MULTIPROCESSOR
> > -   else {
> > +   } else {
> > ci = malloc(sizeof(*ci), M_DEVBUF, M_WAITOK | M_ZERO);
> > cpu_info[dev->dv_unit] = ci;
> > ci->ci_next = cpu_info_list->ci_next;
> > @@ -625,6 +624,8 @@ cpu_attach(struct device *parent, struct
> > ci->ci_flags |= CPUF_AP;
> > ncpus++;
> > }
> > +#else
> > +   ci = &cpu_info_primary;
> >  #endif
> >  
> > ci->ci_dev = dev;
> > Index: arch/arm64/conf/Makefile.arm64
> > ===
> > RCS file: /cvs/src/sys/a

Re: ipsec: refactor TDBF_DELETED

2021-11-26 Thread Hrvoje Popovski
On 25.11.2021. 17:13, Tobias Heider wrote:
> On Thu, Nov 25, 2021 at 03:50:29PM +0100, Tobias Heider wrote:
>> As discussed in the previous thread we can simplify the tdb cleanup
>> code by removing the TDBF_DELETED flag and instead checking if the
>> tdb was already unlinked.
>>
>> ok?
>>
> 
> Now with the missing parts from pfkeyv2.c as noticed by Hrvoje.
> 


I'm hitting this diff for 24 hours and i can't get panic ...




Re: ksh: diff to add tab completion for '..'

2021-11-26 Thread Luís Henriques
On Sun, Nov 21, 2021 at 03:36:33PM +, Luís Henriques wrote:
> Hi!
> 
> I always found it annoying that, in ksh, doing:
> 
>   $ ls ..
> 
> followed by TAB doesn't allow me to list the options (i.e. show files/dirs
> in '..').  I need to do add a trailing '/' to this 'ls' command in order
> to have the completions listed.

ping.  I'm just wondering if this is something worth pursuing or if people
aren't simply interested and I should drop it.

Cheers,
--
Luís
> 
> This diff makes this work without the trailing '/', but I'll be honest:
> I'm not familiar with this code which does all sort of complex parsing
> stuff.  So... yeah, I may be breaking something somewhere.
> 
> Cheers,
> --
> Luís
> 
> diff 6911632ba3a60c1920af7c2d3d79a0a56f9f2d4c /usr/src
> blob - 3089d195d2084b3fa81196fa359818ec914c54b0
> file + bin/ksh/edit.c
> --- bin/ksh/edit.c
> +++ bin/ksh/edit.c
> @@ -701,7 +701,10 @@ add_glob(const char *str, int slen)
>   if (slen < 0)
>   return NULL;
>  
> - toglob = str_nsave(str, slen + 1, ATEMP); /* + 1 for "*" */
> + /*
> +  * + 2 for '*' and for '/' if str is '..'
> +  */
> + toglob = str_nsave(str, slen + 2, ATEMP); /* + 1 for "*" */
>   toglob[slen] = '\0';
>  
>   /*
> @@ -720,8 +723,15 @@ add_glob(const char *str, int slen)
>   saw_slash = true;
>   }
>   if (!*s && (*toglob != '~' || saw_slash)) {
> - toglob[slen] = '*';
> - toglob[slen + 1] = '\0';
> + /* If we're dealing with '..' */
> + if (slen == 2 && toglob[0] == '.' && toglob[1] == '.') {
> + toglob[slen] = '/';
> + toglob[slen + 1] = '*';
> + toglob[slen + 2] = '\0';
> + } else {
> + toglob[slen] = '*';
> + toglob[slen + 1] = '\0';
> + }
>   }
>  
>   return toglob;
> 



sppp(4)/pppoe(4) - avoid endless loop in remote ip negotiation

2021-11-26 Thread Krzysztof Kanas
Hi. When remote side in sppp doesn't reply for to PPP IPCP IP-Address 
sppp will try to negotiate remote IP in endless loop. Instead use 
10.64.64.1 + if_index as remote IP.

While at it maybe it's worth to add that SPP is in RFC 1332 ?

Krzysztof Kanas

Index: share/man/man4/sppp.4
===
RCS file: /home/cvs//src/share/man/man4/sppp.4,v
retrieving revision 1.26
diff -r1.26 sppp.4
284,285c284,285
< Negotiation loop avoidance is not fully implemented.
< If the negotiation doesn't converge, this can cause an endless loop.
---
> In case when remote IP can't be negotiation after 10 retries pick 
> 10.64.64.1 + if_index.
Index: sys/net/if_sppp.h
===
RCS file: /home/cvs//src/sys/net/if_sppp.h,v
retrieving revision 1.30
diff -r1.30 if_sppp.h
148a149,150
> #define IPCP_HISADDR_COUNTER_MAX  10
>   u_int8_t hisaddr_counter;/* number of ipcp req for peer addr */
Index: sys/net/if_spppsubr.c
===
RCS file: /home/cvs//src/sys/net/if_spppsubr.c,v
retrieving revision 1.190
diff -r1.190 if_spppsubr.c
2466,2468c2466,2469
<* XXX This can result in an endless req - nak loop if peer
<* doesn't want to send us his address.  Q: What should we do
<* about it?  XXX  A: implement the max-failure counter.
---
>* This can result in an endless req - nak loop if peer
>* doesn't want to send us his address. Therefore we count
>* the number of request if it exceeds IPCP_HISADDR_COUNTER_MAX
>* assign remote address 10.64.64.1 + if_index.
2471,2479c2472,2492
<   buf[0] = IPCP_OPT_ADDRESS;
<   buf[1] = 6;
<   buf[2] = hisaddr >> 24;
<   buf[3] = hisaddr >> 16;
<   buf[4] = hisaddr >> 8;
<   buf[5] = hisaddr;
<   rlen = 6;
<   if (debug)
<   addlog("still need hisaddr ");
---
>   if (sp->ipcp.hisaddr_counter++ > IPCP_HISADDR_COUNTER_MAX) {
>   sp->ipcp.hisaddr_counter = 0;
>   desiredaddr = 10 << 24 | 64 << 16 | 64 << 8 | 1;
>   desiredaddr += sp->pp_if.if_index;
>   hisaddr = desiredaddr;
>   sp->ipcp.req_hisaddr = desiredaddr;
>   sp->ipcp.flags |= IPCP_HISADDR_SEEN;
>   if (debug)
>   addlog("%s guess ",
>   sppp_dotted_quad(desiredaddr));
>   } else {
>   buf[0] = IPCP_OPT_ADDRESS;
>   buf[1] = 6;
>   buf[2] = hisaddr >> 24;
>   buf[3] = hisaddr >> 16;
>   buf[4] = hisaddr >> 8;
>   buf[5] = hisaddr;
>   rlen = 6;
>   if (debug)
>   addlog("still need hisaddr ");
>   }



Re: [External] : Stop building the kernel with -Wno-uninitialized on clang archs

2021-11-26 Thread Alexandr Nedvedicky
Hello,

On Fri, Nov 26, 2021 at 10:14:47PM +1100, Jonathan Gray wrote:
> On Fri, Nov 26, 2021 at 12:04:21PM +0100, Alexandr Nedvedicky wrote:
> > Hello,
> > 
> > On Fri, Nov 26, 2021 at 04:32:59PM +1100, Jonathan Gray wrote:
> > > Stop building the kernel with -Wno-uninitialized on clang archs.
> > > This hides real problems like the recently fixed uninitialised memory
> > > use in pf and igc.
> > 
> > yes, please. I'd like to have the warning enabled.
> > I'm just able to build amd64,i386 only, not other archs
> > so can't OK those archs.
> > 
> > amd64 builds with warning enabled.
> > 
> > i386 seems to rquire  two touches below. those diffs are just my wild
> > guess to keep build running. I'm far from saying it's correct
> > fix.
> 
> Update your tree, I committed changes to these files a few days ago.

yes indeed, problem at my side.

so amd64,i386 is OK by me.


thanks and
regards
sashan



Re: [External] : Re: make 'set skip on ...' dynamic

2021-11-26 Thread Claudio Jeker
On Thu, Nov 25, 2021 at 02:56:02PM +0100, Alexandr Nedvedicky wrote:
> Hello,
> 
> thank you for taking a look at my diff.
> 
> 
> 
> > >   }
> > >  
> > > - if (kif->pfik_ifp != NULL || kif->pfik_group != NULL || kif == pfi_all)
> > > + if (kif->pfik_ifp != NULL || kif->pfik_group != NULL ||kif == pfi_all)
> > 
> > Missing space over^^^ here
> 
> fixed, looks like unintended change
> > > + if (found == 0) {
> > > + if (name == NULL)
> > > + return (0);
> > > +
> > > + n = strlen(name);
> > > + if ((n < 1) || (n >= IFNAMSIZ))
> > I would just use:
> > if (n < 1 || n >= IFNAMSIZ)
> > like in other places.
> 
> sure.
> 
> > 
> > > + return (0);
> > > +
> > > + if (((name[0] < 'a') || (name[0] > 'z')) ||
> > > + ((name[0] < 'A') && (name[0] > 'Z')))
> > > + return (0);
> > 
> > Not sure what you're after here. The logic of this construct is incorrect.
> > I would steal the defines from libsa/stand.h and then us !isalpha:
> > 
> > #define isupper(c)  ((c) >= 'A' && (c) <= 'Z')
> > #define islower(c)  ((c) >= 'a' && (c) <= 'z')
> > #define isalpha(c)  (isupper(c)||islower(c))
> > 
> > if (!isalpha(name[0]))
> > return (0);
> > 
> > You can also expand the defines if you want.
> > I feel the intention here is to check if this is a interface group. So
> > maybe using the check in pfi_skip_if() would be better:
> > 
> > if (name[n-1] >= '0' && name[n-1] <= '9')
> > return (0); /* group names may not end in a digit */
> > 
> 
> it is just sanity check we deal with either interface or group,
> so isalpha(name[0]) is exactly what I want. And thanks for tip
> to steal it from libsa/stand.h. Perhaps one day some day there
> will be ctype.h for for kernel as well.
> 
> the reason to add this extra check is that I want to be sure we eventually
> don't create interface, which starts with space (white char).
> 
> Remember former code did not create interface (kif object), it just walked
> through list of existing interfaces in table. Now the DIOCSETIFFLAG ioctl
> needs to be more cautious.
> 
> 
> updated diff is below.

One more thing to consider, I think the following test in pfi_set_flags():

> + if ((p->pfik_flags_new != p->pfik_flags) &&
> + (p->pfik_flagrefs == 0))
> + pfi_kif_ref(p, PFI_KIF_REF_FLAG);

should actually check for the PFI_IFLAG_SKIP flag and not any flag.

if (ISSET(p->pfik_flags_new, PFI_IFLAG_SKIP) &&
p->pfik_flagrefs == 0)
pfi_kif_ref(p, PFI_KIF_REF_FLAG);

Same goes for pfi_clear_flags() just in reverse:

> + if ((p->pfik_flags_new != p->pfik_flags) &&
> + (p->pfik_flagrefs == 1))
> + pfi_kif_unref(p, PFI_KIF_REF_FLAG);

Should be changed to:
if (!ISSET(p->pfik_flags_new, PFI_IFLAG_SKIP) &&
p->pfik_flagrefs == 1)
pfi_kif_unref(p, PFI_KIF_REF_FLAG);

We only want to track the PFI_IFLAG_SKIP flag but not any other flag like
PFI_IFLAG_ANY. At least I think we want to do that, but then I guess
pfi_set_flags() should only add a kif
if (found == 0 && ISSET(flags, PFI_IFLAG_SKIP))

I don't really like pfi_set_flags() and pfi_clear_flags()
and their ioctls DIOCSETIFFLAG and DIOCCLRIFFLAG. There are no checks for
valid flag combinations. So anything goes for these functions.
Also should the name check not happen in the ioctl handler and return
EINVAL for bad input?

 
> 8<---8<---8<--8<
> index 8de37375ab4..383b8c38f6a 100644
> --- a/sys/net/pf_if.c
> +++ b/sys/net/pf_if.c
> +void
> +pfi_group_delmember(const char *group, struct ifnet *ifp)
> +{
> + struct pfi_kif  *gkif, *ikif;
> +
> + if ((gkif = pfi_kif_get(group, NULL)) == NULL ||
> + (ikif = pfi_kif_get(ifp->if_xname, NULL)) == NULL)
> + panic("%s: pfi_kif_get failed", __func__);
> + ikif->pfik_flags_new = ikif->pfik_flags & ~gkif->pfik_flags;
> +
> + pfi_group_change(group);
> +}
> +
>  void
>  pfi_group_addmember(const char *group, struct ifnet *ifp)
>  {
> @@ -361,7 +395,7 @@ pfi_group_addmember(const char *group, struct ifnet *ifp)
>   if ((gkif = pfi_kif_get(group, NULL)) == NULL ||
>   (ikif = pfi_kif_get(ifp->if_xname, NULL)) == NULL)
>   panic("%s: pfi_kif_get failed", __func__);
> - ikif->pfik_flags |= gkif->pfik_flags;
> + ikif->pfik_flags_new = ikif->pfik_flags | gkif->pfik_flags;
>  
>   pfi_group_change(group);
>  }
> @@ -786,25 +820,64 @@ int
>  pfi_set_flags(const char *name, int flags)
>  {
>   struct pfi_kif  *p;
> + int found = 0;
> + size_t n;
>  

Re: [External] : Stop building the kernel with -Wno-uninitialized on clang archs

2021-11-26 Thread Jonathan Gray
On Fri, Nov 26, 2021 at 12:04:21PM +0100, Alexandr Nedvedicky wrote:
> Hello,
> 
> On Fri, Nov 26, 2021 at 04:32:59PM +1100, Jonathan Gray wrote:
> > Stop building the kernel with -Wno-uninitialized on clang archs.
> > This hides real problems like the recently fixed uninitialised memory
> > use in pf and igc.
> 
> yes, please. I'd like to have the warning enabled.
> I'm just able to build amd64,i386 only, not other archs
> so can't OK those archs.
> 
> amd64 builds with warning enabled.
> 
> i386 seems to rquire  two touches below. those diffs are just my wild
> guess to keep build running. I'm far from saying it's correct
> fix.

Update your tree, I committed changes to these files a few days ago.

> 
> thank you for proposing this change.
> 
> regards
> sashan
> 
> 8<---8<---8<--8<
> diff --git a/sys/dev/ic/tea5757.c b/sys/dev/ic/tea5757.c
> index 3a4bafa3dc6..d416a80e382 100644
> --- a/sys/dev/ic/tea5757.c
> +++ b/sys/dev/ic/tea5757.c
> @@ -159,7 +159,7 @@ tea5757_encode_lock(u_int8_t lock)
>   ret = TEA5757_S010;
>   else if (lock > 14 && lock < 51)
>   ret = TEA5757_S030;
> - else if (lock > 50)
> + else
>   ret = TEA5757_S150;
>  
>   return ret;
> diff --git a/sys/dev/pci/fmsradio.c b/sys/dev/pci/fmsradio.c
> index 5ab13f2ea5b..07310664603 100644
> --- a/sys/dev/pci/fmsradio.c
> +++ b/sys/dev/pci/fmsradio.c
> @@ -537,7 +537,8 @@ fmsradio_get_info(void *v, struct radio_info *ri)
>   ri->info |= buf & PCR_INFO_STEREO ? 0 : RADIO_INFO_STEREO;
>   break;
>   default:
> - break;
> + ri->rfreq = 0;
> + return (-1);
>   }
>  
>   ri->freq = radio->freq = tea5757_decode_freq(buf,
> 
> 



Re: [External] : Stop building the kernel with -Wno-uninitialized on clang archs

2021-11-26 Thread Alexandr Nedvedicky
Hello,

On Fri, Nov 26, 2021 at 04:32:59PM +1100, Jonathan Gray wrote:
> Stop building the kernel with -Wno-uninitialized on clang archs.
> This hides real problems like the recently fixed uninitialised memory
> use in pf and igc.

yes, please. I'd like to have the warning enabled.
I'm just able to build amd64,i386 only, not other archs
so can't OK those archs.

amd64 builds with warning enabled.

i386 seems to rquire  two touches below. those diffs are just my wild
guess to keep build running. I'm far from saying it's correct
fix.

thank you for proposing this change.

regards
sashan

8<---8<---8<--8<
diff --git a/sys/dev/ic/tea5757.c b/sys/dev/ic/tea5757.c
index 3a4bafa3dc6..d416a80e382 100644
--- a/sys/dev/ic/tea5757.c
+++ b/sys/dev/ic/tea5757.c
@@ -159,7 +159,7 @@ tea5757_encode_lock(u_int8_t lock)
ret = TEA5757_S010;
else if (lock > 14 && lock < 51)
ret = TEA5757_S030;
-   else if (lock > 50)
+   else
ret = TEA5757_S150;
 
return ret;
diff --git a/sys/dev/pci/fmsradio.c b/sys/dev/pci/fmsradio.c
index 5ab13f2ea5b..07310664603 100644
--- a/sys/dev/pci/fmsradio.c
+++ b/sys/dev/pci/fmsradio.c
@@ -537,7 +537,8 @@ fmsradio_get_info(void *v, struct radio_info *ri)
ri->info |= buf & PCR_INFO_STEREO ? 0 : RADIO_INFO_STEREO;
break;
default:
-   break;
+   ri->rfreq = 0;
+   return (-1);
}
 
ri->freq = radio->freq = tea5757_decode_freq(buf,



Re: rpki-client: make maximum number of publication points to sync operator configurable

2021-11-26 Thread Theo de Raadt
I don't agree with any of these reasons.

These limits have been considered carefully.  At this time, there is no
known justification for someone in the 'network admin' role to change
any of them.

We do not know what a future 'emergency' would look like, but I doubt it
would look like "oh I know, I want to change this specific maximum'.

I'm sorry, but I don't believe software should be infinitely reconfigurable
in complex ways.

If people hit real problems, they need to communicate within the culture
and have the experts not just reconsider the limits, but also these various
self-defense mechanisms they are part of, and in most cases code will
get rewritten, not just some number.
 
Jeroen Massar  wrote:

> (chiming in from the sidelines)
> (TLDR: Use a scary looking env variable instead.)
> 
> > On 20211126, at 24:50, Theo de Raadt  wrote:
> > 
> > [..]
> > There are huge benefits to having a userbase running with the same
> > choices.  I don't see evidence that throw that away, by giving them
> > options which encourage fragmented usage patterns.
> 
> I mostly agree with that.
> 
> Though for emergency cases, it might be quicker for people to be able
> to set a documented but otherwise obscure environment variable that has big
> warnings that one should normally not set that, than recompiling code
> they have not recompiled in a while and afterward might not upgrade.
> 
> A command line option has less of a "don't change" feeling to it as that
> makes it an option.
> 
> Naming it the overlong RPKICLIENT_EMERGENCY_MAX_REPO_PER_TAL environment
> variable will dissuade people from changing it (and if they do, their choice)
> while avoiding having to recompile code (and then having a custom built not
> being upgraded with syspatch the next update)
> 
> Same goes for the portable edition, where the distribution's maintainer might
> override the value because "we know better, there was an emergency once" or
> who then implements that code, badly, themselves.
> 
> (At least we have Marco d'Itri taking care of Debian packages and he would
>  no do that, but the possibility still exists ;)
> 
> Greets,
>  Jeroen
> 



update iwx(4) firmware to -67

2021-11-26 Thread Stefan Sperling
This patch updates iwx(4) to new firmware images (API version -67).

Intel has published a related security advisory:
https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00509.html

Make sure to get a fresh kernel from -current sources and update
to iwx-firmware-20211101 with fw_update before trying this patch.
The new firmware version shows as "fw ver 67.8f59b80b.0" in dmesg.
I have tested on AX200 and AX201 and I am not seeing any issues.

iwx(4) devices which are using the iwx-Qu-c0-hr-b0-63 image did
not receive a firmware update. I cannot tell why.

ok?

 
diff 777a5184786f624f57b85b8460919a1130498508 
1d9e5ec96bf733cdb7c339f7179b945ff1e0a937
blob - 1d87b3522c60081eac0b0f54cdd772984de4b340
blob + d48e22237cb568cb0bed6a49e82d3be6d4744da4
--- sys/dev/pci/if_iwx.c
+++ sys/dev/pci/if_iwx.c
@@ -9266,7 +9266,7 @@ iwx_attach(struct device *parent, struct device *self,
 
switch (PCI_PRODUCT(pa->pa_id)) {
case PCI_PRODUCT_INTEL_WL_22500_1:
-   sc->sc_fwname = "iwx-cc-a0-63";
+   sc->sc_fwname = "iwx-cc-a0-67";
sc->sc_device_family = IWX_DEVICE_FAMILY_22000;
sc->sc_integrated = 0;
sc->sc_ltr_delay = IWX_SOC_FLAGS_LTR_APPLY_DELAY_NONE;
@@ -9283,7 +9283,7 @@ iwx_attach(struct device *parent, struct device *self,
return;
}
 
-   sc->sc_fwname = "iwx-QuZ-a0-hr-b0-63";
+   sc->sc_fwname = "iwx-QuZ-a0-hr-b0-67";
sc->sc_device_family = IWX_DEVICE_FAMILY_22000;
sc->sc_integrated = 1;
sc->sc_ltr_delay = IWX_SOC_FLAGS_LTR_APPLY_DELAY_200;



Re: Stop building the kernel with -Wno-uninitialized on clang archs

2021-11-26 Thread Mark Kettenis
> Date: Fri, 26 Nov 2021 16:32:59 +1100
> From: Jonathan Gray 
> 
> Stop building the kernel with -Wno-uninitialized on clang archs.
> This hides real problems like the recently fixed uninitialised memory
> use in pf and igc.
> 
> After visa's recent commit the remaining warnings are
> 
> [-Wsometimes-uninitialized] /sys/arch/arm/arm/cpu.c:352:6: warning: variable 
> 'ci' is used uninitialized whenever 'if' condition is false
> [-Wsometimes-uninitialized] /sys/arch/arm64/arm64/cpu.c:613:6: warning: 
> variable 'ci' is used uninitialized whenever 'if' condition is false
> [-Wsometimes-uninitialized] /sys/arch/riscv64/riscv64/cpu.c:169:6: warning: 
> variable 'ci' is used uninitialized whenever 'if' condition is false
> [-Wsometimes-uninitialized] /tmp/src/sys/arch/powerpc/powerpc/trap.c:467:7: 
> error: variable 'offset' is used uninitialized whenever 'if' condition is 
> false
> [-Wuninitialized] /sys/arch/arm64/dev/acpiiort.c:174:28: warning: variable 
> 'rid' is uninitialized when used here
> 
> cpu.c warnings occur with MULTIPROCESSOR not defined
> powerpc trap.c occurs with DDB not defined
> 
> patch to address these and remove the flag below
> acpiiort part from patrick@

ok kettenis@

> Index: arch/amd64/conf/Makefile.amd64
> ===
> RCS file: /cvs/src/sys/arch/amd64/conf/Makefile.amd64,v
> retrieving revision 1.121
> diff -u -p -r1.121 Makefile.amd64
> --- arch/amd64/conf/Makefile.amd6412 Jul 2021 06:07:33 -  1.121
> +++ arch/amd64/conf/Makefile.amd6426 Nov 2021 04:54:10 -
> @@ -48,7 +48,7 @@ INCLUDES=   -nostdinc -I$S -I${.OBJDIR} -I
>  CPPFLAGS=${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -MD -MP \
>   -DCONFIG_DRM_AMD_DC_DCN3_0
>  CWARNFLAGS=  -Werror -Wall -Wimplicit-function-declaration \
> - -Wno-uninitialized -Wno-pointer-sign \
> + -Wno-pointer-sign \
>   -Wframe-larger-than=2047
>  
>  CMACHFLAGS=  -mcmodel=kernel -mno-red-zone -mno-sse2 -mno-sse -mno-3dnow \
> Index: arch/arm/arm/cpu.c
> ===
> RCS file: /cvs/src/sys/arch/arm/arm/cpu.c,v
> retrieving revision 1.55
> diff -u -p -r1.55 cpu.c
> --- arch/arm/arm/cpu.c25 Mar 2021 04:12:00 -  1.55
> +++ arch/arm/arm/cpu.c23 Nov 2021 00:19:43 -
> @@ -349,14 +349,11 @@ cpu_attach(struct device *parent, struct
>   __asm volatile("mrc p15, 0, %0, c0, c0, 5" : "=r"(mpidr));
>   KASSERT(faa->fa_nreg > 0);
>  
> +#ifdef MULTIPROCESSOR
>   if (faa->fa_reg[0].addr == (mpidr & MPIDR_AFF)) {
>   ci = &cpu_info_primary;
> -#ifdef MULTIPROCESSOR
>   ci->ci_flags |= CPUF_RUNNING | CPUF_PRESENT | CPUF_PRIMARY;
> -#endif
> - }
> -#ifdef MULTIPROCESSOR
> - else {
> + } else {
>   ci = malloc(sizeof(*ci), M_DEVBUF, M_WAITOK | M_ZERO);
>   cpu_info[dev->dv_unit] = ci;
>   ci->ci_next = cpu_info_list->ci_next;
> @@ -364,6 +361,8 @@ cpu_attach(struct device *parent, struct
>   ci->ci_flags |= CPUF_AP;
>   ncpus++;
>   }
> +#else
> + ci = &cpu_info_primary;
>  #endif
>  
>   ci->ci_dev = dev;
> Index: arch/arm64/arm64/cpu.c
> ===
> RCS file: /cvs/src/sys/arch/arm64/arm64/cpu.c,v
> retrieving revision 1.58
> diff -u -p -r1.58 cpu.c
> --- arch/arm64/arm64/cpu.c23 Nov 2021 01:03:35 -  1.58
> +++ arch/arm64/arm64/cpu.c23 Nov 2021 01:28:26 -
> @@ -604,20 +604,19 @@ cpu_attach(struct device *parent, struct
>  {
>   struct fdt_attach_args *faa = aux;
>   struct cpu_info *ci;
> +#ifdef MULTIPROCESSOR
>   uint64_t mpidr = READ_SPECIALREG(mpidr_el1);
> +#endif
>   uint64_t id_aa64mmfr1, sctlr;
>   uint32_t opp;
>  
>   KASSERT(faa->fa_nreg > 0);
>  
> +#ifdef MULTIPROCESSOR
>   if (faa->fa_reg[0].addr == (mpidr & MPIDR_AFF)) {
>   ci = &cpu_info_primary;
> -#ifdef MULTIPROCESSOR
>   ci->ci_flags |= CPUF_RUNNING | CPUF_PRESENT | CPUF_PRIMARY;
> -#endif
> - }
> -#ifdef MULTIPROCESSOR
> - else {
> + } else {
>   ci = malloc(sizeof(*ci), M_DEVBUF, M_WAITOK | M_ZERO);
>   cpu_info[dev->dv_unit] = ci;
>   ci->ci_next = cpu_info_list->ci_next;
> @@ -625,6 +624,8 @@ cpu_attach(struct device *parent, struct
>   ci->ci_flags |= CPUF_AP;
>   ncpus++;
>   }
> +#else
> + ci = &cpu_info_primary;
>  #endif
>  
>   ci->ci_dev = dev;
> Index: arch/arm64/conf/Makefile.arm64
> ===
> RCS file: /cvs/src/sys/arch/arm64/conf/Makefile.arm64,v
> retrieving revision 1.39
> diff -u -p -r1.39 Makefile.arm64
> --- arch/arm64/conf/Makefile.arm647 Jul 2021 02:38:21 -   1.39
> +++ arch/arm64/conf/Makefile.arm6426 Nov 2021 04:55:52 -
> @@ -46,7 +46,7 @@ INCLUDES=   -nostdinc -I