Received: by 10.223.185.116 with SMTP id b49csp1085836wrg; Fri, 23 Feb 2018 11:40:21 -0800 (PST) X-Google-Smtp-Source: AH8x224pJ/e3uQLHWxtZYbNULyxFsxZ9xcCc9tCLMDD9d7UQ18nY3isqe+pfxfR2N+zjA+6SyrJ6 X-Received: by 10.99.97.9 with SMTP id v9mr2206190pgb.373.1519414821587; Fri, 23 Feb 2018 11:40:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519414821; cv=none; d=google.com; s=arc-20160816; b=szsxXaCMo06rim95oi8rQb6SchRDikDh4Ssczy7A8yPd5tVgrk/dp7TwN2u3UIv+h1 /zrTngTjwDj0dQSPQLTS9mPDFi31MyRl862gkrtVSdCCrFnYPjPtFU7TwvczE9yweEsW GqDXcJEH6G65MQPYyfezvqSl0wbpRbYGqCVwGj4OM22G4tY+V3lJgqrse4YKvVFdRaNI WyBPgk8+2g+f6aKJRTDECZ+A4s+Bh36UIUw0eF2uBstm+IpdXL12liI9MoWAalJuB1Dn Mw7Ao0RXE2vAQq6l9T3/lT6Aqf6MZaoL/SpoNzss/A51jroeZ+I0r86hgci24WQ6tC9D NPRA== 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=09SgDvyQM+RgHoGaHtvgY9LCkXl8jC+/t9pDOwvay0E=; b=wBB8wvAF1wFly/JkkLA1H/l5e2nbnzTE1kwriWDPSUiqFylO3LwT2E5X0u6F1s0R9b T0Kw2AG3oMZBXcAZWAF1GLTtVtot0OxMBmLx1Cngko055iFh86bK6yz1lRkzZbTtVPwY m745H3J0SKu3IFZKHuX1K3BxvXHYWvm1FnfdaFbqKzCPEo2pw/bwfHQ5ctOtxxS+TtLR QO78xunwZGAthRVaKyCJNrKKrBEdZLeqRquI0S5X0xG3QMa37UvwbiEiT54IXF3JhNzI IRgVTYiMcrVRKAG1ZD5dRfJomW+mgkEoJuZqifQN0JXVXZx5tsl9LNfazc+4sI59aeNo m9Ng== 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 q26si1706216pfh.129.2018.02.23.11.40.06; Fri, 23 Feb 2018 11:40:21 -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 S934581AbeBWStn (ORCPT + 99 others); Fri, 23 Feb 2018 13:49:43 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:45392 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934016AbeBWStl (ORCPT ); Fri, 23 Feb 2018 13:49:41 -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 4FE0A118E; Fri, 23 Feb 2018 18:49:40 +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.14 016/159] xfrm: check id proto in validate_tmpl() Date: Fri, 23 Feb 2018 19:25:24 +0100 Message-Id: <20180223170745.212745353@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170743.086611315@linuxfoundation.org> References: <20180223170743.086611315@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.14-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 @@ -1443,6 +1443,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;