Received: by 10.223.185.116 with SMTP id b49csp1107606wrg; Fri, 23 Feb 2018 12:04:13 -0800 (PST) X-Google-Smtp-Source: AH8x227FI8JI27+IRaWXGoOLec6Arvo2+u404Zr+fexOeMiq9Inm6Qnady2hdkkNzgACFaKMJd4+ X-Received: by 10.98.149.90 with SMTP id p87mr2848347pfd.28.1519416253857; Fri, 23 Feb 2018 12:04:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519416253; cv=none; d=google.com; s=arc-20160816; b=Qc3gVwe9ewlh63tDjeBtgMo5psoJGv4TKW4XjbKY6d7PnMaZgHJDpqWU/IlwyZMYRh pPDX+ivZXDUYxbFjkhN0pko45kZHFtYVT8jp+j0K9p2yrgihyuzHSKzCUFGgiIhm5PNh ZlLENZLc7mCAy6P/VaigN72ZZv/XRSJKrD6Rk7TEQupNlTgbz7wpk91vZmyPIMpwCu/6 K2p8qdJkq4OFXmpWXcg+bENgvXtiCqRHMp+SzMHR+ScTT5kTXgmJxc7EavltcJWNhfyk tENZOhUdt11+uSdvYZwE1Cm4XT/ICFNggYMjM6RlzAxsulLvtOA0I52cZO44LYtG8qak L22g== 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=Tf5u0HRxyhIWEdjiFvyO5qe6JcViBeitrsqNZuM9GU4=; b=WVhB1KPV3BliKMke3vlT0O0aEqtCUYOwCbQtrmxeSTO/nvpp/GexbDnXggph06FXaP xs/7mGlefjjERNs7zuVyxMUNjxbIp4haET/+KWNI0b2bx3/VsgKlIOnMYsA2oZzbSZn5 A7e4z6J7SyUU/wFXf2Op8/hdCa9mACY0Ds2twty+P4m1J1Oj5Sv6TqWzEvsIJsuchloT +9SM5r1AGfu7dFi7ZjfyUEr+ZQvH04r8w5rD5NVngk2GZTaAjBmo1Zbxq4HNHKvZAPj2 kGWxmZ7ySoJVg4+v4xd4ZdlLQJjuIY6xvmqKtCnyTDeqReNPYBBluQ2zH5fsek7TuJaa cMAQ== 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 i11si1862217pgq.332.2018.02.23.12.03.57; Fri, 23 Feb 2018 12:04:13 -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 S933216AbeBWSnJ (ORCPT + 99 others); Fri, 23 Feb 2018 13:43:09 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:42024 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933180AbeBWSnA (ORCPT ); Fri, 23 Feb 2018 13:43:00 -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 C64DF104C; Fri, 23 Feb 2018 18:42:59 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , Florian Westphal , Pablo Neira Ayuso Subject: [PATCH 4.9 023/145] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_{match|target} Date: Fri, 23 Feb 2018 19:25:29 +0100 Message-Id: <20180223170727.690362562@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: Eric Dumazet commit da17c73b6eb74aad3c3c0654394635675b623b3e upstream. It looks like syzbot found its way into netfilter territory. Issue here is that @name comes from user space and might not be null terminated. Out-of-bound reads happen, KASAN is not happy. v2 added similar fix for xt_request_find_target(), as Florian advised. Signed-off-by: Eric Dumazet Reported-by: syzbot Acked-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/x_tables.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -207,6 +207,9 @@ xt_request_find_match(uint8_t nfproto, c { struct xt_match *match; + if (strnlen(name, XT_EXTENSION_MAXNAMELEN) == XT_EXTENSION_MAXNAMELEN) + return ERR_PTR(-EINVAL); + match = xt_find_match(nfproto, name, revision); if (IS_ERR(match)) { request_module("%st_%s", xt_prefix[nfproto], name); @@ -249,6 +252,9 @@ struct xt_target *xt_request_find_target { struct xt_target *target; + if (strnlen(name, XT_EXTENSION_MAXNAMELEN) == XT_EXTENSION_MAXNAMELEN) + return ERR_PTR(-EINVAL); + target = xt_find_target(af, name, revision); if (IS_ERR(target)) { request_module("%st_%s", xt_prefix[af], name);