From patchwork Wed Jan 24 19:55:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin KaFai Lau X-Patchwork-Id: 13529611 X-Patchwork-Delegate: bpf@iogearbox.net Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12D07133409 for ; Wed, 24 Jan 2024 19:55:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706126151; cv=none; b=S/JLQa8LNiZCjq3ggMhCXX7AuEtif/bd9IlGwE8vaXedrvwUOdCYWDHBwyF9c+MLsQZACnSOSS3HkL/kPRBNlHksF8IJwN7TRrI6fRQ9qkjZpYA2YDxvPi2dMKtSZ5r5gw1ypJ6MexO4PJMx3ohDNBjj1mvm2H6RZmhAR68L5E0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706126151; c=relaxed/simple; bh=WVVyJI13Shfo/IZt29wogaveEudc8xdywF1s/vdWIs0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=gtZW3u5kcZ2wXqxosoGMQ5w3WhxpastcQ3l3O0Bpi+wkKJffLVaBpjsQZvoOXmaNGWE/gfrCUcv4ugvfHUo9HUbsvhx2NH8GQ/KmNGKMB+dTbJP/6IflVU3eGnd5eh//sGj/mopUiMLJPKDGD/8tuJVkJnkDHJJNjdqREqXHVq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=nqt3/mL+; arc=none smtp.client-ip=91.218.175.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="nqt3/mL+" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1706126147; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=SFlrxb82Xv2DmdaqtksaJbPBgkMBD/XHXiZ133Rc6u4=; b=nqt3/mL+ytoySafxL7vKkGPIh41QSeqVdf05e9aKOSGfmP2cdfPLqHBPGKfOdxFvYYPB1h 81IpUIT3oy0OXBYRGlwWwhp95yl0Kik1HsihhbyPDojrg3l6HLniqxRWBm3LtC34Y1KIsO BE8cvY+KEgL1swYODlUa6WYSlw6PDa0= From: Martin KaFai Lau To: bpf@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , kernel-team@meta.com, Kui-Feng Lee Subject: [PATCH bpf-next] libbpf: Stop setting -1 to value_type_btf_obj_fd which breaks backward compatibility Date: Wed, 24 Jan 2024 11:55:19 -0800 Message-Id: <20240124195519.2136101-1-martin.lau@linux.dev> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Patchwork-Delegate: bpf@iogearbox.net From: Martin KaFai Lau Passing -1 in value_type_btf_obj_fd to the kernel will break backward compatibility. This patch fixes it by using 0 as the default. Cc: Kui-Feng Lee Reported-by: Andrii Nakryiko Fixes: 9e926acda0c2 ("libbpf: Find correct module BTFs for struct_ops maps and progs.") Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 3a35472a17c5..b133acfe08fb 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c @@ -192,7 +192,7 @@ int bpf_map_create(enum bpf_map_type map_type, attr.btf_key_type_id = OPTS_GET(opts, btf_key_type_id, 0); attr.btf_value_type_id = OPTS_GET(opts, btf_value_type_id, 0); attr.btf_vmlinux_value_type_id = OPTS_GET(opts, btf_vmlinux_value_type_id, 0); - attr.value_type_btf_obj_fd = OPTS_GET(opts, value_type_btf_obj_fd, -1); + attr.value_type_btf_obj_fd = OPTS_GET(opts, value_type_btf_obj_fd, 0); attr.inner_map_fd = OPTS_GET(opts, inner_map_fd, 0); attr.map_flags = OPTS_GET(opts, map_flags, 0);