From nobody Wed Nov 19 07:02:45 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615314449; cv=none; d=zohomail.com; s=zohoarc; b=WJiBYpuNill0eckFsJCpvnjAgRGJeBKFm/qLMMig959d3Q1UEkJPHbPs99vaH4UsmnFbN9QoCVym17METuJBrVJE6ASP19l8+tc/iRY7+1pwt2wcjyGe/2sOpkT/toI31p+lE9TPxLdz84BUCpXW3vCOz3QQQihwDTkPtBCHrnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615314449; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=JZa/iUsT9VQagkte3HBQwGL7dr2S/uC8iYuWuLSPUy0=; b=Jao71EZneabLBA5GQN5/LOeiX+Bz3eW0p6aBKykJV2cBW6BlJbIC5aMHjj1gaS5r3StTjCMCQ3uC0a5S/PuhLWgPRO/SMIBMtZBoAMHwWmr0zQMTaEZ28lltifag4VG8cfj8CwnxuBMVCqc+f9dOlGpB+q5xp+QooAgoA670dxo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1615314449582618.2637154923037; Tue, 9 Mar 2021 10:27:29 -0800 (PST) Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-71-8AEzVEbFMw2fhEA9QgLrhg-1; Tue, 09 Mar 2021 13:27:24 -0500 Received: by mail-ej1-f69.google.com with SMTP id m4so6022906ejc.14 for ; Tue, 09 Mar 2021 10:27:23 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id be27sm9769289edb.47.2021.03.09.10.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 10:27:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615314446; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JZa/iUsT9VQagkte3HBQwGL7dr2S/uC8iYuWuLSPUy0=; b=UKbxudu5IBpaXXM49cfcI6mQbkra4eMeZP8Txe6aH/WKUKR4bALsxzgAKOI86/q8kVOSQn 41G8ifk/AL8eQcDhIsQSc1XxVgmFWARiqsRIm7OdOYlGzgsy3MkGes2ZljHjRDPLBV6TmT BpvD0E0ToWNkQWS6DVLni0Cnd/d6FeY= X-MC-Unique: 8AEzVEbFMw2fhEA9QgLrhg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JZa/iUsT9VQagkte3HBQwGL7dr2S/uC8iYuWuLSPUy0=; b=VDB1Rg+/GS/ELHGUx3/aw7thAXmiyEYLgbovqKj0xw71J7jbEXJgAf6Nx/3kkzlPmQ HNeczPMoERowis5CAKympHKLMNkzjQKaTbps+maAf2QodV1HudydMkTGSx+G8YMi1IGt QfdZAyb9QYTFaBnh3Eh14EDjywZ6s84cPzMP3Y40HdKeyw2ZEZu5t2lwwF2VjSQj1UKd ceN8AYYyrJofmp2bg5YaZ2aoKOMCPxG1t2C+UiIenpohvpmNbPRD1/DWWFsTDhftZbEm Ic4Jg+WTIvJVuCSfjeXrYrdsbqilXMrLtRS/Nnt6mkJlBdkArwjfQnV6bH1r0JDM6/fT drCg== X-Gm-Message-State: AOAM5335Xkb121kOMa4I4WUNyNspPosxwJ00YaUxhBMSkbRtcQuSwpwm D1mGrRnPz6AyqcSn/2YYXfzoP3dOexztnCC0Bf4awFkCvjqMAg4LIQh09LQpDfXMS4ZSj7t5xpK b0LpogEn22UYKBQ== X-Received: by 2002:a17:906:5918:: with SMTP id h24mr22273158ejq.501.1615314442562; Tue, 09 Mar 2021 10:27:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3sEMTKKT4SaFCXJqzS+fG3uLXd9yFb/u6RpsfKs75PASMey5Whnt69NulDldeWhQvBnv2/Q== X-Received: by 2002:a17:906:5918:: with SMTP id h24mr22273146ejq.501.1615314442454; Tue, 09 Mar 2021 10:27:22 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Dmitry Fleytman , Miroslav Rezanina , Li Qiang , Paolo Bonzini , Jason Wang , Thomas Huth , Alexander Bulekov , Stefano Garzarella , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 1/6] net/eth: Simplify _eth_get_rss_ex_dst_addr() Date: Tue, 9 Mar 2021 19:27:04 +0100 Message-Id: <20210309182709.810955-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210309182709.810955-1-philmd@redhat.com> References: <20210309182709.810955-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The length field is already contained in the ip6_ext_hdr structure. Check it direcly in eth_parse_ipv6_hdr() before calling _eth_get_rss_ex_dst_addr(), which gets a bit simplified. Reviewed-by: Miroslav Rezanina Reviewed-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- net/eth.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/net/eth.c b/net/eth.c index 1e0821c5f81..7d4dd48c1ff 100644 --- a/net/eth.c +++ b/net/eth.c @@ -407,9 +407,7 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int p= kt_frags, { struct ip6_ext_hdr_routing *rthdr =3D (struct ip6_ext_hdr_routing *) e= xt_hdr; =20 - if ((rthdr->rtype =3D=3D 2) && - (rthdr->len =3D=3D sizeof(struct in6_address) / 8) && - (rthdr->segleft =3D=3D 1)) { + if ((rthdr->rtype =3D=3D 2) && (rthdr->segleft =3D=3D 1)) { =20 size_t input_size =3D iov_size(pkt, pkt_frags); size_t bytes_read; @@ -528,10 +526,12 @@ bool eth_parse_ipv6_hdr(const struct iovec *pkt, int = pkt_frags, } =20 if (curr_ext_hdr_type =3D=3D IP6_ROUTING) { - info->rss_ex_dst_valid =3D - _eth_get_rss_ex_dst_addr(pkt, pkt_frags, - ip6hdr_off + info->full_hdr_len, - &ext_hdr, &info->rss_ex_dst); + if (ext_hdr.ip6r_len =3D=3D sizeof(struct in6_address) / 8) { + info->rss_ex_dst_valid =3D + _eth_get_rss_ex_dst_addr(pkt, pkt_frags, + ip6hdr_off + info->full_hdr_l= en, + &ext_hdr, &info->rss_ex_dst); + } } else if (curr_ext_hdr_type =3D=3D IP6_DESTINATON) { info->rss_ex_src_valid =3D _eth_get_rss_ex_src_addr(pkt, pkt_frags, --=20 2.26.2 From nobody Wed Nov 19 07:02:45 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615314451; cv=none; d=zohomail.com; s=zohoarc; b=Fw1Yz3Ok9mGwWqyJdZyhQKK6HzCoGDaa1lOyMd9c3sP4hQPxD8DQpNFhFu0pSIwakGYUkfNDtzd02xz8GWmgqjlwShsM+kHL5GEzzRVCI79qbvKPAMH2/ZZ7fYtM5e6POQFgz3nkjfUBixCqtzXw1eiYB3NY328fmnaIkO6ur8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615314451; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=xHs02CwzRBs33Sh0xyloFVVfVxuoFsSy6sEOJItTgcA=; b=R7oStt/6oLS0bU6nVIrrAWfAgQZMb7JG30Z6Co4JNCtd37NxZs2b81HsAhm27WTlv+uqDHrW0nk/TrCkLgPZvUpZeM2zgjkuKxXEGKKeg5EmguyFlZsCgJw73olwPnzs93ehVQRuNjk3iKrthSWxDYVIYMyFLVKKgp8f3grRWOo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1615314451655651.0959383092647; Tue, 9 Mar 2021 10:27:31 -0800 (PST) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-63-PiRxUZHFN8iD-eWMFJPm7w-1; Tue, 09 Mar 2021 13:27:29 -0500 Received: by mail-ed1-f69.google.com with SMTP id v27so7193127edx.1 for ; Tue, 09 Mar 2021 10:27:28 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id fi11sm8640199ejb.73.2021.03.09.10.27.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 10:27:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615314450; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xHs02CwzRBs33Sh0xyloFVVfVxuoFsSy6sEOJItTgcA=; b=B3ROC5OMIAvDHy4KDamXHmQbVLMJ1zj3fAWOtoO0FCQtQK5fMZwPOqij6sDjTz2RUg0Y6o OKnahJH0wQNWpwtI/j2UVCgWI046OcxW+gmnjnZkhvXbdUjIiUl4MWt7WAjbekR9AXEWSK HSA/cMgdUluSXxIykdDaQXwetFzY3Gs= X-MC-Unique: PiRxUZHFN8iD-eWMFJPm7w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xHs02CwzRBs33Sh0xyloFVVfVxuoFsSy6sEOJItTgcA=; b=SPjoFxPnJ5LztvYGBoMqyhSbfa/KQUtuq6j3kDPQBrFNkVMlrgkWUyidfvbXKSYAPr w7moo6sirKHvM+ebY7XqrYwU92jo9H9O+0q/bx4lurQ5XWYozIkFowlphR2aifh4x2RF QCAEXNc4K6QbcnkuuYXMrb3n6rmPPahteEEMeatecDAZT03LjG8VrjuEkLlZhalp1qgo YlAiKt3LneqXet5PetTjhVaSs0E2WZCpzbn6kzLZCfXI5l5nHi4DU2XznW3UIqFt2Q21 gJfjrnvJUjgXA5TVPasDEU0939NQIzT0iz36htdioY1bAcZIu7z4W51qWfs8BJlC8eBm 5R5A== X-Gm-Message-State: AOAM532oPYwSfJHGjqSUqyFZUbsHh7f4mrPwQAZ6JfW/4hvzbHFp3Wtr uxTEWIfdjc5d5oUKu3x+TvumELpY492ryzqZ2jH/ZHEz5A/XbBUSgVL9Ldj7t2Ewe1sQv6xNYva 2dkek0c3B6MXrgw== X-Received: by 2002:a17:906:32d1:: with SMTP id k17mr21202190ejk.94.1615314447934; Tue, 09 Mar 2021 10:27:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfjbc7NAUdXEPV35+w5oXbtAfHPBJtmvy6MDYIojGumPSCU8ujdHGtBaMQmJO8ESj00duX2w== X-Received: by 2002:a17:906:32d1:: with SMTP id k17mr21202177ejk.94.1615314447825; Tue, 09 Mar 2021 10:27:27 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Dmitry Fleytman , Miroslav Rezanina , Li Qiang , Paolo Bonzini , Jason Wang , Thomas Huth , Alexander Bulekov , Stefano Garzarella , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 2/6] net/eth: Better describe _eth_get_rss_ex_dst_addr's offset argument Date: Tue, 9 Mar 2021 19:27:05 +0100 Message-Id: <20210309182709.810955-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210309182709.810955-1-philmd@redhat.com> References: <20210309182709.810955-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The 'offset' argument represents the offset to the ip6_ext_hdr header, rename it as 'ext_hdr_offset'. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefano Garzarella --- net/eth.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/eth.c b/net/eth.c index 7d4dd48c1ff..6a5a1d04e0b 100644 --- a/net/eth.c +++ b/net/eth.c @@ -401,7 +401,7 @@ eth_is_ip6_extension_header_type(uint8_t hdr_type) =20 static bool _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags, - size_t rthdr_offset, + size_t ext_hdr_offset, struct ip6_ext_hdr *ext_hdr, struct in6_address *dst_addr) { @@ -412,12 +412,12 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int= pkt_frags, size_t input_size =3D iov_size(pkt, pkt_frags); size_t bytes_read; =20 - if (input_size < rthdr_offset + sizeof(*ext_hdr)) { + if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) { return false; } =20 bytes_read =3D iov_to_buf(pkt, pkt_frags, - rthdr_offset + sizeof(*ext_hdr), + ext_hdr_offset + sizeof(*ext_hdr), dst_addr, sizeof(*dst_addr)); =20 return bytes_read =3D=3D sizeof(*dst_addr); --=20 2.26.2 From nobody Wed Nov 19 07:02:45 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615314457; cv=none; d=zohomail.com; s=zohoarc; b=nwC7s4UvYfMIhqMYbE+ZbPhdDsa78z03jQyCWsXpI+JV4tYcigum11FLE1fU+y0USHQsXP7IkpnkWXTg9QijQz0gKwjoCETN7ne+1DNwsgzhWFTNMMs0BfBhEHRKy7Z81SkjRuw5L9nVkhoMyk7lD71wIDQsAUQ88RqQAtNC8Dc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615314457; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=3Cw7CoH51/r0CFse4vhuIOju4779l3jyBvx4wg2pQlc=; b=FpU2l5zyT5+op7YhmJ8ZH1X49wqioo/XUPPdNpOcO5T3HPJj94cMTy4joEAvsZCX/XxGRD1IMuz+1MXeLYCOjps4LKL9nKQmuiB1RPgw3M75IMvdjGNTGIfyitVb4Z02Ui6wUAjEBnjVTJH6JJPIdyNrtK6hNR1HHjQCvqVyPpc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1615314457199736.6002485265689; Tue, 9 Mar 2021 10:27:37 -0800 (PST) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-534-trvjV3t_MZ2auhrTzwxq9A-1; Tue, 09 Mar 2021 13:27:34 -0500 Received: by mail-ej1-f72.google.com with SMTP id v10so6027080ejh.15 for ; Tue, 09 Mar 2021 10:27:34 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id b19sm9571453edu.51.2021.03.09.10.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 10:27:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615314456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3Cw7CoH51/r0CFse4vhuIOju4779l3jyBvx4wg2pQlc=; b=hir0FIrdzP3lpMrHyXhvG7yX9iexrnpVfMbTF9ZxbeSGJfBCDSnV0S7iON/GYeuqAoxBVp 5tH7Jcs/k0xnEeNi4sLwGmtcYlSiq6lsvLAXdFj9BUIILWWdxXoqUMO31G+fd57aRGbG6A tpMo8fh0e9ZBnmxs+6S1ZkMsG53MZQE= X-MC-Unique: trvjV3t_MZ2auhrTzwxq9A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3Cw7CoH51/r0CFse4vhuIOju4779l3jyBvx4wg2pQlc=; b=j6A4VHc1yBW4V5hGlnwNSl/TwyFQbxQXb9Sx79G1RE/LjXPDodke4A1jw/59u33XAN AVGt8gBkhc5Y85wyRnVz0VPv4TK31HtNkaVFU5O4tBilKzpNw2Rf7vzaE/R2SUS+TXEe 2i6NLwOOWJKunDKMvzTJClGZWy9AdvDElie2qyR//w2qAoBvEgRCZn7nsN4TjOcdmycS wE+2Yzkyp0+YkDPyUY/W7Yt3+edBodPgLXdvgfdtn1U3wlhp8zgAYO0d68PSVYixeNe6 jVWSMd+QgFmaEUbhCENCbDadJywa3Fvg3wa4GIXVlvWhZpEdXHc2ydXMvihDYHBsmRks zemg== X-Gm-Message-State: AOAM530dJZV+rG/Fg415bovgobAqbbtDERLfhrkXqac24WxHcWWdC9YU jMkjacaswZ8YzVC4SxxujGTSJ5vZa9+yxUhEQIUNvuJQhGJWWXa06QgSTtZIvaA7uEVi2Fa8tLc HgvxBSd/+EdAYOA== X-Received: by 2002:a50:fe08:: with SMTP id f8mr5646695edt.217.1615314453558; Tue, 09 Mar 2021 10:27:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXOcB/iW1PfnTntYx57G0zbFJG1OuN8NJOGsr9wLYuIB3ixSzYgJP8QYeCuM5F2SBbvSIWyA== X-Received: by 2002:a50:fe08:: with SMTP id f8mr5646680edt.217.1615314453455; Tue, 09 Mar 2021 10:27:33 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Dmitry Fleytman , Miroslav Rezanina , Li Qiang , Paolo Bonzini , Jason Wang , Thomas Huth , Alexander Bulekov , Stefano Garzarella , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 3/6] net/eth: Initialize input_size variable earlier Date: Tue, 9 Mar 2021 19:27:06 +0100 Message-Id: <20210309182709.810955-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210309182709.810955-1-philmd@redhat.com> References: <20210309182709.810955-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Initialize the 'input_size' variable earlier to make the next commit easier to review. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefano Garzarella --- net/eth.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/eth.c b/net/eth.c index 6a5a1d04e0b..77af2b673bb 100644 --- a/net/eth.c +++ b/net/eth.c @@ -405,11 +405,10 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int= pkt_frags, struct ip6_ext_hdr *ext_hdr, struct in6_address *dst_addr) { + size_t input_size =3D iov_size(pkt, pkt_frags); struct ip6_ext_hdr_routing *rthdr =3D (struct ip6_ext_hdr_routing *) e= xt_hdr; =20 if ((rthdr->rtype =3D=3D 2) && (rthdr->segleft =3D=3D 1)) { - - size_t input_size =3D iov_size(pkt, pkt_frags); size_t bytes_read; =20 if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) { --=20 2.26.2 From nobody Wed Nov 19 07:02:45 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615314463; cv=none; d=zohomail.com; s=zohoarc; b=Cw9y4ZeaImUL8SIhgnd8xKhqh3sI6pIL5VvPOeRMCAsBbWOoB+lHDmj4ZcY40sgi2oBsFW6Eh7/My+ko4qgelb3xp8AKpfcQ30rn7rQyN0N+k490EJSoeQrhIp5PVG+00UYIjXd/YXoJrFBSdMwBjPuKaaM1sgzbsSOo5DZs0Ew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615314463; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=TtxWL3Du/wlfW39OySA2Yubdhxe8Lb4gYnlamtSDn8U=; b=l0HatTSEkIPEoXhxk7Tc7fFkmORxQRJPVhoHH4AnS45O1txkkxHh6dD2CFkholgIkWCqY+JKseP7LUYGe8vpV3kgGa4KRkqvCPV4APPdlR1AP9WQS92B0sl3FSmfZP54yRFL9UELzUyg8Z0yWbs00lULKUpcOAOnVCZBy3CjC3I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1615314463154785.8128790721653; Tue, 9 Mar 2021 10:27:43 -0800 (PST) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-475-FJCfA-vwNsqgIvavdU9zYQ-1; Tue, 09 Mar 2021 13:27:40 -0500 Received: by mail-ej1-f71.google.com with SMTP id a22so4308784ejx.10 for ; Tue, 09 Mar 2021 10:27:40 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id i11sm8404377ejf.76.2021.03.09.10.27.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 10:27:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615314462; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TtxWL3Du/wlfW39OySA2Yubdhxe8Lb4gYnlamtSDn8U=; b=H+w3E19lnQ8krn7Dg1spQeOeAGibrMWNC5rDgwLqoG09sJVXfwV/9OPI6MfXww9uXHOusO iAhWe4MWsZCrBDO1vRK0YSwZDyRAgp2hE4Gimw1EWDAUMBE6csKZMUiynye0U4VMPwjdPq T05LJIo8W9+nVhLAI6iX+ad8+RlWKQo= X-MC-Unique: FJCfA-vwNsqgIvavdU9zYQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TtxWL3Du/wlfW39OySA2Yubdhxe8Lb4gYnlamtSDn8U=; b=aQV/3bZJlSPrr8EKdGgflW26Zz7X6KTxV6I90N6KCjl5BbqhYFBAwLLTF+LAJ5E8z0 dEB+zP01NouzKQ1kXZ5ayjy0BN6WycBIkAC4Z9hVLgEbdQJaHPVL9tuAzC51WJUrbEUd TN4VKdNbViI2qowRlNBnhEns29xEFnqVff0w2NX9uFfZ3J8HTkwT0nEIDhvtJL1ygDqS 8ngnDQ8VN5OSWnfuG5c6X+oin+5hTzBG9UoilfyfweAjjZKSodtLdz6/QavTxG3MtxbG KzlyOe+9uaBvQeERTeKXFdf0Vh+VK3kkZkhYfRN7S5QHlNfed2qA7KbMTWYz5PoXdVYV LYiA== X-Gm-Message-State: AOAM531GgzUVPPv6FF7FIVKFrEgVP/8WLZchLqol85g/EvJmQYW6PlpU TCEyVE82FMkpPzr5u1jQS6lTjdbrDB3/QL4yCPG/A2mv+GyHauOLJ/k+qeDW0RO5cCNPMPqC30q GC8mcEaZkjTElOg== X-Received: by 2002:a17:906:d153:: with SMTP id br19mr21277746ejb.360.1615314459130; Tue, 09 Mar 2021 10:27:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxLats5W3APgVrCWb8bH+0UD+CISMfkO/qRWdUZY0wkuB5iJH4fb0jzlaNbjb+fyMpFWnMd/A== X-Received: by 2002:a17:906:d153:: with SMTP id br19mr21277714ejb.360.1615314458838; Tue, 09 Mar 2021 10:27:38 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Dmitry Fleytman , Miroslav Rezanina , Li Qiang , Paolo Bonzini , Jason Wang , Thomas Huth , Alexander Bulekov , Stefano Garzarella , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org Subject: [PATCH v4 4/6] net/eth: Check rt_hdr size before casting to ip6_ext_hdr Date: Tue, 9 Mar 2021 19:27:07 +0100 Message-Id: <20210309182709.810955-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210309182709.810955-1-philmd@redhat.com> References: <20210309182709.810955-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Do not cast our ip6_ext_hdr pointer to ip6_ext_hdr_routing if there isn't enough data in the buffer for a such structure. This fix a 2 bytes buffer overrun in eth_parse_ipv6_hdr() reported by QEMU fuzzer: $ cat << EOF | ./qemu-system-i386 -M pc-q35-5.0 \ -accel qtest -monitor none \ -serial none -nographic -qtest stdio outl 0xcf8 0x80001010 outl 0xcfc 0xe1020000 outl 0xcf8 0x80001004 outw 0xcfc 0x7 write 0x25 0x1 0x86 write 0x26 0x1 0xdd write 0x4f 0x1 0x2b write 0xe1020030 0x4 0x190002e1 write 0xe102003a 0x2 0x0807 write 0xe1020048 0x4 0x12077cdd write 0xe1020400 0x4 0xba077cdd write 0xe1020420 0x4 0x190002e1 write 0xe1020428 0x4 0x3509d807 write 0xe1020438 0x1 0xe2 EOF =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D2859770=3D=3DERROR: AddressSanitizer: stack-buffer-overflow on addr= ess 0x7ffdef904902 at pc 0x561ceefa78de bp 0x7ffdef904820 sp 0x7ffdef904818 READ of size 1 at 0x7ffdef904902 thread T0 #0 0x561ceefa78dd in _eth_get_rss_ex_dst_addr net/eth.c:410:17 #1 0x561ceefa41fb in eth_parse_ipv6_hdr net/eth.c:532:17 #2 0x561cef7de639 in net_tx_pkt_parse_headers hw/net/net_tx_pkt.c:228= :14 #3 0x561cef7dbef4 in net_tx_pkt_parse hw/net/net_tx_pkt.c:273:9 #4 0x561ceec29f22 in e1000e_process_tx_desc hw/net/e1000e_core.c:730:= 29 #5 0x561ceec28eac in e1000e_start_xmit hw/net/e1000e_core.c:927:9 #6 0x561ceec1baab in e1000e_set_tdt hw/net/e1000e_core.c:2444:9 #7 0x561ceebf300e in e1000e_core_write hw/net/e1000e_core.c:3256:9 #8 0x561cef3cd4cd in e1000e_mmio_write hw/net/e1000e.c:110:5 Address 0x7ffdef904902 is located in stack of thread T0 at offset 34 in f= rame #0 0x561ceefa320f in eth_parse_ipv6_hdr net/eth.c:486 This frame has 1 object(s): [32, 34) 'ext_hdr' (line 487) <=3D=3D Memory access at offset 34 over= flows this variable HINT: this may be a false positive if your program uses some custom stack= unwind mechanism, swapcontext or vfork (longjmp and C++ exceptions *are* supported) SUMMARY: AddressSanitizer: stack-buffer-overflow net/eth.c:410:17 in _eth= _get_rss_ex_dst_addr Shadow bytes around the buggy address: 0x10003df188d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10003df188e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10003df188f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10003df18900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10003df18910: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 =3D>0x10003df18920:[02]f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 0x10003df18930: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10003df18940: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10003df18950: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10003df18960: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x10003df18970: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Stack left redzone: f1 Stack right redzone: f3 =3D=3D2859770=3D=3DABORTING Add the corresponding qtest case with the fuzzer reproducer. FWIW GCC 11 similarly reported: net/eth.c: In function 'eth_parse_ipv6_hdr': net/eth.c:410:15: error: array subscript 'struct ip6_ext_hdr_routing[0]' = is partly outside array bounds of 'struct ip6_ext_hdr[1]' [-Werror=3Darray-= bounds] 410 | if ((rthdr->rtype =3D=3D 2) && (rthdr->segleft =3D=3D 1)) { | ~~~~~^~~~~~~ net/eth.c:485:24: note: while referencing 'ext_hdr' 485 | struct ip6_ext_hdr ext_hdr; | ^~~~~~~ net/eth.c:410:38: error: array subscript 'struct ip6_ext_hdr_routing[0]' = is partly outside array bounds of 'struct ip6_ext_hdr[1]' [-Werror=3Darray-= bounds] 410 | if ((rthdr->rtype =3D=3D 2) && (rthdr->segleft =3D=3D 1)) { | ~~~~~^~~~~~~~~ net/eth.c:485:24: note: while referencing 'ext_hdr' 485 | struct ip6_ext_hdr ext_hdr; | ^~~~~~~ Cc: qemu-stable@nongnu.org Buglink: https://bugs.launchpad.net/qemu/+bug/1879531 Reported-by: Alexander Bulekov Reported-by: Miroslav Rezanina Fixes: eb700029c78 ("net_pkt: Extend packet abstraction as required by e100= 0e functionality") Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- net/eth.c | 7 ++++- tests/qtest/fuzz-e1000e-test.c | 53 ++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + tests/qtest/meson.build | 1 + 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/fuzz-e1000e-test.c diff --git a/net/eth.c b/net/eth.c index 77af2b673bb..f0c8dfe8df7 100644 --- a/net/eth.c +++ b/net/eth.c @@ -406,7 +406,12 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int = pkt_frags, struct in6_address *dst_addr) { size_t input_size =3D iov_size(pkt, pkt_frags); - struct ip6_ext_hdr_routing *rthdr =3D (struct ip6_ext_hdr_routing *) e= xt_hdr; + struct ip6_ext_hdr_routing *rthdr; + + if (input_size < ext_hdr_offset + sizeof(*rthdr)) { + return false; + } + rthdr =3D (struct ip6_ext_hdr_routing *) ext_hdr; =20 if ((rthdr->rtype =3D=3D 2) && (rthdr->segleft =3D=3D 1)) { size_t bytes_read; diff --git a/tests/qtest/fuzz-e1000e-test.c b/tests/qtest/fuzz-e1000e-test.c new file mode 100644 index 00000000000..66229e60964 --- /dev/null +++ b/tests/qtest/fuzz-e1000e-test.c @@ -0,0 +1,53 @@ +/* + * QTest testcase for e1000e device generated by fuzzer + * + * Copyright (c) 2021 Red Hat, Inc. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" + +#include "libqos/libqtest.h" + +/* + * https://bugs.launchpad.net/qemu/+bug/1879531 + */ +static void test_lp1879531_eth_get_rss_ex_dst_addr(void) +{ + QTestState *s; + + s =3D qtest_init("-nographic -monitor none -serial none -M pc-q35-5.0"= ); + + qtest_outl(s, 0xcf8, 0x80001010); + qtest_outl(s, 0xcfc, 0xe1020000); + qtest_outl(s, 0xcf8, 0x80001004); + qtest_outw(s, 0xcfc, 0x7); + qtest_writeb(s, 0x25, 0x86); + qtest_writeb(s, 0x26, 0xdd); + qtest_writeb(s, 0x4f, 0x2b); + + qtest_writel(s, 0xe1020030, 0x190002e1); + qtest_writew(s, 0xe102003a, 0x0807); + qtest_writel(s, 0xe1020048, 0x12077cdd); + qtest_writel(s, 0xe1020400, 0xba077cdd); + qtest_writel(s, 0xe1020420, 0x190002e1); + qtest_writel(s, 0xe1020428, 0x3509d807); + qtest_writeb(s, 0xe1020438, 0xe2); + qtest_writeb(s, 0x4f, 0x2b); + qtest_quit(s); +} + +int main(int argc, char **argv) +{ + const char *arch =3D qtest_get_arch(); + + g_test_init(&argc, &argv, NULL); + + if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { + qtest_add_func("fuzz/test_lp1879531_eth_get_rss_ex_dst_addr", + test_lp1879531_eth_get_rss_ex_dst_addr); + } + + return g_test_run(); +} diff --git a/MAINTAINERS b/MAINTAINERS index f22d83c1782..4eb5784ff83 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2003,6 +2003,7 @@ e1000e M: Dmitry Fleytman S: Maintained F: hw/net/e1000e* +F: tests/qtest/fuzz-e1000e-test.c =20 eepro100 M: Stefan Weil diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 58efc46144e..7997d895449 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -60,6 +60,7 @@ (config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ? ['tpm-tis-test'] : [= ]) + \ (config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ? ['tpm-tis-swtpm-test= '] : []) + \ (config_all_devices.has_key('CONFIG_RTL8139_PCI') ? ['rtl8139-test'] : [= ]) + \ + (config_all_devices.has_key('CONFIG_E1000E_PCI_EXPRESS') ? ['fuzz-e1000e= -test'] : []) + \ qtests_pci + = \ ['fdc-test', 'ide-test', --=20 2.26.2 From nobody Wed Nov 19 07:02:45 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615314468; cv=none; d=zohomail.com; s=zohoarc; b=gSXjYchL1YA14J6p4zFKiKFhftXK7jL1TEzH9vpkJ8v8P+nkBkb+BW72UA7XkPDl4zVakhGylRcFkcCk6jARq60WbwB/8djx6VvaqpYrrsn2k2c0909LUeNwnSNTJ95aE8V/scjbnyHMud6565pGvguuGgC2Wh9UnnmVVyTbM34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615314468; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=6Q1w6fXMkJ/+WaYRHjG7T+TBBkT12mVGuAnMjp1JEOk=; b=nLjurFGL7KpCrFTfQjlR2nVwB+kKHgoRSpbHn7sPNgX3UDKJIao9k5IKxNLcsbDyHDmYHdZr8XpQ+84jhRTaLymy74XYDx9OP5qeodcoFhBdPSvs3QCB10rgUytITHMe8kMWotBkCkTCGq9N92W8OJkzLb9Vnmpu4R9d71QBY1o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1615314468626132.60057510337185; Tue, 9 Mar 2021 10:27:48 -0800 (PST) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-11-M3u7etteOHCs9Xj1xi75Tw-1; Tue, 09 Mar 2021 13:27:46 -0500 Received: by mail-ej1-f70.google.com with SMTP id li22so1511487ejb.18 for ; Tue, 09 Mar 2021 10:27:45 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id bx24sm9035103ejc.88.2021.03.09.10.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 10:27:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615314467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Q1w6fXMkJ/+WaYRHjG7T+TBBkT12mVGuAnMjp1JEOk=; b=fOtKtDyKPvMH4maA7/DcVJO60og+qNKlm9Su8HwSlNXp4h0dkuss4O9kGMScGCGX+hNSnX WGCBTSZG9W3h8ZJlTnR2VXbH5pbShV4TiBgCp5tzzwL0xsSKFqqTxtMFiba7KCUgjBgfzg UIlJaXmGwNWiqXKgRLjQfz/fVgfx6M8= X-MC-Unique: M3u7etteOHCs9Xj1xi75Tw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6Q1w6fXMkJ/+WaYRHjG7T+TBBkT12mVGuAnMjp1JEOk=; b=KccdMDNuckZ6N0ps+gBiASN77Q8F77g1h6MgvrZTejPZNTUc/9w8HdHGosZ/ASlvrV iS5FczLvo4K3XnWpc4aMIvKCnNVTAygL7ZoQsgfe7sDIMvga2mfBoAKls3CfKhF1Zz7h ZmzlyyIkVp3UmV70ffe9YUR0MpSX5JjkRlxCjSyItnIvFnypEfvDVftMSZzFJUSaV7aw PhcayUc2/UdhaMtv1HZmNSM0nNWGEtDVnuQqUqJ1pWyEVgdBromDUoZUWkXF4U95G1IQ 67kAP3S5byH7YPDTze07aYlBUTgsb/nXvPffMnG60t89eJtXKiQ18TuB8OpJi97NtPa2 YpeA== X-Gm-Message-State: AOAM533qpKeYI1CvBm4KE5No3rTBUUhBbtj6XHKMSf4675AAU0hcQv/g 5iUSPbv/TiRA0hfPxPrqKf65KH7Dg7H2mFTAuhkrfNXPEw/iBrqudd6v3iGIkNDS8dY4hpP5ooI y33Ni0TOR6eooGw== X-Received: by 2002:a17:906:c081:: with SMTP id f1mr21920802ejz.97.1615314464764; Tue, 09 Mar 2021 10:27:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwT1UTXtzRJxP4PcxxMs61k9mYR2n7eXb2zmrVAYDGW155JhoUC3xQdUt4/pJ8e1T+PYvp7qw== X-Received: by 2002:a17:906:c081:: with SMTP id f1mr21920775ejz.97.1615314464574; Tue, 09 Mar 2021 10:27:44 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Dmitry Fleytman , Miroslav Rezanina , Li Qiang , Paolo Bonzini , Jason Wang , Thomas Huth , Alexander Bulekov , Stefano Garzarella , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 5/6] net/eth: Remove now useless size check Date: Tue, 9 Mar 2021 19:27:08 +0100 Message-Id: <20210309182709.810955-6-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210309182709.810955-1-philmd@redhat.com> References: <20210309182709.810955-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) In the previous commit we checked there is enough room for a ip6_ext_hdr_routing in the buffer. The ip6_ext_hdr_routing structure starts with a ip6_ext_hdr, so we already checked that input_size is big enough for a ip6_ext_hdr :) Remove that now useless check. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- net/eth.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/net/eth.c b/net/eth.c index f0c8dfe8df7..e984edcfb0b 100644 --- a/net/eth.c +++ b/net/eth.c @@ -416,10 +416,6 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int = pkt_frags, if ((rthdr->rtype =3D=3D 2) && (rthdr->segleft =3D=3D 1)) { size_t bytes_read; =20 - if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) { - return false; - } - bytes_read =3D iov_to_buf(pkt, pkt_frags, ext_hdr_offset + sizeof(*ext_hdr), dst_addr, sizeof(*dst_addr)); --=20 2.26.2 From nobody Wed Nov 19 07:02:45 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615314476; cv=none; d=zohomail.com; s=zohoarc; b=WkSKaMRuIfrdGj4AP3IJBewvrbDoHtuXZiwlEI0c4f+5tmX5lbDdnH1bmH8/4Bz/RDtr42BfZn5l2NySaHY2TUf0SWJkiD7hrgBRmEAtyL4FBtH6WdhpdlbehjEl9K1jmmn30IKmtRDMQeq/T0hjk/KlAHLlaIouttMV2nM1VJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615314476; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=pz2LHGBFo7rdr0OLuP12qCzCTyCC4J17mZdA7YWW5O8=; b=XNLK2zufOAJFa7bLjLsZqALxCOjHqzfLhXJzZ9zapSct5CXrvgfVMgmCJoB4NdSeklKRvCZkI2qe6c6YKqIO3yHok7wpUnngqS64S8evbN4Clv61YG/bEz9bWXSgfu0HkJftbOyt7pXucc/HlPTaWD9hkTxoE3RfM7njcYh2ijY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1615314476900288.4257140232751; Tue, 9 Mar 2021 10:27:56 -0800 (PST) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-84-4Y6jWMEIPAOSDNNtpUuWug-1; Tue, 09 Mar 2021 13:27:51 -0500 Received: by mail-ed1-f69.google.com with SMTP id h5so7199121edf.17 for ; Tue, 09 Mar 2021 10:27:51 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id eo22sm8984049ejc.0.2021.03.09.10.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 10:27:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615314474; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pz2LHGBFo7rdr0OLuP12qCzCTyCC4J17mZdA7YWW5O8=; b=M/Rwx/neptKsP5nCATG1UJmbdn2rMYIxJrabFrpnLb2Dlbw8FX8TmItIcldXvXkEU/LEyM pByRnvd786kv4J7Qv+tI7X9pSg2he8RKSfYjpy+ELds5fJtQGy5YHm1vx6Fn7FqRZugUmu kin6P1opxObwl/Du5mSrh5LdoCA8elo= X-MC-Unique: 4Y6jWMEIPAOSDNNtpUuWug-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pz2LHGBFo7rdr0OLuP12qCzCTyCC4J17mZdA7YWW5O8=; b=cTL9plce2vzRKaZx+u3zPpEjkcWJkz9BJq+RU8HqKoAxS4o5V8k1pt5TmNi50da9fK e1+/GWdPu1DXnYdoSr0MnKTuTYRRbBSEgxwDZ7Sw8jIw37Qp0T9qNonE30lfAyV9dEZi AO2qOKZcPY65kumeOaI1FVWX36RuKzV3/9GNiiylLYsxy8DAo7P/4s/qxsSpcEmd3gcY tYdwe1b2dr3wenFILM7B77jmQJYDDnDRq0zZRqOum1u67YzwSOLJp+wsruESJCgICNKO g2Yn6dkavdc5cwGTIbMiBwyHjTrJymXQv/zefX4Fp+jXxIBHeBNGKeqSFtKZp8DTkO64 WVsQ== X-Gm-Message-State: AOAM5303QgxnYW5BOmS2BqPWn48R+vq1gxNmYjyYCiodN3Q0jsrCtA0U 6GtHkUqVn+J5vM6ssXqMVxgb/UXLcDZjLCsPgGEiFkmjfmhyEm0JqdM1WIEMqh28OfqrlEOsfGd +gfRDO+CsAn/irg== X-Received: by 2002:a17:906:a896:: with SMTP id ha22mr21606516ejb.503.1615314470233; Tue, 09 Mar 2021 10:27:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyL8ZBx3d5KC/PlT963GamrJPASs8TsG67PMKppdoM+EDRqttqbd2XfBTD0nhHu9UJiKgB42g== X-Received: by 2002:a17:906:a896:: with SMTP id ha22mr21606503ejb.503.1615314470087; Tue, 09 Mar 2021 10:27:50 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Dmitry Fleytman , Miroslav Rezanina , Li Qiang , Paolo Bonzini , Jason Wang , Thomas Huth , Alexander Bulekov , Stefano Garzarella , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 6/6] net/eth: Return earlier in _eth_get_rss_ex_dst_addr() Date: Tue, 9 Mar 2021 19:27:09 +0100 Message-Id: <20210309182709.810955-7-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210309182709.810955-1-philmd@redhat.com> References: <20210309182709.810955-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Slightly simplify _eth_get_rss_ex_dst_addr() by returning earlier. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- net/eth.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/net/eth.c b/net/eth.c index e984edcfb0b..b44439d31c5 100644 --- a/net/eth.c +++ b/net/eth.c @@ -407,23 +407,21 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int= pkt_frags, { size_t input_size =3D iov_size(pkt, pkt_frags); struct ip6_ext_hdr_routing *rthdr; + size_t bytes_read; =20 if (input_size < ext_hdr_offset + sizeof(*rthdr)) { return false; } rthdr =3D (struct ip6_ext_hdr_routing *) ext_hdr; =20 - if ((rthdr->rtype =3D=3D 2) && (rthdr->segleft =3D=3D 1)) { - size_t bytes_read; - - bytes_read =3D iov_to_buf(pkt, pkt_frags, - ext_hdr_offset + sizeof(*ext_hdr), - dst_addr, sizeof(*dst_addr)); - - return bytes_read =3D=3D sizeof(*dst_addr); + if ((rthdr->rtype !=3D 2) || (rthdr->segleft !=3D 1)) { + return false; } =20 - return false; + bytes_read =3D iov_to_buf(pkt, pkt_frags, ext_hdr_offset + sizeof(*ext= _hdr), + dst_addr, sizeof(*dst_addr)); + + return bytes_read =3D=3D sizeof(*dst_addr); } =20 static bool --=20 2.26.2