Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2269336pxb; Mon, 11 Jan 2021 05:39:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPh6OLWRO2ZXzuh1CbiZRtvKnXcKrzPMSJOXh6vdk1h6CPEjoYm3AtRmHw8iWz5F5nXGyb X-Received: by 2002:a17:906:1719:: with SMTP id c25mr11214828eje.251.1610372347407; Mon, 11 Jan 2021 05:39:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610372347; cv=none; d=google.com; s=arc-20160816; b=zFcDXzPyyonVDATCmiaPq6BUoIb0Wbap4LhuT+7mNmmoupvsaALd/rKWKkxD1AeRtW XsDtkeKfgTNeeqLpBpuJN8481xwKzJSrD7FEAcEcVj2rqeGsAYo9ZaqKSMzIlvHUmZDx +VgnEmKltUPqATNlMjK+bkz12cE8um3dO+Yoea1WkYvLRFQKMGrBHC5oAnif6SzDMf+F 3k4jVfzv1n9cqJf/dzaFL5xss+0wa7phDvCqcP2JgcKK1jzRBx/T8oC5yYtoaMNfHUdF 82YiDEBggsLAMszOI++mppG2mhVETIW1us58ManHcBWCSgSTLCvnyG98hW9f05+2fD1U njvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZSOldiHvwPoF7jQoomAjp8FdrHnJMm0HqXisCXsrmYA=; b=g8fDo7uEb/yqrTjcfwu1lYrOS/Uc2yNhxrZmZN5H611vs32Cc/rbD3wtsYiIFwyofx qszGnJWdd2BT+FU/mfqvkvCdLS7b2ypmHD0iGE1VG6O/Y2unWF0T+aFEcZyiOBX2LczB v6ns6vyyxHrX15sZ01lAnefRzPjyUiO+KSTrdbgdxiYKU5S3OaJJrJRoo0oldMJvf+5M nLMhkcb8Imiab9E5hLcgU6caZfpsj0SSh9BB5gh5OlO0KkJeHmHIVv01lSub9K1nN2lH g6YM5jpbF0RrWBiaTkNcOh9OB51GfBsUYQVQ1h4sr/Co6w0xMK4UNwXGtvbXM/1Fn+UB SCcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tKKF31Wi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si6903325eds.390.2021.01.11.05.38.43; Mon, 11 Jan 2021 05:39:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tKKF31Wi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731976AbhAKNNn (ORCPT + 99 others); Mon, 11 Jan 2021 08:13:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:60468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731919AbhAKNNd (ORCPT ); Mon, 11 Jan 2021 08:13:33 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id CBB9A2253A; Mon, 11 Jan 2021 13:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370772; bh=38g0OaW0S0xlW9lL1byQD9zjXHWS9D4jvgtVRmqoqac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tKKF31Wiyqfs/ZIkBEr6rx2kIj749V6S6sSk0oiW3PMLZRJ34wrt4cB7JYaH3kwCr k78fCo6dpo935+ytcDVKPOIRDXOCOw2AZF35dt5Dmpi2DjqIcbCPlutLSwAVKvy4Zf Stg71KOcPJzj8fTAntZV3iXwqU1JkESSpVhXFwnI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+e86f7c428c8c50db65b4@syzkaller.appspotmail.com, Florian Westphal , Pablo Neira Ayuso Subject: [PATCH 5.4 89/92] netfilter: xt_RATEEST: reject non-null terminated string from userspace Date: Mon, 11 Jan 2021 14:02:33 +0100 Message-Id: <20210111130043.447563580@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130039.165470698@linuxfoundation.org> References: <20210111130039.165470698@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Westphal commit 6cb56218ad9e580e519dcd23bfb3db08d8692e5a upstream. syzbot reports: detected buffer overflow in strlen [..] Call Trace: strlen include/linux/string.h:325 [inline] strlcpy include/linux/string.h:348 [inline] xt_rateest_tg_checkentry+0x2a5/0x6b0 net/netfilter/xt_RATEEST.c:143 strlcpy assumes src is a c-string. Check info->name before its used. Reported-by: syzbot+e86f7c428c8c50db65b4@syzkaller.appspotmail.com Fixes: 5859034d7eb8793 ("[NETFILTER]: x_tables: add RATEEST target") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/xt_RATEEST.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/netfilter/xt_RATEEST.c +++ b/net/netfilter/xt_RATEEST.c @@ -115,6 +115,9 @@ static int xt_rateest_tg_checkentry(cons } cfg; int ret; + if (strnlen(info->name, sizeof(est->name)) >= sizeof(est->name)) + return -ENAMETOOLONG; + net_get_random_once(&jhash_rnd, sizeof(jhash_rnd)); mutex_lock(&xn->hash_lock);