Re: pf_create_state() is sometimes better to use pf_unlink_state()

2015-05-27 Thread Alexandr Nedvedicky
Hello,


On Wed, May 27, 2015 at 07:44:15PM +0200, Mike Belopuhov wrote:
> On Wed, May 27, 2015 at 10:39 +0200, Alexandr Nedvedicky wrote:
> > Hello,
> > 
> > > > -   if (pf_state_insert(BOUND_IFACE(r, pd->kif), skw, sks, s)) {
> > > > -   pf_state_key_detach(s, PF_SK_STACK);
> > > > -   pf_state_key_detach(s, PF_SK_WIRE);
> > > 
> > > This bug is not yours, but doing two pf_state_key_detach is wrong
> > > and results in all kinds of protection fault fireworks.  The right
> > > thing is to do pf_detach_state that would handle the case where
> > > PF_SK_STACK == PF_SK_WIRE (i.e. we need only one invocation).
> > good catch.
> > 
> > > 
> > > In csfailed case we do pf_remove_src_node and then call
> > > pf_src_tree_remove_state.  With your diff this means that
> > > pf_src_tree_remove_state will be dereferencing sni->sn that
> > > might be pool_put by the pf_remove_src_node.  Therefore their
> > > order needs to be reversed.
> > 
> > I see. Another option to fix it would be to do:
> > 
> > sni->sn = sns[i];
> > sns[i] = NULL;
> >
> 
> I'm not sure I follow.  Where do you want to do it?
> If it's when we pool_get sni's, then this would mean
> we won't run pf_remove_src_node and cleanup source
> nodes that might have been created.
> 

sorry I was too brief. The snippet below comes from
pf_create_state() with your patch applied:

   3560 for (i = 0; i < PF_SN_MAX; i++)
   3561 if (sns[i] != NULL) {
   3562 struct pf_sn_item   *sni;
   3563
   3564 sni = pool_get(&pf_sn_item_pl, PR_NOWAIT);
   3565 if (sni == NULL) {
   3566 REASON_SET(&reason, PFRES_MEMORY);
   3567 goto csfailed;
   3568 }
   3569 sni->sn = sns[i];
   3570 sns[i] = NULL;
   3571 SLIST_INSERT_HEAD(&s->src_nodes, sni, next);
   3572 sni->sn->states++;
   3573 }
   3574

the point of my suggestion is to transfer ownership of source node from
local variable sns[] to state. so the check performed later in csfailed
at line 3617, will find NULL pointer in sns[i] field and won't attempt
to call pf_remove_src_node().

   3610 csfailed:
   3611 if (s) {
   3612 pf_normalize_tcp_cleanup(s);/* safe even w/o init */
   3613 pf_src_tree_remove_state(s);
   3614 }
   3615
   3616 for (i = 0; i < PF_SN_MAX; i++)
   3617 if (sns[i] != NULL)
   3618 pf_remove_src_node(sns[i]);
   3619


your patch updated by my suggestion is further below.

regards
sasha

? pf.c.diff
? pf.c.patch
Index: pf.c
===
RCS file: /cvs/src/sys/net/pf.c,v
retrieving revision 1.916
diff -u -r1.916 pf.c
--- pf.c26 May 2015 16:17:51 -  1.916
+++ pf.c27 May 2015 22:59:32 -
@@ -3557,16 +3557,6 @@
goto csfailed;
}
 
-   if (pf_state_insert(BOUND_IFACE(r, pd->kif), skw, sks, s)) {
-   pf_state_key_detach(s, PF_SK_STACK);
-   pf_state_key_detach(s, PF_SK_WIRE);
-   *sks = *skw = NULL;
-   REASON_SET(&reason, PFRES_STATEINS);
-   goto csfailed;
-   } else
-   *sm = s;
-
-   /* attach src nodes late, otherwise cleanup on error nontrivial */
for (i = 0; i < PF_SN_MAX; i++)
if (sns[i] != NULL) {
struct pf_sn_item   *sni;
@@ -3574,16 +3564,22 @@
sni = pool_get(&pf_sn_item_pl, PR_NOWAIT);
if (sni == NULL) {
REASON_SET(&reason, PFRES_MEMORY);
-   pf_src_tree_remove_state(s);
-   STATE_DEC_COUNTERS(s);
-   pool_put(&pf_state_pl, s);
-   return (PF_DROP);
+   goto csfailed;
}
sni->sn = sns[i];
+   sns[i] = NULL;
SLIST_INSERT_HEAD(&s->src_nodes, sni, next);
sni->sn->states++;
}
 
+   if (pf_state_insert(BOUND_IFACE(r, pd->kif), skw, sks, s)) {
+   pf_detach_state(s);
+   *sks = *skw = NULL;
+   REASON_SET(&reason, PFRES_STATEINS);
+   goto csfailed;
+   } else
+   *sm = s;
+
pf_set_rt_ifp(s, pd->src);  /* needs s->state_key set */
if (tag > 0) {
pf_tag_ref(tag);
@@ -3612,12 +3608,16 @@
return (PF_PASS);
 
 csfailed:
+   if (s) {
+   pf_normalize_tcp_cleanup(s);/* safe even w/o init */
+   pf_src_tree_remove_state

Re: unneeded var breaks build in xenocara/driver/xf86-video-mach64

2015-05-27 Thread Christian Weisgerber
Matthias Kilian:

> I've
> 
>   #define TV_OUT 1
> 
> in /usr/xobj/driver/xf86-video-mach64/config.h, and my build log shows
> 
>   checking whether to include TV Out support... yes
> 
> for xf86-video-mach64.

It turns out TV_OUT is defined on i386, but not on amd64.

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



Re: unneeded var breaks build in xenocara/driver/xf86-video-mach64

2015-05-27 Thread Matthias Kilian
Hi,

On Wed, May 27, 2015 at 08:56:01PM +0200, Matthias Kilian wrote:
> I just ran into the same problem, with the trees updated this
> afternoon.
> 
> > > /usr/xenocara/driver/xf86-video-mach64/src/atipreinit.c: In function 
> > > 'ATIPreInit':
> > > /usr/xenocara/driver/xf86-video-mach64/src/atipreinit.c:703: error: 
> > > 'pInt10Info' undeclared (first use in this function)
> > 
> > That is only reached if TV_OUT is defined... but TV_OUT is *not*
> > defined in the build.
> 
> I've
> 
>   #define TV_OUT 1
> 
> in /usr/xobj/driver/xf86-video-mach64/config.h, and my build log shows
> 
>   checking whether to include TV Out support... yes
> 
> for xf86-video-mach64.

Neither the OP nor me mentioned that it happens specifically on
i386. Looks like TV Out is automagically enabled for i386. From
/usr/xenocara/driver/xf86-video-mach64/configure.ac:

ATIMISC_CPIO=no
ATIMISC_DGA=yes
ATIMISC_TV_OUT=no

case $host_cpu in
  i*86)
ATIMISC_TV_OUT=yes
ATIMISC_CPIO=yes
;;
  x86_64|amd64|alpha|ia64)
ATIMISC_CPIO=yes
;;
  sparc)
ATIMISC_DGA=no
;;
  *)
;;
esac

I'll give this a try

Index: configure.ac
===
RCS file: /cvs/xenocara/driver/xf86-video-mach64/configure.ac,v
retrieving revision 1.6
diff -u -p -r1.6 configure.ac
--- configure.ac23 May 2015 15:26:41 -  1.6
+++ configure.ac27 May 2015 19:22:15 -
@@ -126,7 +126,6 @@ ATIMISC_TV_OUT=no
 
 case $host_cpu in
   i*86)
-ATIMISC_TV_OUT=yes
 ATIMISC_CPIO=yes
 ;;
   x86_64|amd64|alpha|ia64)

Ciao,
Kili



Re: unneeded var breaks build in xenocara/driver/xf86-video-mach64

2015-05-27 Thread Matthieu Herrb
On Wed, May 27, 2015 at 08:56:01PM +0200, Matthias Kilian wrote:
> Hi,
> 
> On Wed, May 27, 2015 at 04:55:39PM +, Christian Weisgerber wrote:
> > > someone will hit this soon enough if they haven't already, but building
> > > xerocara after recent import gave the following error:
> > 
> > What's "recent"?
> > "Update to xf86-video-mach64 6.9.5" was four days ago and I've built
> > xenocara since then without any problems.
> 
> I just ran into the same problem, with the trees updated this
> afternoon.
> 
> > > /usr/xenocara/driver/xf86-video-mach64/src/atipreinit.c: In function 
> > > 'ATIPreInit':
> > > /usr/xenocara/driver/xf86-video-mach64/src/atipreinit.c:703: error: 
> > > 'pInt10Info' undeclared (first use in this function)
> > 
> > That is only reached if TV_OUT is defined... but TV_OUT is *not*
> > defined in the build.
> 
> I've
> 
>   #define TV_OUT 1
> 
> in /usr/xobj/driver/xf86-video-mach64/config.h, and my build log shows
> 
>   checking whether to include TV Out support... yes
> 
> for xf86-video-mach64.
> 
> Full build log at https://openbsd.dead-parrot.de/build.log, and
> config.log at https://openbsd.dead-parrot.de/config.log.
> 
> Ciao,
>   Kili
> 
> ps: yes, /usr/xobj completely wiped out before the build.
> 


None of you cared to mention the important bit : $MACHINE...

it only shows up on i386 (where configure defines TV_OUT) and it was
caused by a bad merge of local changes I had to do to an earlier
version of the driver.

Fix committed a few minutes ago. Sorry for the trouble.
-- 
Matthieu Herrb



Re: unneeded var breaks build in xenocara/driver/xf86-video-mach64

2015-05-27 Thread Matthias Kilian
Hi,

On Wed, May 27, 2015 at 04:55:39PM +, Christian Weisgerber wrote:
> > someone will hit this soon enough if they haven't already, but building
> > xerocara after recent import gave the following error:
> 
> What's "recent"?
> "Update to xf86-video-mach64 6.9.5" was four days ago and I've built
> xenocara since then without any problems.

I just ran into the same problem, with the trees updated this
afternoon.

> > /usr/xenocara/driver/xf86-video-mach64/src/atipreinit.c: In function 
> > 'ATIPreInit':
> > /usr/xenocara/driver/xf86-video-mach64/src/atipreinit.c:703: error: 
> > 'pInt10Info' undeclared (first use in this function)
> 
> That is only reached if TV_OUT is defined... but TV_OUT is *not*
> defined in the build.

I've

#define TV_OUT 1

in /usr/xobj/driver/xf86-video-mach64/config.h, and my build log shows

checking whether to include TV Out support... yes

for xf86-video-mach64.

Full build log at https://openbsd.dead-parrot.de/build.log, and
config.log at https://openbsd.dead-parrot.de/config.log.

Ciao,
Kili

ps: yes, /usr/xobj completely wiped out before the build.



Re: unneeded var breaks build in xenocara/driver/xf86-video-mach64

2015-05-27 Thread Mark Patruck
Same here. make build finished w/o any issues...that was 7 hours ago.

On Wed, May 27, 2015 at 04:55:39PM +, Christian Weisgerber wrote:
> On 2015-05-27, dan mclaughlin  wrote:
> 
> > someone will hit this soon enough if they haven't already, but building
> > xerocara after recent import gave the following error:
> 
> What's "recent"?
> "Update to xf86-video-mach64 6.9.5" was four days ago and I've built
> xenocara since then without any problems.
> 
> > /usr/xenocara/driver/xf86-video-mach64/src/atipreinit.c: In function 
> > 'ATIPreInit':
> > /usr/xenocara/driver/xf86-video-mach64/src/atipreinit.c:703: error: 
> > 'pInt10Info' undeclared (first use in this function)
> 
> That is only reached if TV_OUT is defined... but TV_OUT is *not*
> defined in the build.
> 
> -- 
> Christian "naddy" Weisgerber  na...@mips.inka.de
> 

-- 
Mark Patruck ( mark at wrapped.cx )
GPG key 0xF2865E51 / 187F F6D3 EE04 1DCE 1C74  F644 0D3C F66F F286 5E51

http://www.wrapped.cx



Re: Use m_defrag in intel wireless drivers

2015-05-27 Thread Mike Belopuhov
On Tue, May 26, 2015 at 22:56 +0200, Mark Kettenis wrote:
> Some of you may have seen the iwn(4) diff before, but I tweaked it a
> bit to minimize the diff.  Tested iwn(4) and wpi(4) myself.  Further
> tests and/or ok's are welcome.
>

OK mikeb



Re: pf_create_state() is sometimes better to use pf_unlink_state()

2015-05-27 Thread Mike Belopuhov
On Wed, May 27, 2015 at 10:39 +0200, Alexandr Nedvedicky wrote:
> Hello,
> 
> > > -   if (pf_state_insert(BOUND_IFACE(r, pd->kif), skw, sks, s)) {
> > > -   pf_state_key_detach(s, PF_SK_STACK);
> > > -   pf_state_key_detach(s, PF_SK_WIRE);
> > 
> > This bug is not yours, but doing two pf_state_key_detach is wrong
> > and results in all kinds of protection fault fireworks.  The right
> > thing is to do pf_detach_state that would handle the case where
> > PF_SK_STACK == PF_SK_WIRE (i.e. we need only one invocation).
> good catch.
> 
> > 
> > In csfailed case we do pf_remove_src_node and then call
> > pf_src_tree_remove_state.  With your diff this means that
> > pf_src_tree_remove_state will be dereferencing sni->sn that
> > might be pool_put by the pf_remove_src_node.  Therefore their
> > order needs to be reversed.
> 
> I see. Another option to fix it would be to do:
> 
>   sni->sn = sns[i];
>   sns[i] = NULL;
>

I'm not sure I follow.  Where do you want to do it?
If it's when we pool_get sni's, then this would mean
we won't run pf_remove_src_node and cleanup source
nodes that might have been created.

> since your fix works my comment is kind of bikeshedding.
> 
> regards
> sasha
> 



Re: unneeded var breaks build in xenocara/driver/xf86-video-mach64

2015-05-27 Thread Christian Weisgerber
On 2015-05-27, dan mclaughlin  wrote:

> someone will hit this soon enough if they haven't already, but building
> xerocara after recent import gave the following error:

What's "recent"?
"Update to xf86-video-mach64 6.9.5" was four days ago and I've built
xenocara since then without any problems.

> /usr/xenocara/driver/xf86-video-mach64/src/atipreinit.c: In function 
> 'ATIPreInit':
> /usr/xenocara/driver/xf86-video-mach64/src/atipreinit.c:703: error: 
> 'pInt10Info' undeclared (first use in this function)

That is only reached if TV_OUT is defined... but TV_OUT is *not*
defined in the build.

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



Re: xserver arm_video.c simplification - test on zaurus please

2015-05-27 Thread Matthieu Herrb
On Wed, May 27, 2015 at 04:25:23PM +0200, Sigi Rudzio wrote:
> Hi,
> 
> finally finished compiling it, X works, anything special I should
> test?

No. Having X that still starts is enough as a test. 
Thanks for taking the time to do it.

> 
> Regards,
> 
> S. Rudzio
> 
> 2015-05-23 23:28 GMT+02:00 Matthieu Herrb :
> > Hi,
> >
> > Since my zaurus was stolen last year, I need someone to test the diff
> > below on a zaurus...
> >
> > it simplifies the code a bit (more to come for xserver 1.17 later) and
> > makes it possible to run the wsudl on armv7 with a few more tweaks.
> >
> > Thanks in advance.
> >
> > Index: hw/xfree86/os-support/bsd/arm_video.c
> > ===
> > RCS file: /cvs/xenocara/xserver/hw/xfree86/os-support/bsd/arm_video.c,v
> > retrieving revision 1.11
> > diff -u -p -u -r1.11 arm_video.c
> > --- hw/xfree86/os-support/bsd/arm_video.c   27 Sep 2014 17:53:02 -  
> > 1.11
> > +++ hw/xfree86/os-support/bsd/arm_video.c   23 May 2015 21:23:41 -
> > @@ -69,33 +69,23 @@
> >  #include "xf86_OSlib.h"
> >  #include "xf86OSpriv.h"
> >
> > -#include "bus/Pci.h"
> > -
> >  #ifndef MAP_FAILED
> >  #define MAP_FAILED ((caddr_t)-1)
> >  #endif
> >
> > -#include 
> > -#include 
> > -
> >  
> > /***/
> >  /* Video Memory Mapping section
> > */
> >  
> > /***/
> >
> > -#ifdef __OpenBSD__
> > -#undef DEV_MEM
> > -#define DEV_MEM "/dev/xf86"
> > -#endif
> > -
> > -static void* ppcMapVidMem(int, unsigned long, unsigned long, int flags);
> > -static void ppcUnmapVidMem(int, void *, unsigned long);
> > +static void* armMapVidMem(int, unsigned long, unsigned long, int flags);
> > +static void armUnmapVidMem(int, void *, unsigned long);
> >
> >  void
> >  xf86OSInitVidMem(VidMemInfoPtr pVidMem)
> >  {
> >  pVidMem->linearSupported = TRUE;
> > -pVidMem->mapMem = ppcMapVidMem;
> > -pVidMem->unmapMem = ppcUnmapVidMem;
> > +pVidMem->mapMem = armMapVidMem;
> > +pVidMem->unmapMem = armUnmapVidMem;
> >  pVidMem->initialised = TRUE;
> >  }
> >
> > @@ -103,7 +93,7 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
> >  volatile unsigned char *ioBase = MAP_FAILED;
> >
> >  static void*
> > -ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int 
> > flags)
> > +armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int 
> > flags)
> >  {
> >  int fd = xf86Info.consoleFd;
> >  void *base;
> > @@ -124,40 +114,17 @@ ppcMapVidMem(int ScreenNum, unsigned lon
> >  }
> >
> >  static void
> > -ppcUnmapVidMem(int ScreenNum, void *Base, unsigned long Size)
> > +armUnmapVidMem(int ScreenNum, void *Base, unsigned long Size)
> >  {
> >
> >  munmap(Base, Size);
> >  }
> >
> > -static int kmem = -1;
> > -
> >  int
> >  xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
> >   int Len)
> >  {
> > -int rv;
> > -
> > -if (Base < 0x8000) {
> > -xf86Msg(X_WARNING, "No VGA Base=%#lx\n", Base);
> > -return 0;
> > -}
> > -
> > -if (kmem == -1) {
> > -kmem = open(DEV_MEM, 2);
> > -if (kmem == -1) {
> > -FatalError("xf86ReadBIOS: open %s", DEV_MEM);
> > -}
> > -}
> > -
> > -#ifdef DEBUG
> > -xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n",
> > -Base, Offset, Len);
> > -#endif
> > -
> > -lseek(kmem, Base + Offset, 0);
> > -rv = read(kmem, Buf, Len);
> > -return rv;
> > +return -1;
> >  }
> >
> >  /*
> > @@ -166,26 +133,6 @@ xf86ReadBIOS(unsigned long Base, unsigne
> >  void
> >  xf86PrivilegedInit(void)
> >  {
> > -int mib[2];
> > -char buf[128];
> > -size_t len;
> > -
> > -mib[0] = CTL_HW;
> > -mib[1] = HW_MACHINE;
> > -len = sizeof(buf);
> > -if (sysctl(mib, 2, buf, &len, NULL, 0) < 0) {
> > -FatalError("Cannot get hw.machine");
> > -}
> > -if (strcmp(buf, "zaurus") != 0 &&
> > -strcmp(buf, "armish") != 0) {
> > -/* Not Zaurus */
> > -kmem = open(DEV_MEM, 2);
> > -if (kmem == -1) {
> > -ErrorF("errno: %d\n", errno);
> > -FatalError("xf86PrivilegedInit: open %s", DEV_MEM);
> > -}
> > -pci_system_init();
> > -}
> >  xf86OpenConsole();
> >  }
> >
> >
> > --
> > Matthieu Herrb
> >

-- 
Matthieu Herrb



Re: xserver arm_video.c simplification - test on zaurus please

2015-05-27 Thread Sigi Rudzio
Hi,

finally finished compiling it, X works, anything special I should test?

Regards,

S. Rudzio

2015-05-23 23:28 GMT+02:00 Matthieu Herrb :
> Hi,
>
> Since my zaurus was stolen last year, I need someone to test the diff
> below on a zaurus...
>
> it simplifies the code a bit (more to come for xserver 1.17 later) and
> makes it possible to run the wsudl on armv7 with a few more tweaks.
>
> Thanks in advance.
>
> Index: hw/xfree86/os-support/bsd/arm_video.c
> ===
> RCS file: /cvs/xenocara/xserver/hw/xfree86/os-support/bsd/arm_video.c,v
> retrieving revision 1.11
> diff -u -p -u -r1.11 arm_video.c
> --- hw/xfree86/os-support/bsd/arm_video.c   27 Sep 2014 17:53:02 -
>   1.11
> +++ hw/xfree86/os-support/bsd/arm_video.c   23 May 2015 21:23:41 -
> @@ -69,33 +69,23 @@
>  #include "xf86_OSlib.h"
>  #include "xf86OSpriv.h"
>
> -#include "bus/Pci.h"
> -
>  #ifndef MAP_FAILED
>  #define MAP_FAILED ((caddr_t)-1)
>  #endif
>
> -#include 
> -#include 
> -
>  /***/
>  /* Video Memory Mapping section*/
>  /***/
>
> -#ifdef __OpenBSD__
> -#undef DEV_MEM
> -#define DEV_MEM "/dev/xf86"
> -#endif
> -
> -static void* ppcMapVidMem(int, unsigned long, unsigned long, int flags);
> -static void ppcUnmapVidMem(int, void *, unsigned long);
> +static void* armMapVidMem(int, unsigned long, unsigned long, int flags);
> +static void armUnmapVidMem(int, void *, unsigned long);
>
>  void
>  xf86OSInitVidMem(VidMemInfoPtr pVidMem)
>  {
>  pVidMem->linearSupported = TRUE;
> -pVidMem->mapMem = ppcMapVidMem;
> -pVidMem->unmapMem = ppcUnmapVidMem;
> +pVidMem->mapMem = armMapVidMem;
> +pVidMem->unmapMem = armUnmapVidMem;
>  pVidMem->initialised = TRUE;
>  }
>
> @@ -103,7 +93,7 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
>  volatile unsigned char *ioBase = MAP_FAILED;
>
>  static void*
> -ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int 
> flags)
> +armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int 
> flags)
>  {
>  int fd = xf86Info.consoleFd;
>  void *base;
> @@ -124,40 +114,17 @@ ppcMapVidMem(int ScreenNum, unsigned lon
>  }
>
>  static void
> -ppcUnmapVidMem(int ScreenNum, void *Base, unsigned long Size)
> +armUnmapVidMem(int ScreenNum, void *Base, unsigned long Size)
>  {
>
>  munmap(Base, Size);
>  }
>
> -static int kmem = -1;
> -
>  int
>  xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
>   int Len)
>  {
> -int rv;
> -
> -if (Base < 0x8000) {
> -xf86Msg(X_WARNING, "No VGA Base=%#lx\n", Base);
> -return 0;
> -}
> -
> -if (kmem == -1) {
> -kmem = open(DEV_MEM, 2);
> -if (kmem == -1) {
> -FatalError("xf86ReadBIOS: open %s", DEV_MEM);
> -}
> -}
> -
> -#ifdef DEBUG
> -xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n",
> -Base, Offset, Len);
> -#endif
> -
> -lseek(kmem, Base + Offset, 0);
> -rv = read(kmem, Buf, Len);
> -return rv;
> +return -1;
>  }
>
>  /*
> @@ -166,26 +133,6 @@ xf86ReadBIOS(unsigned long Base, unsigne
>  void
>  xf86PrivilegedInit(void)
>  {
> -int mib[2];
> -char buf[128];
> -size_t len;
> -
> -mib[0] = CTL_HW;
> -mib[1] = HW_MACHINE;
> -len = sizeof(buf);
> -if (sysctl(mib, 2, buf, &len, NULL, 0) < 0) {
> -FatalError("Cannot get hw.machine");
> -}
> -if (strcmp(buf, "zaurus") != 0 &&
> -strcmp(buf, "armish") != 0) {
> -/* Not Zaurus */
> -kmem = open(DEV_MEM, 2);
> -if (kmem == -1) {
> -ErrorF("errno: %d\n", errno);
> -FatalError("xf86PrivilegedInit: open %s", DEV_MEM);
> -}
> -pci_system_init();
> -}
>  xf86OpenConsole();
>  }
>
>
> --
> Matthieu Herrb
>



Re: OpenBSD/NTRU policy mismatch [Was: NTRU Open Source Project / Post-quantum era]

2015-05-27 Thread Okembe Mbwambo
26.05.2015, 23:08, "Chris Cappuccio" :

>>  FWIW, a BSD-licensed NTRU implementation exists at 
>> https://github.com/tbuktu/libntru and while it is patent encumbered, it 
>> offers a compile switch that causes it to become patent free in 2017 as 
>> opposed to the GPL implementation which will be patent encumbered until 2020.
>
> Are the patents held by the copyright authors? If the copyright is not held 
> by the patent holder, I imagine this becomes much less important.

>From the description on the GitHub page, it looks to me like the BSD-licensed 
>implementation was written by somebody not affiliated with the patent holder. 
>But I guess the only way to know for sure is to ask.

Okembe



[PATCH] Fix ospfd segmentation fault on startup

2015-05-27 Thread Johan Ymerson
Hi,

When debugging problems with ospfd and carp on startup, I managed to get
ospfd to segfault a couple of times.
I tracked down the issue to if_change() and main_imsg_compose_ospfe().

if_change() is called before imsg_init is called to initialize the
imsgbuf struct. If a link state change to UP occurs during the small
time frame the imsgbuf pointer is uninitialized, we have a null pointer
dereference in main_imsg_compose_ospfe().

Safe-guard against this by simply not calling imsg_compose_event() if
the imsgbuf pointer is null.

Index: ospfd.c
===
RCS file: /cvs/src/usr.sbin/ospfd/ospfd.c,v
retrieving revision 1.83
diff -u -p -r1.83 ospfd.c
--- ospfd.c 10 Feb 2015 05:24:48 -  1.83
+++ ospfd.c 27 May 2015 12:35:08 -
@@ -511,13 +511,15 @@ main_dispatch_rde(int fd, short event, v
 void
 main_imsg_compose_ospfe(int type, pid_t pid, void *data, u_int16_t datalen)
 {
-   imsg_compose_event(iev_ospfe, type, 0, pid, -1, data, datalen);
+   if (iev_ospfe)
+   imsg_compose_event(iev_ospfe, type, 0, pid, -1, data, datalen);
 }
 
 void
 main_imsg_compose_rde(int type, pid_t pid, void *data, u_int16_t datalen)
 {
-   imsg_compose_event(iev_rde, type, 0, pid, -1, data, datalen);
+   if (iev_rde)
+   imsg_compose_event(iev_rde, type, 0, pid, -1, data, datalen);
 }
 
 void




Re: test null before free in relayd

2015-05-27 Thread sven falempin
Unmangled diff:

http://pastebin.com/p9Qi9rZX

On Mon, May 25, 2015 at 4:24 PM, sven falempin 
wrote:

>
>
> On Mon, May 25, 2015 at 2:55 PM, Gleydson Soares 
> wrote:
>>
>>
>> your diff is incomplete...
>> well, why just this occurrence? there is others check null before
>> free(3) in same file.
>>
>> and please, be more specific adding more details about your changes: eg.:
>> (I am removing the null check here, because free(3) itself already
>> check against null).
>>
>
> Index: config.c
> ===
> RCS file: /cvs/src/usr.sbin/./relayd/config.c,v
> retrieving revision 1.25
> diff -u -p -r1.25 config.c
> --- config.c2 May 2015 13:15:24 -   1.25
> +++ config.c25 May 2015 20:18:34 -
> @@ -178,10 +178,8 @@ config_purge(struct relayd *env, u_int r
> if (what & CONFIG_PROTOS && env->sc_protos != NULL) {
> while ((proto = TAILQ_FIRST(env->sc_protos)) != NULL) {
> TAILQ_REMOVE(env->sc_protos, proto, entry);
> -   if (proto->style != NULL)
> -   free(proto->style);
> -   if (proto->tlscapass != NULL)
> -   free(proto->tlscapass);
> +  free(proto->style);
> +  free(proto->tlscapass);
> free(proto);
> }
> env->sc_protocount = 0;
> @@ -949,12 +947,9 @@ config_getrelay(struct relayd *env, stru
> return (0);
>
>   fail:
> -   if (rlay->rl_tls_cert)
> -   free(rlay->rl_tls_cert);
> -   if (rlay->rl_tls_key)
> -   free(rlay->rl_tls_key);
> -   if (rlay->rl_tls_ca)
> -   free(rlay->rl_tls_ca);
> +   free(rlay->rl_tls_cert);
> +   free(rlay->rl_tls_key);
> +   free(rlay->rl_tls_ca);
> close(rlay->rl_s);
> free(rlay);
> return (-1);
> @@ -998,7 +993,6 @@ config_getrelaytable(struct relayd *env,
> return (0);
>
>   fail:
> -   if (rlt != NULL)
> -   free(rlt);
> +  free(rlt);
> return (-1);
>  }
> Index: parse.y
> ===
> RCS file: /cvs/src/usr.sbin/./relayd/parse.y,v
> retrieving revision 1.204
> diff -u -p -r1.204 parse.y
> --- parse.y 2 May 2015 13:15:24 -   1.204
> +++ parse.y 25 May 2015 20:18:34 -
> @@ -1275,8 +1275,7 @@ ruleopts  : METHOD STRING
>   {
> rule->rule_kv[keytype].kv_value == NULL)
> fatal("out of memory");
> free($3);
> -   if ($4)
> -   free($4);
> +  free($4);
> rule->rule_kv[keytype].kv_type = keytype;
> }
> | COOKIE key_option {
> @@ -1296,8 +1295,7 @@ ruleopts  : METHOD STRING
>   {
> rule->rule_kv[keytype].kv_value == NULL)
> fatal("out of memory");
> free($3);
> -   if ($4)
> -   free($4);
> +  free($4);
> rule->rule_kv[keytype].kv_type = keytype;
> }
> | HEADER key_option {
> @@ -1315,8 +1313,7 @@ ruleopts  : METHOD STRING
>   {
> rule->rule_kv[keytype].kv_value == NULL)
> fatal("out of memory");
> free($3);
> -   if ($4)
> -   free($4);
> +  free($4);
> rule->rule_kv[keytype].kv_type = keytype;
> }
> | PATH key_option   {
> @@ -1332,8 +1329,7 @@ ruleopts  : METHOD STRING
>   {
> yyerror("combining query type and the
> given "
> "option is not supported");
> free($3);
> -   if ($4)
> -   free($4);
> +  free($4);
> YYERROR;
> break;
> }
> @@ -1346,8 +1342,7 @@ ruleopts  : METHOD STRING
>   {
> rule->rule_kv[keytype].kv_value == NULL)
> fatal("out of memory");
> free($3);
> -   if ($4)
> -   free($4);
> +  free($4);
> rule->rule_kv[keytype].kv_type = keytype;
> }
> | QUERYSTR key_option   {
> @@ -1386,8 +1381,7 @@ ruleopts  : METHOD STRING
>   {
>

Re: Issue with erlang package ?

2015-05-27 Thread P Arun Babu
Initially i did use a mirror near me.
Then I tried with the main website; with no success.

Anyways, I managed to build the latest erlang version from source.

Thanks for your time.
Arun


On Wed, May 27, 2015 at 1:11 PM, Stuart Henderson  wrote:

> On 2015/05/26 10:18, P Arun Babu wrote:
> > Hi,
> >
> > I get an error while installing the erlang package:
> > Is there a known issue here ?
> >
> > [ ~ ] $ uname -a
> > OpenBSD xyz.my.domain 5.7 GENERIC#825 amd64
> >
> > [ ~ ] $ sudo pkg_add erlang
> > quirks-2.54 signed on 2015-03-08T12:33:05Z
> > Fatal error: Ustar [
> >
> http://ftp.openbsd.org/pub/OpenBSD/5.7/packages/amd64/erlang-16b.03v0.tgz][lib/erlang/doc/pdf/otp-system-documentation-5.10.4.pdf
> ]:
> > Premature end of archive
>
> No known issue but there may be some network problem between you
> and ftp.openbsd.org. Try a different mirror from the list on
> www.openbsd.org/ftp.html, ideally one in a nearby country to you.
>
> > Adjusting sha for /usr/local/lib/erlang/doc/pdf/pkg.XCjcOR5zxY from
> > NNEnrUeL7HzciYfkbdpxhMEhtyxHs5sOIdi9F3wmGqM= to
> > 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
> > Fatal error: Installation of erlang-16b.03v0 failed, partial installation
> > recorded as partial-erlang-16b.03v0.3
> >  at /usr/libdata/perl5/OpenBSD/PkgAdd.pm line 817.
> >
> > Thanks,
> > Arun
>


unneeded var breaks build in xenocara/driver/xf86-video-mach64

2015-05-27 Thread dan mclaughlin
someone will hit this soon enough if they haven't already, but building
xerocara after recent import gave the following error:

/usr/xenocara/driver/xf86-video-mach64/src/atipreinit.c: In function 
'ATIPreInit':
/usr/xenocara/driver/xf86-video-mach64/src/atipreinit.c:703: error: 
'pInt10Info' undeclared (first use in this function)
/usr/xenocara/driver/xf86-video-mach64/src/atipreinit.c:703: error: (Each 
undeclared identifier is reported only once
/usr/xenocara/driver/xf86-video-mach64/src/atipreinit.c:703: error: for each 
function it appears in.)
*** Error 1 in driver/xf86-video-mach64/obj/src (Makefile:543 'atipreinit.lo')
*** Error 1 in driver/xf86-video-mach64/obj (Makefile:409 'install-recursive')
*** Error 1 in driver/xf86-video-mach64 (/usr/X11R6/share/mk/bsd.xorg.mk:196 
'realinstall')
*** Error 1 in driver (:48 'realinstall')
*** Error 1 in . (:48 'realinstall')
*** Error 1 in /usr/xenocara (Makefile:116 'release-install')

pInt10Info is only in xenocara/driver/xf86-video-mach64/src/atipreinit.c,
and nowhere else in the tree.

if (pVBE && !(flags & PROBE_DETECT))
{
xf86Int10InfoPtr pInt10Info = pVBE->pInt10;

/* Validate, then make a private copy of, the initialised BIOS */
CARD8 *pBIOS = xf86int10Addr(pInt10Info, pInt10Info->BIOSseg << 4);



pInt10Info = NULL;

the last one doesn't seem to serve a purpose given that it is only used as
above to call a function. actually it doesn't look like that variable is
really needed at all.

i don't know what upstream is thinking, maybe a dev is already in contact,
so i'm not sure if i should even propose a diff at this point, but for
myself i just removed the last line.


--- driver/xf86-video-mach64/src/atipreinit.c.orig  Tue May 26 08:45:39 2015
+++ driver/xf86-video-mach64/src/atipreinit.c   Wed May 27 04:12:32 2015
@@ -700,7 +700,6 @@ ATIPreInit
 #else
 pATI->pVBE = pVBE;
 pVBE = NULL;
-pInt10Info = NULL;
 #endif /* TV_OUT */
 
 if (ConfiguredMonitor && !(flags & PROBE_DETECT))



Re: Issue with erlang package ?

2015-05-27 Thread Stuart Henderson
On 2015/05/26 10:18, P Arun Babu wrote:
> Hi,
> 
> I get an error while installing the erlang package:
> Is there a known issue here ?
> 
> [ ~ ] $ uname -a
> OpenBSD xyz.my.domain 5.7 GENERIC#825 amd64
> 
> [ ~ ] $ sudo pkg_add erlang
> quirks-2.54 signed on 2015-03-08T12:33:05Z
> Fatal error: Ustar [
> http://ftp.openbsd.org/pub/OpenBSD/5.7/packages/amd64/erlang-16b.03v0.tgz][lib/erlang/doc/pdf/otp-system-documentation-5.10.4.pdf]:
> Premature end of archive

No known issue but there may be some network problem between you
and ftp.openbsd.org. Try a different mirror from the list on
www.openbsd.org/ftp.html, ideally one in a nearby country to you.

> Adjusting sha for /usr/local/lib/erlang/doc/pdf/pkg.XCjcOR5zxY from
> NNEnrUeL7HzciYfkbdpxhMEhtyxHs5sOIdi9F3wmGqM= to
> 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
> Fatal error: Installation of erlang-16b.03v0 failed, partial installation
> recorded as partial-erlang-16b.03v0.3
>  at /usr/libdata/perl5/OpenBSD/PkgAdd.pm line 817.
> 
> Thanks,
> Arun



Re: pf_create_state() is sometimes better to use pf_unlink_state()

2015-05-27 Thread Alexandr Nedvedicky
Hello,

> > -   if (pf_state_insert(BOUND_IFACE(r, pd->kif), skw, sks, s)) {
> > -   pf_state_key_detach(s, PF_SK_STACK);
> > -   pf_state_key_detach(s, PF_SK_WIRE);
> 
> This bug is not yours, but doing two pf_state_key_detach is wrong
> and results in all kinds of protection fault fireworks.  The right
> thing is to do pf_detach_state that would handle the case where
> PF_SK_STACK == PF_SK_WIRE (i.e. we need only one invocation).
good catch.

> 
> In csfailed case we do pf_remove_src_node and then call
> pf_src_tree_remove_state.  With your diff this means that
> pf_src_tree_remove_state will be dereferencing sni->sn that
> might be pool_put by the pf_remove_src_node.  Therefore their
> order needs to be reversed.

I see. Another option to fix it would be to do:

sni->sn = sns[i];
sns[i] = NULL;

since your fix works my comment is kind of bikeshedding.

regards
sasha



Re: Use m_defrag in intel wireless drivers

2015-05-27 Thread Mark Kettenis
> From: Alexey Suslikov 
> Date: Wed, 27 May 2015 06:51:58 + (UTC)
> 
> Mark Kettenis  xs4all.nl> writes:
> 
> > Index: if_ipw.c
> > /* too many fragments, linearize */
> 
> > Index: if_iwi.c
> > /* too many fragments, linearize */
> 
> > Index: if_iwn.c
> > /* Too many DMA segments, linearize mbuf. */
> 
> > Index: if_wpi.c
> > /* Too many DMA segments, linearize mbuf. */
> 
> This comments can be homogenized. I'd choose iwn/wpi variant.

Yes they can.  I don't really see the point.