Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp5249025rwb; Wed, 9 Aug 2023 00:37:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSoUdPtPQOkfQ6ZQsDxmKfzEldEztQ2noCwMmnXeiq2GWZfIblJyob5kWsDx67VhE1N8M6 X-Received: by 2002:a9d:67c7:0:b0:6bd:a47:7bb6 with SMTP id c7-20020a9d67c7000000b006bd0a477bb6mr1852582otn.14.1691566631584; Wed, 09 Aug 2023 00:37:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691566631; cv=none; d=google.com; s=arc-20160816; b=R/0478aeAcAyQDvjDi6ITYfUZgRWVwpAb5D3TK5EH4TuRi8jtzcI3ikX78i5DRjHDD vyjnYhxkO09Zsy254Urm+yAZiqL3Qi5fDewIO/jL0o7ZFcD26QzpencNcNL3KG7bsyqT F2esoMKytZNf5OcM+TSEX4puysxIR2RrCehQXpMf7Y1CRLJtpYNS00yBe/L2Pyjzq3b8 PQzmECAdIIaVzhlppGdHUm1SDftvFnsUR2ulO2x25WO9cwxea9Nd9sYr1Ft/yVapo4MR wOM67ZHVPH8vj5UY7jDK7neLghaNkhW4hcFtZFXoySe0rg9jXXptZXewJvRvDkezGKjR MjXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5AL2Qh1UqrIVkGC4xXTyf7U88C/3mJCH2hTyHZlRPyI=; fh=gFcEIuCL+v8KNXBkJ7Bqhmtx8vgCWHHc6Jy+Lto4s84=; b=mVFw7xraiiToSrR42fawclMARsKUZi010BOUAMWcIjGm1NsSQphO8d2BfO472x0gLL HZnBdyB0myj0K3fYYZS1ZLnO/1/FDgrXJiR2wlbRTuoOr4F+fi0Klcy6Okqt6x6cf6H9 QKtIf86AG9WJtrG0HwPKdJ7CgNV1ZYgfXvhbbrfCJi63KdAuQCWRGr+GJPI2bzgHbmkQ SIjBxmy5UGeeI3TjbFjPQzLSBWd6AeWM+2Nc+f3LW1hDjUop6Y6y9YcUQpMJZaRmh3wi bhlG5zbfCTbxGNW7s2YOsJEKVL4PxewEDaaV5wLMFoJOG4dizxdxOKUDpBE529NV9rTb ofSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jod8fe3h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r130-20020a632b88000000b00553813c2df0si8298698pgr.513.2023.08.09.00.36.59; Wed, 09 Aug 2023 00:37:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jod8fe3h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231337AbjHIHDK (ORCPT + 99 others); Wed, 9 Aug 2023 03:03:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230359AbjHIHDJ (ORCPT ); Wed, 9 Aug 2023 03:03:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4CA5E7D; Wed, 9 Aug 2023 00:03:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8208262FBF; Wed, 9 Aug 2023 07:03:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2156BC433C9; Wed, 9 Aug 2023 07:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691564587; bh=P2+3vf+gBALf2UGu15Ac/T463go2awfYas36ymRipBM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jod8fe3hOqqkL3j5kbVUq2qQm+GHBF8hrvNay9C/ZMfrd3yi7fSMXkpSOPrssAYyY XULvJ6XtdjS/wtWa0Bj2EYj3VTHUWzs/cqVrGjhHdP/bfuvz2/3u+HllwdGK28edUm f537bCuDOhyGl74bvCgASsIme1km/1zAFRKT667qJWOuRBgA6vTnI8B8k4IkxLq57P D5d0EisXO8GDSz/9Y6dXfMPwBo2XjVUekxGr/QqBoLiBVRDrCN/VWs55a2djm6qO0C Wny/oRsqOQHaA1/3fJZyqczIUAdKCTmEfoRqEgGI56CAb/aNHJDR3VgDTEfNXDjHvp gcXSlRpk/JCUQ== Date: Wed, 9 Aug 2023 10:03:02 +0300 From: Leon Romanovsky To: Jijie Shao Cc: yisen.zhuang@huawei.com, salil.mehta@huawei.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shenjian15@huawei.com, wangjie125@huawei.com, liuyonglong@huawei.com, chenhao418@huawei.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH net] net: hns3: fix strscpy causing content truncation issue Message-ID: <20230809070302.GR94631@unreal> References: <20230809020902.1941471-1-shaojijie@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230809020902.1941471-1-shaojijie@huawei.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 09, 2023 at 10:09:02AM +0800, Jijie Shao wrote: > From: Hao Chen > > hns3_dbg_fill_content()/hclge_dbg_fill_content() is aim to integrate some > items to a string for content, and we add '\n' and '\0' in the last > two bytes of content. > > strscpy() will add '\0' in the last byte of destination buffer(one of > items), it result in finishing content print ahead of schedule and some > dump content truncation. > > One Error log shows as below: > cat mac_list/uc > UC MAC_LIST: > > Expected: > UC MAC_LIST: > FUNC_ID MAC_ADDR STATE > pf 00:2b:19:05:03:00 ACTIVE > > The destination buffer is length-bounded and not required to be > NUL-terminated, so just change strscpy() to memcpy() to fix it. I think that you should change to strtomem() and not use plain memcpy(). Thanks