All of lore.kernel.org
 help / color / mirror / Atom feed
* [OE-core][PATCH] utils: lockfile: Fix infinite loop
@ 2018-09-25 12:34 ` Ioan-Adrian Ratiu
  0 siblings, 0 replies; 3+ messages in thread
From: Ioan-Adrian Ratiu @ 2018-09-25 12:34 UTC (permalink / raw)
  To: bitbake-devel, openembedded-core

A nasty corner case leads to a hang when utils.lockfile is called from
oe-core's package-manager:deploy_dir_lock (in turn called from
rootfs:_create further up the call stack) with "name" owned by root
and the user running bitbake has no write access.

Because this code runs under pseudo, the UID and EUID of the bitbake
worker process are 0, so the os.access(dirname, os.W_OK) returns True
i.e. it thinks the path is writable when in fact it's not writable.

Only later when trying to open the file an Exception it thrown because
the OS prohibits writing, but the Exception is ignored and the open is
retried leading to an infinite loop.

So this fix is to not ignore the "Permission Denied" exception.

An alternative fix would be to replace the os.access() call with an
try: open() except() at the beginning of the function.

Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
---
 lib/bb/utils.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 56894f13..73b6cb42 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -497,7 +497,11 @@ def lockfile(name, shared=False, retry=True, block=False):
                 if statinfo.st_ino == statinfo2.st_ino:
                     return lf
             lf.close()
-        except Exception:
+        except OSError as e:
+            if e.errno == errno.EACCES:
+                logger.error("Unable to acquire lock '%s', %s",
+                             e.strerror, name)
+                sys.exit(1)
             try:
                 lf.close()
             except Exception:
-- 
2.19.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bitbake-devel][PATCH] utils: lockfile: Fix infinite loop
@ 2018-09-25 12:34 ` Ioan-Adrian Ratiu
  0 siblings, 0 replies; 3+ messages in thread
From: Ioan-Adrian Ratiu @ 2018-09-25 12:34 UTC (permalink / raw)
  To: bitbake-devel, openembedded-core

A nasty corner case leads to a hang when utils.lockfile is called from
oe-core's package-manager:deploy_dir_lock (in turn called from
rootfs:_create further up the call stack) with "name" owned by root
and the user running bitbake has no write access.

Because this code runs under pseudo, the UID and EUID of the bitbake
worker process are 0, so the os.access(dirname, os.W_OK) returns True
i.e. it thinks the path is writable when in fact it's not writable.

Only later when trying to open the file an Exception it thrown because
the OS prohibits writing, but the Exception is ignored and the open is
retried leading to an infinite loop.

So this fix is to not ignore the "Permission Denied" exception.

An alternative fix would be to replace the os.access() call with an
try: open() except() at the beginning of the function.

Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
---
 lib/bb/utils.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 56894f13..73b6cb42 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -497,7 +497,11 @@ def lockfile(name, shared=False, retry=True, block=False):
                 if statinfo.st_ino == statinfo2.st_ino:
                     return lf
             lf.close()
-        except Exception:
+        except OSError as e:
+            if e.errno == errno.EACCES:
+                logger.error("Unable to acquire lock '%s', %s",
+                             e.strerror, name)
+                sys.exit(1)
             try:
                 lf.close()
             except Exception:
-- 
2.19.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* ✗ patchtest: failure for utils: lockfile: Fix infinite loop
  2018-09-25 12:34 ` [bitbake-devel][PATCH] " Ioan-Adrian Ratiu
  (?)
@ 2018-09-25 13:05 ` Patchwork
  -1 siblings, 0 replies; 3+ messages in thread
From: Patchwork @ 2018-09-25 13:05 UTC (permalink / raw)
  To: Ioan-Adrian Ratiu; +Cc: openembedded-core

== Series Details ==

Series: utils: lockfile: Fix infinite loop
Revision: 1
URL   : https://patchwork.openembedded.org/series/14218/
State : failure

== Summary ==


Thank you for submitting this patch series to OpenEmbedded Core. This is
an automated response. Several tests have been executed on the proposed
series by patchtest resulting in the following failures:



* Issue             Series does not apply on top of target branch [test_series_merge_on_head] 
  Suggested fix    Rebase your series on top of targeted branch
  Targeted branch  master (currently at e3f5ceec69)



If you believe any of these test results are incorrect, please reply to the
mailing list (openembedded-core@lists.openembedded.org) raising your concerns.
Otherwise we would appreciate you correcting the issues and submitting a new
version of the patchset if applicable. Please ensure you add/increment the
version number when sending the new version (i.e. [PATCH] -> [PATCH v2] ->
[PATCH v3] -> ...).

---
Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-25 13:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-25 12:34 [OE-core][PATCH] utils: lockfile: Fix infinite loop Ioan-Adrian Ratiu
2018-09-25 12:34 ` [bitbake-devel][PATCH] " Ioan-Adrian Ratiu
2018-09-25 13:05 ` ✗ patchtest: failure for " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.