Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1083949pxk; Fri, 25 Sep 2020 05:58:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwJ/kfPCTxMyUnqzxwpisy3HUUGR3AT54OEtQOZRLIuwvSXB7z4elImj8uYtCfaUZ5G/2Y X-Received: by 2002:a17:906:c55:: with SMTP id t21mr2683464ejf.276.1601038696147; Fri, 25 Sep 2020 05:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601038696; cv=none; d=google.com; s=arc-20160816; b=MdFPFmOH5/XfIz+mQcz7HHzP2ek55CjTj4zkPDXuuz0fXGQsUcE+BV6sEbzcsCATd2 NRetMUVvnoVw7hJFn3ImvlGqDWP0jjCbm6S8agWR/CIZjqpbsjD5G3LPHTC+7ba0WhQr 4miZRRzwCn81Ra7HkX8RXnLRFtFAsmQEOV5L37j266iwkkQ+IMkKFD9gzZ2SsXzVRkLL oShfk1/GxRQ7NSJfu8jrzw6g8gqsZ1ttZh6MS9hcyAzg5tV+RarLZm5xzwP47JJhZZps XV9nfXhpVcyF0FVrENGK86m00h1Es7W16EySOAMcHjggwDgFjEOh79Mde6Y98M59ETwZ hG6w== 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=1AhAIBZjt6D0/hmfQ7vw+8cOppXRi02YWsabdOscA1o=; b=Z+KMK1+rFSuLjxJGpP1riR/HsgIEkG7GKiK/4YC4vwLRTX6Dj74zIDK2rxFQILtSYo Zv8amyUzhT5XjgF+5yGYAhe9qXA5ImQbHo+NXlPn/+XNFj9yeDOZXZJsiTM8mXdBRebg dRlaefugSOvzotOIdS96reegkBkRVEhFLDGpDRlUW3jMl7FCSbTbdoIAoVrmZL4GE1ww Sp78gBlEquzCyKf6yQPpg/ZIglwoD/HPiZ/nkxp3VtmjxvirIa8PaQzoUjPLSysQ/SEE gv5gvBW/r8tK0A8cRtCT/xN9TpctyFA8UXqG/uqsOXTH0P3WXBsXiCsgCYC+9S71r6yM FDCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s7U3B6GE; 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 oq13si1762361ejb.308.2020.09.25.05.57.52; Fri, 25 Sep 2020 05:58:16 -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=s7U3B6GE; 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 S1729455AbgIYMxh (ORCPT + 99 others); Fri, 25 Sep 2020 08:53:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:59234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729074AbgIYMxg (ORCPT ); Fri, 25 Sep 2020 08:53:36 -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 80BFA2072E; Fri, 25 Sep 2020 12:53:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601038414; bh=M+RP/klM8mJ/hXyQDk2kbS5oj9shWR1CNkMe/84/Klk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s7U3B6GETcg56nzY1mgy1BZwKsJtKVTdPFkmaNRwlZJCi/23YxyDifHdawJGdsjDK mgGZ4us3KVci9me03QvSavdboJrzLxmEhxFCRkb5FVys+pvWzmfRLUz7t0eHmKo0Ax W70X5eRQFoo5p7eaCtuIcDky+Fc23IKjVp1X0RnA= 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 4.19 01/37] af_key: pfkey_dump needs parameter validation Date: Fri, 25 Sep 2020 14:48:29 +0200 Message-Id: <20200925124721.158581982@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200925124720.972208530@linuxfoundation.org> References: <20200925124720.972208530@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 @@ -1855,6 +1855,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);