Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3081886pxj; Mon, 17 May 2021 17:18:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzn10BZwys5P8V0kxsO63jJFqKIs1/0b68XshMdUFXnhFXGbQXEQFVU19/fyyLpxr9ezb/c X-Received: by 2002:a17:906:f283:: with SMTP id gu3mr2823735ejb.91.1621297099410; Mon, 17 May 2021 17:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621297099; cv=none; d=google.com; s=arc-20160816; b=cd74hO3K10fPFx6br0HENIcezFperKzTpsV/rh1b6by5dh8iP9pI9m8WJpHIxtcyt2 Vl7jl2R/K/7bjpTzBMUKXcUPz3Bc8rfpfDEZNHi7KwPMW3O9EVhtCRlbF6m7seBYsgsu viFc4iVmUN2q0Hu+qivHg8QoD8TrboWKB3/+TCaVoq6q3Ef8tXyIXftfFa9x01G6nAaX Se/4tRXwbl7pD5G2ZmWk+QTN/1vza5Hf5h4JSxRbgLRpnD849729aljqPPChXDpiPx7i BDCQjcFYJ9wQi9HflOSDpkwqwofU4+LEdebov+rocxINw7dBGI8Mw+afag/ZTnlFR+Rs 4voQ== 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=11y9vcv3QpCeRA2PXzO35+4eHLf1qWPUdDB0zpQxSAs=; b=LVB0qQ9T8TdCqF6kwcuZvuI6KHLEP0+BNkyoo3S5+ndeDUV9/LIEV0w7WY2dOLE5nI exsS5vYvMkr0snMY+whxV0GkY5TwJeI59KPxwscw5m76DqTMDeMoRZd8bloVwMRQPHnU zybnQlHvhQeUYQsLEdC3GBHpNRlfr36yqj5HHhMek6UWxf5uPoe+mJCVb+qMk6gBsDTi DzN7h5n6EiZzm5sb1/QvzGK8sjz64Rl6jUDMEWE1WEtA0AsU0+i3eVnpPQyf/8+7dy4X 8rMIUrGof7mWbNJd4qWsQM0RF83uZRBT+v0U/ftiuzZf5AJGMPrsrIByErZ2ZriF0reJ XpDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=einl4GjX; 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 v9si6440606ejg.627.2021.05.17.17.17.56; Mon, 17 May 2021 17:18:19 -0700 (PDT) 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=einl4GjX; 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 S238003AbhEQO1z (ORCPT + 99 others); Mon, 17 May 2021 10:27:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:53016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239447AbhEQOYH (ORCPT ); Mon, 17 May 2021 10:24:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CED3C613CE; Mon, 17 May 2021 14:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260754; bh=u0cuOepqDr5lz0DiSS8gKOWHOLaJIYMmmSUixmLFq8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=einl4GjXKtO2JnDVm74e7LC3dnnkZZqdCOgtR2BOOtsyhNfurDLdefkd20I/GCQoD zwzQNRipJsf+7GViYFQteWgUIAUnYqszB8IXMb/u0H926mJkhXd1lBjj1lW5cRYZ0Y 1kZ9HC1JWEOt6tRVp/3HSRNO6TXzgz5p1rDK4BKI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nucca Chen , Cong Wang , David Ahern , "David S. Miller" , Jakub Kicinski , Jamal Hadi Salim , Jiri Pirko , Jiri Pirko , Sasha Levin Subject: [PATCH 5.12 226/363] net: fix nla_strcmp to handle more then one trailing null character Date: Mon, 17 May 2021 16:01:32 +0200 Message-Id: <20210517140310.230308130@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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: Maciej Żenczykowski [ Upstream commit 2c16db6c92b0ee4aa61e88366df82169e83c3f7e ] Android userspace has been using TCA_KIND with a char[IFNAMESIZ] many-null-terminated buffer containing the string 'bpf'. This works on 4.19 and ceases to work on 5.10. I'm not entirely sure what fixes tag to use, but I think the issue was likely introduced in the below mentioned 5.4 commit. Reported-by: Nucca Chen Cc: Cong Wang Cc: David Ahern Cc: David S. Miller Cc: Jakub Kicinski Cc: Jamal Hadi Salim Cc: Jiri Pirko Cc: Jiri Pirko Fixes: 62794fc4fbf5 ("net_sched: add max len check for TCA_KIND") Change-Id: I66dc281f165a2858fc29a44869a270a2d698a82b Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- lib/nlattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nlattr.c b/lib/nlattr.c index 5b6116e81f9f..1d051ef66afe 100644 --- a/lib/nlattr.c +++ b/lib/nlattr.c @@ -828,7 +828,7 @@ int nla_strcmp(const struct nlattr *nla, const char *str) int attrlen = nla_len(nla); int d; - if (attrlen > 0 && buf[attrlen - 1] == '\0') + while (attrlen > 0 && buf[attrlen - 1] == '\0') attrlen--; d = attrlen - len; -- 2.30.2