Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3047958imb; Mon, 4 Mar 2019 22:50:41 -0800 (PST) X-Google-Smtp-Source: APXvYqyp9a5ihNOQz7LgvFv8JIG9XM9lK0hFYW+JyuSZBwfNZMXQDj4dePp5fYajZcrrvdYkf3YO X-Received: by 2002:a65:628f:: with SMTP id f15mr97819pgv.410.1551768641434; Mon, 04 Mar 2019 22:50:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551768641; cv=none; d=google.com; s=arc-20160816; b=MCeKn0WoK9RbuKZllEwPfc7tSENBNE942Qdhg3sS6CUI3uFKOa1O/E7lBF6VRp+p6J ITX9UbfyhEUbtr74lJuUxpKdkOKD+ccyu4HUW2jwZ0gIwyWfhc2F0rk5xhGHVTI3QRSv fcGMoOHZJKmIuk35HmQ/KHYMcMniiqH176uHasj7TYxU9Ltz6hKkzSnp/mhm5XMbV/jx ihaoThkfO+jtdxSZ8FnbYFkI0Mm3MIXGkzZNgCT4dvKe+rOhIwaRvHhgvPlml/kd1cDA GMVB9DKCBjGfr145GbyHe+SHo7OEh4odHz4RMHro3j1lN0Jg+qwPEnxvsRAR1TBTrF9J 9Nrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=hZuFDZo+fbxP1n3Lh+r4cB7gcH6xFzEO65ymU5OLk1s=; b=Pry84+frb7eGwSnjKPIeOzpM40q3z9cAvdPzEqtKtKFji5RwEsWPqIPofFbTwNjrrm IpA7la2HFcH454EB+TYOxRdVXcdTICx+ORS4KB292v+KIbmdn4ZAj7JH0Sw5WMBFT4mK 8jpV7sg/rAsfThHbDFVh+axz+jf8fYQefyGkVAS3jsrCxdSMAHOPIFrSci2AYda7KYVY Cz3I+tudYc/YtRYPOXsNn96Ir6QWeCvLGkxJz1DX8rZrsoMFQVrb7/Lpv04KYDztRJ3F dA8+Z2THrsjqd2W4nffm3qOMvbP1eWFXt7b+nYXrt73tmiE8P53yu+ndYnxJheg09bC8 HgiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z13si6781143pgp.34.2019.03.04.22.50.25; Mon, 04 Mar 2019 22:50:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726329AbfCEGta (ORCPT + 99 others); Tue, 5 Mar 2019 01:49:30 -0500 Received: from orcrist.hmeau.com ([104.223.48.154]:40662 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbfCEGta (ORCPT ); Tue, 5 Mar 2019 01:49:30 -0500 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1h13tC-00038m-QR; Tue, 05 Mar 2019 14:49:22 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1h13tA-0000Vy-Mt; Tue, 05 Mar 2019 14:49:20 +0800 Date: Tue, 5 Mar 2019 14:49:20 +0800 From: Herbert Xu To: Su Yanjun Cc: steffen.klassert@secunet.com, davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: xfrm: Fix potential oops in xfrm_user_rcv_msg and array out of bounds Message-ID: <20190305064920.gcpwvkp7yikq33cy@gondor.apana.org.au> References: <1551671259-21311-1-git-send-email-suyj.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1551671259-21311-1-git-send-email-suyj.fnst@cn.fujitsu.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 03, 2019 at 10:47:39PM -0500, Su Yanjun wrote: > When i review xfrm_user.c code, i found some potentical bug in it. > > In xfrm_user_rcvmsg if type parameter from user space is set to > XFRM_MSG_MAX or XFRM_MSG_NEWSADINFO or XFRM_MSG_NEWSPDINFO. It will cause > xfrm_user_rcv_msg referring to null entry in xfrm_dispatch array. > > Signed-off-by: Su Yanjun > --- > net/xfrm/xfrm_user.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c > index a131f9f..d832783 100644 > --- a/net/xfrm/xfrm_user.c > +++ b/net/xfrm/xfrm_user.c > @@ -2630,11 +2630,13 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, > return -EOPNOTSUPP; > > type = nlh->nlmsg_type; > - if (type > XFRM_MSG_MAX) > + if (type >= XFRM_MSG_MAX) > return -EINVAL; Your patch is wrong. Please check the definition of XFRM_MSG_MAX. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt