ebtables lock file fcntl errno value not correctly checked

Bug #1772456 reported by Dan Streetman
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ebtables (Ubuntu)
Fix Released
Medium
Dan Streetman
Trusty
Fix Released
Medium
Dan Streetman
Xenial
Fix Released
Medium
Dan Streetman
Artful
Fix Released
Medium
Dan Streetman
Bionic
Fix Released
Medium
Dan Streetman
Cosmic
Fix Released
Medium
Dan Streetman

Bug Description

[impact]

bug 1645324 introduced code to improve the existing file-based locking, by using fcntl instead of exclusive file opening.

However, when fcntl fails the new code tries to check for errno of EAGAIN or EACCES, but does so incorrectly:

+ ret = fcntl(lockfd, F_SETLK, &fl);
+ if (ret == -1 && errno != (EAGAIN || EACCES))

"errno != (EAGAIN || EACCES)" is not correct, because it will always evaluate to true when errno is either EAGAIN or EACCES; the bitwise OR of EAGAIN (11) and EACCES (13) produces 15 (ENOTBLK) which will never match either, so != always is true.

[test case]

run ebtables in a tight loop from two separate shells, to force lockfile contention, for example:

#!/bin/bash

dev="$1"

while test 1; do
sleep 0
ebtables --concurrent -t nat -A PREROUTING -i ${dev} -j ACCEPT
if [ $? -ne 0 ]; then
echo "odd!"
fi
ebtables --concurrent -t nat -D PREROUTING -i ${dev} -j ACCEPT
if [ $? -ne 0 ]; then
echo "odd!"
fi
done

that can be run with any text param (e.g. "foo" and "bar") from 2 shells, to produce the failure:

Unable to create lock file /var/lib/ebtables/lock.

[regression potential]

like the previous patch, this change also has the potential to introduce errors in file locking that ebtables uses; however considering the file locking currently does not work at all due to the above logic error, this patch should only help. The only regression potential is see is the possibility of breaking non-contended file locking, which currently does work.

[other info]

see previous bug 1645324
https://launchpad.net/bugs/1645324

Revision history for this message
Dan Streetman (ddstreet) wrote :

thanks @setuid for reproducer bash script that I used in description

Changed in ebtables (Ubuntu):
status: New → In Progress
assignee: nobody → Dan Streetman (ddstreet)
importance: Undecided → Medium
no longer affects: ebtables (Ubuntu Precise)
no longer affects: ebtables (Ubuntu Precise)
Changed in ebtables (Ubuntu Trusty):
status: New → In Progress
Dan Streetman (ddstreet)
Changed in ebtables (Ubuntu Bionic):
status: New → In Progress
Changed in ebtables (Ubuntu Artful):
status: New → In Progress
Changed in ebtables (Ubuntu Xenial):
status: New → In Progress
Changed in ebtables (Ubuntu Bionic):
importance: Undecided → Medium
Changed in ebtables (Ubuntu Artful):
importance: Undecided → Medium
Changed in ebtables (Ubuntu Xenial):
importance: Undecided → Medium
Changed in ebtables (Ubuntu Trusty):
importance: Undecided → Medium
Changed in ebtables (Ubuntu Bionic):
assignee: nobody → Dan Streetman (ddstreet)
Changed in ebtables (Ubuntu Artful):
assignee: nobody → Dan Streetman (ddstreet)
Changed in ebtables (Ubuntu Xenial):
assignee: nobody → Dan Streetman (ddstreet)
Changed in ebtables (Ubuntu Trusty):
assignee: nobody → Dan Streetman (ddstreet)
Revision history for this message
Steve Langasek (vorlon) wrote : Please test proposed package

Hello Dan, or anyone else affected,

Accepted ebtables into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ebtables/2.0.10.4-3.5ubuntu2.18.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in ebtables (Ubuntu Cosmic):
status: In Progress → Fix Committed
Changed in ebtables (Ubuntu Bionic):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-bionic
Changed in ebtables (Ubuntu Xenial):
status: In Progress → Fix Committed
tags: added: verification-needed-xenial
Revision history for this message
Steve Langasek (vorlon) wrote :

Hello Dan, or anyone else affected,

Accepted ebtables into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ebtables/2.0.10.4-3.4ubuntu2.16.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in ebtables (Ubuntu Artful):
status: In Progress → Fix Committed
tags: added: verification-needed-artful
Revision history for this message
Steve Langasek (vorlon) wrote :

Hello Dan, or anyone else affected,

Accepted ebtables into artful-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ebtables/2.0.10.4-3.5ubuntu2.17.10.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-artful to verification-done-artful. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-artful. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Revision history for this message
Steve Langasek (vorlon) wrote :

Hello Dan, or anyone else affected,

Accepted ebtables into trusty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ebtables/2.0.10.4-3ubuntu1.14.04.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-trusty to verification-done-trusty. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-trusty. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in ebtables (Ubuntu Trusty):
status: In Progress → Fix Committed
tags: added: verification-needed-trusty
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ebtables - 2.0.10.4-3.5ubuntu3

---------------
ebtables (2.0.10.4-3.5ubuntu3) cosmic; urgency=medium

  * Fix check of fcntl errno value, to allow lockfile contention to work.
    (LP: #1772456)

 -- Dan Streetman <email address hidden> Mon, 21 May 2018 13:20:15 -0400

Changed in ebtables (Ubuntu Cosmic):
status: Fix Committed → Fix Released
Revision history for this message
Dan Streetman (ddstreet) wrote :

cosmic:

ubuntu@lp1772456-c:~$ dpkg -l | grep ebtables
ii ebtables 2.0.10.4-3.5ubuntu3 amd64 Ethernet bridge frame table administration

ubuntu@lp1772456-c:~$ sudo ./repro.sh foo & sudo ./repro.sh bar &
[1] 15848
[2] 15849
ubuntu@lp1772456-c:~$ Trying to obtain lock /run/ebtables.lock
Trying to obtain lock /run/ebtables.lock
Trying to obtain lock /run/ebtables.lock

verified fixed in cosmic.

Revision history for this message
Dan Streetman (ddstreet) wrote :

bionic:

ubuntu@lp1772456-b:~$ dpkg -l | grep ebtables
ii ebtables 2.0.10.4-3.5ubuntu2 amd64 Ethernet bridge frame table administration

ubuntu@lp1772456-b:~$ sudo ./repro.sh foo & sudo ./repro.sh bar &
[1] 2807
[2] 2808
ubuntu@lp1772456-b:~$ Unable to create lock file /run/ebtables.lock.
odd!
Unable to create lock file /run/ebtables.lock.
odd!
Unable to create lock file /run/ebtables.lock.
odd!
Unable to create lock file /run/ebtables.lock.
odd!
Unable to create lock file /run/ebtables.lock.
odd!
Unable to create lock file /run/ebtables.lock.

ubuntu@lp1772456-b:~$ dpkg -l | grep ebtables
ii ebtables 2.0.10.4-3.5ubuntu2.18.04.1 amd64 Ethernet bridge frame table administration

ubuntu@lp1772456-b:~$ sudo ./repro.sh foo & sudo ./repro.sh bar &
[1] 17609
[2] 17610
ubuntu@lp1772456-b:~$ Trying to obtain lock /run/ebtables.lock
Trying to obtain lock /run/ebtables.lock
Trying to obtain lock /run/ebtables.lock
Trying to obtain lock /run/ebtables.lock
Trying to obtain lock /run/ebtables.lock

verified fixed in bionic.

Revision history for this message
Dan Streetman (ddstreet) wrote :

artful:

ubuntu@lp1772456-a:~$ dpkg -l | grep ebtables
ii ebtables 2.0.10.4-3.5ubuntu2 amd64 Ethernet bridge frame table administration

ubuntu@lp1772456-a:~$ sudo ./repro.sh foo & sudo ./repro.sh bar &
[1] 2576
[2] 2577
ubuntu@lp1772456-a:~$ Unable to create lock file /run/ebtables.lock.
odd!
Unable to create lock file /run/ebtables.lock.
odd!
Unable to create lock file /run/ebtables.lock.
odd!
Sorry, rule does not exist.
odd!
Unable to create lock file /run/ebtables.lock.
odd!
Sorry, rule does not exist.
odd!
Unable to create lock file /run/ebtables.lock.

ubuntu@lp1772456-a:~$ dpkg -l | grep ebtables
ii ebtables 2.0.10.4-3.5ubuntu2.17.10.1 amd64 Ethernet bridge frame table administration

ubuntu@lp1772456-a:~$ sudo ./repro.sh foo & sudo ./repro.sh bar &
[1] 30343
[2] 30344
ubuntu@lp1772456-a:~$ Trying to obtain lock /run/ebtables.lock
Trying to obtain lock /run/ebtables.lock
Trying to obtain lock /run/ebtables.lock
Trying to obtain lock /run/ebtables.lock

verified fixed in artful.

Revision history for this message
Dan Streetman (ddstreet) wrote :

xenial:

ubuntu@lp1772456-x:~$ dpkg -l | grep ebtables
ii ebtables 2.0.10.4-3.4ubuntu2 amd64 Ethernet bridge frame table administration

ubuntu@lp1772456-x:~$ sudo ./repro.sh foor & sudo ./repro.sh bar &
[1] 18987
[2] 18988
ubuntu@lp1772456-x:~$ Unable to create lock file /run/ebtables.lock.
odd!
Unable to create lock file /run/ebtables.lock.
odd!
Unable to create lock file /run/ebtables.lock.
odd!
Unable to create lock file /run/ebtables.lock.
odd!
Unable to create lock file /run/ebtables.lock.
odd!
Sorry, rule does not exist.
Unable to create lock file /run/ebtables.lock.
odd!
odd!
Unable to create lock file /run/ebtables.lock.

ubuntu@lp1772456-x:~$ dpkg -l | grep ebtables
ii ebtables 2.0.10.4-3.4ubuntu2.16.04.1 amd64 Ethernet bridge frame table administration

ubuntu@lp1772456-x:~$ sudo ./repro.sh foor & sudo ./repro.sh bar &
[1] 23212
[2] 23213
ubuntu@lp1772456-x:~$ Trying to obtain lock /run/ebtables.lock
Trying to obtain lock /run/ebtables.lock
Trying to obtain lock /run/ebtables.lock
Trying to obtain lock /run/ebtables.lock

verified fixed in xenial.

Revision history for this message
Dan Streetman (ddstreet) wrote :

trusty:

ubuntu@lp1772456-t:~$ dpkg -l | grep ebtables
ii ebtables 2.0.10.4-3ubuntu1.14.04.1 amd64 Ethernet bridge frame table administration

ubuntu@lp1772456-t:~$ sudo ./repro.sh foo & sudo ./repro.sh bar &
[1] 2728
[2] 2729
ubuntu@lp1772456-t:~$ Unable to create lock file /var/lib/ebtables/lock.
odd!
Unable to create lock file /var/lib/ebtables/lock.
odd!
Unable to create lock file /var/lib/ebtables/lock.
odd!
Sorry, rule does not exist.
odd!
Unable to create lock file /var/lib/ebtables/lock.
odd!
Unable to create lock file /var/lib/ebtables/lock.

ubuntu@lp1772456-t:~$ dpkg -l | grep ebtables
ii ebtables 2.0.10.4-3ubuntu1.14.04.2 amd64 Ethernet bridge frame table administration

ubuntu@lp1772456-t:~$ sudo ./repro.sh foo & sudo ./repro.sh bar &
[1] 5643
[2] 5644
ubuntu@lp1772456-t:~$ Trying to obtain lock /var/lib/ebtables/lock
Trying to obtain lock /var/lib/ebtables/lock
Trying to obtain lock /var/lib/ebtables/lock
Trying to obtain lock /var/lib/ebtables/lock
Trying to obtain lock /var/lib/ebtables/lock

verified fixed in trusty.

tags: added: verification-done verification-done-artful verification-done-bionic verification-done-trusty verification-done-xenial
removed: verification-needed verification-needed-artful verification-needed-bionic verification-needed-trusty verification-needed-xenial
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ebtables - 2.0.10.4-3.5ubuntu2.18.04.1

---------------
ebtables (2.0.10.4-3.5ubuntu2.18.04.1) bionic; urgency=medium

  * Fix check of fcntl errno value, to allow lockfile contention to work.
    (LP: #1772456)

 -- Dan Streetman <email address hidden> Mon, 21 May 2018 13:20:15 -0400

Changed in ebtables (Ubuntu Bionic):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for ebtables has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ebtables - 2.0.10.4-3.5ubuntu2.17.10.1

---------------
ebtables (2.0.10.4-3.5ubuntu2.17.10.1) artful; urgency=medium

  * Fix check of fcntl errno value, to allow lockfile contention to work.
    (LP: #1772456)

 -- Dan Streetman <email address hidden> Mon, 21 May 2018 13:20:15 -0400

Changed in ebtables (Ubuntu Artful):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ebtables - 2.0.10.4-3.4ubuntu2.16.04.1

---------------
ebtables (2.0.10.4-3.4ubuntu2.16.04.1) xenial; urgency=medium

  * Fix check of fcntl errno value, to allow lockfile contention to work.
    (LP: #1772456)

 -- Dan Streetman <email address hidden> Mon, 21 May 2018 13:20:15 -0400

Changed in ebtables (Ubuntu Xenial):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ebtables - 2.0.10.4-3ubuntu1.14.04.2

---------------
ebtables (2.0.10.4-3ubuntu1.14.04.2) trusty; urgency=medium

  * Fix check of fcntl errno value, to allow lockfile contention to work.
    (LP: #1772456)

 -- Dan Streetman <email address hidden> Mon, 21 May 2018 13:20:15 -0400

Changed in ebtables (Ubuntu Trusty):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.