Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4619853pxj; Wed, 12 May 2021 09:22:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyg9H1J8Nc1SX1QEmoLLmla/GMwFLEuWk4WKeng9dWPd1J0WSHq54c0FNcck83KEtvA0I4k X-Received: by 2002:a17:906:2559:: with SMTP id j25mr37528418ejb.42.1620836565989; Wed, 12 May 2021 09:22:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836565; cv=none; d=google.com; s=arc-20160816; b=fgHUuD6mews6rxrJoMwYkJFKKSGaji/bXZkmoOOXcu2LcS4szYHHBd520r+PNuBGh7 yzPBRe3THN9msKncUIxyqt7UbdMlQ8/bF1za5NJ3ZJ+DeeMhOPUiMtIJYhIV1d5UaGle ile43RJN0gsZ8QXbsT/4aEx4vSS3OfZHbTtsOPDA/gf5Kduf45A5ratbcUqmdTBTKUST RdZ6RAoKFtKWktNnLf8i4RNu2SmvfwyM/HbXk084AVVLkpQJ+lPelBpsye3v08zQkDWZ FSkt2XzXMHAhIbEgN9x8BocRExyHpbDqe+3rYitZRTD3or7BsCwB6B91fgLcmPFEbAwA rQLg== 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=gc04JSIsLgyfjcBEEGIB2Kh1ePg2sij7KNPo8/Qixn4=; b=0b4F8JJZMHfwBWpZj++vMZqdZSwCmDaPfDVOsKz+9aMj9OQ84K9J2Ps18IcxJtY+N5 AN9lhWz3oUFE9z76YNhthD9qtxXZaYnE9KiyzPAaUWqErFQChXl3LovWWRsRyr+eGZDv xXh3lRjFYbf5QGHuhY/aCD9xzTxrBPAH2LPFPkOGzdp6nbC74I81seApv3R/qqR6iL7W X3QQcSQLCaZsxPA+bbBQEXCcOwKj674wpvG/Amrij8L/9zZDnXRJTaD5g3RP4lNoU/2H t6GVmx7M9mhlufdq5rKuw9ZoieiJYcVgjQWoUsJxr0BNEWnW/9mA0Nl/jPoIZk5HrJj7 YBDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=r7hqkhWe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g20si91845edt.518.2021.05.12.09.22.21; Wed, 12 May 2021 09:22:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=r7hqkhWe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S239998AbhELQQx (ORCPT + 99 others); Wed, 12 May 2021 12:16:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:45780 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234536AbhELPdQ (ORCPT ); Wed, 12 May 2021 11:33:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D337161984; Wed, 12 May 2021 15:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832627; bh=nXOtUTuEyoWEAoXjKVKOg46/nORIoY98s0detD/cGuQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r7hqkhWekB4AC3epMZ1R6wC5Haw3l0lpPt3XLZQOGsbfMDJW/xFIaZyyuuHtCr125 XCDq9Zaw6H1ACKY4Xo/tROpELO9GTwjR/HRbCDW68vYwKBMPyeV40Mq6PFFkoajNtS R8WcHBDbFT5hxyNT8MMxmQsxm6m41Wb8iMzUHs+g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrii Nakryiko , Alexei Starovoitov , Sasha Levin Subject: [PATCH 5.10 357/530] libbpf: Add explicit padding to bpf_xdp_set_link_opts Date: Wed, 12 May 2021 16:47:47 +0200 Message-Id: <20210512144831.521856596@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrii Nakryiko [ Upstream commit dde7b3f5f2f458297aeccfd4783e53ab8ca046db ] Adding such anonymous padding fixes the issue with uninitialized portions of bpf_xdp_set_link_opts when using LIBBPF_DECLARE_OPTS macro with inline field initialization: DECLARE_LIBBPF_OPTS(bpf_xdp_set_link_opts, opts, .old_fd = -1); When such code is compiled in debug mode, compiler is generating code that leaves padding bytes uninitialized, which triggers error inside libbpf APIs that do strict zero initialization checks for OPTS structs. Adding anonymous padding field fixes the issue. Fixes: bd5ca3ef93cd ("libbpf: Add function to set link XDP fd while specifying old program") Signed-off-by: Andrii Nakryiko Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20210313210920.1959628-2-andrii@kernel.org Signed-off-by: Sasha Levin --- tools/lib/bpf/libbpf.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index 6909ee81113a..57d10b779dea 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h @@ -507,6 +507,7 @@ struct xdp_link_info { struct bpf_xdp_set_link_opts { size_t sz; int old_fd; + size_t :0; }; #define bpf_xdp_set_link_opts__last_field old_fd -- 2.30.2