Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp830000rdg; Fri, 13 Oct 2023 02:21:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0sstZJznPTn0HiPHaUMGv1bTqxpcNdKaJPTdNQHDqdWrRPPkXzRkNH2mmuI6CzrEcC0+X X-Received: by 2002:a17:90b:3107:b0:27d:4935:8d9a with SMTP id gc7-20020a17090b310700b0027d49358d9amr294366pjb.4.1697188888337; Fri, 13 Oct 2023 02:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697188888; cv=none; d=google.com; s=arc-20160816; b=bVL0BJ8wd9l2OtzlbFTYqbduq45B3ZZ5DB2Zay8LaBftp2B2k7Nx3Cn99ckvsNKFwn /CJAcBfc7q9loSPPEveo+PZda+wj2lPJgIwUL7x6nHCjslCgj2P8DvirnuUEARMAp5PF yfG3vDFe0agVnY+Wwv+hBTas1/XRCd/IcPHb8B+n4XKRgQ6GxM2Am67Guy8LyPV4Zs5d OnsyGzcMpMEDSJLZk18SeTblNQyEqtP+h9ibhXScQfaHHB4Yi7J6Rho8bha4Th5U/um9 MlDI4AGENKopvwPNlLEMv5JGXKIbeHsu7cnm9Rvd++JX+oZApjsnFzsctDDBt3mH05Jq WqEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=AA0abo7vRDoKTH4r8QYX13cmhkSwsgvyR/HS+Qc/N4s=; fh=XDKUtB1eQBpXyoADaSC+h4PxdAOofkp2b1sEZTheVa4=; b=miSxM73Ag9XWtmtH1dkLVEFN8ujnNrko2JwJqpaJGl58bFL1i8Fb4j4OMjUvbZ3Whl NwDTCoF2rc8JAVoLAVMmSk+MAbUeT3R8ec9hgzsWZfa3yA36jSbICiN83fRHu8ngpykM G6mxRaca1w9r3/g/X1bJbr4riG4KLxTAW8zMF3Ln3brEWm3d7lXy5i4i+SOQ9IXr3OdI 6jobzeDHmARz07njGDJUtEpmxqFyxee8Q7c6cb2NxSw05XSpGSxTlhDq3j+TJVn5tDxm bxQ0dP+85wIvF5eHwI13Hy/8Cl1yh6xNuKBGe+ULu8Y0CO9hwkTDLk9ddOHZLUSyW/Ih AwEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id by22-20020a056a02059600b00577549e67b9si4862172pgb.589.2023.10.13.02.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 02:21:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 0C55F809E8AA; Fri, 13 Oct 2023 02:20:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230475AbjJMJUp (ORCPT + 99 others); Fri, 13 Oct 2023 05:20:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230421AbjJMJUd (ORCPT ); Fri, 13 Oct 2023 05:20:33 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:237:300::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69DDE95; Fri, 13 Oct 2023 02:20:30 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1qrEKy-0006XP-FO; Fri, 13 Oct 2023 11:20:04 +0200 Date: Fri, 13 Oct 2023 11:20:04 +0200 From: Florian Westphal To: Ma Ke Cc: jmaloy@redhat.com, ying.xue@windriver.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] tipc: Fix uninit-value access in tipc_nl_node_get_link() Message-ID: <20231013092004.GA4980@breakpoint.cc> References: <20231013070408.1979343-1-make_ruc2021@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231013070408.1979343-1-make_ruc2021@163.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-0.8 required=5.0 tests=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 morse.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 (morse.vger.email [0.0.0.0]); Fri, 13 Oct 2023 02:20:56 -0700 (PDT) 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; If the existing userspace is passing 0-terminated strings it would be better to fix the policy (tipc_nl_link_policy) instead (and set NLA_NUL_STRING). And if not, above change breaks userspace.