Received: by 10.223.185.116 with SMTP id b49csp1140971wrg; Fri, 23 Feb 2018 12:39:50 -0800 (PST) X-Google-Smtp-Source: AH8x226i9Z+82FOvXA6oT9869zaIzLX45qEYNB7yOCXaCZw/sWGxFfJRrDBLz3VsVJVgVvFqxwnx X-Received: by 10.98.14.200 with SMTP id 69mr2914992pfo.168.1519418390696; Fri, 23 Feb 2018 12:39:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519418390; cv=none; d=google.com; s=arc-20160816; b=YQ4re9mBrCraEKTrfIBtBWjkOiKDD3gsraGdFEIRmIHsqP9S3RLgDtTkKdb0PHafvD rpMPnrNQiXh94jv492AO9D6vgFQuYDxgrTQSw6nGJSuIhZZKQi73SrqCkLmSUH9TjDck 0OU0bk5582ISuWOVW4UtpHhSugB1T4xmgN9+w2n6A0u9aYx7nQBEEmpwuSgnhvdpiHtX r08Io7qxCNto4Y+gddf4eLK+2F692uJn9XCJrbG+pjLDbP9px4xfaOSx+Y+LpfMTdRTt HH2FugK47UtqrlOE0Y6Gy3lYfRcZSMMhb3Eo8Dd8QjCn9p/Xo6KzE8Hplr3H0diP8tAc Cezw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=OJE5esd8rPvcwEwAX/xuIi4gftqcmm2TCJxuxNazbuQ=; b=rKjHG5bAlYWuzWv30wvuK3aqBTxukyCtDO0oMcnPly4VS5+M4YM8LCAvVjjyflHXKH tctk5/2ZOAs0XF21QIBzUCcbFz3GEOhXmYzcTVcu9Ibp7fwE8J2cgIKj2WOdGoUgKMT1 xajpPDnavXvUnPXHqP0WhDW+GVQXETSD1Gq7PhwOdiyjIHXJn8lPU6iHCUY5DBl9hGHJ G59jANBDI4+de9r/DY82m9g1ZRn6iMvZdh3KGot+hsa4wEjuOsdzF2A1wysJKrF+LsQD ikSk4UJXjhMaScjrzCW0ZGh9klzCJNbhVD98oGB+Z2B+CMrm1ZvNqIqLtDCSwKkk2olz /3dg== 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 a6-v6si1124897plm.489.2018.02.23.12.39.36; Fri, 23 Feb 2018 12:39:50 -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 S1753507AbeBWSeQ (ORCPT + 99 others); Fri, 23 Feb 2018 13:34:16 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36836 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753482AbeBWSeO (ORCPT ); Fri, 23 Feb 2018 13:34:14 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3BAD8121B; Fri, 23 Feb 2018 18:34:14 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Steffen Klassert , Herbert Xu , Cong Wang Subject: [PATCH 4.4 006/193] xfrm: check id proto in validate_tmpl() Date: Fri, 23 Feb 2018 19:23:59 +0100 Message-Id: <20180223170327.047820034@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170325.997716448@linuxfoundation.org> References: <20180223170325.997716448@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cong Wang commit 6a53b7593233ab9e4f96873ebacc0f653a55c3e1 upstream. syzbot reported a kernel warning in xfrm_state_fini(), which indicates that we have entries left in the list net->xfrm.state_all whose proto is zero. And xfrm_id_proto_match() doesn't consider them as a match with IPSEC_PROTO_ANY in this case. Proto with value 0 is probably not a valid value, at least verify_newsa_info() doesn't consider it valid either. This patch fixes it by checking the proto value in validate_tmpl() and rejecting invalid ones, like what iproute2 does in xfrm_xfrmproto_getbyname(). Reported-by: syzbot Cc: Steffen Klassert Cc: Herbert Xu Signed-off-by: Cong Wang Signed-off-by: Steffen Klassert Signed-off-by: Greg Kroah-Hartman --- net/xfrm/xfrm_user.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -1402,6 +1402,21 @@ static int validate_tmpl(int nr, struct default: return -EINVAL; } + + switch (ut[i].id.proto) { + case IPPROTO_AH: + case IPPROTO_ESP: + case IPPROTO_COMP: +#if IS_ENABLED(CONFIG_IPV6) + case IPPROTO_ROUTING: + case IPPROTO_DSTOPTS: +#endif + case IPSEC_PROTO_ANY: + break; + default: + return -EINVAL; + } + } return 0;