Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3400694rwb; Sat, 3 Dec 2022 04:29:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf5jdZ3ISe9GorlfTpT32+1QPvFD/7p114Hf0GW09ynBUoDfxPEW1tLKdaPeZOG/pMQ+SJ3f X-Received: by 2002:a63:b16:0:b0:46e:c052:a6b0 with SMTP id 22-20020a630b16000000b0046ec052a6b0mr49011586pgl.91.1670070572403; Sat, 03 Dec 2022 04:29:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670070572; cv=none; d=google.com; s=arc-20160816; b=JuNZGECg5MF0pRok+Fz+CS9hJ6MfSlFuAYADUuiPgiBQUD6U2DsBgVEIX+zMPDSrZq t0zQ/Z7B5tM0Dimox781aiKGYG9Ua0TJXxsYFFzQezCwcXyQVnb77kk//GJ4pyOSOZfF 6XH8Q7g2/xv6hxsC+I7ndBZLm02uzPIxufREUWGNupfagPowWdhQ3FADRGO9ltGYEgtN Ui/VSaxT3CZlDXMkzNlwPzVhSpIqSct0bM8aGcoBGBfoXXbeaSIdSsVsIKfvFaH3EvQm KkE088QS304Iq1Iv2OoDRe/9o+FU8gF6/dXR51iRYs6yAO6k0P9L6dFokqleaKjT5llY ZK5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=h70TBke2aedZh5TRlzmm86xQSiyKUCTbsGye69uQbfc=; b=qinFvhBWeElF1wWl1yG8DXf2UkCWyZ20TZx5xlNj7V0Wh15ESU4sqwDJeKYMDMFSWl 64VcDOGcy7oTii1stfEXbJ52EHx4tdTMWA1CoL58S9+W8+KRyPcmj6/XhAhdOWivrsqr XoZhY621q7vgL2RLr2JX3h1MrFBu4nM6IQk/hLWY4EQdOwomn/7yediGoW81WYzxLi3D 93v0/mKw/1Atq9fI5FJD80yDCDFt2T2BsDkmczNz+fRrza8j3gqP5xI0HTag5ULUXmz3 f/Xl7W+7RY/r2cSLjKqOHL+coxZUl1JYoGBoW3H5PABESWSnjIDlMP8LL6WjhvsJA6R0 vLaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NIkPiX6S; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g3-20020a056a0023c300b0056c94208afcsi10949684pfc.6.2022.12.03.04.29.20; Sat, 03 Dec 2022 04:29:32 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=NIkPiX6S; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229633AbiLCMQV (ORCPT + 84 others); Sat, 3 Dec 2022 07:16:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbiLCMQU (ORCPT ); Sat, 3 Dec 2022 07:16:20 -0500 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADF092B255; Sat, 3 Dec 2022 04:16:19 -0800 (PST) Received: by mail-qt1-x82c.google.com with SMTP id a27so8473946qtw.10; Sat, 03 Dec 2022 04:16:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=h70TBke2aedZh5TRlzmm86xQSiyKUCTbsGye69uQbfc=; b=NIkPiX6SYMKIpWDkM71wQJEknqTrJzZw5L7HgIGRrU6NwirQ26wXQalq2Xj/4s2X4E WkaOsZHLQ/a9c28tYXVWMRo1G1EZwMlL1FY2LELfyp+yah/ejHprJMlyhp/QFD7nwKB/ zMl3giAKCBMEEgSVfw2Hh7kmaDfGKHf7vBe4WZlI2XhNZjAUwS4tqypvzBz/LHNCD5EG Y4S/K1vfA5Vi3kDeJpFgCAr7tF7ql07N+7xF5lux5eFTDL6sabNmAj65pBDxkWMAIH02 xhmck6ZkNslD7azACPIh0Y7ytwnRwA1EsWjvbkUNuN+aj99s9ECAJu383UYiKMoRgQvD 89og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=h70TBke2aedZh5TRlzmm86xQSiyKUCTbsGye69uQbfc=; b=wRBywX3dMNKR3zi1nf8+K3MseXzm/7r4Ikv3Ja+dO6iiqlifTSi5G5uG/4mEweccvv FukVHwSNlmLyOqsTCBw606coeMQoHfreBsdXpwuPTLABb0uv2hjifNFCzmh/Gx11yxKc lJIMDONat9RdOCMe1hO6zJ+VCe1GwOJKnFYiaxvSl5LDFjG9cKKFqBnIN/g0DBzkz0C1 bT4rJen5n/MQcZn+D19VL22EfeqiMFfLjkGZJ12F3RwVri7A6USt8BWWqO5AKCXo0n51 DFGZ86Hx+G+QumL0lxQZutUxqEqNcmlUbHdUj+esNeMu9Y6GUERdEN2rQ8liSjyGbmU1 vRNA== X-Gm-Message-State: ANoB5pl3GooVgyUNS8lY36XHOY5MtWg5tkmw2FqP+ZxDM2+LFpaqHt/Y ZsAD2COc0/8NQCMwUVGwla6pGW6Wizi/k9MOgIs= X-Received: by 2002:ac8:7eeb:0:b0:3a5:2615:5694 with SMTP id r11-20020ac87eeb000000b003a526155694mr53700676qtc.429.1670069778762; Sat, 03 Dec 2022 04:16:18 -0800 (PST) MIME-Version: 1.0 References: <202212031424175433783@zte.com.cn> In-Reply-To: <202212031424175433783@zte.com.cn> From: Andy Shevchenko Date: Sat, 3 Dec 2022 14:15:42 +0200 Message-ID: Subject: Re: [PATCH linux-next] x86/platform/uv: use strscpy to instead of strncpy() To: yang.yang29@zte.com.cn Cc: steve.wahl@hpe.com, mike.travis@hpe.com, dimitri.sivanich@hpe.com, russ.anderson@hpe.com, dvhart@infradead.org, andy@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, xu.panda@zte.com.cn Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 Sat, Dec 3, 2022 at 8:24 AM wrote: > The implementation of strscpy() is more robust and safer. > That's now the recommended way to copy NUL terminated strings. ... > /* (remove possible '\n') */ > - strncpy(arg, val, ACTION_LEN - 1); > - arg[ACTION_LEN - 1] = '\0'; > + strscpy(arg, val, ACTION_LEN - 1); Should be ACTION_LEN here, no? > p = strchr(arg, '\n'); > if (p) > *p = '\0'; Wouldn't be better to refactor this p = strnchrnul(val, ACTION_LEN, '\n'); strscpy(arg, val, p - val); ? -- With Best Regards, Andy Shevchenko