Received: by 10.223.185.116 with SMTP id b49csp1036069wrg; Fri, 23 Feb 2018 10:45:04 -0800 (PST) X-Google-Smtp-Source: AH8x2242Wuzem4KIPp/h/1La4rAYf9WviiWMjwUjLIuNEzYSLfWir0r+mWIfiguZiVPN0EIWanrL X-Received: by 10.98.135.76 with SMTP id i73mr2682319pfe.140.1519411504558; Fri, 23 Feb 2018 10:45:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519411504; cv=none; d=google.com; s=arc-20160816; b=xBHkqJQS7lAYAzUXV6UAQl3OnA7via3QmPQhMpJ66PoVrKym7CjN5GF/jiQehUCbT0 RmK5rexzZLA7QUIhEsmTJWRjoCIZn899FZZt2GCUdvS1kjhIerRoM8N+4vMejlDY0ZL4 SkxJjX2WVx4xdBp/HXNICNDYwCpoFo0S0xxFXwSCAtedKeijvcCMzXWh3T59gv2/BFiG 3ZrTObK7h29/4mQXGA/wS8y9Fdxn4stEtCvEtqcUEA13Eg6aGr7EZpWPdSKPO9/CjMbh U81EGV4hjg4CXfSDYCTEnRb999qhZep1tlIgNhXmKyqNKHX/A+42tkfpwJcLYZtjVonF R1xA== 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=OfRbAnkftnQREWtkjMI8ac5UtrOwQejxA9sgIPl1WxM=; b=OLo4pm65Zgm8m6yJ1wBfVZuzHQMAjYFd4XT5ddhaU0kii3HE7ueItzUS8WYOR3rBfg gBWtxYX3bS19GmyLpUH15zSdknelxth/D9vkAjklVFx5Jw2r0P8FDMBqb9FZJP528tLL NWjC2HybuTfC/5JcaR+CC+vryp3psNswRjG5p9dYFFKZhtrB4+hm6JuZJBlp9/TZS7IE JFiEjoFpojkNZV4Swq3qfJApP3KaK3b4VMcXmPFyskP8QOHEbEsGFnphwCQAvIARAh81 q2QlcR7dNx6STtBZKYKqUnyYc53U64cUfdgvD/XiUOSpJJ5XUFtb2FPPBsWtnegnjtv0 lgbA== 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 63-v6si2149429pla.526.2018.02.23.10.44.50; Fri, 23 Feb 2018 10:45:04 -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 S933498AbeBWSoH (ORCPT + 99 others); Fri, 23 Feb 2018 13:44:07 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:42430 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932663AbeBWSoE (ORCPT ); Fri, 23 Feb 2018 13:44:04 -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 0A602121B; Fri, 23 Feb 2018 18:44:03 +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.9 008/145] xfrm: check id proto in validate_tmpl() Date: Fri, 23 Feb 2018 19:25:14 +0100 Message-Id: <20180223170725.820280249@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@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.9-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 @@ -1406,6 +1406,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;