[PATCH 1/5] scripts: add "find_backports" mode to process-advisories.sh to find more packports

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Tue Nov 10 15:39:49 GMT 2026



On 06/11/26 05:23, Rolf Eike Beer wrote:
> This will look through the stable branches to find additional backports of
> the fix for the given advisory.
> 
> Signed-off-by: Rolf Eike Beer <eb@emlix.com>

Thanks for the v2, it handles most of my previous comments. However, two of them
are still open, and I think both should be fixed before this goes in.

> ---
>  advisories/README             | 22 +++++++++++++++++++
>  scripts/process-advisories.sh | 40 +++++++++++++++++++++++++++++++++--
>  2 files changed, 60 insertions(+), 2 deletions(-)
> 
> diff --git a/advisories/README b/advisories/README
> index d16049085f..f75f906fc1 100644
> --- a/advisories/README
> +++ b/advisories/README
> @@ -65,6 +65,9 @@ An advisory for a CVE needs to be added on the master branch in two steps:
>     tags.  Don't bother adding the release-version subscript since the
>     next step will overwrite it.
>  
> +   For backports that are already pushed see "Updating an Advisory" below

s/packports/backports/ in the subject.

> +   for an alternative way that automates the collection.
> +
>  3. Run the process-advisories.sh script in the scripts directory on the
>     advisory:
>  
> @@ -74,6 +77,25 @@ An advisory for a CVE needs to be added on the master branch in two steps:
>  
>  4. Verify the updated advisory and push the result.
>  
> +Updating an Advisory
> +--------------------
> +
> +When not all backports were immediately available when the advisory was
> +published, e.g. because no fix existed in the first place, adding more
> +Fix-Commit entries later can be automated. Be careful, this only works
> +for backports already _pushed_ as the scripts checks the remote branches
> +instead of the local one.

s/the scripts checks/the script checks/

> +
> +In case you had to revert backports and cherry-pick them again make sure
> +to remove the Fix-Commit entries for the reverted commits from the
> +advisory file.
> +
> +Run:
> +
> +  scripts/process-advisories.sh find_backports GLIBC-SA-YYYY-NNNN
> +
> +Afterwards review and commit the results as usual.
> +
>  Rejecting an Advisory
>  ---------------------
>  
> diff --git a/scripts/process-advisories.sh b/scripts/process-advisories.sh
> index a520fab5e6..ed21785ebd 100755
> --- a/scripts/process-advisories.sh
> +++ b/scripts/process-advisories.sh
> @@ -25,7 +25,7 @@ command=$1
>  
>  usage () {
>      cat >&2 <<EOF
> -usage: $0 {update|news}
> +usage: $0 {update|news|find_backports}
>  EOF
>      exit 1
>  }
> @@ -33,7 +33,7 @@ EOF
>  command="$1"
>  
>  case "$command" in
> -    update|news)
> +    update|news|find_backports)
>      ;;
>      *)
>          usage
> @@ -69,6 +69,42 @@ advisories_update() {
>      done
>  }
>  
> +advisories_find_backports() {
> +  advisory=$1
> +
> +  if [ -z $1 ]; then
> +    echo "Usage: $0 update GLIBC-SA-YYYY-NNNN"

As Gabriel pointed out, s/update/find_backports/.

> +    exit 1
> +  fi
> +
> +  advisory_file=advisories/$advisory
> +
> +  FIX=($(sed -nr '/^Fix-Commit: /s/Fix-Commit: *([0-9a-fA-F]+) *\(2\.[0-9]+\).*/\1/p' $advisory_file))

This still matches only an annotated master commit, so a bare 'Fix-Commit: <hash>'
line, which is what step 2 produces, is ignored.  For instance,
GLIBC-SA-2026-0016 has no Fix-Commit yet.  Adding the master fix as step 2 says:

  Fix-Commit: cbf59b836645b6ac69ad8c47a560598bc4942ecc

and then running find_backports fails with "No Fix-Commit found". 

The regex I suggested on v1 handles both forms:

  # Master fix commits are either not yet annotated with a release version or
  # annotated with a plain "(2.NN)".  Backport entries carry a "(2.NN-MMM)"
  # subscript and must not be scanned for.
  FIX=($(sed -nr 's/^Fix-Commit: *([0-9a-fA-F]+) *(\(2\.[0-9]+\))? *$/\1/p' $advisory_file))

With it, GLIBC-SA-2026-0016 gets the 2.41-166, 2.42-102, 2.43-72 and
2.44-55 backports.

> +
> +  if [ ${#FIX[@]} -eq 0 ]; then
> +    echo "No Fix-Commit found in $advisory_file"
> +    exit 1
> +  fi
> +
> +  release_branches=($(git for-each-ref --format='%(refname:short)' 'refs/remotes/origin/release/2.*/master'))

If the remote has another name this list is empty, and the script exits 0
without adding anything, which looks like "no new backports".  I think it
should fail instead:

  if [ ${#release_branches[@]} -eq 0 ]; then
    echo "No origin/release/2.*/master branches found"
    exit 1
  fi

> +
> +  for n in ${release_branches[@]}; do
> +    for f in ${FIX[@]}; do
> +      BACKPORT=($(git log origin/master..${n} --grep "cherry picked from commit ${f}" --format=%H))
> +      if [ ${#BACKPORT[@]} -eq 0 ]; then
> +        continue
> +      fi
> +      grep -q "^Fix-Commit: ${BACKPORT[0]} " $advisory_file && continue

The trailing space still misses bare lines, so a backport already listed as
'Fix-Commit: <hash>' is added again with the subscript, and 'update' then
leaves two identical lines.  As on v1:

  grep -qE "^Fix-Commit: ${BACKPORT[0]}( |\$)" $advisory_file && continue

> +      if [ ${#BACKPORT[@]} -ne 1 ]; then
> +        # This can happen when a backport was later reverted and cherry-picked again.
> +        # Since "git log" has the most recent one first picking [0] still is the correct thing.
> +        echo "Warning: Multiple matches for backport of ${f} found in branch ${n}: ${BACKPORT[@]}"
> +      fi
> +      echo "Fix-Commit: ${BACKPORT[0]} ($(get_rel ${BACKPORT[0]}))" >> $advisory_file
> +    done
> +  done
> +}
> +
>  advisories_news() {
>    rel=$(get_rel "HEAD")
>    for f in $(grep -l "^Fix-Commit: .* ($rel)$" advisories/*); do



More information about the Libc-alpha mailing list