Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1870517lql; Wed, 13 Mar 2024 10:18:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWY09S2SWGQGBX/zsJdtrD1KX5FPq6eH8cOBRJebXFJerVhR6HRsOETEA5lsASv5yNifzkxeNdnc4I78nI8Z4cJJ8JG7dsQgA1wIfTBag== X-Google-Smtp-Source: AGHT+IH/J7SqvKWSlHLRbfQdZtLb4F3nacoZwBzbccir/ZF+A38TKp3Ofsw5ES3o1X37ZuuGG8mI X-Received: by 2002:a17:907:8744:b0:a46:2623:7525 with SMTP id qo4-20020a170907874400b00a4626237525mr7591983ejc.20.1710350287454; Wed, 13 Mar 2024 10:18:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710350287; cv=pass; d=google.com; s=arc-20160816; b=wPM2nsO5uLZ32aVNGkpvsF+HU7lDR4UalbB4H/T+dVqMsoE0n/dvaOfv2EUFi/HXKc YetjHj0KiQY4MfOjB/33pWQjgxUZm6DxzgjNc+9F/chZey72JfjfEq95JQ8U+S71/3wQ yxAVe9hh4JLZYsnbeQWvyCQetc2M0shaUu9mf51VQLTgxLeW56IYTt7TAPBYl/egbFKL +I1oc9MyfyFGzFYbgCYGLEEPj8NX7QWQQ4Xztwfzv5pGVD5lexTNGtIysnAawfzl+DP3 FqubKxoYSsTwY07APIDD822LvUIiwo2+OfXe4xF0p5GSOOgYJ7rdjfjfN1UTblhS2c3w rpYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gkEBxwr+Jxy8y1SAX+f0LlK78V2bXxUTbYrebHIfmPo=; fh=GEiuxw0Vxgdpy0LuA4ioav0xhGOuD6SBmK+cd6VvlP0=; b=oE87cbmoOWOGyfpK/DZU3iaosECG5L6x0Vdfg2z9b7xP2lv2TF1/yTMn2Wvqi5101l njIlpL0mhFzIrqytOKly+GCqolSy3/iVvdJ9ZqLcNi69tg2An7PmMrqb2rwpbJYmmg+s KccizEObQxt2txjp9P+4dWqS43SO8SbibRI5H9cAydpu0Szor0xtHStD3aWEHKMzj10j PTN1YYLJsUVLLul4fOww5B4f2rSxZALVRhcZuubyGsk2OfQ9LArCcvoUbdbzZCcyPtXY z2HYtVsXrerQzZHaCzFcqTjV/qqd2IDMDfBu3hdpNtv3hGAAVb6FcCVA8jj8FFWCFpar NP0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="OyO3o7U/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101881-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101881-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kh22-20020a170906f81600b00a461f6da4ebsi3559236ejb.271.2024.03.13.10.18.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:18:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101881-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="OyO3o7U/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101881-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101881-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BB2141F25C58 for ; Wed, 13 Mar 2024 17:06:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 760A578B6A; Wed, 13 Mar 2024 16:40:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OyO3o7U/" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9AB5B78B4A; Wed, 13 Mar 2024 16:40:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348016; cv=none; b=dxwZYfDngHmlNe+wRnKdRqIVkW2eI5lltkF15mAyFMl8Z1Jj29W9BOy9fD6inaQ3V/4hZEfsgDy5a+mtvQFwwLC1WLPjZUi6dPWxukf00pX4KVVVDwMb6vrUYkVCapw688YDZd2M2HP58QM9dC1Yk8eCbPv8H3KeUpKg8HSKxYU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348016; c=relaxed/simple; bh=ybuXajKoE/4oZjZoTSRqY5XuI6zt6tVcd4UpFloBw+U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xz3TlbN+Fq+oIYw4ru21kF//lLpMalvVKR6gH34UDvZQfc4v3Xhl9+WkK4F2TshQBwC8fH/6QV63hEkctGoohe/sUHLRaVozTbyd0C/7rnkjBD9cPNxOr3fDKJllYA680KeyMPubTs5PDm9WIJ5Xg3PNJXbtr/k0FVXu5m/wXek= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OyO3o7U/; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DE7DC433F1; Wed, 13 Mar 2024 16:40:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348016; bh=ybuXajKoE/4oZjZoTSRqY5XuI6zt6tVcd4UpFloBw+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OyO3o7U/Ix4xj7DhiGuP7PbmgeBoLQ4f64VLL4awjp5cTnCD11+MYAtCVaujwgT9h LEP5d+uMPC36IF2E72H/aw4mpKtv2uADPz3qsRHzka7Hf/HkzQky5FJDYMz55bUAgN nJH8PUHPgPvI4I4+PpUb3YTI2a/oFJqShBSxcdUF/EIKT3WId1SUYJ1fk4W1fUcFQN F2pMLLOr4L6FOVWEWi0vgwPjRdA4AYCvIRMCBmUPcHiaZ6GlpHkTSjkthARH0j+B3d jlUjp3dfpK9CsOxNbhzlu5/jUXwjzboDY5qLDpWpArbQYHJM5Yaceponuw4SfQl/Vd gweYu5yCfsHkg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , =?UTF-8?q?Tobias=20B=C3=B6hm?= , Martin KaFai Lau , Sasha Levin Subject: [PATCH 6.1 13/71] cpumap: Zero-initialise xdp_rxq_info struct before running XDP program Date: Wed, 13 Mar 2024 12:38:59 -0400 Message-ID: <20240313163957.615276-14-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313163957.615276-1-sashal@kernel.org> References: <20240313163957.615276-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.1.82-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-6.1.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 6.1.82-rc1 X-KernelTest-Deadline: 2024-03-15T16:39+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Toke Høiland-Jørgensen [ Upstream commit 2487007aa3b9fafbd2cb14068f49791ce1d7ede5 ] When running an XDP program that is attached to a cpumap entry, we don't initialise the xdp_rxq_info data structure being used in the xdp_buff that backs the XDP program invocation. Tobias noticed that this leads to random values being returned as the xdp_md->rx_queue_index value for XDP programs running in a cpumap. This means we're basically returning the contents of the uninitialised memory, which is bad. Fix this by zero-initialising the rxq data structure before running the XDP program. Fixes: 9216477449f3 ("bpf: cpumap: Add the possibility to attach an eBPF program to cpumap") Reported-by: Tobias Böhm Signed-off-by: Toke Høiland-Jørgensen Link: https://lore.kernel.org/r/20240305213132.11955-1-toke@redhat.com Signed-off-by: Martin KaFai Lau Signed-off-by: Sasha Levin --- kernel/bpf/cpumap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c index 08a8e81027289..0508937048137 100644 --- a/kernel/bpf/cpumap.c +++ b/kernel/bpf/cpumap.c @@ -222,7 +222,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu, void **frames, int n, struct xdp_cpumap_stats *stats) { - struct xdp_rxq_info rxq; + struct xdp_rxq_info rxq = {}; struct xdp_buff xdp; int i, nframes = 0; -- 2.43.0