Skip to content

Commit cfe0fd2

Browse files
authored
Re-add xattr allowlist from readlinkFS (#1942)
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
1 parent e43fc30 commit cfe0fd2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pkg/build/build.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,17 @@ func sourceDateEpoch(defaultTime time.Time) (time.Time, error) {
13901390
return time.Unix(sec, 0).UTC(), nil
13911391
}
13921392

1393+
// xattrIgnoreList contains a mapping of xattr names used by various
1394+
// security features which leak their state into packages. We need to
1395+
// ignore these xattrs because they require special permissions to be
1396+
// set when the underlying security features are in use.
1397+
var xattrIgnoreList = map[string]bool{
1398+
"com.apple.provenance": true,
1399+
"security.csm": true,
1400+
"security.selinux": true,
1401+
"com.docker.grpcfuse.ownership": true,
1402+
}
1403+
13931404
// Record on-disk xattrs and mode bits set during package builds in order to apply them in the new in-memory filesystem
13941405
// This will allow in-memory and bind mount runners to persist xattrs correctly
13951406
func storeXattrs(dir string) (map[string]map[string][]byte, map[string]fs.FileMode, error) {
@@ -1434,6 +1445,10 @@ func storeXattrs(dir string) (map[string]map[string][]byte, map[string]fs.FileMo
14341445
attrs := stringsFromByteSlice(buf[:read])
14351446
result := make(map[string][]byte)
14361447
for _, attr := range attrs {
1448+
if _, ok := xattrIgnoreList[attr]; ok {
1449+
continue
1450+
}
1451+
14371452
s, err := unix.Getxattr(path, attr, nil)
14381453
if err != nil {
14391454
continue

0 commit comments

Comments
 (0)