Received: by 10.223.185.116 with SMTP id b49csp1144234wrg; Fri, 23 Feb 2018 12:44:01 -0800 (PST) X-Google-Smtp-Source: AH8x226AWpRkQhk/YbmCEYoHxpTONhMIEtTIGV2kgVpkK4ozae/8iF/J42wsUDZKQ+OKOBI+9hG9 X-Received: by 10.99.97.86 with SMTP id v83mr2353934pgb.138.1519418641228; Fri, 23 Feb 2018 12:44:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519418641; cv=none; d=google.com; s=arc-20160816; b=qowO746s+sJ+G2lth9qKnSLasgkfZBv/RxDYXfDunqOK8Y7VR46/pzYnVSxTutdPvH D8lHAf2SfmSdjFM3LCWH4qA+Jr8nK3xxg/6M7lAEKRxqIfU9IjMZbW8OtHEV5T4mr8xc uJio83j3uQEMiFjtntztiv45QRHcfR/KqeKKK5SalQGghnjYlDcwhTQtIAuXhFvrsriA kDp0hy2IlgpKoM08yP7WE7ZBACR5MBbjsPp5Vi3xZTXYjrB8Bo0PZNRzLt+rbJOaoa4F GwsBlhrM/WEsDGspddzp6Mvti8EW5i1qpOzJ27WcY4QV9Cu3u4Sn4lGR88dPsUPzc9tg 1KKA== 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=EC/AQ3pwxtCBvbGUxxr1jCi3B+iN7oZgR7MOtgrM9j0=; b=p6A1K0ei60Ssz2UmIwFQHAkAqQ7dgWiT4plRdVDVj6qeyw8zHMPgQRuX+fIAwbmqYh 5OZH25bxPyG9XM6IbIHiJPkspD9whQdwYJ20Qd0pagYPgcPJaLITW/bOWyXrJXQtZD5B ZdpLCBFslSMP+H6Wehkg7FAUajAG8KDaoqJj2AsE7I4Q21pJeUe/jzyYwH7JftMq4Df2 MEPfnDXYEr66Si9ZdtLblQoMXdHdawIwxex7O4SXa3jZI3gFqo3GbpcyakXUysK1hYr9 aV7ChTPAOaW8QnyqI2mT58W/kWAzhJtrcyXEox1+h9F8YasS+mVRJm6rnfWq+5MokNrk 6n1A== 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 s13-v6si1954102plp.675.2018.02.23.12.43.46; Fri, 23 Feb 2018 12:44:01 -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 S1753143AbeBWSdM (ORCPT + 99 others); Fri, 23 Feb 2018 13:33:12 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36450 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753102AbeBWSdK (ORCPT ); Fri, 23 Feb 2018 13:33:10 -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 17F8B1070; Fri, 23 Feb 2018 18:33:09 +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.4 016/193] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_{match|target} Date: Fri, 23 Feb 2018 19:24:09 +0100 Message-Id: <20180223170328.642062300@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: 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 @@ -206,6 +206,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); @@ -248,6 +251,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);