tools/libs/light: Fix nic->vlan memory allocation
PATCH 1/1 tools/libs/light: Fix nic->vlan memory allocation
After the following commit:3bc14e4fa4b9 ("tools/libs/light: Add vlan field to libxl_device_nic") xl list -l aborts with a double free error if a domain has at least one vif defined:
$ sudo xl list -l free(): double free detected in tcache 2 Aborted
Orginally, the vlan field was called vid and was defined as an integer. It was appropriate to call libxl__xs_read_checked() with gc passed as the string data was copied to a different variable. However, the final version uses a string data type and the call should have been changed to use NOGC instead of gc to allow that data to live past the gc controlled lifetime, in line with the other string fields.
This patch makes the change to pass NOGC instead of gc and moves the new code to be next to the other string fields (fixing a couple of errant tabs along the way), as recommended by Jason.
--- tools/libs/light/libxl_nic.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
tools/libs/light/libxl_nic.c +4 -5
@@ -318,11 +318,6 @@ static int libxl__nic_from_xenstore(libxl__gc *gc, const char *libxl_path, nic->mtu =LIBXL_DEVICE_NIC_MTU_DEFAULT ; } - rc =libxl__xs_read_checked (gc,XBT_NULL , -GCSPRINTF ("%s/vlan" , libxl_path), - (const char **)(&nic->vlan)); -if (rc) goto out; - rc =libxl__xs_read_checked (gc,XBT_NULL ,GCSPRINTF ("%s/mac" , libxl_path), &tmp);if (rc) goto out;
@@ -345,6 +340,10 @@ static int libxl__nic_from_xenstore(libxl__gc *gc, const char *libxl_path,GCSPRINTF ("%s/script" , libxl_path), (const char **)(&nic->script));if (rc) goto out; + rc =libxl__xs_read_checked (NOGC ,XBT_NULL , +GCSPRINTF ("%s/vlan" , libxl_path), + (const char **)(&nic->vlan)); +if (rc) goto out; rc =libxl__xs_read_checked (NOGC ,XBT_NULL ,GCSPRINTF ("%s/forwarddev" , libxl_path), (const char **)(&nic->coloft_forwarddev));
Signature · 1 line
2.39.2
Quoted 16 lines · Leigh Brown
After the following commit:
3bc14e4fa4b9("tools/libs/light: Add vlan field tolibxl_device_nic") xl list -l aborts with a double free error if a domain has at least one vif defined:$ sudo xl list -l free(): double free detected in tcache 2 AbortedOrginally, the vlan field was called vid and was defined as an integer. It was appropriate to call
libxl__xs_read_checked()with gc passed as the string data was copied to a different variable. However, the final version uses a string data type and the call should have been changed to use NOGC instead of gc to allow that data to live past the gc controlled lifetime, in line with the other string fields.
Quoted 6 lines
This patch makes the change to pass NOGC instead of gc and moves the new code to be next to the other string fields (fixing a couple of errant tabs along the way), as recommended by Jason.
Fixes 3bc14e4fa4b9 ("tools/libs/light: Add vlan field to libxl_device_nic")Signed-off-by Leigh Brown <[email protected]>
Thanks,
Jason
Quoted 17 lines · Jason Andryuk
Quoted 16 lines · Leigh Brown
After the following commit:
3bc14e4fa4b9("tools/libs/light: Add vlan field tolibxl_device_nic") xl list -l aborts with a double free error if a domain has at least one vif defined:$ sudo xl list -l free(): double free detected in tcache 2 AbortedOrginally, the vlan field was called vid and was defined as an integer. It was appropriate to call
libxl__xs_read_checked()with gc passed as the string data was copied to a different variable. However, the final version uses a string data type and the call should have been changed to use NOGC instead of gc to allow that data to live past the gc controlled lifetime, in line with the other string fields.
Quoted 8 lines
Quoted 6 lines
This patch makes the change to pass NOGC instead of gc and moves the new code to be next to the other string fields (fixing a couple of errant tabs along the way), as recommended by Jason.
Fixes 3bc14e4fa4b9 ("tools/libs/light: Add vlan field to libxl_device_nic")Signed-off-by Leigh Brown <[email protected]>Reviewed-by Jason Andryuk <[email protected]>
I notice this wasn't Cc-ed to the maintainer, which likely is the reason for there not having been an ack yet. Anthony, any thoughts?
Further at this point, bug fix or not, it would likely also need a release ack. Oleksii, thoughts?
Jan
Quoted 36 lines · Jan Beulich
Quoted 29 lines · Jason Andryuk
Quoted 28 lines · Leigh Brown
After the following commit:
3bc14e4fa4b9("tools/libs/light: Add vlan field tolibxl_device_nic")
xl list -l aborts with a double free error if a domain has at least
one vif defined:$ sudo xl list -l free(): double free detected in tcache 2 AbortedOrginally, the vlan field was called vid and was defined as an integer.
It was appropriate to calllibxl__xs_read_checked()with gc passed as
the string data was copied to a different variable. However, the final
version uses a string data type and the call should have been changed
to use NOGC instead of gc to allow that data to live past the gc controlled lifetime, in line with the other string fields.This patch makes the change to pass NOGC instead of gc and moves the
new code to be next to the other string fields (fixing a couple of
errant tabs along the way), as recommended by Jason.Quoted 5 lines
Quoted 3 lines
Fixes 3bc14e4fa4b9 ("tools/libs/light: Add vlan field to
libxl_device_nic")Signed-off-by Leigh Brown <[email protected]>Reviewed-by Jason Andryuk <[email protected]>
Quoted 7 lines
I notice this wasn't Cc-ed to the maintainer, which likely is the reason
for there not having been an ack yet. Anthony, any thoughts?Further at this point, bug fix or not, it would likely also need a release
ack. Oleksii, thoughts?
It seems to me it is bug fix, so it should be in release:
~ Oleksii
Anthony PERARD
Acked-byQuoted 17 lines · Jason Andryuk
Quoted 16 lines · Leigh Brown
After the following commit:
3bc14e4fa4b9("tools/libs/light: Add vlan field tolibxl_device_nic") xl list -l aborts with a double free error if a domain has at least one vif defined:$ sudo xl list -l free(): double free detected in tcache 2 AbortedOrginally, the vlan field was called vid and was defined as an integer. It was appropriate to call
libxl__xs_read_checked()with gc passed as the string data was copied to a different variable. However, the final version uses a string data type and the call should have been changed to use NOGC instead of gc to allow that data to live past the gc controlled lifetime, in line with the other string fields.
Quoted 8 lines
Quoted 6 lines
This patch makes the change to pass NOGC instead of gc and moves the new code to be next to the other string fields (fixing a couple of errant tabs along the way), as recommended by Jason.
Fixes 3bc14e4fa4b9 ("tools/libs/light: Add vlan field to libxl_device_nic")Signed-off-by Leigh Brown <[email protected]>Reviewed-by Jason Andryuk <[email protected]>
Thanks,
Signature · 5 lines
Anthony Perard | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech
Quoted 22 lines · Anthony PERARD
Quoted 21 lines · Jason Andryuk
Quoted 20 lines · Leigh Brown
After the following commit:
3bc14e4fa4b9("tools/libs/light: Add vlan field tolibxl_device_nic") xl list -l aborts with a double free error if a domain has at least one vif defined:$ sudo xl list -l free(): double free detected in tcache 2 AbortedOrginally, the vlan field was called vid and was defined as an integer. It was appropriate to call
libxl__xs_read_checked()with gc passed as the string data was copied to a different variable. However, the final version uses a string data type and the call should have been changed to use NOGC instead of gc to allow that data to live past the gc controlled lifetime, in line with the other string fields.This patch makes the change to pass NOGC instead of gc and moves the new code to be next to the other string fields (fixing a couple of errant tabs along the way), as recommended by Jason.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Fixes 3bc14e4fa4b9 ("tools/libs/light: Add vlan field to libxl_device_nic")Signed-off-by Leigh Brown <[email protected]>Reviewed-by Jason Andryuk <[email protected]>Acked-by Anthony PERARD <[email protected]>
Btw, at the example of this: Are you meaning to update ./MAINTAINERS with that new email address of yours. Strictly speaking I think for Acked-by: to actually fulfill its purpose (and for R-b to have its normally implied meaning of "ack" when coming from a maintainer), it probably ought to match the corresponding entry in ./MAINTAINERS.
Jan