{"id":1409794,"url":"http://patchwork.ozlabs.org/api/patches/1409794/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20201202152611.677753-5-stefanha@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20201202152611.677753-5-stefanha@redhat.com>","list_archive_url":null,"date":"2020-12-02T15:26:11","name":"[v2,4/4] block/export: avoid g_return_val_if() input validation","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"86ce8c874110f3eeea86b7d9f0748cfe2f3297cc","submitter":{"id":17227,"url":"http://patchwork.ozlabs.org/api/people/17227/?format=json","name":"Stefan Hajnoczi","email":"stefanha@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20201202152611.677753-5-stefanha@redhat.com/mbox/","series":[{"id":218104,"url":"http://patchwork.ozlabs.org/api/series/218104/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=218104","date":"2020-12-02T15:26:07","name":"vhost-user: avoid g_return_val_if() in get/set_config()","version":2,"mbox":"http://patchwork.ozlabs.org/series/218104/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/1409794/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/1409794/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=<UNKNOWN>)","ozlabs.org;\n dmarc=fail (p=none dis=none) header.from=redhat.com","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=cPlwyZGz;\n\tdkim-atps=neutral","relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 4CmND33FtQz9sSf\n\tfor <incoming@patchwork.ozlabs.org>; Thu,  3 Dec 2020 02:28:51 +1100 (AEDT)","from localhost ([::1]:49776 helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1kkU3l-0006mJ-EL\n\tfor incoming@patchwork.ozlabs.org; Wed, 02 Dec 2020 10:28:49 -0500","from eggs.gnu.org ([2001:470:142:3::10]:51096)\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <stefanha@redhat.com>)\n id 1kkU2d-0006SG-NO\n for qemu-devel@nongnu.org; Wed, 02 Dec 2020 10:27:39 -0500","from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38448)\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256)\n (Exim 4.90_1) (envelope-from <stefanha@redhat.com>)\n id 1kkU2b-000493-18\n for qemu-devel@nongnu.org; Wed, 02 Dec 2020 10:27:39 -0500","from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id\n us-mta-169-XL5BWiaXOO6PdMl8NP6oYA-1; Wed, 02 Dec 2020 10:27:29 -0500","from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com\n [10.5.11.22])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19DE75708B;\n Wed,  2 Dec 2020 15:27:28 +0000 (UTC)","from localhost (ovpn-114-255.ams2.redhat.com [10.36.114.255])\n by smtp.corp.redhat.com (Postfix) with ESMTP id EDDF71001B2C;\n Wed,  2 Dec 2020 15:27:13 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1606922851;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=+QVw1FA0gSbZOuZ4y7uGJDFYO+dNUFEqyXxgdyQXFpQ=;\n b=cPlwyZGzp2Kni996mjg+2Zomr93Uz71JOvudx4bXRjNSn4fGzK0E2stnKqnwv4mwHzbe51\n VaJwY5rPdCaYh0Y2LizpWM0Hd0I0jiIFcziYOzJA3dQGlOuMpPscXeB5hWZL3is7Lttnfp\n PbS+OEXax0ToUh93lokQbJKtX4DYJgU=","X-MC-Unique":"XL5BWiaXOO6PdMl8NP6oYA-1","From":"Stefan Hajnoczi <stefanha@redhat.com>","To":"qemu-devel@nongnu.org","Subject":"[PATCH v2 4/4] block/export: avoid g_return_val_if() input validation","Date":"Wed,  2 Dec 2020 15:26:11 +0000","Message-Id":"<20201202152611.677753-5-stefanha@redhat.com>","In-Reply-To":"<20201202152611.677753-1-stefanha@redhat.com>","References":"<20201202152611.677753-1-stefanha@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 2.84 on 10.5.11.22","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"base64","Content-Type":"text/plain; charset=\"US-ASCII\"","Received-SPF":"pass client-ip=216.205.24.124;\n envelope-from=stefanha@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com","X-Spam_score_int":"-18","X-Spam_score":"-1.9","X-Spam_bar":"-","X-Spam_report":"(-1.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.495,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n MIME_BASE64_TEXT=1.741, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001,\n RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org,\n \"Michael S. Tsirkin\" <mst@redhat.com>, Markus Armbruster <armbru@redhat.com>,\n Coiby Xu <Coiby.Xu@gmail.com>, Raphael Norwitz <raphael.norwitz@nutanix.com>,\n\t=?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@gmail.com>,\n Gerd Hoffmann <kraxel@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>,\n\t=?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>,\n Max Reitz <mreitz@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n <qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"Do not validate input with g_return_val_if(). This API is intended for\nchecking programming errors and is compiled out with -DG_DISABLE_CHECKS.\n\nUse an explicit if statement for input validation so it cannot\naccidentally be compiled out.\n\nSuggested-by: Markus Armbruster <armbru@redhat.com>\nSigned-off-by: Stefan Hajnoczi <stefanha@redhat.com>\n---\n block/export/vhost-user-blk-server.c | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)","diff":"diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user-blk-server.c\nindex 62672d1cb9..bccbc98d57 100644\n--- a/block/export/vhost-user-blk-server.c\n+++ b/block/export/vhost-user-blk-server.c\n@@ -267,7 +267,11 @@ vu_blk_get_config(VuDev *vu_dev, uint8_t *config, uint32_t len)\n     VuServer *server = container_of(vu_dev, VuServer, vu_dev);\n     VuBlkExport *vexp = container_of(server, VuBlkExport, vu_server);\n \n-    g_return_val_if_fail(len <= sizeof(struct virtio_blk_config), -1);\n+    if (len > sizeof(struct virtio_blk_config)) {\n+        error_report(\"Invalid get_config len %u, expected <= %zu\",\n+                     len, sizeof(struct virtio_blk_config));\n+        return -1;\n+    }\n \n     memcpy(config, &vexp->blkcfg, len);\n     return 0;\n","prefixes":["v2","4/4"]}