Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp8596387rwd; Tue, 20 Jun 2023 18:05:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Qk1rgeZcmToklkkfVvnULhQSZD/twPkwidd0HVbJeC+nPmuqaDzjSwG/Z3u9YVBev9sgJ X-Received: by 2002:a05:6830:e13:b0:6b1:655b:cd57 with SMTP id do19-20020a0568300e1300b006b1655bcd57mr8041167otb.35.1687309514637; Tue, 20 Jun 2023 18:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687309514; cv=none; d=google.com; s=arc-20160816; b=XUmcxDbOaiM8p1+do9Vm2HWCG935/8HNlnIlwEElqXTp4dSnCgPcnDyn0JXHQTFMFA Qo9pwVDXA7nZ0lAq1uzLZ5QWD1ElFPAQxKTGIEANoUBrp5IpvdhltKuPVDdMdHP6M8uQ wn+sBP1ZW4KtKTBHN4F1c03ptZe5kTTApFqTY7LnNKUPjXODmLqU053TPKsdGTetCuKr XUK/hy+sX9e+3P/h+rEel+rQEseCnBIo13pq4CKsHFUy7aVxTjVwqoghJoVUUcBsoqG6 2tiKGkPokDQOUwkglrYniiE/5iaIi1lRQd3inb4OohRGd2UNqroG0enMcinHB9G7ApbW u9BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:references:in-reply-to:user-agent:subject:cc:to:from :date:dkim-signature; bh=oNWBDRKApdOLxdjKV1Rj6TJLCQPQyXjERxHyoSwvcnU=; b=rx6qCLwnEgvoivw+WKYM+209EgRjpTtGGzkbB55yLFCCOvpTq7xfr8dkB3W3TPB7aE jz1VpXzSUK0n1c8ibprBOu7M+nqjNMgWQ012nJCRQbGmHUYhnCvHTTvPFquQiRzdnbxI RwhI1Yh5Nd9JMVdQi6T4hgGMAo2msVuOLN/y2kCE98CR8xCTDpW763SX17grJ3ScBCTg fpIi+UPoGj/hAIELPruX/wayaIfTa1W9OXvnGBdCkAqauKpTALKyou1UXDvcRywtEAyZ VfVoJ+/x9qLcQEFk0bBAUAOtFAQjzJcnLsM7BYPVxEGLzbXBHDZP4Sl/vttr0iVxayuP NU2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uMSEWNGY; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t3-20020a637803000000b0053ff3283f5asi2654373pgc.599.2023.06.20.18.05.02; Tue, 20 Jun 2023 18:05:14 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=uMSEWNGY; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229877AbjFUAPG (ORCPT + 99 others); Tue, 20 Jun 2023 20:15:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229871AbjFUAPD (ORCPT ); Tue, 20 Jun 2023 20:15:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9DB71987; Tue, 20 Jun 2023 17:15:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 28CD8611D2; Wed, 21 Jun 2023 00:15:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A339C433C8; Wed, 21 Jun 2023 00:14:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687306499; bh=oNWBDRKApdOLxdjKV1Rj6TJLCQPQyXjERxHyoSwvcnU=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=uMSEWNGYINBquxtH48bJhslQuNw5lB8rU6TotOiezIQZUXsnhRwuNsFkK1saArPiS LYIMEoiUF6cU0Dbls+wLnKtP0uCUglXFIVj/PrB7NYMTw3PdZdNI/yQDxhGBSxQuNo PX8qN1SQYOkw/a1mUZyAylOpi/mv0sFmHz0Jv6dd9mk2XrNuso72qV+sNblQTDK1zC 1dpuWK/sBqieGeFe6ohug9/tjEBL48ZNbOKi40r7P9RnJ2ONKyDdoHvyfaKqGDhhNc 1BiqZxFS7IUTglt2ypYlBwLAQzoEKnCe2JaLwrveMCK+YV1pKv0TH7ENjXxZurq7ZB X6ITcbVMPPgkA== Date: Tue, 20 Jun 2023 17:14:57 -0700 From: Kees Cook To: Dinh Nguyen , Kees Cook CC: Azeem Shaikh , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] nios2: Replace all non-returning strlcpy with strscpy User-Agent: K-9 Mail for Android In-Reply-To: <40af3815-b0ee-e96f-f7a8-9f0fe9f938d0@kernel.org> References: <20230530162358.984149-1-azeemshaikh38@gmail.com> <202305301620.346CC541@keescook> <45ed31e0-9ecd-56ea-c0d4-3c68a3fd8cf5@kernel.org> <202306201313.C425BCB@keescook> <40af3815-b0ee-e96f-f7a8-9f0fe9f938d0@kernel.org> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 June 20, 2023 3:27:29 PM PDT, Dinh Nguyen wrote: > > >On 6/20/23 15:15, Kees Cook wrote: >> On Tue, Jun 13, 2023 at 05:15:41PM -0500, Dinh Nguyen wrote: >>>=20 >>>=20 >>> On 5/30/23 18:20, Kees Cook wrote: >>>> On Tue, May 30, 2023 at 04:23:58PM +0000, Azeem Shaikh wrote: >>>>> strlcpy() reads the entire source buffer first=2E >>>>> This read may exceed the destination size limit=2E >>>>> This is both inefficient and can lead to linear read >>>>> overflows if a source string is not NUL-terminated [1]=2E >>>>> In an effort to remove strlcpy() completely [2], replace >>>>> strlcpy() here with strscpy()=2E >>>>> No return values were used, so direct replacement is safe=2E >>>>>=20 >>>>> [1] https://www=2Ekernel=2Eorg/doc/html/latest/process/deprecated=2E= html#strlcpy >>>>> [2] https://github=2Ecom/KSPP/linux/issues/89 >>>>>=20 >>>>> Signed-off-by: Azeem Shaikh >>>>=20 >>>> Reviewed-by: Kees Cook >>>>=20 >>>=20 >>> Applied! >>=20 >> Thanks for taking this patch! I just wanted to double-check, though; I >> haven't seen it show up in -next yet=2E Is this still queued? >>=20 >> Thanks! > >I've queued it for v6=2E5=2E Do you need it in v6=2E4? 6=2E5 is fine, yeah=2E I just wanted to make sure it didn't get lost=2E :)= (I didn't see it in sfr's linux-next merges tree=2E) Thanks! -Kees --=20 Kees Cook