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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38B9BC7EE23 for ; Wed, 24 May 2023 02:45:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239173AbjEXCpf (ORCPT ); Tue, 23 May 2023 22:45:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239072AbjEXCpd (ORCPT ); Tue, 23 May 2023 22:45:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E9CE1B1; Tue, 23 May 2023 19:45:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E756860D3C; Wed, 24 May 2023 02:45:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0D9BC433EF; Wed, 24 May 2023 02:45:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684896322; bh=wZsIDsg+ZlPARQbVta0O5G6YiegJHg7H0ipQSG2Emwc=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=jTNxwaivk/NZdKnug2SNBU4Ics8ezPi4ZEwiivWwFOKJLpsp5dFgKCFNZw9qiEn1Q P8blR5A1UyOMpzt0vCKoEXHRjysnfot8sGsbCyUMjB1D3q1TgXHuVMfrlurKCNrW/x BUc5OdqqW3w5dkHkkV1lJsMwxunTkDET8GYfmdiZpXLgbMOewvMjQHdtsyEcmC5mJG UCiPV5p1AeOxNi1wBQYCbid7q7jJYpxnezxQu9RpPiug6KiAnea8BrOUZ2kVF6cyaI iCr++qGs5zYoKCIGhDGKPUSE514lRb9+DL2qJC1Rl9LJn4ODZmpOTSAXtbLl3t+nPY 33nps5+I+ITAg== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 24 May 2023 05:45:18 +0300 Message-Id: Cc: "Azeem Shaikh" , "David Howells" , , , , "James Morris" , "Serge E. Hallyn" , Subject: Re: [PATCH] KEYS: Replace all non-returning strlcpy with strscpy From: "Jarkko Sakkinen" To: "Paul Moore" X-Mailer: aerc 0.14.0 References: <20230518041513.1669386-1-azeemshaikh38@gmail.com> In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat May 20, 2023 at 12:11 AM EEST, Paul Moore wrote: > On Thu, May 18, 2023 at 2:01=E2=80=AFPM Jarkko Sakkinen wrote: > > On Thu May 18, 2023 at 7:15 AM EEST, Azeem Shaikh wrote: > > > strlcpy() reads the entire source buffer first. > > > This read may exceed the destination size limit. > > > This is both inefficient and can lead to linear read > > > overflows if a source string is not NUL-terminated [1]. > > > In an effort to remove strlcpy() completely [2], replace > > > strlcpy() here with strscpy(). > > > No return values were used, so direct replacement is safe. > > > > > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#st= rlcpy > > > [2] https://github.com/KSPP/linux/issues/89 > > > > > > Signed-off-by: Azeem Shaikh > > > --- > > > security/keys/request_key_auth.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/security/keys/request_key_auth.c b/security/keys/request= _key_auth.c > > > index 41e9735006d0..8f33cd170e42 100644 > > > --- a/security/keys/request_key_auth.c > > > +++ b/security/keys/request_key_auth.c > > > @@ -178,7 +178,7 @@ struct key *request_key_auth_new(struct key *targ= et, const char *op, > > > if (!rka->callout_info) > > > goto error_free_rka; > > > rka->callout_len =3D callout_len; > > > - strlcpy(rka->op, op, sizeof(rka->op)); > > > + strscpy(rka->op, op, sizeof(rka->op)); > > > > > > /* see if the calling process is already servicing the key requ= est of > > > * another process */ > > > > > > Reviewed-by: Jarkko Sakkinen > > Since you maintain this code Jarkko, are you planning to merge this > into your tree or would you prefer the KSPP folks merge it? I can pick it. BR, Jarkko