Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3579808imm; Tue, 29 May 2018 09:35:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZopDFu4OdXLeLYfa+ggL7Kghj2qjpVmQP4QlTcvxFMSfPLseoiYLLdc2pHPpzwSzdkU8rN/ X-Received: by 2002:a63:a60a:: with SMTP id t10-v6mr14337852pge.351.1527611717022; Tue, 29 May 2018 09:35:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527611716; cv=none; d=google.com; s=arc-20160816; b=HEKiXcQbaMpHBQlExQadIvA/JlbGa175+0bBtGenL2ZNsDlc4wCQMyzoc/8ineA+7P zyxIY+2ZpCl4e2fu0ygMMLPrQsyytNTffxToc8G/K+/hFck0amuN/fAh6p7jDBqoN/Bk PyI3VkpCHvtb0enLezMJFQyzA9/BfbcmzKpC0xKF5lQK/Kz2ZqgZkHXzzEmdFtNO2jEv mc8OQ5yFbaHZagQLIlnPVpIHnVxab+JCDYuVEOdLl0wgnGwiPUq6T6o9piqDtWukV//7 xQjPGOBq10H5nxIfmjTZjCmwVv1rAFKM4IytPJkIAXZMjnL4tKuNMIdBFgd40QphZKoP jt5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=xvqcICKPdnH7YDbMpkUGH2z8ZbATaHWECsI75iXUXIU=; b=QjRKkq773KvXC2u2vLlYo1JxQfkaBpb8kQAEf5qIK/JITvCtbW/5iJRrUWQIpw1Zhi fHj/0mH4nBIgO+ZlMCmNYmFMDmjIiKwN0PnZMJbAS4JS12Nl3k1wHx+GHauOOlw/MhfI RpQwX4Ecmsy8O/dn6PxOwbuh6mYQrrTvAm+f7rADGaqhdnh/PJrx/t2Sx8HDerRM+d/3 4IjKoAaNYioKfS5PHfBkGlmjr6+hedbEVQcrswwX9+K98H4CJtq7EI787QoGHQmZmcoz 60Rarsb5R90XqafPO+9zVGST7j/BTWkW+c4gbkPQCkmMIOV5S3FjAPsObnNMt45BPdMW 4B0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=muY7Rhw8; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k16-v6si34249662pli.171.2018.05.29.09.35.02; Tue, 29 May 2018 09:35:16 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=muY7Rhw8; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936934AbeE2QeE (ORCPT + 99 others); Tue, 29 May 2018 12:34:04 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:45887 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936570AbeE2QeD (ORCPT ); Tue, 29 May 2018 12:34:03 -0400 Received: by mail-pl0-f66.google.com with SMTP id bi12-v6so9256995plb.12; Tue, 29 May 2018 09:34:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xvqcICKPdnH7YDbMpkUGH2z8ZbATaHWECsI75iXUXIU=; b=muY7Rhw8h8dvFO3rlQ3mUIFRdG9fwR5zp00k/f9dyKnqHy1YXksJxHhtuqmC5lrRSK g2rVzevjbP8pMPNDvyUQCEGZd0yyt730C098LCvvfIh+Yt28a307z3hF752as0OAAfH4 RlqfMIurVE20YGbn3XKPrgLLO+iSZCepipS8c799oqDyb46pt/Ak2/AwP4xUNmVaBkQJ 9++wewRzdaDX00DpEG4KBvGriSyU50qHrzprjcgauknAyV3nsyRUNmthrSEnimqEkCfU 4zrn1RIQHGzC/aIZAeBU9NFmK7XhGTErLrXU9pc+wfdB4OFVDWr7x9ubxbnJGbY8931Y VTAQ== 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:user-agent; bh=xvqcICKPdnH7YDbMpkUGH2z8ZbATaHWECsI75iXUXIU=; b=IwpUru8+ttAy/uuVJ53uobLkZD39lXeFezsl1BRIpSpqTUiVTQLKhjkfMkYgZP8sN8 QObrcVgUxZGnFSNwQsetv+QtmMPGo59jTnP1BaVAS64usHuwKfnm5SHkXOCCo1hDPGU8 7W2uozzeWzh/K+mvAQeNy9d2VSy/BScvdDnxEkpNikkUha26UxDKoWw/NYQIZ/nDItag 2bT/3ltuw7uDyj+kRjF4uUVp8rG8egc2M8xVVUuTsyi1GBK3MKSoozMZBfjaVLEVd2td eOpEK55U4kaboPWuB+wz5T4vvMnBO0lJcjMT7TmIXIUajaHnPCbMn2WegecQjeYJ/Bny 0tww== X-Gm-Message-State: ALKqPweeGa79qs5qS4BmvAya4ji+4EgkMm1v65lc9CKVnB1fY2a8TAWH 6OKnim6/8CzEZlVujJDJrXM= X-Received: by 2002:a17:902:b418:: with SMTP id x24-v6mr2935429plr.2.1527611642532; Tue, 29 May 2018 09:34:02 -0700 (PDT) Received: from gmail.com ([2620:15c:17:3:dc28:5c82:b905:e8a8]) by smtp.gmail.com with ESMTPSA id d72-v6sm65701043pfe.150.2018.05.29.09.34.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 09:34:01 -0700 (PDT) Date: Tue, 29 May 2018 09:34:00 -0700 From: Eric Biggers To: Nick Desaulniers Cc: herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] crypto: blkcipher: prefer strlcpy to strncpy Message-ID: <20180529163400.GA166256@gmail.com> References: <1527572683-26098-1-git-send-email-nick.desaulniers@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1527572683-26098-1-git-send-email-nick.desaulniers@gmail.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 28, 2018 at 10:44:43PM -0700, Nick Desaulniers wrote: > Fixes stringop-truncation warnings from gcc-8. > > Signed-off-by: Nick Desaulniers > --- > crypto/ablkcipher.c | 8 ++++---- > crypto/blkcipher.c | 4 ++-- > 2 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c > index d880a48..e38867f 100644 > --- a/crypto/ablkcipher.c > +++ b/crypto/ablkcipher.c > @@ -370,8 +370,8 @@ static int crypto_ablkcipher_report(struct sk_buff *skb, struct crypto_alg *alg) > { > struct crypto_report_blkcipher rblkcipher; > > - strncpy(rblkcipher.type, "ablkcipher", sizeof(rblkcipher.type)); > - strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "", > + strlcpy(rblkcipher.type, "ablkcipher", sizeof(rblkcipher.type)); > + strlcpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "", > sizeof(rblkcipher.geniv)); > > rblkcipher.blocksize = alg->cra_blocksize; > @@ -444,8 +444,8 @@ static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg) > { > struct crypto_report_blkcipher rblkcipher; > > - strncpy(rblkcipher.type, "givcipher", sizeof(rblkcipher.type)); > - strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "", > + strlcpy(rblkcipher.type, "givcipher", sizeof(rblkcipher.type)); > + strlcpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "", > sizeof(rblkcipher.geniv)); > > rblkcipher.blocksize = alg->cra_blocksize; > diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c > index 01c0d4a..ee88e48 100644 > --- a/crypto/blkcipher.c > +++ b/crypto/blkcipher.c > @@ -509,8 +509,8 @@ static int crypto_blkcipher_report(struct sk_buff *skb, struct crypto_alg *alg) > { > struct crypto_report_blkcipher rblkcipher; > > - strncpy(rblkcipher.type, "blkcipher", sizeof(rblkcipher.type)); > - strncpy(rblkcipher.geniv, alg->cra_blkcipher.geniv ?: "", > + strlcpy(rblkcipher.type, "blkcipher", sizeof(rblkcipher.type)); > + strlcpy(rblkcipher.geniv, alg->cra_blkcipher.geniv ?: "", > sizeof(rblkcipher.geniv)); > > rblkcipher.blocksize = alg->cra_blocksize; > -- > 2.7.4 > Hi Nick, this patch is wrong. The 'struct crypto_report_blkcipher' is being copied to userspace via netlink, so all bytes of it must be initialized. strncpy() does this but strlcpy() does not. I noticed that you're sending out some other patches replacing strncpy() with strlcpy() too. Can you please double check them for this same bug? Thanks, - Eric