From nobody Sat Nov 23 17:40:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 172381240110139.160759496452215; Fri, 16 Aug 2024 05:46:41 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 16F4B1373; Fri, 16 Aug 2024 08:46:40 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D14891599; Fri, 16 Aug 2024 08:45:19 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id EE35F1310; Fri, 16 Aug 2024 08:45:12 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 7C96D1358 for ; Fri, 16 Aug 2024 08:45:12 -0400 (EDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-422-nWhMjwCPN-u10w4She2cNg-1; Fri, 16 Aug 2024 08:45:10 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-427ffa0c9c7so20520495e9.1 for ; Fri, 16 Aug 2024 05:45:10 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37189896c50sm3597037f8f.85.2024.08.16.05.45.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 05:45:08 -0700 (PDT) Received: from wheatley.pinto-pinecone.ts.net (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 60DD31C16EA5 for ; Fri, 16 Aug 2024 14:45:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723812312; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XZ55D+VFOI/n85uDqOVP7Oh+zm0NVHf5rYyZoymlg00=; b=MCIuOsuaBIxE697g1F0vRpNO5u7TzJaEm8vM4KGgh5bKY9v+5eK5FWupcnzWVgOh+S6Wsm HfCg6OfOd3hqC81QdEwFdorikt3Gib1Z3QGl65zjuj76Ohb/S/uPzap51V7vyyM6e8z56C xCeS162Pr8OWxXdWKYNWK5GouBOPgL0= X-MC-Unique: nWhMjwCPN-u10w4She2cNg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723812309; x=1724417109; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XZ55D+VFOI/n85uDqOVP7Oh+zm0NVHf5rYyZoymlg00=; b=p4aPhzyytI1pt//x4GHKoh8wYXRrrXACBTWoXdjk0nlydQDgqxdzepVF+J8dbOOTjO mS7geAZtworpOhpOgQr5ONZ6ZosFRmbLM0vZAK0bj7kDLRdNZuMm4oWVyOn2za4eK9u/ 1B0hZdV6bw4bq/f6o359fkvrvcPxds7qlFTV45PqiR4hWU4/0VLKgMOBqjMWLXCq4xFQ +sDPqnqSBDz4wOBrpQ8qy7hU6cU2wvBKlLrF//LCE1RfpyqC4By1ASB7qwHL9TFa78C0 Jsnbkb/8lyoFBOeB6iIzdHa3ZZCYS6awIDWRByxPqzfZh7SEJZpnk/WvI22aec6daw1r /oIg== X-Gm-Message-State: AOJu0YwLBROPKu/kc/qRtVsadV0SfbkEzr5pl+Oe1wI5+yeY9VMH34W7 Z7vwJl++nNAvgcaEI0yrPPDzfFQSo0MaudoD6NbPdIg0u7Oaq7ZrIG12E3UpMVF+jMuEwT4cMvJ xM014zTQIHE63BDF/sPrQr825UmmkMhCG6KIsgdHihtsRcb4k7eu0FxclwGcdp0sgJEhzCsF6Q5 JTagg5rHHEof1jA2O8CDtmtGgD3Kw/jS7dkjV/J98= X-Received: by 2002:a05:6000:b51:b0:371:869b:4e5e with SMTP id ffacd0b85a97d-37194315752mr2172513f8f.1.1723812309314; Fri, 16 Aug 2024 05:45:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2X/Ju9S4bv7L4Kjp3KOIu7aUzVNrLVDd6JkQ/iNYu5icxGaDOyLqPigop9xiZL6tOLViYuQ== X-Received: by 2002:a05:6000:b51:b0:371:869b:4e5e with SMTP id ffacd0b85a97d-37194315752mr2172486f8f.1.1723812308750; Fri, 16 Aug 2024 05:45:08 -0700 (PDT) From: Martin Kletzander To: devel@lists.libvirt.org Subject: [PATCH 2/3] virarptable: Fix check for message length Date: Fri, 16 Aug 2024 14:45:03 +0200 Message-ID: <2fb405691bc7805c56c701b93ca3801ce6a08daf.1723811504.git.mkletzan@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: CU5FOMP3YDYOUUIGNUPETQETU257UACW X-Message-ID-Hash: CU5FOMP3YDYOUUIGNUPETQETU257UACW X-MailFrom: mkletzan@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1723812402911116600 Content-Type: text/plain; charset="utf-8"; x-default="true" The previous check was all wrong since it calculated the how long would the netlink message be if the netlink header was the payload and then subtracted that from the whole message length, a variable that was not used later in the code. This check can fail if there are no additional payloads, struct rtattr in particular, which we are parsing later, however the RTA_OK macro would've caught that anyway. Signed-off-by: Martin Kletzander Reviewed-by: Laine Stump --- src/util/virarptable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virarptable.c b/src/util/virarptable.c index d8e41c5a8668..8e805fb35332 100644 --- a/src/util/virarptable.c +++ b/src/util/virarptable.c @@ -84,7 +84,7 @@ virArpTableGet(void) int len =3D nh->nlmsg_len; void *addr; =20 - if ((len -=3D NLMSG_LENGTH(sizeof(*nh))) < 0) { + if (len < NLMSG_SPACE(sizeof(*r))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("wrong nlmsg len")); goto cleanup; --=20 2.46.0