Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1086099pxk; Fri, 25 Sep 2020 06:01:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbjYIOXwpebVPqrc7A03Qa+cluj0Tq7M0F62wY5com7qHtwNlUmTiJLxDZsldrRBqSxG4r X-Received: by 2002:a17:906:4bd7:: with SMTP id x23mr2528569ejv.92.1601038890536; Fri, 25 Sep 2020 06:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601038890; cv=none; d=google.com; s=arc-20160816; b=b4tj6asE6R8geteHERb2sBb1Y2MF8eGpOh3G+kZOTG12272kBmizDL3fhaOTLys9fi IW3Kt/kBIl4sFQJZdW9Hiu0UNXoh2xdO+2WUFT6QZy+meVUFvpxNWxweLfYTDt+N1hhu iluoOi2J8mpXqW2813O5NKajluYVzlga0Qtci51HfBoctzo5tD5ZbYIIVoJnAkRTXdvu DeT8tyejr3Y0I3vNdy5aZRYcJbhWLFYhEYLcvmXMFRzki1PsASikrss4NCxl6YbljZUN Ir8kjf5lw7Udr/1OqytN4UvcGJ1qjE3GOESglGDhvasNOc28H6zvLUGYceqS3xeZyn5G Uamg== 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=Ry9d8WL6kChQKRdhG0yC4xOYKNhZcG/LMm+/abb9Rtc=; b=sm8LylPwTEqPrmxzIi2mZb8Ph9JOmtbZifDp4PDODqJXMIWzg2uk93JKRMPKvES5zX qr8c7tdOUdDEeegrqQrqH8TzdUNC8mHEO3lQZWM06AK6Ged5sevX89LuY+S33NErlpAV sQ+GyvbSJGlC81q2Tcjak3tIfNrN6TjIWcl0AbVEiNAWD8KHrOy7zCifdnNkoF7e3z/U +c4jDlNjimIb6XiIdPT1W1sKv3DCznwYrerJsUufK/WUKReCZaVICc5d/oBpjCWHjiFR iSYAzslZD3Vo/Bq6bM6iifjBONKcn6VADm5BbTwTvPE8LSv1QfWHZ+220wbqbG9aaPcd d4wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oSXPxOqk; 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=fail (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 j11si1832193ejk.10.2020.09.25.06.01.06; Fri, 25 Sep 2020 06:01:30 -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=@kernel.org header.s=default header.b=oSXPxOqk; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729435AbgIYM45 (ORCPT + 99 others); Fri, 25 Sep 2020 08:56:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:55336 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729177AbgIYMvN (ORCPT ); Fri, 25 Sep 2020 08:51:13 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C44382072E; Fri, 25 Sep 2020 12:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601038272; bh=SFKx5C2EQJ7V9toW7OanK7PJteM0Y4ByohNIwnS2J+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oSXPxOqk1iE94EX8bTq35EE0HasToNz/yT+BKBAJ6ZGy+/G3vGY6cH+SMn6oNUdzD SIh9l+K7gm1DxEIKsxkNsnGFPUaHH/JizcJukDpfVgd2d6DQbxUAcnjOf8/yLNvlkO 8sh+QW3w7JbIFdchhp5WfdFqumknFJ2AJ1Rbu/h8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Salyzyn , netdev@vger.kernel.org, kernel-team@android.com, Steffen Klassert , Herbert Xu , "David S. Miller" , Jakub Kicinski Subject: [PATCH 5.4 01/43] af_key: pfkey_dump needs parameter validation Date: Fri, 25 Sep 2020 14:48:13 +0200 Message-Id: <20200925124723.752097958@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200925124723.575329814@linuxfoundation.org> References: <20200925124723.575329814@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore 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: Mark Salyzyn commit 37bd22420f856fcd976989f1d4f1f7ad28e1fcac upstream. In pfkey_dump() dplen and splen can both be specified to access the xfrm_address_t structure out of bounds in__xfrm_state_filter_match() when it calls addr_match() with the indexes. Return EINVAL if either are out of range. Signed-off-by: Mark Salyzyn Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: kernel-team@android.com Cc: Steffen Klassert Cc: Herbert Xu Cc: "David S. Miller" Cc: Jakub Kicinski Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Steffen Klassert Signed-off-by: Greg Kroah-Hartman --- net/key/af_key.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -1849,6 +1849,13 @@ static int pfkey_dump(struct sock *sk, s 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 >= + (sizeof(xfrm_address_t) << 3)) || + (xfilter->sadb_x_filter_dplen >= + (sizeof(xfrm_address_t) << 3))) { + mutex_unlock(&pfk->dump_lock); + return -EINVAL; + } filter = kmalloc(sizeof(*filter), GFP_KERNEL); if (filter == NULL) { mutex_unlock(&pfk->dump_lock);