dotnet / dotnet/core

Clashing .build-ids in ELF binaries generated by dotnet

Open
#9,897 6 comments 4 reactions 0 assignees View on GitHub
Dominant language
PowerShell
Stars
22k
Forks
4.9k
Avg merge
5d 5h
Merged PRs (30d)
29

Description

## Summary

When generating ELF binaries for dotnet packages using `dotnet build --runtime linux-x64 -c Release` different projects will generate binaries that have the same .note.gnu.build-id

We have seen this from two separate dotnet rpms generated by entirely different vendors so this is not a theoretical issue.

## Why is that a problem?

When these binaries are packaged up as rpms with standard rpmbuild tooling the build-ids are generated as symlinks in /usr/lib/.build-id. Two packages cannot have the same .build-id in that folder structure so two dotnet packages both built in this way cannot be installed on the same Redhat based linux system.

## Workarounds

The builder of the rpm can exclude the build-id information from the /usr/lib structure in various ways (e.g. %define _build_id_links none in the rpm spec)

## Repro Scenario

Create two separate dotnet console applications with something like `dotnet create console -o app` and `dotnet create console -o app2`.

Modify one application to produce different output so the binaries should not be the same

Run `dotnet build --runtime linux-x64 -c Release` in both directories

Run `readelf bin/Release/net8.0/linux-x64/app2 -n` in both directories and note that the binaries have the same.

```
dotnet --info
.NET SDK:
Version: 8.0.116
Commit: 4d8dee1e9e
Workload version: 8.0.100-manifests.0b4715a7

Runtime Environment:
OS Name: ubuntu
OS Version: 24.04
OS Platform: Linux
RID: ubuntu.24.04-x64
Base Path: /usr/lib/dotnet/sdk/8.0.116/

.NET workloads installed:
Workload version: 8.0.100-manifests.0b4715a7
There are no installed workloads to display.

Host:
Version: 8.0.16
Architecture: x64
Commit: efd5742bb5

.NET SDKs installed:
8.0.116 [/usr/lib/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.16 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.16 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download
```

```
cksum bin/Release/net8.0/linux-x64/app
1731968489 72520 bin/Release/net8.0/linux-x64/app

readelf bin/Release/net8.0/linux-x64/app -n

Displaying notes found in: .note.ABI-tag
Owner Data size Description
GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag)
OS: Linux, ABI: 2.6.32

Displaying notes found in: .note.gnu.build-id
Owner Data size Description
GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring)
Build ID: 9a284db3053a0dfa2eefa864aadec40c08b2c09d
```

```
cksum bin/Release/net8.0/linux-x64/app2
3813021713 72520 bin/Release/net8.0/linux-x64/app2
readelf bin/Release/net8.0/linux-x64/app2 -n

Displaying notes found in: .note.ABI-tag
Owner Data size Description
GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag)
OS: Linux, ABI: 2.6.32

Displaying notes found in: .note.gnu.build-id
Owner Data size Description
GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring)
Build ID: 9a284db3053a0dfa2eefa864aadec40c08b2c09d
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.