From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=FAKE_REPLY_C, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9861ECDFB1 for ; Fri, 13 Jul 2018 15:19:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 738D220875 for ; Fri, 13 Jul 2018 15:19:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 738D220875 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codewreck.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730149AbeGMPeM (ORCPT ); Fri, 13 Jul 2018 11:34:12 -0400 Received: from nautica.notk.org ([91.121.71.147]:58792 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729736AbeGMPeM (ORCPT ); Fri, 13 Jul 2018 11:34:12 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id BA8FFC009; Fri, 13 Jul 2018 17:19:06 +0200 (CEST) Date: Fri, 13 Jul 2018 17:18:51 +0200 From: Dominique Martinet To: Daniel Thompson , David Laight Cc: Jason Wessel , Arnd Bergmann , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH 14/18] kdb_support: change strncpy+truncation to strlcpy Message-ID: <20180713151851.GA14190@nautica> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <93d3ace9a35b4436930ed0521127c12b@AcuMS.aculab.com> <20180713103321.thjpohla6fuszona@holly.lan> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Daniel Thompson wrote on Fri, Jul 13, 2018: > On Fri, Jul 13, 2018 at 03:25:58AM +0200, Dominique Martinet wrote: > > Generated by scripts/coccinelle/misc/strncpy_truncation.cocci > > > > Signed-off-by: Dominique Martinet > > It would have been good for you to mention in the changelog how > you reviewed your change to verify that the extra zero padding > from strncpy() isn't required. I'm sorry, I went a bit too fast with the send-email button on this path series; I agree it is lacking. > However... I have taken a look and can't see any problem so: > > Reviewed-by: Daniel Thompson Thank you for the review, I will update the commit message with more details and change strlcpy to strscpy in a v2 David Laight wrote on Fri, Jul 13, 2018: > > - strncpy(knt1, symtab->sym_name, knt1_size); > > - knt1[knt1_size-1] = '\0'; > > + strlcpy(knt1, symtab->sym_name, knt1_size); > > You'd be better using strscpy() not strlcpy(). > The return value of strlcpy() is the length of the source string. > If the source string isn't '\0' terminated horrid things happen. I was suggested to use strlcpy for drm and didn't realize this at this point, but you are correct; strlcpy is far from being as protective. I'll update the coccinelle patch to use strscpy and resend this. > David > > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, > MK1 1PT, UK > Registration No: 1397386 (Wales) > > P Please consider the environment and don't print this e-mail unless > you really need to (By the way, your e-mail client sends both html and text, but the text version only included the footer so my mail client, which prefers text, was displaying an empty mail message. If possible I would appreciate if you could disable either version so as to get a coherent message) -- Dominique Martinet