Received: by 10.223.185.116 with SMTP id b49csp1074524wrg; Fri, 23 Feb 2018 11:27:29 -0800 (PST) X-Google-Smtp-Source: AH8x224vdAfslLPX8nh/uM23GZwkHbKxES6IRSMOyqjdu3eZ/HYU5dRAKK75xyHVBAWjSzkF1JoQ X-Received: by 2002:a17:902:67cf:: with SMTP id g15-v6mr2691856pln.106.1519414049025; Fri, 23 Feb 2018 11:27:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519414048; cv=none; d=google.com; s=arc-20160816; b=vhGyxVDN0IyNqqvjNDw4pULxsFYQ5ZkSciYN1x2MVoRWETvRiIRb2g5EmReiRik28Q gwq/8WyEUmEnjbhkTctSxRuXIb6dLMDfl2Xj9YhSUOM4duhHnIx4Y8cJLQDq5QWtewcc flZM0LqMh/G4CLJlkwIkggHl67Mv1mhTKC5Efu7iWJuErjMy//lFKiZ8/uasDaCGh4Ic WY+yxk2nQ6yHNGJdky14HoueaG1js6dRrmUm7PoS2dHz/WzCjtY7sJUQ6aL2HNENK9cA jBATZokYSxj5bFwTYpHLg8GUsy/e1RyyNgNQZ2gETdtSrNcp5cD4RbG7l5JKkf4YZxTD 3sUw== 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=j2NJ7himbOYA3GAH0Ryt2GvQMx84r5sMZ0UajXhX/b8=; b=bE/nhylZmY29JOYSmzxDsz6+OeXTLaa7hmiGOfs0V/tUv4Fd6p/5cj4U+oTB9lzOrY 51rz8fjF1UPvwkTPejDYr/ovpmICbnk+q3dBMr30i9BHteWj9PYiDvGYcmwC3gGcfI1e ocQSV1i1nHnl20LIq1dcmMRhP0jAlXgdgCLBUpmb6s5TxteRMDE/LEI77FDOH3WHwEJd VDO3XGrsyQiU//mQr/fHT/gsE9KA25f9/pG9mXaUNm9eEFMzBiREdtTT2BeGttNbkdM1 2C6FzbxWGVOZXN4sNwew1luhmx4KZhw7W6mTULWGWZqyanJq2GL7/9vOmMP3KaJfcfJ3 CVbQ== 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 1-v6si449935plk.52.2018.02.23.11.27.14; Fri, 23 Feb 2018 11:27:28 -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 S935161AbeBWSwe (ORCPT + 99 others); Fri, 23 Feb 2018 13:52:34 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:46970 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935132AbeBWSwc (ORCPT ); Fri, 23 Feb 2018 13:52:32 -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 A39CFF82; Fri, 23 Feb 2018 18:52:31 +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.14 036/159] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_{match|target} Date: Fri, 23 Feb 2018 19:25:44 +0100 Message-Id: <20180223170747.841183223@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: 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);