Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp504602pxj; Tue, 18 May 2021 08:10:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMfiQwpEIm3tEghrvTpzbr3YZUGkcTfCH1zbREI3sPEBYwiG601o7O2QGhw65BT+Rwgw+9 X-Received: by 2002:a17:907:b09:: with SMTP id h9mr6285999ejl.430.1621350655806; Tue, 18 May 2021 08:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621350655; cv=none; d=google.com; s=arc-20160816; b=rAeHF235ANQt775fHLo4I47tiG9qAcNNnxNXilyAalJj2f1odXUOamfjGodnVWmYmM itbMM8w/L8MAIzv2HaJaiLIbVJbG8g/vcyzVl5rwKpDgy1Q7Pa09TVygZ0b7BrIAq/wj tWV/EflEZhsqGk10WfCiKWYrcZX7HTStPhIm/tIB0PhI7mYWdUP6ye4KhFbdHN2WDiri v1BFWowxbdEdSUfH9867r2mgtyqUJ9SIz48fJ+lY+EhXm+0J28MoYId22GdqV25AGEpJ tfosyas1fx4hTvM3TWh2kmJX+AD9sQ4esFbiwVObNovep4d2Usa3I+Q66F7E/RMQgLyD TcCQ== 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=MfPrvWhcXsJxAEUIuTXUUxKjtfm7gmGtcqMOFjNI0iA=; b=C1SiHmC84pDKczu1kywMseU4HrqEgA8wX/fUg8qVRkCezJYl/4JEg3UPvF1ktR+uNM Fgi+GxRnP4EHH/MdStrlzr5Fqm+N1SIVDr8nEC+u+56WQHIlFYEyN9Ma7VvQ59wDra8c RecgGegnEsofkK2k+zx/gRS9as89utO1IBMD8HbXsbITIr9JtgPoALxsHAF8bG2NUZC4 RIcV139Cww7arUHQKuIy0Q++t5tvj+hkYxVGrbx3ohglrXyn9BfrxEU4sUCKA8+WEM1l 0svnvYl81CxNi0aD/GOG2FiVEAQ4zGp44H0ZzPsQfAV5WMH0jlzU1A1bVs4B7yRvhRwB IHOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="RMoxnMk/"; 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 w17si19267770ejb.702.2021.05.18.08.10.24; Tue, 18 May 2021 08:10:55 -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="RMoxnMk/"; 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 S245409AbhEQPv4 (ORCPT + 99 others); Mon, 17 May 2021 11:51:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:40300 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343699AbhEQPen (ORCPT ); Mon, 17 May 2021 11:34:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BF96E61CE1; Mon, 17 May 2021 14:39:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262374; bh=wYFPf511ZY+gZoxEt6THiv5+5ykUtLdGvdTv31NzjJA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RMoxnMk/G17haVIOkNuJOp3L9wymRJErInVtDi+oO/j5L+oei1HKlpFijbSrvObxa 0nLeRcdjOh0ChJjGzHmPgQ0DioJuJRsL1nvvkvkopL649DaSVnZiM/S0VEhTKOBuCc lCAOwgpuqnSTr1Qt9qsMrUUptDyR1uGfYe8xdUIc= 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.10 174/289] net: fix nla_strcmp to handle more then one trailing null character Date: Mon, 17 May 2021 16:01:39 +0200 Message-Id: <20210517140310.974673845@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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 74019c8ebf6b..fe60f9ae9db1 100644 --- a/lib/nlattr.c +++ b/lib/nlattr.c @@ -816,7 +816,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