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

Gabriel Ravier gabravier@gmail.com
Fri Nov 6 09:57:40 GMT 2026


On 11/6/26 9:23 AM, 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>
> ---
>   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
> +   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.
> +
> +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"

update -> find_backports, I assume

> +    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))
> +
> +  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'))
> +
> +  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
> +      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