Skip to contentSkip to conversation

Trivial patches for 2015-12-04

GIT PULL Applied Michael Tokarev 2 participants 11 messages Dec 4, 2015 Crypto API

lore
Share & tools
lore
#1 lore raw

[Qemu-devel] [PULL 1/9] util/id: fully allocate names table

In reply to Michael Tokarev

From: John Snow <[email protected]>

Trivial: this array should be allocated to have ID_MAX entries always. Otherwise if someone were to forget to expand this table, the assertion in the id generator won't actually trigger; it will read junk data.

---
 util/id.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
util/id.c +2 -2
index bcc64d8..7883fbe 100644
@@ -29,7 +29,7 @@ bool id_wellformed(const char *id)
 
 #define ID_SPECIAL_CHAR '#'
 
-static const char *const id_subsys_str[] = {
+static const char *const id_subsys_str[ID_MAX] = {
     [ID_QDEV]  = "qdev",
     [ID_BLOCK] = "block",
 };
@@ -53,7 +53,7 @@ char *id_generate(IdSubSystems id)
     static uint64_t id_counters[ID_MAX];
     uint32_t rnd;
 
-    assert(id < ID_MAX);
+    assert(id < ARRAY_SIZE(id_subsys_str));
     assert(id_subsys_str[id]);
 
     rnd = g_random_int_range(0, 100);
Signature · 1 line
2.1.4
#2 lore raw

[Qemu-devel] [PULL 6/9] gt64xxx: fix decoding of ISD register

In reply to Michael Tokarev

From: Paolo Bonzini <[email protected]>

The GT64xxx's internal registers can be placed above the first 4 GiB in the address space, but not above the first 64 GiB. Correctly cast the register to a 64-bit integer, and mask away bits above bit 35.

Datasheet at http://pdf.datasheetarchive.com/datasheetsmain/Datasheets-33/DSA-655889.pdf
(bug reported by Coverity).

---
 hw/mips/gt64xxx_pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/mips/gt64xxx_pci.c +2 -1
index 10fcca3..f76a9fd 100644
@@ -275,7 +275,8 @@ static void check_reserved_space (hwaddr *start,
 
 static void gt64120_isd_mapping(GT64120State *s)
 {
-    hwaddr start = s->regs[GT_ISD] << 21;
+    /* Bits 14:0 of ISD map to bits 35:21 of the start address.  */
+    hwaddr start = ((hwaddr)s->regs[GT_ISD] << 21) & 0xFFFE00000ull;
     hwaddr length = 0x1000;
 
     if (s->ISD_length) {
Signature · 1 line
2.1.4
#3 lore raw

[Qemu-devel] [PULL 9/9] bt: check struct sizes

In reply to Michael Tokarev

From: Paolo Bonzini <[email protected]>

See http://permalink.gmane.org/gmane.linux.bluez.kernel/36505. For historical reasons these do not use sizeof, and Coverity caught a mistake in EVT_ENCRYPT_CHANGE_SIZE.

In addition:

- remove status from create_conn_cancel_cp; the "status" field is only in rp structs. Note that this means that the OCF_CREATE_CONN_CANCEL could never have worked (it would have failed the LENGTH_CHECK), but I am keeping it anyway.

- OCF_READ_LINK_QUALITY similarly could never have worked, but I am fixing read_link_quality_cp anyway.

- fix inquiry_info which is shorter by one: the kernel has a struct that is 14 byte long, but not counting the initial num_responses byte which the kernel parses separately;

- remove extended_inquiry_info altogether, since it's not used and unlike the other inquiry structs does not have the initial num_responses byte.

---
 include/hw/bt.h | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)
include/hw/bt.h +4 -17
index cb2a7e6..c7c7909 100644
@@ -504,7 +504,6 @@ typedef struct {
 
 #define OCF_CREATE_CONN_CANCEL		0x0008
 typedef struct {
-    uint8_t	status;
     bdaddr_t	bdaddr;
 } QEMU_PACKED create_conn_cancel_cp;
 #define CREATE_CONN_CANCEL_CP_SIZE 6
@@ -1266,13 +1265,13 @@ typedef struct {
     uint8_t	status;
     uint16_t	handle;
 } QEMU_PACKED reset_failed_contact_counter_rp;
-#define RESET_FAILED_CONTACT_COUNTER_RP_SIZE 4
+#define RESET_FAILED_CONTACT_COUNTER_RP_SIZE 3
 
 #define OCF_READ_LINK_QUALITY		0x0003
 typedef struct {
     uint16_t	handle;
 } QEMU_PACKED read_link_quality_cp;
-#define READ_LINK_QUALITY_CP_SIZE 4
+#define READ_LINK_QUALITY_CP_SIZE 2
 
 typedef struct {
     uint8_t	status;
@@ -1332,7 +1331,7 @@ typedef struct {
     uint8_t	dev_class[3];
     uint16_t	clock_offset;
 } QEMU_PACKED inquiry_info;
-#define INQUIRY_INFO_SIZE 14
+#define INQUIRY_INFO_SIZE 15
 
 #define EVT_CONN_COMPLETE		0x03
 typedef struct {
@@ -1381,7 +1380,7 @@ typedef struct {
     uint16_t	handle;
     uint8_t	encrypt;
 } QEMU_PACKED evt_encrypt_change;
-#define EVT_ENCRYPT_CHANGE_SIZE 5
+#define EVT_ENCRYPT_CHANGE_SIZE 4
 
 #define EVT_CHANGE_CONN_LINK_KEY_COMPLETE	0x09
 typedef struct {
@@ -1629,18 +1628,6 @@ typedef struct {
 } QEMU_PACKED evt_sniff_subrate;
 #define EVT_SNIFF_SUBRATE_SIZE 11
 
-#define EVT_EXTENDED_INQUIRY_RESULT	0x2F
-typedef struct {
-    bdaddr_t	bdaddr;
-    uint8_t	pscan_rep_mode;
-    uint8_t	pscan_period_mode;
-    uint8_t	dev_class[3];
-    uint16_t	clock_offset;
-    int8_t	rssi;
-    uint8_t	data[240];
-} QEMU_PACKED extended_inquiry_info;
-#define EXTENDED_INQUIRY_INFO_SIZE 254
-
 #define EVT_TESTING			0xFE
 
 #define EVT_VENDOR			0xFF
Signature · 1 line
2.1.4
#4 lore raw

[Qemu-devel] [PULL 5/9] configure: use appropriate code fragment for -fstack-protector checks

In reply to Michael Tokarev

From: Rodrigo Rebello <[email protected]>

The check for stack-protector support consisted in compiling and linking the test program below (output by function write_c_skeleton()) with the compiler flag -fstack-protector-strong first and then with -fstack-protector-all if the first one failed to work:

int main(void) { return 0; }

This caused false positives when using certain toolchains in which the compiler accepted -fstack-protector-strong but no support was provided by the C library, since for this stack-protector variant the compiler emits canary code only for functions that meet specific conditions (local arrays, memory references to local variables, etc.) and the code fragment under test included none of them (hence no stack protection code generated, no link failure).

This fix changes the test program used for -fstack-protector checks to include a function that meets conditions which cause the compiler to generate canary code in all variants.

---
 configure | 10 ++++++++++
 1 file changed, 10 insertions(+)
configure +10 -0
index 2e8a672..b9552fd 100755
@@ -1491,6 +1491,16 @@ for flag in $gcc_flags; do
 done
 
 if test "$stack_protector" != "no"; then
+  cat > $TMPC << EOF
+int main(int argc, char *argv[])
+{
+    char arr[64], *p = arr, *c = argv[0];
+    while (*c) {
+        *p++ = *c++;
+    }
+    return 0;
+}
+EOF
   gcc_flags="-fstack-protector-strong -fstack-protector-all"
   sp_on=0
   for flag in $gcc_flags; do
Signature · 1 line
2.1.4
#0 lore raw

Hello.

During the freeze period, let me please add my trivial pull request too ;)

There are just 9 patches this time, which are either (small) bugfixes, or just prettifying one or another part of code to look nicely in the release tarball. Here are all of them:

aniel P. Berrange (1):
crypto: avoid two coverity false positive error reports
this is a cleanup together with a small tracing bugfix, an easy patch. An making coverity even more useful is nice too.

Hervé Poussineau (1):
scsi: remove scsi_req_free prototype
just removing a prototype of a single unused function

John Snow (1):
util/id: fully allocate names table
a small bugfix avoiding accessing "random" memory

Markus Armbruster (1):
typedefs: Put them back into alphabetical order
this one sorts include/qemu/typedefs.h in alphabetical order, and removes duplicates while at it. Actual set of typedefs isn't changed. We should have good-looking code conforming to our own standards in the released tarball :)

Paolo Bonzini (3):
bt: avoid unintended sign extension
a simple bt bugfix

gt64xxx: fix decoding of ISD register
this is a small mips platform bugfix

bt: check struct sizes
this one is rather large, but it tries to fix real mess in BT device emulation which we have now

Peter Maydell (1):
configure: Diagnose broken linkers directly
A simple patch trying to verify whenever linker works too, not only compiler, at configure time before doing more complex tests.

Rodrigo Rebello (1):
configure: use appropriate code fragment for -fstack-protector checks
this is an interesting patch in context of the freeze time. In short, current test for -fstack-protector gives false positives (claiming the feature is available) in some configuration, because it only verifies whenever compiler accepts this option but not whenever it can compile and link a code which actually uses stack.

Please consider applying.

Thanks,

/mjt

The following changes since commit 4c65fed8bdf96780735dbdb92a8bd0d6b6526cc3:

ui: vnc: avoid floating point exception (2015-12-03 13:34:50 +0000)

are available in the git repository at:

git://git.corpit.ru/qemu.git tags/pull-trivial-patches-2015-12-04

for you to fetch changes up to 98475746b357f6c048caf9e001998d8a0618b2e4:

bt: check struct sizes (2015-12-04 09:39:55 +0300)

----------------------------------------------------------------
trivial patches for 2015-12-04

----------------------------------------------------------------
Daniel P. Berrange (1):
crypto: avoid two coverity false positive error reports

Hervé Poussineau (1):
scsi: remove scsi_req_free prototype

John Snow (1):
util/id: fully allocate names table

Markus Armbruster (1):
typedefs: Put them back into alphabetical order

Paolo Bonzini (3):
bt: avoid unintended sign extension
gt64xxx: fix decoding of ISD register
bt: check struct sizes

Peter Maydell (1):
configure: Diagnose broken linkers directly

Rodrigo Rebello (1):
configure: use appropriate code fragment for -fstack-protector checks

 configure               | 13 +++++++++++++
 crypto/tlscreds.c       |  4 ++--
 crypto/tlscredsx509.c   |  1 +
 hw/bt/sdp.c             |  2 +-
 hw/mips/gt64xxx_pci.c   |  3 ++-
 include/hw/bt.h         | 21 ++++-----------------
 include/hw/scsi/scsi.h  |  1 -
 include/qemu/typedefs.h | 13 ++++++-------
 util/id.c               |  4 ++--
 9 files changed, 31 insertions(+), 31 deletions(-)
#5 lore raw

[Qemu-devel] [PULL 7/9] scsi: remove scsi_req_free prototype

From: Hervé Poussineau <[email protected]>

Function has been deleted in ad2d30f79d3b0812f02c741be2189796b788d6d7.

---
 include/hw/scsi/scsi.h | 1 -
 1 file changed, 1 deletion(-)
include/hw/scsi/scsi.h +0 -1
index cdaf0f8..1915a73 100644
@@ -250,7 +250,6 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d,
 SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun,
                           uint8_t *buf, void *hba_private);
 int32_t scsi_req_enqueue(SCSIRequest *req);
-void scsi_req_free(SCSIRequest *req);
 SCSIRequest *scsi_req_ref(SCSIRequest *req);
 void scsi_req_unref(SCSIRequest *req);
 
Signature · 1 line
2.1.4
#6 lore raw

[Qemu-devel] [PULL 4/9] crypto: avoid two coverity false positive error reports

In reply to Michael Tokarev

From: "Daniel P. Berrange" <[email protected]>

In qcrypto_tls_creds_get_path() coverity complains that we are checking '*creds' for NULL, despite having dereferenced it previously. This is harmless bug due to fact that the trace call was too early. Moving it after the cleanup gets the desired semantics.

In qcrypto_tls_creds_check_cert_key_purpose() coverity complains that we're passing a pointer to a previously free'd buffer into gnutls_x509_crt_get_key_purpose_oid() This is harmless because we're passing a size == 0, so gnutls won't access the buffer, but rather just report what size it needs to be. We can avoid it though by explicitly setting the buffer to NULL after free'ing it.

---
 crypto/tlscreds.c     | 4 ++--
 crypto/tlscredsx509.c | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)
crypto/tlscreds.c +2 -2
index 5ec982c..e7d9c1c 100644
@@ -123,10 +123,10 @@ qcrypto_tls_creds_get_path(QCryptoTLSCreds *creds,
         goto cleanup;
     }
 
-    trace_qcrypto_tls_creds_get_path(creds, filename,
-                                     *cred ? *cred : "<none>");
     ret = 0;
  cleanup:
+    trace_qcrypto_tls_creds_get_path(creds, filename,
+                                     *cred ? *cred : "<none>");
     return ret;
 }
 
crypto/tlscredsx509.c +1 -0
index d080deb..26f18cb 100644
@@ -255,6 +255,7 @@ qcrypto_tls_creds_check_cert_key_purpose(QCryptoTLSCredsX509 *creds,
         }
 
         g_free(buffer);
+        buffer = NULL;
     }
 
     if (isServer) {
Signature · 1 line
2.1.4
#7 lore raw

[Qemu-devel] [PULL 3/9] configure: Diagnose broken linkers directly

In reply to Michael Tokarev

From: Peter Maydell <[email protected]>

Currently if the user's compiler works for creating .o files but their linker is broken such that compiling an executable from a C file does not work, we will report a misleading error message about the compiler not supporting __thread (since that happens to be the first test we run which requires a working linker). Explicitly check that compile_prog works as well as compile_object, so that people whose toolchain setup is broken get a more helpful error message.

---
 configure | 3 +++
 1 file changed, 3 insertions(+)
configure +3 -0
index 67801b0..2e8a672 100755
@@ -1428,6 +1428,9 @@ if compile_object ; then
 else
     error_exit "\"$cc\" either does not exist or does not work"
 fi
+if ! compile_prog ; then
+    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
+fi
 
 # Check that the C++ compiler exists and works with the C compiler
 if has $cxx; then
Signature · 1 line
2.1.4
#8 lore raw

[Qemu-devel] [PULL 2/9] bt: avoid unintended sign extension

In reply to Michael Tokarev

From: Paolo Bonzini <[email protected]>

In the case of a 4-byte length, shifting a value by 24 may cause an unintended sign extension when converting from int to size_t. Use a uint32_t variable instead.

---
 hw/bt/sdp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/bt/sdp.c +1 -1
index b9bcdcc..04eaeca 100644
@@ -42,7 +42,7 @@ struct bt_l2cap_sdp_state_s {
 
 static ssize_t sdp_datalen(const uint8_t **element, ssize_t *left)
 {
-    size_t len = *(*element) ++ & SDP_DSIZE_MASK;
+    uint32_t len = *(*element) ++ & SDP_DSIZE_MASK;
 
     if (!*left)
         return -1;
Signature · 1 line
2.1.4
#9 lore raw

[Qemu-devel] [PULL 8/9] typedefs: Put them back into alphabetical order

In reply to Michael Tokarev

From: Markus Armbruster <[email protected]>

"Please keep this list in alphabetical order" has been more honoured in the breach than in the observance. Clean up.

While there, drop a redundant struct declaration.

---
 include/qemu/typedefs.h | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
include/qemu/typedefs.h +6 -7
index 6b1093d..3eedcf4 100644
@@ -3,7 +3,6 @@
 
 /* A load of opaque types so that device init declarations don't have to
    pull in all the real definitions.  */
-struct Monitor;
 
 /* Please keep this list in alphabetical order */
 typedef struct AdapterInfo AdapterInfo;
@@ -19,8 +18,8 @@ typedef struct BusState BusState;
 typedef struct CharDriverState CharDriverState;
 typedef struct CompatProperty CompatProperty;
 typedef struct CPUAddressSpace CPUAddressSpace;
-typedef struct DeviceState DeviceState;
 typedef struct DeviceListener DeviceListener;
+typedef struct DeviceState DeviceState;
 typedef struct DisplayChangeListener DisplayChangeListener;
 typedef struct DisplayState DisplayState;
 typedef struct DisplaySurface DisplaySurface;
@@ -46,6 +45,7 @@ typedef struct MigrationIncomingState MigrationIncomingState;
 typedef struct MigrationParams MigrationParams;
 typedef struct MigrationState MigrationState;
 typedef struct Monitor Monitor;
+typedef struct MonitorDef MonitorDef;
 typedef struct MouseTransformInfo MouseTransformInfo;
 typedef struct MSIMessage MSIMessage;
 typedef struct NetClientState NetClientState;
@@ -63,13 +63,13 @@ typedef struct PCIESlot PCIESlot;
 typedef struct PCIExpressDevice PCIExpressDevice;
 typedef struct PCIExpressHost PCIExpressHost;
 typedef struct PCIHostState PCIHostState;
-typedef struct PCMachineState PCMachineState;
 typedef struct PCMachineClass PCMachineClass;
+typedef struct PCMachineState PCMachineState;
 typedef struct PCMCIACardState PCMCIACardState;
 typedef struct PixelFormat PixelFormat;
 typedef struct PostcopyDiscardState PostcopyDiscardState;
-typedef struct PropertyInfo PropertyInfo;
 typedef struct Property Property;
+typedef struct PropertyInfo PropertyInfo;
 typedef struct QEMUBH QEMUBH;
 typedef struct QemuConsole QemuConsole;
 typedef struct QEMUFile QEMUFile;
@@ -78,10 +78,10 @@ typedef struct QemuOpts QemuOpts;
 typedef struct QemuOptsList QemuOptsList;
 typedef struct QEMUSGList QEMUSGList;
 typedef struct QEMUSizedBuffer QEMUSizedBuffer;
-typedef struct QEMUTimerListGroup QEMUTimerListGroup;
 typedef struct QEMUTimer QEMUTimer;
-typedef struct Range Range;
+typedef struct QEMUTimerListGroup QEMUTimerListGroup;
 typedef struct RAMBlock RAMBlock;
+typedef struct Range Range;
 typedef struct SerialState SerialState;
 typedef struct SHPCDevice SHPCDevice;
 typedef struct SMBusDevice SMBusDevice;
@@ -89,6 +89,5 @@ typedef struct SSIBus SSIBus;
 typedef struct uWireSlave uWireSlave;
 typedef struct VirtIODevice VirtIODevice;
 typedef struct Visitor Visitor;
-typedef struct MonitorDef MonitorDef;
 
 #endif /* QEMU_TYPEDEFS_H */
Signature · 1 line
2.1.4
#10 lore raw
In reply to Michael Tokarev
Quoted 69 lines · Michael Tokarev

Hello.

During the freeze period, let me please add my trivial pull request too ;)

There are just 9 patches this time, which are either (small) bugfixes, or just prettifying one or another part of code to look nicely in the release tarball. Here are all of them:

aniel P. Berrange (1):
crypto: avoid two coverity false positive error reports
this is a cleanup together with a small tracing bugfix, an easy patch. An making coverity even more useful is nice too.

Hervé Poussineau (1):
scsi: remove scsi_req_free prototype
just removing a prototype of a single unused function

John Snow (1):
util/id: fully allocate names table
a small bugfix avoiding accessing "random" memory

Markus Armbruster (1):
typedefs: Put them back into alphabetical order
this one sorts include/qemu/typedefs.h in alphabetical order, and removes duplicates while at it. Actual set of typedefs isn't changed. We should have good-looking code conforming to our own standards in the released tarball :)

Paolo Bonzini (3):
bt: avoid unintended sign extension
a simple bt bugfix

gt64xxx: fix decoding of ISD register
this is a small mips platform bugfix

bt: check struct sizes
this one is rather large, but it tries to fix real mess in BT device emulation which we have now

Peter Maydell (1):
configure: Diagnose broken linkers directly
A simple patch trying to verify whenever linker works too, not only compiler, at configure time before doing more complex tests.

Rodrigo Rebello (1):
configure: use appropriate code fragment for -fstack-protector checks
this is an interesting patch in context of the freeze time. In short, current test for -fstack-protector gives false positives (claiming the feature is available) in some configuration, because it only verifies whenever compiler accepts this option but not whenever it can compile and link a code which actually uses stack.

Please consider applying.

Thanks,

/mjt

The following changes since commit 4c65fed8bdf96780735dbdb92a8bd0d6b6526cc3:

ui: vnc: avoid floating point exception (2015-12-03 13:34:50 +0000)

are available in the git repository at:

git://git.corpit.ru/qemu.git tags/pull-trivial-patches-2015-12-04

Quoted 8 lines

for you to fetch changes up to 98475746b357f6c048caf9e001998d8a0618b2e4:

bt: check struct sizes (2015-12-04 09:39:55 +0300)

----------------------------------------------------------------
trivial patches for 2015-12-04

----------------------------------------------------------------

Applied, thanks.

-- PMM