From mboxrd@z Thu Jan 1 00:00:00 1970 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 8F7F36BB5B; Tue, 12 Aug 2025 18:51:44 +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=1755024704; cv=none; b=YxY0Y0WPLncCOcfn8FKwcHmrPLOTK8JYNqZoYE0U2LGiEWlmnk2kf2zK86cuPIxdFvrg8ACbhHXSBg9q3ZaiV6ve2nM7AzS6YVFShtumQvKuB9ALOZwTn4vsffax624ijHuuBB/N12Us4R0akza+YbbtRautC9i2DJaMpHgSQOY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755024704; c=relaxed/simple; bh=MtoNYhGqSwoahDLIueiDNp+8z5kok2Cl+sQM52F6EfU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eIshus8Lcz3pZbBw0CahOswGikrsA/A3a+SHAXkcfDPlrlGdOppKKR8Jn/47NZWRwQs0lruiak/vVJGysVqI2I2z4c7bTj3rFdaxELUCD9mYlIgz8S0+JOY7REKsUuyqcNkVo4RpAVkGPA/qp4iMJFFwH6higGYcWwlKXvTBbis= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gd9dz2Dz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="gd9dz2Dz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3606C4CEF0; Tue, 12 Aug 2025 18:51:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1755024704; bh=MtoNYhGqSwoahDLIueiDNp+8z5kok2Cl+sQM52F6EfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gd9dz2DzyLQSwtYNkbKzol2yf1+joN+qEUGYgaAoO3GpvGJEpsB3D0wkc9/YX3RtG O7qfdSKWJ8Xhta/6O4YQEWGTeY/qU3ue4PseUjhuEUIHR6l5mJyE1HzwHvP0matVen Wp57YWN3Tmo2TJ/Rl+IfC5MqzHmwrRR+RpgenW9I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+ccac90e482b2a81d74aa@syzkaller.appspotmail.com, Paul Chaignon , Yonghong Song , Eduard Zingerman , Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.16 451/627] bpf: Check flow_dissector ctx accesses are aligned Date: Tue, 12 Aug 2025 19:32:26 +0200 Message-ID: <20250812173437.215686075@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250812173419.303046420@linuxfoundation.org> References: <20250812173419.303046420@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paul Chaignon [ Upstream commit ead3d7b2b6afa5ee7958620c4329982a7d9c2b78 ] flow_dissector_is_valid_access doesn't check that the context access is aligned. As a consequence, an unaligned access within one of the exposed field is considered valid and later rejected by flow_dissector_convert_ctx_access when we try to convert it. The later rejection is problematic because it's reported as a verifier bug with a kernel warning and doesn't point to the right instruction in verifier logs. Fixes: d58e468b1112 ("flow_dissector: implements flow dissector BPF hook") Reported-by: syzbot+ccac90e482b2a81d74aa@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=ccac90e482b2a81d74aa Signed-off-by: Paul Chaignon Acked-by: Yonghong Song Acked-by: Eduard Zingerman Link: https://lore.kernel.org/r/cc1b036be484c99be45eddf48bd78cc6f72839b1.1754039605.git.paul.chaignon@gmail.com Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- net/core/filter.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/core/filter.c b/net/core/filter.c index 47073a0180a4..2c3196dadd54 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -9449,6 +9449,9 @@ static bool flow_dissector_is_valid_access(int off, int size, if (off < 0 || off >= sizeof(struct __sk_buff)) return false; + if (off % size != 0) + return false; + if (type == BPF_WRITE) return false; -- 2.39.5