Received: by 2002:a05:622a:251a:b0:39a:b4a2:e86 with SMTP id cm26csp316202qtb; Wed, 19 Oct 2022 02:42:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ej7bBdsZORxKya9D0vKjBISMedc6NAk6h8YX56cBBIMikfnH68mzYHmSjuCLgqEl1btq1 X-Received: by 2002:a17:907:971c:b0:78e:63f:c766 with SMTP id jg28-20020a170907971c00b0078e063fc766mr5964147ejc.330.1666172579149; Wed, 19 Oct 2022 02:42:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666172579; cv=none; d=google.com; s=arc-20160816; b=GOl7TFygG+lPT+lMNO6E7Qn0UBo6MBdX+jWv/YFMFvwG+bi6ZJ2e28YRGI65dHdqij 9Vx2qIRFSAI0j4ETPHQCVFQVj/BPssqZQ/adiuGnnnWtkUmY/Iln2c7OfbdaXiUBaqRo 5ugY3xbBwKBESoXQ5L2a8rrLfaCFrYT7GSTOBi8H5WlMUolFogVTpWPpR07IQscsDmtq /tsuY6ci8qOP9jqvRmoHAwVh4CFwwZrsX3oRgrLzp0yXH4c1mzVxRkdCJmU9LjsT75E0 XXgxMOVsOiud6dei8cAIe2B6tls22LN0ndfFtrOzKFFOlMsV5GraWDMVcUBMcB6VxF7w IyvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HVOWa+6MXo9LYGClhBmlkarfC9QJVJ5D0fBxPIu/o1o=; b=spbR1dDn51VdZECVRQ83UE/zw2YxoK7RiIBrsbbH8CHm99pb/LeDY/p+F6qdT2dgdL tMsmLzkJQc8yqiEv9hzjY646taN/t1PO2YLnXVvUa2Xel5KcfTGPzA4+wUwPCzWRwV23 yg6/V/MMmAlzoppDC8Fx+4MHa6brk/vRlZDKgH5xcsMSWWAvajCsrMBjqSXqKaw7hb+a KPx9RSzAEhouUaylLtDZJ+C736Yk002TBlCzluO8kxoeJpk5AekaSfa4athMsW/hDXLC Q937AyL+tYM/HEVdDkjzb/xMOzKiWEX4ZdAfoEd3tRaOFLoAGA1RgX/3J4cEIPd6Goj3 l4KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AKaEDWYV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cz3-20020a0564021ca300b00459be46b0f4si11928480edb.131.2022.10.19.02.42.32; Wed, 19 Oct 2022 02:42:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AKaEDWYV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233661AbiJSJ2w (ORCPT + 99 others); Wed, 19 Oct 2022 05:28:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233586AbiJSJ1P (ORCPT ); Wed, 19 Oct 2022 05:27:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02305E09EC; Wed, 19 Oct 2022 02:12:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 414DF617E3; Wed, 19 Oct 2022 09:10:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51FA7C433D7; Wed, 19 Oct 2022 09:10:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170621; bh=iOp5sUohYYKlU8xKhB8swSLrL8/OASDUJXxbMxBidxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AKaEDWYVkGUh+ir7ix4PYaO2n7LqBmC/BlzgvPid65FDMX9IgbgCWgyDYQvfPZXuY 9wBdqdoSu5jzycDX6dRJHE8qsoko0e2sDrDKkT6WqsX1478eQPhx3lqpGWtarZcSpf PkLMK+mweNN/tyqgR7AaVdnfRT5SsQalM1DFsPUk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Liu , Andrii Nakryiko , Sasha Levin Subject: [PATCH 6.0 725/862] libbpf: Fix overrun in netlink attribute iteration Date: Wed, 19 Oct 2022 10:33:32 +0200 Message-Id: <20221019083321.967563918@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xin Liu [ Upstream commit 51e05a8cf8eb34da7473823b7f236a77adfef0b4 ] I accidentally found that a change in commit 1045b03e07d8 ("netlink: fix overrun in attribute iteration") was not synchronized to the function `nla_ok` in tools/lib/bpf/nlattr.c, I think it is necessary to modify, this patch will do it. Signed-off-by: Xin Liu Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20220930090708.62394-1-liuxin350@huawei.com Signed-off-by: Sasha Levin --- tools/lib/bpf/nlattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/bpf/nlattr.c b/tools/lib/bpf/nlattr.c index f57e77a6e40f..3900d052ed19 100644 --- a/tools/lib/bpf/nlattr.c +++ b/tools/lib/bpf/nlattr.c @@ -32,7 +32,7 @@ static struct nlattr *nla_next(const struct nlattr *nla, int *remaining) static int nla_ok(const struct nlattr *nla, int remaining) { - return remaining >= sizeof(*nla) && + return remaining >= (int)sizeof(*nla) && nla->nla_len >= sizeof(*nla) && nla->nla_len <= remaining; } -- 2.35.1