From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B365CC83F18 for ; Mon, 28 Aug 2023 10:16:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230380AbjH1KPy (ORCPT ); Mon, 28 Aug 2023 06:15:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230395AbjH1KPf (ORCPT ); Mon, 28 Aug 2023 06:15:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99B48103 for ; Mon, 28 Aug 2023 03:15:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 30C8E636A8 for ; Mon, 28 Aug 2023 10:15:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C480C433C8; Mon, 28 Aug 2023 10:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1693217731; bh=B4Dd6y1fsVMbxMbzh+oaAzUv+o0i5mqucQ9atXhpdTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1P4aLRgP4U0vY4hHYuZyxUNcexkKIa/JlSjBKS01HrX1QcD5wUX3sZmmeVJj+ncww oMDHKlQ/XYA4GKeGH+1WPaQetPJf3BYD3sY7qW0xHJED40KvGJ7Mx8Obk952AHN66g LMiGwFundIA3cZFtFHazRxdMt0CyMbkjjUM7r97U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Lin Ma , Steffen Klassert , Sasha Levin Subject: [PATCH 4.14 20/57] net: af_key: fix sadb_x_filter validation Date: Mon, 28 Aug 2023 12:12:40 +0200 Message-ID: <20230828101144.974108902@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230828101144.231099710@linuxfoundation.org> References: <20230828101144.231099710@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lin Ma [ Upstream commit 75065a8929069bc93181848818e23f147a73f83a ] When running xfrm_state_walk_init(), the xfrm_address_filter being used is okay to have a splen/dplen that equals to sizeof(xfrm_address_t)<<3. This commit replaces >= to > to make sure the boundary checking is correct. Fixes: 37bd22420f85 ("af_key: pfkey_dump needs parameter validation") Signed-off-by: Lin Ma Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/key/af_key.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/key/af_key.c b/net/key/af_key.c index 49813e6d05ed7..197990b9b97df 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -1858,9 +1858,9 @@ static int pfkey_dump(struct sock *sk, struct sk_buff *skb, const struct sadb_ms if (ext_hdrs[SADB_X_EXT_FILTER - 1]) { struct sadb_x_filter *xfilter = ext_hdrs[SADB_X_EXT_FILTER - 1]; - if ((xfilter->sadb_x_filter_splen >= + if ((xfilter->sadb_x_filter_splen > (sizeof(xfrm_address_t) << 3)) || - (xfilter->sadb_x_filter_dplen >= + (xfilter->sadb_x_filter_dplen > (sizeof(xfrm_address_t) << 3))) { mutex_unlock(&pfk->dump_lock); return -EINVAL; -- 2.40.1