[Bug 234442] libnetgraph race condition

2019-10-13 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234442

Kubilay Kocak  changed:

   What|Removed |Added

  Flags||mfc-stable11+,
   ||mfc-stable12+

--- Comment #10 from Kubilay Kocak  ---
^Triage: Track MFC's

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 234442] libnetgraph race condition

2019-10-11 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234442

Mark Johnston  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|In Progress |Closed

--- Comment #8 from Mark Johnston  ---
I don't have the means to test this on stable/11, but please feel free to MFC
the change there if you can verify that it works.

--- Comment #9 from commit-h...@freebsd.org ---
A commit references this bug:

Author: eugen
Date: Fri Oct 11 18:05:06 UTC 2019
New revision: 353445
URL: https://svnweb.freebsd.org/changeset/base/353445

Log:
  MFC r347439 by markj: Atomically update the global gMsgId in libnetgraph.

  Otherwise concurrently running threads may inadvertently use the same
  token for different messages.

  Preserve the behaviour of disallowing negative message tokens, but allow
  a message token value of zero since this simplifies the code a bit and
  tokens are documented to be non-negative.

  PR:   234442

Changes:
_U  stable/11/
  stable/11/lib/libnetgraph/msg.c

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 234442] libnetgraph race condition

2019-06-08 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234442

--- Comment #7 from commit-h...@freebsd.org ---
A commit references this bug:

Author: markj
Date: Sun Jun  9 03:31:08 UTC 2019
New revision: 348827
URL: https://svnweb.freebsd.org/changeset/base/348827

Log:
  MFC r347439:
  Atomically update the global gMsgId in libnetgraph.

  PR:   234442

Changes:
_U  stable/12/
  stable/12/lib/libnetgraph/msg.c

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 234442] libnetgraph race condition

2019-05-10 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234442

Rodney W. Grimes  changed:

   What|Removed |Added

 CC||n...@freebsd.org

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 234442] libnetgraph race condition

2019-05-10 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234442

Mark Johnston  changed:

   What|Removed |Added

   Assignee|n...@freebsd.org |ma...@freebsd.org

--- Comment #5 from Mark Johnston  ---
(In reply to Eugene Grosbein from comment #4)
Thanks.  I will commit the change then, with a long MFC timeout.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 234442] libnetgraph race condition

2019-05-10 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234442

Eugene Grosbein  changed:

   What|Removed |Added

 Status|New |In Progress

--- Comment #4 from Eugene Grosbein  ---
(In reply to Mark Johnston from comment #3)

Yes, thanks. Due to the nature of the race it's hard to be exact but at least
the change does not make it worse. And the problem has not repeated yet with
patch applied.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 234442] libnetgraph race condition

2019-05-09 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234442

--- Comment #3 from Mark Johnston  ---
Ping? Did you try testing the patch?

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 234442] libnetgraph race condition

2019-01-09 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234442

--- Comment #2 from Mark Johnston  ---
(In reply to Mark Johnston from comment #1)
Note, the patch permits a msgid of 0 instead of starting from 1.  The
netgraph(3) man page says that tokens only need to be non-negative, so I think
this is fine, but I did not test it.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 234442] libnetgraph race condition

2019-01-09 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234442

Mark Johnston  changed:

   What|Removed |Added

 CC||ma...@freebsd.org

--- Comment #1 from Mark Johnston  ---
Created attachment 200960
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=200960=edit
atomically increment gMsgId

The attached patch uses C11 atomics in an attempt to fix the problem.  It even
compiles and appears to generate the intended code with gcc 4.2.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


[Bug 234442] libnetgraph race condition

2018-12-27 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234442

Bug ID: 234442
   Summary: libnetgraph race condition
   Product: Base System
   Version: 11.2-STABLE
  Hardware: Any
OS: Any
Status: New
  Severity: Affects Some People
  Priority: ---
 Component: bin
  Assignee: n...@freebsd.org
  Reporter: eu...@freebsd.org
CC: a...@freebsd.org, gleb...@freebsd.org, k...@freebsd.org,
m...@freebsd.org

Created attachment 200557
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=200557=edit
fight race with mutex

Hi!

lib/libnetgraph/msg.c defines static int gMsgId and public functions
NgSendMsg() and NgSendAsciiMsg() that both increment gMsgId in racy way in
attempt to produce unique id for a request sent over AF_NETGRAPH socket.

For long-lived multi-threaded application like net/mpd5 daemon: first thread
can increase gMsgId upto INT_MAX and next moment another thread can increate
gMsgId again to become -1. Then it is copied to unsigned msg.header.token and
returned as signed integer. This means false error status returned with
errno==0 and this breaks workflow of the daemon. I get this problem "in wild"
from time to time.

I have very straightforward and naive patch protecting the variable with simple
mutex (attached) but it has its penalty for performance.

Usage of atomic operations should be better approach but I'm not familiar with
FreeBSD atomic operations. Any help will be appreciated.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"