Received: by 10.223.185.116 with SMTP id b49csp1058199wrg; Fri, 23 Feb 2018 11:08:40 -0800 (PST) X-Google-Smtp-Source: AH8x227zkchAgEOVEfeWOa0V62lnfgIghOkaWDYSIrCZP/6M5+w++EjwoJYJdBS0y8eaV748RIVP X-Received: by 2002:a17:902:c1:: with SMTP id a59-v6mr2564260pla.284.1519412920664; Fri, 23 Feb 2018 11:08:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519412920; cv=none; d=google.com; s=arc-20160816; b=yZnDB4QQ5dCO3sxSPxQzBeJ96F6Lz/b8GadftcMwGPYTxsO6sWZ7OghlSKpspSEmb9 bzcOXdoocRXlRGOfP84juoIPP6YnAe2FnVnGf6ODpRp50VJfFCOYu+YZTu5WxHtcp66Y u/BkeTibQUAkh3hY/MGa+5fooCkjo01ZaCgw+K5f0KxexcnChhw+71tBZ54r2vMiPHic sPuYBj8T/u2MN/WBH3auuIUEPL5BnDS4+wsFrmnZlxHKYtFJlYoVbDqtmQ1/TdivhZGp ondE+zxQ+g8pwlztbWlVPGjm6mjxM00D4FtA1XgeBmqEwPQQFT5fSDulNVOzg98wgCfr LEUQ== 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=gj8ov2eCxDHkZimj6p2+Q0h4ARE7MW/wcrJyHG0vqeI=; b=I2CDySYdnzQVv3B9VyuDDZGsS4EKeexpZSvIiLZgd3oMN49WU1zRdSop0UcWh71SEi OG4hur7x18sx5NebBdgBSTeQa8gtWYJj75amug1tDJ9+/1lY9eBS26ocnstRJCe4HJ5g 5+wuobrAH5yzSRiAKEInMO4Y9LTyrQ3ypII2vdM3E7dSp1vMHYF2Z4MZ/+I5nO6OwPaY OejbKyAifyTsz7PTepj7YiXSQDbik4WqTbQbAYwzJsBz0KuplZB6n0WccaF7nVDI4lWh W21BakWaG79W1QbQCW6yyJfmbHEBVwK+hwzg4IhHA0J3Cc5aRMrrR+YPVoJ7M/sRQv// hXgA== 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 q4-v6si2163550plr.39.2018.02.23.11.08.26; Fri, 23 Feb 2018 11:08:40 -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 S965389AbeBWS51 (ORCPT + 99 others); Fri, 23 Feb 2018 13:57:27 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50166 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965312AbeBWS5V (ORCPT ); Fri, 23 Feb 2018 13:57:21 -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 45CFDC40; Fri, 23 Feb 2018 18:57:20 +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.15 14/45] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_{match|target} Date: Fri, 23 Feb 2018 19:28:53 +0100 Message-Id: <20180223170717.611089900@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170715.197760019@linuxfoundation.org> References: <20180223170715.197760019@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.15-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 @@ -209,6 +209,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); @@ -251,6 +254,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);