Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp819468rdg; Fri, 13 Oct 2023 01:57:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8RHA/N8pWocAk0YiftOHHsFGYu3cmETHsDKnPO3W0TI1q6y3dV2dZtcWNIBZCYgMzcmQu X-Received: by 2002:a05:6a00:93a8:b0:6b2:69c:346a with SMTP id ka40-20020a056a0093a800b006b2069c346amr1609265pfb.19.1697187455676; Fri, 13 Oct 2023 01:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697187455; cv=none; d=google.com; s=arc-20160816; b=eC2p6tO53GCOG5yz905dr0A1U5covATcbsrn9u15thYvUHC3MlHKm1MYnqBv+AojD0 QNYZmJRTWcI08tB5cGba/JjUs7/dFkSGK9C/agk5jpZgC2mzkRD1vh0r2XanpzjJ56va b/bMqb/7Cz1p7SkKYjMtcRoygdE18KRgcvo/otqySnEA37WbQobJ2NthFWmBaetjrYrl 5V6/B5hBDac36Jj2ep5ug5WfrLjMbA1HrW18/nzLgqigt7VnBnTOCOikaWgkBKgp3bQL NHZ/phpIKlzVk/BPvVKg/lJwqs5cqct98DCujYX3Dtq5NoPlMybnS/jLEMwbrhTiGqvR ztMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=buruCN/2QVN4PwlAqjp2tz9lsRhDJNGAaY3eMM7JqzM=; fh=tH9o8FidmvDUPDMKF0X1Kqh/zifW9F8otdpl1IdqCjM=; b=j1Z4ut3sAuYKoHRFUTM85udmVMruzw1R0NF038fG3VzEKPVKEvekOXLXHSADfCiiiU Etv3BTIWRlxXmql2smWBwt8hyOmipuN7fWu+hhZKwv3e1q0zDfk5VvulKvvJXVCIl07E Zzaj8WlW0QakcvRIjRj8Gei/7z8axx7x5/0zmzCefyuzC1UkZW4FezMnEi9W+Hzn95/w DojsotFAXZj1fc0WWPY8BtpE/hcRm2lLa7h3UxvR5PB0mooYfhkQ/g056EGsla37A7BY nytnPQv8SWKxtFrBuxKKwI0YeUq5QiyhP1gdTlPO7NZWQaE8ol1THXin47H7NDRv07m+ /ZxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=W8cVnmBB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id r10-20020a63ce4a000000b00563a0bacbb4si4060117pgi.694.2023.10.13.01.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 01:57:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=W8cVnmBB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 779028020BE4; Fri, 13 Oct 2023 01:57:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230198AbjJMI5D (ORCPT + 99 others); Fri, 13 Oct 2023 04:57:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230193AbjJMI5A (ORCPT ); Fri, 13 Oct 2023 04:57:00 -0400 Received: from out-203.mta0.migadu.com (out-203.mta0.migadu.com [IPv6:2001:41d0:1004:224b::cb]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDCDD95 for ; Fri, 13 Oct 2023 01:56:58 -0700 (PDT) Message-ID: <2c7a813d-bbbf-4061-b8ad-efa4e7f03d26@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1697187413; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=buruCN/2QVN4PwlAqjp2tz9lsRhDJNGAaY3eMM7JqzM=; b=W8cVnmBBDGjI6CVsC+xWcY1+6N0JsdIdCNY3rRqkPSgEjEv+GxL7OYzlYA0FijIfFDfB3S bRi78p5Bxd3HkwOOaHMKbYWwFJIE10E9yrqZUXyp+WV69+IarSKzirMzMdAhnR6akVPtWo g85UjIl4PNxxn6zrq/pFm0ZtegCybtE= Date: Fri, 13 Oct 2023 09:56:49 +0100 MIME-Version: 1.0 Subject: Re: [PATCH] tipc: Fix uninit-value access in tipc_nl_node_get_link() Content-Language: en-US To: Ma Ke , jmaloy@redhat.com, ying.xue@windriver.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <20231013070408.1979343-1-make_ruc2021@163.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Vadim Fedorenko In-Reply-To: <20231013070408.1979343-1-make_ruc2021@163.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 13 Oct 2023 01:57:11 -0700 (PDT) On 13/10/2023 08:04, Ma Ke wrote: > Names must be null-terminated strings. If a name which is not > null-terminated is passed through netlink, strstr() and similar > functions can cause buffer overrun. This patch fixes this issue > by returning -EINVAL if a non-null-terminated name is passed. > > Signed-off-by: Ma Ke > --- > net/tipc/node.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/net/tipc/node.c b/net/tipc/node.c > index 3105abe97bb9..a02bcd7e07d3 100644 > --- a/net/tipc/node.c > +++ b/net/tipc/node.c > @@ -2519,6 +2519,9 @@ int tipc_nl_node_get_link(struct sk_buff *skb, struct genl_info *info) > return -EINVAL; > > name = nla_data(attrs[TIPC_NLA_LINK_NAME]); > + if (name[strnlen(name, > + nla_len(attrs[TIPC_NLA_LINK_NAME]))] != '\0') > + return -EINVAL; The better choice would be to use strncmp() with limit of TIPC_MAX_LINK_NAME in tipc_node_find_by_name(). This patch fixes tipc_nl_node_get_link(), but the same pattern is used in tipc_nl_node_set_link() and tipc_nl_node_reset_link_stats(), these functions also need improvements. Changes to strncmp() and strnstr() will fix all spots. > > msg.skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); > if (!msg.skb)