Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4721649ybc; Fri, 15 Nov 2019 09:03:24 -0800 (PST) X-Google-Smtp-Source: APXvYqyfR+ZON11A05F9d8tNe5Mq49Ldf5p0PdbXG2XNd++P2A/GPUwnHb+q4b8+W818Vli7LrI2 X-Received: by 2002:a17:906:3f8a:: with SMTP id b10mr2184207ejj.315.1573837404098; Fri, 15 Nov 2019 09:03:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573837404; cv=none; d=google.com; s=arc-20160816; b=AvC6BfN92VnISItE/GjdpWHgkmeb2/HjIDDsCqp+82f3tXzp/fAsQEkDWOSNtNUzn3 /eUDyhaQbwe+J5lasR26piox4Lwp/tZ7pYnhOUf6Wp9pYUlpY1S0pztxX9c28uyRxeOV L+nG4y/fzBuLTCbcanyaR3S76QrxmkwEiCJi5aR3kWh36NvYeTwm76C1q5ofYoms65KU 2A6k0BPaoaO1+pcoll6i8DXr52dca88syGOb+lPTw7grZbFqmXUUMpFByuYeu9s1BAaE exRQAmStZfultCWoMRUci8H/0fWqiI2dJYKHiUh5JLl0xT6dm1XWa3yFHsdMJfGN0yQh Bn7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=6KJTXmV3nRW8gUbGqQ4GcrDPQULApXAqF7C+3pqi6RM=; b=Mdif2VOlqKFFxRjw091WeoG2KTJ+dF9ZKunUlEVHsky27TvCw65WOlDgmU5ak+ygo7 TF6I17nYlkehWbcd8pGpB9mP3owPwOCt1qct8o/5tYBcoZLnuwksAb9zzW3c3rTWzSVv fo0Z7Q7i8Xw6LhAmJHYeHRQ+XmL8TbAiGCc0g/7ykibM7Z6jxzXFwQCSjhoDFLk7j22X Y0kGmXjadbqE3NnnDHqSzv+YimWN+cAxEeM7gpVOMuz9utz8Bp27mtACNb3UV+U+9Svk KeQjuQo2kyfX5MNhjeM6lJ83OT7IeMDq1Cck8fHIN5zXOIQ6BImUGnv17PoWewhPxJ8f ypPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lea72v0a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k24si1213084ejk.280.2019.11.15.09.02.56; Fri, 15 Nov 2019 09:03:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lea72v0a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727628AbfKORAa (ORCPT + 99 others); Fri, 15 Nov 2019 12:00:30 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46786 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727540AbfKORAa (ORCPT ); Fri, 15 Nov 2019 12:00:30 -0500 Received: by mail-pl1-f195.google.com with SMTP id l4so5040956plt.13 for ; Fri, 15 Nov 2019 09:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=6KJTXmV3nRW8gUbGqQ4GcrDPQULApXAqF7C+3pqi6RM=; b=lea72v0aKBO/HzkW9xRW0+gmfuKWuweJm8ZuZhTIE6ZspE9e3DdbgdeOqryeh2WpHs 69VCzsotxdw11qrFs2/xzVdgNpKaC8lZYDeHIj6pnZlDX4VWEl4FWcoKYqGnAas8lUU4 1dbEIwD9NKRURLHoHwSslyp2NZXgzpz91sk68= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6KJTXmV3nRW8gUbGqQ4GcrDPQULApXAqF7C+3pqi6RM=; b=XBsCA57rzWp17p7ZHyXMQF1Jhw/PJZOpN8zSgJaWDO0ZkpTVACYH/mCcKnlhXXaqBi kc9JnPabgwm4s67rB73vezKCl25guvApPoLa6A8qHkpleyP5XltxJ0Pb13adM4ahLOvf lkrXkbArJ8krwwwzRrkl/y9NtPvhawp26RzAeI/TLz+hvqyKBAY28KghlqQNzyBG/eQ0 K0PDQYpS7mNUpYra5q9lmhA08IxLTjKQmTXzemZthTx4sW1Ds8vx60/XYVV5XMN3wtyr aMGqUmpdYZg2QDvDeiQrotIokW2j7+CqVQ24seK4WanpkH1OO0evyqO6aNsyQVXYbUDN Pkdw== X-Gm-Message-State: APjAAAV5BUIIeRncoImwUbs22s82ApKtffj1GO/kzJYyfryksFRhyZ+u Gr4nSoOipE1fzXBhOffny6an3g== X-Received: by 2002:a17:90a:b393:: with SMTP id e19mr21641421pjr.115.1573837228497; Fri, 15 Nov 2019 09:00:28 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id i22sm8907804pjx.1.2019.11.15.09.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 09:00:27 -0800 (PST) Date: Fri, 15 Nov 2019 09:00:26 -0800 From: Kees Cook To: Peng Fan Cc: "sboyd@kernel.org" , "linux@armlinux.org.uk" , dl-linux-imx , "linux-clk@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Alice Guo Subject: Re: [PATCH] clk: clkdev: Replace strlcpy with strscpy Message-ID: <201911150900.817CDE33@keescook> References: <1573812819-5030-1-git-send-email-peng.fan@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1573812819-5030-1-git-send-email-peng.fan@nxp.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 15, 2019 at 10:17:53AM +0000, Peng Fan wrote: > From: Peng Fan > > The implementation of strscpy() is more robust and safer. > > The strscpy was introduced to fix some API problems around strlcpy. > strscpy is preferred to strlcpy() since the API doesn't require > reading memory from the src string beyond the specified "count" bytes, > and since the return value is easier to error-check than strlcpy()'s. > In addition, the implementation is robust to the string changing out > from underneath it, unlike the current strlcpy() implementation. > > Cc: Kees Cook > Signed-off-by: Peng Fan Reviewed-by: Kees Cook -Kees > --- > drivers/clk/clkdev.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c > index 0f2e3fcf0f19..ee56109bc0b4 100644 > --- a/drivers/clk/clkdev.c > +++ b/drivers/clk/clkdev.c > @@ -165,7 +165,7 @@ vclkdev_alloc(struct clk_hw *hw, const char *con_id, const char *dev_fmt, > > cla->cl.clk_hw = hw; > if (con_id) { > - strlcpy(cla->con_id, con_id, sizeof(cla->con_id)); > + strscpy(cla->con_id, con_id, sizeof(cla->con_id)); > cla->cl.con_id = cla->con_id; > } > > -- > 2.16.4 > -- Kees Cook