Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5961885rwb; Mon, 5 Dec 2022 06:22:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf7KT2d7DIMk5fZDMHMWpdcGntuX/EBldMPBBhzvP5THTupF6fXeullgxNzqDYzGWMUSqo4C X-Received: by 2002:a05:6402:28ac:b0:46a:b8d0:a052 with SMTP id eg44-20020a05640228ac00b0046ab8d0a052mr41603235edb.399.1670250170883; Mon, 05 Dec 2022 06:22:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670250170; cv=none; d=google.com; s=arc-20160816; b=u7rjWOWj15epqCTB4km1wDW7FKZ4a3wYX7l7FRT2n54Yj8pisvfhcVKoerWyerrDeX H2XR0AZ0Lz4lpFuYQapB8ssRYqfB5CfZ8cgmMYhFrhb6Gba4Y0bGj6GyjIe+pJZ1O9DP /stTHaJd86uppD65ojrLnm+KSIOU8LPFyOHN6VRTUg33Urvk+wwV4rYBkhC7QTW4IUPB 9IOlDX2xASe6MyM9LgSbL7RoTQ/7j2hLgFW2VoH9z3yeGqSURNA8GaGNgss/VjggAIdA jQrzkoTpIVCmfAlOKwxmWCRmr1GTVXMyJWRWORu1yGYOdxogLRXcqlrkGItW2Itfg9hc 5TwA== 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=1IEd4mI8XLAQBexIi+9IpqUT3OWzPJE+9etDyFsEtDA=; b=iwygSqtT45FhDfhbBzyrmhWMWGv5Cmku6bFoKCpzDSgp6GBhOtnYyVEoggS2Tc1Dl8 Wa38alrZdVqxJOQnrCbEultMKEPJTHwdYjqZEWbS9z1b6c2xwBaP2rYepcPh/wS2ZMoU tK5UhOaA4k+bCsS7eqbOQ0iBDdRl3FXJox6iaUOHl36XQ7Qnd21UtrY8P4Q3hTdkktnL 54Oyq7d9gR7D/wb2+kEKVHVsvpBfWFGq81rWDC+pc1tV+p8D90Ufn60vX3n66aYhNOtR hfnH9UFz7s0dfmeOG5tMJ5RKb/1KjatMYPPMXSNYc0ReUpHNfzJwLfs7cV4X6/Zl0c4D 29rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oE4GEmTd; 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 hd14-20020a170907968e00b00730936657d1si13792602ejc.552.2022.12.05.06.22.29; Mon, 05 Dec 2022 06:22:50 -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=oE4GEmTd; 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 S232128AbiLENQ1 (ORCPT + 81 others); Mon, 5 Dec 2022 08:16:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232124AbiLENQZ (ORCPT ); Mon, 5 Dec 2022 08:16:25 -0500 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CD8B13D45; Mon, 5 Dec 2022 05:16:24 -0800 (PST) Received: by mail-qk1-x734.google.com with SMTP id v8so4841808qkg.12; Mon, 05 Dec 2022 05:16:24 -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=1IEd4mI8XLAQBexIi+9IpqUT3OWzPJE+9etDyFsEtDA=; b=oE4GEmTdC5yMQ2N4/NNW936SbQWyASzL2GuhCgJV06hdVm6aJV1VE+JWgnNKKaeEfo sNEfc0zY8Q4FnCXI+p0D7cXW5Atsp9oZJtjSe0d3OhOvJ8SKC9o43u5rA+4Xkt8+mGgm Ti4wx1Dz8q8Tcw951dsL7GPoSCVh+hqMEQ9i+BAO1UbkFAyFQLpifCAlIqZ89C4gkVHL 01nWkpKl09O9Tigi+S9k+tLIO+N+BCVbWrVclaS9+Cj2YZYVbovBP8eqlynW72hrYtt0 hp1iSQwBJ2fqvaLioSbqT0M4pAbEJkRL/GWK7oH2E6ojmEXRMneyPE05JXf+HlZU20AJ 0hyg== 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=1IEd4mI8XLAQBexIi+9IpqUT3OWzPJE+9etDyFsEtDA=; b=q0XPZU+GalljuOBJa+88px4QEhIn3355JVzqiyYam8Dk6PEX+4AqCYRsY65TFBhp24 YcoZAZn5aQ5U8w6jcBTVNcjvNLOFQcuzaxQPlPSJwLNVEFTYgmSMbcj3Jr4vX4N4Ff6g l3lTuUeIzkJ/yg3PyxtR3f7ZiVg6se7z2v2scVm0Vp8qgztv/EGbIm4QKuTuKJ9KYd4k UEWBaGusC0+J+BVTN28MLgAe3uCtZSCo8MWpGpSZ3mSuQEJgZE3cRX43HVB2jWlegj1I G2eCHAmPQvmxtxsChbk5yQeLz3THc6VOxsCEVMOPe1EgpjGuR3vJRTRxROKAEPOJvbxe MZVg== X-Gm-Message-State: ANoB5pkR8Fd/o8KfBjUZYAems3yGl/YgSetyoHcyKm+0dTF+U4wNw71h ngHz1GXB8nW84L97HG8nyx8P1+zi6o5LHQIwBp2BgLCmppg14Q== X-Received: by 2002:a05:620a:2053:b0:6fc:abc1:d154 with SMTP id d19-20020a05620a205300b006fcabc1d154mr14630302qka.320.1670246183553; Mon, 05 Dec 2022 05:16:23 -0800 (PST) MIME-Version: 1.0 References: <202212051942082259437@zte.com.cn> In-Reply-To: From: Andy Shevchenko Date: Mon, 5 Dec 2022 15:15:47 +0200 Message-ID: Subject: Re: [PATCH linux-next v2] 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 Mon, Dec 5, 2022 at 3:13 PM Andy Shevchenko wrote: > On Mon, Dec 5, 2022 at 1:42 PM wrote: ... > > char arg[ACTION_LEN], *p; > > > > /* (remove possible '\n') */ > > - strncpy(arg, val, ACTION_LEN - 1); > > - arg[ACTION_LEN - 1] = '\0'; > > - p = strchr(arg, '\n'); > > - if (p) > > - *p = '\0'; > > + strscpy(arg, val, strnchrnul(val, ACTION_LEN, '\n') - val); > > And even better is to replace ACTION_LEN by sizeof(arg). Btw, have you compiled this with `make W=1 ...`? I believe you will get a new warning after your change. -- With Best Regards, Andy Shevchenko