From patchwork Wed Oct 19 08:26:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5024 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp246239wrs; Wed, 19 Oct 2022 03:37:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Ntq3TcvKpa7GaMkLmuj/RRi2aUZGkxRkI80HemJe7beJMVnG1bLO2VMvac3qqW+ot1YRB X-Received: by 2002:a17:907:3da2:b0:78d:3b45:11d9 with SMTP id he34-20020a1709073da200b0078d3b4511d9mr6163779ejc.87.1666175863896; Wed, 19 Oct 2022 03:37:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666175863; cv=none; d=google.com; s=arc-20160816; b=gc21g8suxTIb9ouFYckb1Hdg2zHFhzpDM2gIKjhOMr7HCToCb+xFII+SgbOxHbWxe5 M/8dEvyuf8UIvVSKMZmGXXCywWnsYEmU43vyvA+H7PTQuiYYNZZVbGxwtsKZxbsPeLgd RAwktssEyral4OCqUers4YXvsDX4Wl+lV9VOO+mSIW/Q17tGwn1MUF8eOwcL99sig4ij SB1AtC5Ch84TyhfPrfLONRWu2wz2omEcJZrDykGbjYDTKmUyPtfL1SVbxB+2cbuIjQdX xLOZLf6QhIo7nInZoU5UN01L180P6hpW3rgTJP/mz0cWvfDwNwyxHNopKsGIdRYBcRGw cLMA== 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=RIkfwStvFGMUot9Z7jY0YMCcbsRhgnogPqVX1f9Q9AI=; b=opzsplSZ0U68K/U91XMPF51IC2sk72Dzxwmy+N8GkJs37TUzZjF1YUmxEYuNgnBEzm WuJQWg4GTQMR4505A4P829/qonXawqOLAOZT2Asx6SSEhsfQVvHJVIV/3Jfe1Oul4zKD XXDPc+zYSXM+YjW8VV0/Y6jj7SAP3WJyfXwfMtGswYCLrjUYXmM4mgzLXCNikfWpMTc1 3xtLI1ND800VJpX+aWR+68FqOiZTESZHMCvbPS50AlwRMx5NVorgaTSCMiURt+0Tf8mm G1179G8CXoH9D4HdXk48fHW+N4gytyyKpMqFMLkzBBwmksywAjwaJApTWCgiEAtsDrTM K5Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zcCqxMZE; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ko1-20020a170907986100b00782a5657512si12994539ejc.416.2022.10.19.03.37.17; Wed, 19 Oct 2022 03:37:43 -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=zcCqxMZE; 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 S230339AbiJSKfg (ORCPT + 99 others); Wed, 19 Oct 2022 06:35:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231910AbiJSKeG (ORCPT ); Wed, 19 Oct 2022 06:34:06 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5480BC467; Wed, 19 Oct 2022 03:13:30 -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 ams.source.kernel.org (Postfix) with ESMTPS id 82117B823B4; Wed, 19 Oct 2022 08:53:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3359C433C1; Wed, 19 Oct 2022 08:53:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169619; bh=OPp2VmU2xuhn8QhfIRqDT+QYwwrcCJFreKlrbF9Gf0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zcCqxMZENL3UvsK8P+nXb+sTlR0Y+98qorPa6o5O5ZD49Py/guZHEmpbN0a/79t7e lDqKL+6ezSRaJAsLHBXQT1JCn8Yg9mq2688yd7HIgenpBuI9HpQQcynzh7ZHjpwBdC LwLnz8OYFJSGhnewUWkGedMJhQb31eFl4M86m4C8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Grant Seltzer Richman , Andrii Nakryiko , Martin KaFai Lau , Sasha Levin Subject: [PATCH 6.0 311/862] libbpf: restore memory layout of bpf_object_open_opts Date: Wed, 19 Oct 2022 10:26:38 +0200 Message-Id: <20221019083303.755808690@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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747112022731498975?= X-GMAIL-MSGID: =?utf-8?q?1747112022731498975?= From: Andrii Nakryiko [ Upstream commit dbdea9b36fb61da3b9a1be0dd63542e2bfd3e5d7 ] When attach_prog_fd field was removed in libbpf 1.0 and replaced with `long: 0` placeholder, it actually shifted all the subsequent fields by 8 byte. This is due to `long: 0` promising to adjust next field's offset to long-aligned offset. But in this case we were already long-aligned as pin_root_path is a pointer. So `long: 0` had no effect, and thus didn't feel the gap created by removed attach_prog_fd. Non-zero bitfield should have been used instead. I validated using pahole. Originally kconfig field was at offset 40. With `long: 0` it's at offset 32, which is wrong. With this change it's back at offset 40. While technically libbpf 1.0 is allowed to break backwards compatibility and applications should have been recompiled against libbpf 1.0 headers, but given how trivial it is to preserve memory layout, let's fix this. Reported-by: Grant Seltzer Richman Fixes: 146bf811f5ac ("libbpf: remove most other deprecated high-level APIs") Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/r/20220923230559.666608-1-andrii@kernel.org Signed-off-by: Martin KaFai Lau Signed-off-by: Sasha Levin --- tools/lib/bpf/libbpf.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index 61493c4cddac..9f956e6058ed 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h @@ -118,7 +118,9 @@ struct bpf_object_open_opts { * auto-pinned to that path on load; defaults to "/sys/fs/bpf". */ const char *pin_root_path; - long :0; + + __u32 :32; /* stub out now removed attach_prog_fd */ + /* Additional kernel config content that augments and overrides * system Kconfig for CONFIG_xxx externs. */