Package: sudo
Version: 1.9.16p2-3+deb13u2
Severity: normal
Tags: patch

The sudoers parser generation rule in plugins/sudoers/Makefile.in
declares gram.c and gram.h as ordinary multiple targets:

|$(devdir)/gram.c $(devdir)/gram.h: $(srcdir)/gram.y prologue|

The recipe generates both files using Bison via the temporary files
y.tab.c and y.tab.h.

With this ordinary multiple-target rule, GNU make may execute the
recipe separately for each target during parallel builds. This can
cause duplicate Bison invocations and potentially race over the
temporary output files.

The rule should use a grouped target instead:

|$(devdir)/gram.c $(devdir)/gram.h &: $(srcdir)/gram.y prologue|

Grouped targets were introduced in GNU make 4.3, so this change
requires GNU make >= 4.3.

I tested the change on Debian trixie with GNU make 4.4.1 and
Bison 3.8.2.

For both the simple and LDAP build configurations, I removed the
generated parser files and ran parallel builds with make -j4.
A wrapper around Bison confirmed exactly one invocation for
gram.y in each configuration. The generated parser files were
identical to the previously generated files.

A subsequent full binary package build completed successfully.

The attached patch contains the proposed fix.

Best regards

Marcel Jueling


Description: Prevent duplicate Bison invocations during parallel sudoers builds
Author: Marcel Jueling
Forwarded: not-needed

--- a/plugins/sudoers/Makefile.in
+++ b/plugins/sudoers/Makefile.in
@@ -510 +510 @@
-$(devdir)/gram.c $(devdir)/gram.h: $(srcdir)/gram.y prologue
+$(devdir)/gram.c $(devdir)/gram.h &: $(srcdir)/gram.y prologue

Reply via email to