Skip to contentSkip to conversation

livepatch-build-tools: fix section mismatch

PATCH Glenn Enright 2 participants 3 messages Apr 1, 2019 – Apr 12, 2019

lore
Share & tools
lore
#0 lore raw

I hit an issue generating a livepatch for a recent xsa. I saw the following lines from the create-diff-object.log ...

/livepatch-build-tools/create-diff-object: ERROR: grant_table.o: kpatch_regenerate_special_section: 1162: group size mismatch for section .altinstructions

This looks really similar to the issue reported and fixed in https://github.com/dynup/kpatch/pull/528

The attached patch is based on that report, and resulted in a good livepatch. The alt section size in my case was actually 14.

Regards, Glenn

create-diff-object.c +28 -2
index 82f777e..f9f4abf 100644
@@ -962,9 +962,35 @@ static int bug_frames_0_group_size(struct kpatch_elf *kelf, int offset) { return
 static int bug_frames_1_group_size(struct kpatch_elf *kelf, int offset) { return 8; }
 static int bug_frames_2_group_size(struct kpatch_elf *kelf, int offset) { return 8; }
 static int bug_frames_3_group_size(struct kpatch_elf *kelf, int offset) { return 16; }
-static int ex_table_group_size(struct kpatch_elf *kelf, int offset) { return 8; }
-static int altinstructions_group_size(struct kpatch_elf *kelf, int offset) { return 12; }
+int ex_table_group_size(struct kpatch_elf *kelf, int offset)
+{
+	static int size = 0;
+	char *str;
+
+	if (!size) {
+		str = getenv("EX_STRUCT_SIZE");
+		if (!str)
+			ERROR("EX_STRUCT_SIZE not set");
+		size = atoi(str);
+	}
+
+	return size;
+}
 
+int altinstructions_group_size(struct kpatch_elf *kelf, int offset)
+{
+	static int size = 0;
+	char *str;
+
+	if (!size) {
+		str = getenv("ALT_STRUCT_SIZE");
+		if (!str)
+			ERROR("ALT_STRUCT_SIZE not set");
+		size = atoi(str);
+	}
+
+	return size;
+}
 /*
  * The rela groups in the .fixup section vary in size.  The beginning of each
  * .fixup rela group is referenced by the .ex_table section. To find the size
livepatch-build +21 -0
index c057fa1..6c3409c 100755
@@ -304,6 +304,27 @@ if [ "${SKIP}" != "build" ]; then
         XEN_DEBUG="debug=$XEN_DEBUG"
     fi
 
+    echo "Reading special section data"
+    SPECIAL_VARS=$(readelf -wi "$XENSYMS" |
+        gawk --non-decimal-data '
+	BEGIN { a = e = 0 }
+	a == 0 && /DW_AT_name.* alt_instr$/ {a = 1; next}
+	e == 0 && /DW_AT_name.* exception_table_entry$/ {e = 1; next}
+	a == 1 {printf("export ALT_STRUCT_SIZE=%d\n", $4); a = 2}
+	e == 1 {printf("export EX_STRUCT_SIZE=%d\n", $4); e = 2}
+	a == 2 && b == 2 && p == 2 && e == 2 {exit}')
+
+    [[ -n $SPECIAL_VARS ]] && eval "$SPECIAL_VARS"
+
+    if [[ -z $ALT_STRUCT_SIZE ]] || [[ -z $EX_STRUCT_SIZE ]]; then
+	die "can't find special struct size"
+    fi
+    for i in $ALT_STRUCT_SIZE $EX_STRUCT_SIZE; do 
+	if [[ ! $i -gt 0 ]] || [[ ! $i -le 16 ]]; then
+		die "invalid special struct size $i"
+	fi
+    done
+
     echo "Perform full initial build with ${CPUS} CPU(s)..."
     build_full
 

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#1 lore raw

HI all

A quick bump on this, and added Andrew to the CC list since he appears to have looked at livepatch 'stuff' recently.

Was this patch of any interest at all? Or just wrong? After reading patch submission guidlines, should I resend this a different way?

Regards, Glenn

Quoted 6 lines · Glenn Enright

I hit an issue generating a livepatch for a recent xsa. I saw the following lines from the create-diff-object.log ...

/livepatch-build-tools/create-diff-object: ERROR: grant_table.o: kpatch_regenerate_special_section: 1162: group size mismatch for section .altinstructions

This looks really similar to the issue reported and fixed in https://github.com/dynup/kpatch/pull/528

Quoted 9 lines

The attached patch is based on that report, and resulted in a good livepatch. The alt section size in my case was actually 14.

Regards, Glenn

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 7 lines · Glenn Enright

HI all

A quick bump on this, and added Andrew to the CC list since he appears to have looked at livepatch 'stuff' recently.

Was this patch of any interest at all? Or just wrong? After reading patch submission guidlines, should I resend this a different way?

What patch? Please send it to xen-devel mailing list and use git-send-email.

And also CC the maintainers -which are me and Ross.

Thanks.

Quoted 24 lines

Regards, Glenn

Quoted 20 lines · Glenn Enright

I hit an issue generating a livepatch for a recent xsa. I saw the following lines from the create-diff-object.log ...

/livepatch-build-tools/create-diff-object: ERROR: grant_table.o:
kpatch_regenerate_special_section: 1162: group size mismatch for section .altinstructions

This looks really similar to the issue reported and fixed in
https://github.com/dynup/kpatch/pull/528

The attached patch is based on that report, and resulted in a good livepatch. The alt section size in my case was actually 14.

Regards, Glenn

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel