From nobody Sun May 12 07:36:15 2024 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=1615401095; cv=none; d=zohomail.com; s=zohoarc; b=NJbXTjnmi9K1oxPUwEI6/rqtMOUtdFbmYpbNxyf1Q49t/4qUa+9nrf0KC6/kzRz5ThEclkcW0Tb8lPkQ4VOt0ml9Tu2exmRxMr5SqmgVWYaoWZ8K6J2sRHt83qtKNyildqujgpoeQepBrijHX9K4UANm/Vz6A6cD+nCjXmUH1X4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615401095; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=ipgg6mN4Nj5/k/GECTeOGbUIwyHhVgdcMcgTAKQ9hjM=; b=SCAo7DKnH5MNEKIOGg8zObtzjGZQpnUNyQNIAQUF6XQPyZNt4s7o64lv/pFhLOe2oVytJ4Uclekwu0xBcjWN21E5Iwl+/Pe1PoN6hf8cRHRGbn5EEODXars5UX1d2NUQbjWnvU7gRycOzCzjybwqOIhyMOscZgTB+BrtE6lz1GQ= 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 1615401095882453.3194269541682; Wed, 10 Mar 2021 10:31:35 -0800 (PST) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-246-tjLmZW1LMKmcFx920GeRlQ-1; Wed, 10 Mar 2021 13:31:32 -0500 Received: by mail-ed1-f70.google.com with SMTP id u1so8800449edt.4 for ; Wed, 10 Mar 2021 10:31:32 -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 br13sm129461ejb.87.2021.03.10.10.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 10:31:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615401094; 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=ipgg6mN4Nj5/k/GECTeOGbUIwyHhVgdcMcgTAKQ9hjM=; b=cjWusd2rJdqvxoF2SLeS8K3CDkyOd/laQNN+TEXrz1wruNHJ2A397ACOcXP4AtyGDdkjIV IfApQ27x0MQzJnDGIRL3waDFDsPJKUjUGNqmtALvdTJjuogeVnyWl1ws99hSheNG1L13vl 9B5Wnou9+L0EhG5WM2jA9QoB8LAnhSs= X-MC-Unique: tjLmZW1LMKmcFx920GeRlQ-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=ipgg6mN4Nj5/k/GECTeOGbUIwyHhVgdcMcgTAKQ9hjM=; b=Lad7VpCpV77mT4pGr5Lie2P1RrmGAgrWd6nmhHKe2cIX83y3XCsTKsJDid5dkKi0UP Rf9UaMO35v5KJSVOOEYvd3VjRrOom42Ave08C7HyAgYRrXqMEULeqI+DdUlkR7FFUqCm VRFYbl3zjRmj/KHOwtFSCjA2dtf1AxLtSb2FQRvWz1tsa73tZzo2AB3hdwRFQtWDy29M S3QBoidu7quUmoyco7Ftm7UCz1iLhddbmw58YUrsrjEpzR4C9c36eaAKpweF/7rfKpwh x43+JIp84SkrLlv6jGZIqnRZTd35EFvsPUCIwp9LbOXOtIu0c1Au+QjLWCgONZgPo4W/ vRuA== X-Gm-Message-State: AOAM531nqJsSdVP0F4asyIuf683I4g6BAc2DGXs9kbmLUAB7QH9xmPMe A2yKsxw071KGcG2CSqcbc4aVAZHlNgEK1Uf1vNU8BUjsSBD8AbMJ2R2hy0XMAQK0AnXcYoFSj5K 0nYuAA5aKgUb8nQ== X-Received: by 2002:a17:906:82c5:: with SMTP id a5mr5236348ejy.232.1615401091550; Wed, 10 Mar 2021 10:31:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZori+yBg4baXM9CgHd+nY+QgzxVd74b302zxJ8PmITHPDL2a80GeRY9tCjeTM/QUNhkfHcw== X-Received: by 2002:a17:906:82c5:: with SMTP id a5mr5236328ejy.232.1615401091321; Wed, 10 Mar 2021 10:31:31 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jason Wang , Stefano Garzarella , Thomas Huth , Miroslav Rezanina , Dmitry Fleytman , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org Subject: [PATCH v6 1/7] net/eth: Use correct in6_address offset in _eth_get_rss_ex_dst_addr() Date: Wed, 10 Mar 2021 19:31:17 +0100 Message-Id: <20210310183123.1212612-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210310183123.1212612-1-philmd@redhat.com> References: <20210310183123.1212612-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 in6_address comes after the ip6_ext_hdr_routing header, not after the ip6_ext_hdr one. Fix the offset. Cc: qemu-stable@nongnu.org Reported-by: Stefano Garzarella Fixes: eb700029c78 ("net_pkt: Extend packet abstraction as required by e100= 0e functionality") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Miroslav Rezanina Reviewed-by: Stefano Garzarella --- net/eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/eth.c b/net/eth.c index 1e0821c5f81..ef1b5136f1c 100644 --- a/net/eth.c +++ b/net/eth.c @@ -419,7 +419,7 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int p= kt_frags, } =20 bytes_read =3D iov_to_buf(pkt, pkt_frags, - rthdr_offset + sizeof(*ext_hdr), + rthdr_offset + sizeof(*rthdr), dst_addr, sizeof(*dst_addr)); =20 return bytes_read =3D=3D sizeof(*dst_addr); --=20 2.26.2 From nobody Sun May 12 07:36:15 2024 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=1615401102; cv=none; d=zohomail.com; s=zohoarc; b=ElEZZBV1aoJHBSaLE/DulPEt/pu7Ew6IUkJF1DwrlwsBmlJjo4GHUhiWxT2WSyNc1IjS9nbOY+q0CII1dzWUHy6tSc9krhsIaKC55Zb7L/8Ea7zYkX6saAbTizRI3iqiPc/VWpKzZtNAmSWgz7a3QR4epo4G7LjO6Ljpxl1GhIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615401102; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=pPZTkTxCUwe1BzyMkjpxJZKSLxu9sd2VzFrAuF5J8Hk=; b=dPaHKAS4i7r+8Ez5qEPlGxg5mNpxXmF8dkcW09EJ3FK2/goXHyl4MVPFhqacjcgi1JTUD1IJI0sab/Q+jhAGuEcv5HvJOiFf0ZsRDbBfzLXaZIbpGSt848C3TStG01wgP4k1JvVSIf5QmvQ3CWSjRiHcmuFj/OQXDru1b16G2TY= 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 1615401102332683.1175153190572; Wed, 10 Mar 2021 10:31:42 -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-596-0BBNjk6hNvO21FZ0bMv-IA-1; Wed, 10 Mar 2021 13:31:37 -0500 Received: by mail-ej1-f70.google.com with SMTP id r26so7630271eja.22 for ; Wed, 10 Mar 2021 10:31:37 -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 x4sm46869edd.58.2021.03.10.10.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 10:31:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615401101; 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=pPZTkTxCUwe1BzyMkjpxJZKSLxu9sd2VzFrAuF5J8Hk=; b=g3neQTUKmUo5U2d90rCgJT78GrrAfrVPs2Q61guJK+V1zjU3HC0P96BvMEtO4Ntt1h0qHZ zlg5b3fLxXY4HlgL6dLWU2vPlwlNiyPKcPTaVOAgFb9OF+woOooqwV3Nb8YxMA7drhGhrD f1Kkgzr7YDiFKLKwuMILwS8lslN+u1k= X-MC-Unique: 0BBNjk6hNvO21FZ0bMv-IA-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=pPZTkTxCUwe1BzyMkjpxJZKSLxu9sd2VzFrAuF5J8Hk=; b=ke03syNbVSUDuU+oghNuZJIEyTZIhiq7ZiMMt4ac+clvrIM9kmUS/bTNdH/1Aq4/dc wunRExLFVgevqyVLXbcLjz0GD72zNn1dT7LGL83CvQDEF5FrsfoiiqnknJffNIox44OK f+fcQoTI0VAPFEH0WwJqgykdmivsZ+MUKFNbm81e/U7SRAIwE2pgViG2t41f50lEAUql tNDEPBzmbCi3uBKGv5lyWvTCy0R8xz8odT/gAD6GVuoxQ74mQUNcZuy31x761E6mif6L eQWa4NyMlICpK7lNYD3iJKVA4EjvcmqxYPsbqaFwyxoxc/XgTnz3wXQRZUkbUvj+S4nr 7Khw== X-Gm-Message-State: AOAM533kXvGnrVZOt80gfCfpQwQ3/cfYxPtMkAX/rW4Uv/ENNFcVUVuj 5ezhG0KKHJWccQT+leOe38fe/3FNQEkDn1/TR0KmNtEJkL1rdJbvrhIBg52q/NHSTYF29EOnvgu kYJmMvZ+7Lj9wtA== X-Received: by 2002:a05:6402:68e:: with SMTP id f14mr4793540edy.169.1615401096468; Wed, 10 Mar 2021 10:31:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxR3FeBW8th+e4GIxVjgta8Op0WRdhJ2+Xm6cB/ysQbGPT4M7Ad7FcvBiyafE4uKADUKHXDBg== X-Received: by 2002:a05:6402:68e:: with SMTP id f14mr4793522edy.169.1615401096357; Wed, 10 Mar 2021 10:31:36 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jason Wang , Stefano Garzarella , Thomas Huth , Miroslav Rezanina , Dmitry Fleytman , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 2/7] net/eth: Simplify _eth_get_rss_ex_dst_addr() Date: Wed, 10 Mar 2021 19:31:18 +0100 Message-Id: <20210310183123.1212612-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210310183123.1212612-1-philmd@redhat.com> References: <20210310183123.1212612-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 ef1b5136f1c..b9ceb30a194 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 Sun May 12 07:36:15 2024 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=1615401105; cv=none; d=zohomail.com; s=zohoarc; b=DOEmt4v2CVaXmGmD8CasX+O0f84LsZk36DSPpli2cSDvm5rwxiSDy+g/4nLg8GKc4RiW0KIpv4NVSjZ0jMdKCiAvZmWr05W9FsiknHxOymH4eHQz1ZW8OAKjj0bmqHyigXC6WETrkhXrUxSpIJvVc5fXRA6/cv3tTdfFWLbIX28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615401105; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=q5DY/aN4CG9GqGVr+tCHRu+SWwcj5rYLvRE4za5fNpY=; b=Zjjxcd2nLm7MyhtoR3w+4O42SKaGpKimCPkkgl5bRH8xzRByESXTJzJrwjtRAIQ87TsUXTD7+GEJ2EtopxrgHoowQ2eqeouQ+wetDEF43scM50IXjpZ3lT+f091GgTIa3DYqXHQibp2M6No3ZEzshHjrlTeVBBZ3Ncp3diX8MAA= 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 1615401105283533.8356636417308; Wed, 10 Mar 2021 10:31:45 -0800 (PST) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-553-qa5_eb1PPfSBVDEP05q7rQ-1; Wed, 10 Mar 2021 13:31:42 -0500 Received: by mail-ed1-f71.google.com with SMTP id a26so1759642edt.23 for ; Wed, 10 Mar 2021 10:31:42 -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 z9sm41099edr.75.2021.03.10.10.31.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 10:31:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615401104; 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=q5DY/aN4CG9GqGVr+tCHRu+SWwcj5rYLvRE4za5fNpY=; b=S4pF+w2YKJCPSYtsqrG8EYNby3dYj0jjC2HFANRsnvttItRcLQjIFdHCI1et6SMQ2S+JyX mDS1wYoSAu3VokRmXTivxkHN+tDPw3mSOFDMK+ICYtUlTpElZ5WXk7FOK6BiUiZ9Htefyj YB07ajkdRSJxwfvPXudHhO/+BGGGH0Q= X-MC-Unique: qa5_eb1PPfSBVDEP05q7rQ-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=q5DY/aN4CG9GqGVr+tCHRu+SWwcj5rYLvRE4za5fNpY=; b=Y6vv5v/U/FPaegpbp9YNjhPFvm365hgDgYJ5CHOt0EEtjuffV3EeHOFlhDdQBfV/b0 YxuHRY8oVmZit7plSJlFKKQVR0FVoCTq2nBKDp7da32GAEN13nruMFqDpf4nl+SK/ZE8 F4K4KYeA0fejq5em5jZKAj/X/e4OCwz4EPGkFLxCC40z0pORoDpNj50pyLc2foJRZfLK PhFQrzKyf4Ykb5wo7GE2z3XBkSXhc+w2KKl3EY+6JR4hOYlykvsSNmXF72eSj+lGRtoP 5ScUkhfcNvZ1Rk3tGlpT2lt0Xu+o22puTjxJO+PFlTuMHCHDLXQAj2AdOS9QXICZDSxz ymLQ== X-Gm-Message-State: AOAM530SRAYBrcHUDxZ2TzNRNUG8/xnF0WYQ2vkSTog5vk/7ktV6lie0 olzSaMpKfm03G8vDra6psKBeAct3h32WWUk77+EslYBe9EEvF/YvBD0hnv6E0eCOXYcKVREgIRS emkY0rb1PinxrUA== X-Received: by 2002:a17:907:9709:: with SMTP id jg9mr4969903ejc.276.1615401101540; Wed, 10 Mar 2021 10:31:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWTQg6EygPmC2GgxVCIA7ul6jWqPeNaDFR+Z37X4bE302PLYRiq0SEAQM4DxlQUSPeQ/yRpA== X-Received: by 2002:a17:907:9709:: with SMTP id jg9mr4969891ejc.276.1615401101378; Wed, 10 Mar 2021 10:31:41 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jason Wang , Stefano Garzarella , Thomas Huth , Miroslav Rezanina , Dmitry Fleytman , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 3/7] net/eth: Better describe _eth_get_rss_ex_dst_addr's offset argument Date: Wed, 10 Mar 2021 19:31:19 +0100 Message-Id: <20210310183123.1212612-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210310183123.1212612-1-philmd@redhat.com> References: <20210310183123.1212612-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'. Reviewed-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Miroslav Rezanina --- net/eth.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/eth.c b/net/eth.c index b9ceb30a194..ed047b5760b 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(*rthdr), + ext_hdr_offset + sizeof(*rthdr), dst_addr, sizeof(*dst_addr)); =20 return bytes_read =3D=3D sizeof(*dst_addr); --=20 2.26.2 From nobody Sun May 12 07:36:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615401288; cv=none; d=zohomail.com; s=zohoarc; b=DnQ7i5WAyWgPY72+jt7fkY5zK9f7i7t1kRKUg3F/VP25j9dosSjUThnxP/Ead060TAq+ZqCD+FMSY1S2ZS54k14EwkU+BN0+fyheTqpSE7C2ERU6CatfyPke0q30qssy526np0OEtOgeJ3LIU3MgwJdbmfFRooRaISpyG3re9Wk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615401288; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cVxutgLWbsHETCN5jy828gv0QTW9f6WZtMgIaL8WtCw=; b=BIg61G4ghxhLLNmj0sIBmxJl2E4wT/H2VruwipDvGvhNTjk8wacvgKQF3pfoXvooGlDJREl8mxGOE0szagGmz2lUlbsFBjuphjIQ2lU24/IokKSBlS88AGszE5lmCqwpqVokdzdJaAxl4ZSEAuQS2Q2pEiF2BDqbQfctMClPJaU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1615401288880991.2037124647951; Wed, 10 Mar 2021 10:34:48 -0800 (PST) Received: from localhost ([::1]:57634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lK3fT-0007No-M4 for importer@patchew.org; Wed, 10 Mar 2021 13:34:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lK3cf-0005eZ-Bd for qemu-devel@nongnu.org; Wed, 10 Mar 2021 13:31:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lK3cd-0003AM-PK for qemu-devel@nongnu.org; Wed, 10 Mar 2021 13:31:53 -0500 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-601-d7kI1jEzN9-TALkyBx1fZQ-1; Wed, 10 Mar 2021 13:31:48 -0500 Received: by mail-ed1-f70.google.com with SMTP id o15so8832019edv.7 for ; Wed, 10 Mar 2021 10:31:47 -0800 (PST) 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 l1sm46800edt.59.2021.03.10.10.31.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 10:31:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615401111; 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=cVxutgLWbsHETCN5jy828gv0QTW9f6WZtMgIaL8WtCw=; b=R4pCSn8HUf8cBvQoCrCtwHeB7QVVeJz7mlrMzoFQ6lMw4vfUXfOMPjFJxtvt5lsT257vdE ua41yDJSS78Ma7DMiS/4LpdNXo2RJo2D3dog1xZPQEL3xjmbwa1KEboVl4jvejduwkjMca +djoCgUUHYKUcp+k2pf83fvfzUBnxz8= X-MC-Unique: d7kI1jEzN9-TALkyBx1fZQ-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=cVxutgLWbsHETCN5jy828gv0QTW9f6WZtMgIaL8WtCw=; b=puwwVVjrMasOKjamUXv4GCl/yGxcF1j7lHM6R3PQzX05FiD0YoVlnH/KwOvVywfCSN 3T8R03ZVqCrYZHJLdruMvR19UGIdVZqO501DTPM5W1WeI/TMCSxEYoqy5ojdwFBMGWYQ lrNl5aTc66z1CAc0BFDTyTh46sXZBH8U8leg2zqjWUnFeVwY1XlI6hDMVNJKycK8neht iPBxsGcx91I0/wDC1G1Ac/WE//NqrG1zQacP9QJ2mysVc4gsBApfW6TEMgNAmv5hHDuO /Wtm/uI23woNZAiQ03Q5ZkoPa0nWRPAnCuI6kD+xHGi4L/VTk5G8Vzy/f+8uwN3jQFoU E+Ww== X-Gm-Message-State: AOAM530UG8fv5oqK3vStC2g560aHiuvN8SNktri3rxA2OCMIi53YZ8uc ZJQxynFlOhbokjH1q4cI1KB4Zt86AXG5yii6FutTWC+N4HoAas/r2OD08lgABkZw/6/Xn8Lhs3H oMj49SMZ6V8tnBJfaS4GrWB3bqTA64t2BvG+PkqIMkcGRDW9f8tlPivv45ftGQyyz X-Received: by 2002:a50:f38f:: with SMTP id g15mr4777484edm.262.1615401106511; Wed, 10 Mar 2021 10:31:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFTm8bvR5JbHuRlKvusWoKijCjYjWBuuzyu4Um+n/Ft5PMrFRPw690bsI3d6ebIsc3Q/oK7A== X-Received: by 2002:a50:f38f:: with SMTP id g15mr4777461edm.262.1615401106376; Wed, 10 Mar 2021 10:31:46 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v6 4/7] net/eth: Check size earlier in _eth_get_rss_ex_dst_addr() Date: Wed, 10 Mar 2021 19:31:20 +0100 Message-Id: <20210310183123.1212612-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210310183123.1212612-1-philmd@redhat.com> References: <20210310183123.1212612-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 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.243, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Dmitry Fleytman , Jason Wang , Paolo Bonzini , Miroslav Rezanina , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Reviewed-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Miroslav Rezanina --- net/eth.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/net/eth.c b/net/eth.c index ed047b5760b..492359afbbb 100644 --- a/net/eth.c +++ b/net/eth.c @@ -406,16 +406,14 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int= pkt_frags, struct in6_address *dst_addr) { struct ip6_ext_hdr_routing *rthdr =3D (struct ip6_ext_hdr_routing *) e= xt_hdr; + size_t input_size =3D iov_size(pkt, pkt_frags); + size_t bytes_read; + + if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) { + return false; + } =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; - - if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) { - return false; - } - bytes_read =3D iov_to_buf(pkt, pkt_frags, ext_hdr_offset + sizeof(*rthdr), dst_addr, sizeof(*dst_addr)); --=20 2.26.2 From nobody Sun May 12 07:36:15 2024 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=1615401117; cv=none; d=zohomail.com; s=zohoarc; b=M+EvDxavup+kM+C+b8LXz9a6ijVk1f+rzYPhIOrLE/ducnD7I/TlxgVGSLuTf430crpsbxecJm8VzZcwAg208gcYIbqXs3KB/zW2W69A3GUfYVWjtge4mrwrufHHukYsisgfbZQZsOnQlgBxyxV7xzbtECI4z849RDjhUG5g5IM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615401117; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=jlY0Kaoccpxu0Z7znINrHN6ufu6pyEGXYRMIKp0FRTw=; b=hR3utOYsBORA8/ZJr03znf0Qk7Habo2KDGEQZmB79GDVJMmzvkRa+QKHLEXiHA4f6phmOZcOuwvIYK5uLLoUX6z97K034V6ypkyXNjp1MgR/hGWb9bmIqAtgPMnCNn/QYXy4vrntEX6F4TVGv+6kxCObQCyoy13pyKa8cEB/QRY= 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 1615401117285824.6920925804183; Wed, 10 Mar 2021 10:31:57 -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-229-rydJkXsHN7S4Zcxby0IEWA-1; Wed, 10 Mar 2021 13:31:52 -0500 Received: by mail-ej1-f70.google.com with SMTP id a22so5881745ejx.10 for ; Wed, 10 Mar 2021 10:31:52 -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 q11sm144137ejr.36.2021.03.10.10.31.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 10:31:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615401116; 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=jlY0Kaoccpxu0Z7znINrHN6ufu6pyEGXYRMIKp0FRTw=; b=avNk89D5i1ZqlD/+xkELcdeEDDPLwmEvo3FXSwF1zQjQ0WkgC6FE7vMDD5JzXgzaCvdUXK 0E1atSyP6HVn9O0L3zpKpKIwdyvuA8Gn2TiGw6mRU7nqVop2iV/ruFTZR5hhbpVUl6Zkz+ m8YPZBL8/OdYwEg4MS9hnQnLs2VfC7Y= X-MC-Unique: rydJkXsHN7S4Zcxby0IEWA-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=jlY0Kaoccpxu0Z7znINrHN6ufu6pyEGXYRMIKp0FRTw=; b=RabmNxicRtZSDPVu4DlEJvqUddZhVI40PtiDk4mmzkZSJYsLiPnTiFbacj1jC8yFig rUuXVyX2kuaK4XJWhbKf7pGIo16Bq+Yh61bYbZ0JZ2NdyMg8k+FaKi9mHMTK3p4PPQUm Pavuk/2XbFNdqTx11grf2L/7zGIt6jNakFWGS8IVRtUt8V+8TgJmLe5BCxsfIFmpS4AC 2diwn6XhapOvxndTn+7Vj2qd5kZbMTy+wkcE753ZUYlUlPguJ9Ft76/cB34nG68mJsGS Zo8927HQYJVUqHr1tXF2nhOFp3gL6hQPm30G4gO+iPsA6gstu7wMKnSJhEmWCgLJheA7 bMQw== X-Gm-Message-State: AOAM530eKP3B/r9INgWPklUT73acv7rvccq+fh3SKsHTV5mxEAjsPDm2 44FHcId/APHb7Rm8Bt+x5G1iG+Qqcdro/JpZ1AEJpjtThIbZpU/uVK6ExQ+bbLxLYvhlTngUwSL rY+tq6ycWvTEVqg== X-Received: by 2002:a17:906:565a:: with SMTP id v26mr5145586ejr.516.1615401111534; Wed, 10 Mar 2021 10:31:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3LpsKoj2p9zOHybiY+Edt4HvewveyE/LAO8x5Rs3XfgqmSr4JgEhs077OfbxaoS+CuxbegQ== X-Received: by 2002:a17:906:565a:: with SMTP id v26mr5145573ejr.516.1615401111432; Wed, 10 Mar 2021 10:31:51 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jason Wang , Stefano Garzarella , Thomas Huth , Miroslav Rezanina , Dmitry Fleytman , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 5/7] net/eth: Check iovec has enough data earlier Date: Wed, 10 Mar 2021 19:31:21 +0100 Message-Id: <20210310183123.1212612-6-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210310183123.1212612-1-philmd@redhat.com> References: <20210310183123.1212612-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) We want to check fields from ip6_ext_hdr_routing structure and if correct read the full in6_address. Let's directly check if our iovec contains enough data for everything, else return early. Suggested-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Miroslav Rezanina --- net/eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/eth.c b/net/eth.c index 492359afbbb..b78aa526efc 100644 --- a/net/eth.c +++ b/net/eth.c @@ -409,7 +409,7 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int p= kt_frags, size_t input_size =3D iov_size(pkt, pkt_frags); size_t bytes_read; =20 - if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) { + if (input_size < ext_hdr_offset + sizeof(*rthdr) + sizeof(*dst_addr)) { return false; } =20 --=20 2.26.2 From nobody Sun May 12 07:36:15 2024 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=1615401122; cv=none; d=zohomail.com; s=zohoarc; b=VTFbID/9Oe09GCKje9seCnx7rK6scv+bqrIGIFiTNsjy7kzXCx3ZkTr1VH1iuHAS8J9MtlrZGf0FLwORIfH6V5BehyEm8Suoyj74oM/EyW5zH7cBrOtJ22ZRjNcv04hIHndwN3d9LYvd6wLkKkTACXc97dc64FZTg/xbTTSv4+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615401122; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=eTfED9BoXm91g2/VwSi3NLwF+JU0zW5FI7cD1K8YdRo=; b=FGHoKz51vfv8keiEHEuQxQQAyoYXRgIMO36amwsvG1OG1OoktSN8riX88JaWP4sAtlMr7izjceoAxKiESZE7l0nDeQ5wTgArTbUYFMZdPJmCbWx6ORqoAW2+cj5EUUB9RFHZZC7GNav6o+xVVtBV3JAyCgT7/uNE7TcfobsFqx0= 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 1615401122909199.63646281080378; Wed, 10 Mar 2021 10:32:02 -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-359-VT_2HBgTNHmnwqOQhQFxcA-1; Wed, 10 Mar 2021 13:31:59 -0500 Received: by mail-ed1-f69.google.com with SMTP id a2so8803406edx.0 for ; Wed, 10 Mar 2021 10:31:58 -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 c19sm62699edu.20.2021.03.10.10.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 10:31:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615401121; 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=eTfED9BoXm91g2/VwSi3NLwF+JU0zW5FI7cD1K8YdRo=; b=GPTkiklm6zl2z5TW8eaDRHwll7rYZTtuRvwm7VceXBbyvZ8gmLmsYeH4qWGzAFBj/Aey8B lVLCV9BiwIOnb966XcTNBDov1jbK6hZhJQJKPaPqxySuDRGVm1/1NKpv7HHRxm32BmjNJq /uljM7DuuMHx21Z4GPttzZbSwqOshoI= X-MC-Unique: VT_2HBgTNHmnwqOQhQFxcA-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=eTfED9BoXm91g2/VwSi3NLwF+JU0zW5FI7cD1K8YdRo=; b=eyT231f1iVU1vIo/HVszxrSwJan5o8oDt+u2euCPfnTkEJtO/qbTde2RbZEfNwH/Zo foweNbFl271qWzHAw4/quKtsW2b28PyWQrM+BE+YCqZV44E+plpF7vx4O/TWuITvGJm9 h+37QJ0Vgv5mjrtkmipy88QWZNDpy4OSlqxNTnCs7DSiQksMkLSQELhygxEmxkNkXsh6 Hb7wsxkbK1mcuRJRqxjR10MiVpJOFYYRn+GKhq3eFecE+9lg8pZ+LZ8kI0Hf8a2W0jk+ Ty9FPmgQhhwdclTjEtZi/SA1ANuIXxQn0lEmeorlCO1O1u4+Z8pJNLF0M1bFDD4ZAgJq kxjA== X-Gm-Message-State: AOAM531TXGZ/UTb8BQ20KUepN2vjiLzCy3n16GcJ5MOzrw8v0brJKHIm /7y2hCUzp3LGQxbP6KwVKhwC+lN+RUc1yQdUCRKjj3WJft+81h19HdfwapdmvIYYwoMpfwBtafl WUPnzPY3UNnalhw== X-Received: by 2002:a17:906:f9cc:: with SMTP id lj12mr4966837ejb.544.1615401116926; Wed, 10 Mar 2021 10:31:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9m3xx4dxgKj9xy83ghS5gqmUpRNYkRht+Bn9bUDqRDx6fBjjaJDAUKof5cD7M++9RXP+EMw== X-Received: by 2002:a17:906:f9cc:: with SMTP id lj12mr4966824ejb.544.1615401116700; Wed, 10 Mar 2021 10:31:56 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jason Wang , Stefano Garzarella , Thomas Huth , Miroslav Rezanina , Dmitry Fleytman , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org, Alexander Bulekov Subject: [PATCH v6 6/7] net/eth: Read ip6_ext_hdr_routing buffer before accessing it Date: Wed, 10 Mar 2021 19:31:22 +0100 Message-Id: <20210310183123.1212612-7-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210310183123.1212612-1-philmd@redhat.com> References: <20210310183123.1212612-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) We can't know the caller read enough data in the memory pointed by ext_hdr to cast it as a ip6_ext_hdr_routing. Declare rt_hdr on the stack and fill it again from the iovec. Since we already checked there is enough data in the iovec buffer, simply add an assert() call to consume the bytes_read variable. 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 Reviewed-by: Stefano Garzarella Fixes: eb700029c78 ("net_pkt: Extend packet abstraction as required by e100= 0e functionality") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Miroslav Rezanina --- net/eth.c | 13 +++++---- tests/qtest/fuzz-e1000e-test.c | 53 ++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + tests/qtest/meson.build | 1 + 4 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 tests/qtest/fuzz-e1000e-test.c diff --git a/net/eth.c b/net/eth.c index b78aa526efc..284ade4ab0b 100644 --- a/net/eth.c +++ b/net/eth.c @@ -405,17 +405,20 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int= pkt_frags, struct ip6_ext_hdr *ext_hdr, struct in6_address *dst_addr) { - struct ip6_ext_hdr_routing *rthdr =3D (struct ip6_ext_hdr_routing *) e= xt_hdr; + struct ip6_ext_hdr_routing rt_hdr; size_t input_size =3D iov_size(pkt, pkt_frags); size_t bytes_read; =20 - if (input_size < ext_hdr_offset + sizeof(*rthdr) + sizeof(*dst_addr)) { + if (input_size < ext_hdr_offset + sizeof(rt_hdr) + sizeof(*dst_addr)) { return false; } =20 - if ((rthdr->rtype =3D=3D 2) && (rthdr->segleft =3D=3D 1)) { - bytes_read =3D iov_to_buf(pkt, pkt_frags, - ext_hdr_offset + sizeof(*rthdr), + bytes_read =3D iov_to_buf(pkt, pkt_frags, ext_hdr_offset, + &rt_hdr, sizeof(rt_hdr)); + assert(bytes_read =3D=3D sizeof(rt_hdr)); + + if ((rt_hdr.rtype =3D=3D 2) && (rt_hdr.segleft =3D=3D 1)) { + bytes_read =3D iov_to_buf(pkt, pkt_frags, ext_hdr_offset + sizeof(= rt_hdr), dst_addr, sizeof(*dst_addr)); =20 return bytes_read =3D=3D sizeof(*dst_addr); 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 738786146d6..cc5f3aa6b60 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 Sun May 12 07:36:15 2024 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=1615401125; cv=none; d=zohomail.com; s=zohoarc; b=bVJVDhDfk4UHNKirx1NFOv+UANLMpvE06G0J69M6ZHykZmR7bw21sVUDWtJPhnJr2GrcVl6WEJ3WRT7s6XusRwUw9SZq+1Y64OSq+Gl3t1tiGmB0cWFtFg+adk+kBHTr/ZeEIvbA1oEuuo6/o9E3MZa4Kvl+oCXQfqN0QcsNPbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615401125; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=AL0j1J/qe/7XitsoK9+V0I0JiSKNuHRh+kEClor55V0=; b=BO5SH5bYdEZqTO3hMjwffJfw1P4f+4e6DDRFOFKnvi+PpChYTn1SMZSOgc+TA/hw+RaJXJJ+X3iwjyV9BmdIw6l96fHqRwh5zTEHvvfvA5lTKWHJvBXJx2Hn1ahsCnIa2UndUfpDdmQTxQyfLRyq3u+xXXP6OkrYvpkEpfUpQRA= 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 1615401125635960.5929159429039; Wed, 10 Mar 2021 10:32:05 -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-21-YT-sP1C_MPWsWJcfF1f65A-1; Wed, 10 Mar 2021 13:32:02 -0500 Received: by mail-ej1-f69.google.com with SMTP id h14so7640461ejg.7 for ; Wed, 10 Mar 2021 10:32:02 -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 l18sm131048ejk.86.2021.03.10.10.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 10:32:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615401124; 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=AL0j1J/qe/7XitsoK9+V0I0JiSKNuHRh+kEClor55V0=; b=RD7wWrlFfCJWGWQFPs4EEPc0ia+Qw8yFA5tCITZ121xW12dXexPkmBLH8hxrHBbzcD77pO Wp7dYdZzY3bBH5T2XPMSdT/ct2LdrL8PTDoIFoQy3s9vCJHhvAWRmD0/61L0gEjqZHj56Q 1oXOEODXUqeMXwjqXSjKhrzJaPsoTBM= X-MC-Unique: YT-sP1C_MPWsWJcfF1f65A-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=AL0j1J/qe/7XitsoK9+V0I0JiSKNuHRh+kEClor55V0=; b=adOp32dMCn6LyVFjJYsPc3R0Am7B1FjocF8kyexma6EngHqDelqR0JO541EI/b3Kf5 nROJz9ZpQFHbPtrsxmOPz9D4Mf/B5n5NeIdprZNECHR85QGGpkyziEEdR7ShJAa2m612 gbH2E/CzkI1Szc0s8dQlc2o/DYSM/AYNK7/zceLo/0/kcvgzSbubSkPZu+JdBYmZnwUD zIX9BhoWOTt8IV+oqXSXtTLYsIuUT2w3nq8FcYkF00DAXYy+VgByYYvfhdCbZRAITDHc jAD7jWt6jEaHbFyVHiqulfZ4kxgL2hpHXnaNZS9+OJB/IRXCDy/O00nQnDYPxpj4O82f lkLg== X-Gm-Message-State: AOAM532K2o4ogZ5fzywY0bdvX8JDa9/le2TptiOpz8YL17UbmmBV138X Kr2yxntneZnQj0qMPuKRXRaybkkTaIur3J1To+DEbyCpgtO4wtbbJwvJ0Y//PUyS7PPI966AwcW APZeb11tUBjRlug== X-Received: by 2002:aa7:c4cc:: with SMTP id p12mr4666925edr.325.1615401121806; Wed, 10 Mar 2021 10:32:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKNj+qW2K71MVh/nPK8L/+yxc1cWWElb7IG3ciBrD3rEW2oU0jbxDk5sx1CbFoPi2bOUhNEA== X-Received: by 2002:aa7:c4cc:: with SMTP id p12mr4666918edr.325.1615401121702; Wed, 10 Mar 2021 10:32:01 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Jason Wang , Stefano Garzarella , Thomas Huth , Miroslav Rezanina , Dmitry Fleytman , Paolo Bonzini , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v6 7/7] net/eth: Add an assert() and invert if() statement to simplify code Date: Wed, 10 Mar 2021 19:31:23 +0100 Message-Id: <20210310183123.1212612-8-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210310183123.1212612-1-philmd@redhat.com> References: <20210310183123.1212612-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) To simplify the function body, invert the if() statement, returning earlier. Since we already checked there is enough data in the iovec buffer, simply add an assert() call to consume the bytes_read variable. Reviewed-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Miroslav Rezanina --- net/eth.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/net/eth.c b/net/eth.c index 284ade4ab0b..f5fde6d83e3 100644 --- a/net/eth.c +++ b/net/eth.c @@ -416,15 +416,14 @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int= pkt_frags, bytes_read =3D iov_to_buf(pkt, pkt_frags, ext_hdr_offset, &rt_hdr, sizeof(rt_hdr)); assert(bytes_read =3D=3D sizeof(rt_hdr)); - - if ((rt_hdr.rtype =3D=3D 2) && (rt_hdr.segleft =3D=3D 1)) { - bytes_read =3D iov_to_buf(pkt, pkt_frags, ext_hdr_offset + sizeof(= rt_hdr), - dst_addr, sizeof(*dst_addr)); - - return bytes_read =3D=3D sizeof(*dst_addr); + if ((rt_hdr.rtype !=3D 2) || (rt_hdr.segleft !=3D 1)) { + return false; } + bytes_read =3D iov_to_buf(pkt, pkt_frags, ext_hdr_offset + sizeof(rt_h= dr), + dst_addr, sizeof(*dst_addr)); + assert(bytes_read =3D=3D sizeof(*dst_addr)); =20 - return false; + return true; } =20 static bool --=20 2.26.2