Bug 974208

Summary: libbtrfs-devel 4.5.1 breaks Docker build
Product: [openSUSE] openSUSE Tumbleweed Reporter: Aleksa Sarai <asarai>
Component: BasesystemAssignee: David Sterba <dsterba>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Major    
Priority: P5 - None CC: mpluskal
Version: Current   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Aleksa Sarai 2016-04-06 08:41:29 UTC
If you look at the build logs in OBS for the Virtualization:containers devel package for Docker using the Factory build repo[1]:

[   97s] ---> Making bundle: dynbinary (in bundles/1.10.3/dynbinary)
[  116s] Created binary: bundles/1.10.3/dynbinary/dockerinit-1.10.3
[  116s] Building: bundles/1.10.3/dynbinary/docker-1.10.3
[  149s] # github.com/docker/docker/daemon/graphdriver/btrfs
[  149s] .gopath/src/github.com/docker/docker/daemon/graphdriver/btrfs/btrfs.go:164: args.name undefined (type C.struct_btrfs_ioctl_vol_args_v2 has no field or method name)
[  199s] error: Bad exit status from /var/tmp/rpm-tmp.V2LGzY (%build)

This error was not present a few days ago, and it appears to have been triggered by some change in the header files for btrfs. This results in us not being able to build Docker on Factory or Tumbleweed. Leap builds still work with the older libbtrfs-devel package.

[1]: https://build.opensuse.org/package/live_build_log/Virtualization:containers/docker/openSUSE_Factory_standard/x86_64
Comment 1 Aleksa Sarai 2016-04-06 15:28:07 UTC
It appears that the change to /usr/include/btrfs/ioctl.h is to blame. Specifically, the btrfs_ioctl_vol_args_v2 structure now has the name field inside a union. cgo (and Go in general) doesn't support unions, so this is a breaking change for us.

For comparison, here's the definition of the structure in btrfs/ioctl.h:

#define BTRFS_SUBVOL_NAME_MAX 4039
struct btrfs_ioctl_vol_args_v2 {
	__s64 fd;
	__u64 transid;
	__u64 flags;
	union {
		struct {
			__u64 size;
			struct btrfs_qgroup_inherit __user *qgroup_inherit;
		};
		__u64 unused[4];
	};
	union {
		char name[BTRFS_SUBVOL_NAME_MAX + 1];
		__u64 devid;
	};
};

And here's the definition in linux/btrfs.h:

#define BTRFS_SUBVOL_NAME_MAX 4039
struct btrfs_ioctl_vol_args_v2 {
	__s64 fd;
	__u64 transid;
	__u64 flags;
	union {
		struct {
			__u64 size;
			struct btrfs_qgroup_inherit *qgroup_inherit;
		};
		__u64 unused[4];
	};
	char name[BTRFS_SUBVOL_NAME_MAX + 1];
};

I'm investigating just using linux/btrfs.h, but that'll be a no-go if we have any requirements on any functions defined by libbtrfs-devel.
Comment 2 Aleksa Sarai 2016-04-07 09:44:27 UTC
This was fixed by defining a C function that would fill the name field. The fix is also upstream (https://github.com/docker/docker/pull/21723). Closing.
Comment 3 David Sterba 2016-04-07 10:27:09 UTC
Good to see you found a fix. The anonymous union inside struct is a common and convenient way of reusing existing bytes. We won't change that back and can extend other structures the same way in the future.

I'm doing release candidates before a major version, so it would be good time to identify and catch such issues in advance.
Comment 4 Swamp Workflow Management 2016-08-26 01:09:20 UTC
SUSE-RU-2016:2158-1: An update that has 10 recommended fixes can now be installed.

Category: recommended (low)
Bug References: 974208,978260,980555,983015,984942,987198,988707,989566,993847,994568
CVE References: 
Sources used:
SUSE OpenStack Cloud 6 (src):    containerd-0.2.2-4.1, docker-1.11.2-76.1, runc-0.1.1-4.1
SUSE Linux Enterprise Module for Containers 12 (src):    containerd-0.2.2-4.1, docker-1.11.2-76.1, runc-0.1.1-4.1
Comment 5 Swamp Workflow Management 2016-12-12 12:12:01 UTC
SUSE-SU-2016:3084-1: An update that solves one vulnerability and has 14 fixes is now available.

Category: security (moderate)
Bug References: 1004490,1006368,1007249,1009961,974208,978260,983015,987198,988408,989566,995058,995102,995620,996015,999582
CVE References: CVE-2016-8867
Sources used:
SUSE OpenStack Cloud 6 (src):    containerd-0.2.4+gitr565_0366d7e-9.1, docker-1.12.3-81.2, runc-0.1.1+gitr2816_02f8fa7-9.1
SUSE Linux Enterprise Module for Containers 12 (src):    containerd-0.2.4+gitr565_0366d7e-9.1, docker-1.12.3-81.2, rubygem-docker-api-1.31.0-11.2, rubygem-excon-0.52.0-9.1, runc-0.1.1+gitr2816_02f8fa7-9.1