Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1883328rwd; Tue, 13 Jun 2023 16:06:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ69gAzkxiyUuVeakSCvKqWVo2f1H1FlFCQgOhUfrKINaKOH9lzIrsN3RFsGJdI30OWACbGP X-Received: by 2002:a19:5012:0:b0:4f7:6650:17be with SMTP id e18-20020a195012000000b004f7665017bemr46145lfb.24.1686697588911; Tue, 13 Jun 2023 16:06:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686697588; cv=none; d=google.com; s=arc-20160816; b=BOZHSNCYt6tC9ojTHq9xFf4OtFImefRSlzSuYK/Pa/NYk0yHnFm5Ln9/DhZzicI+Gh X0N4Ybr1h/Y9rkgj3I0GSc5oIbpHb94SewL4ttASwbvImy8mO7rf8jHfoH3b96PZqrcZ uQ0Mf8v4gp2A2gwWRIY2faGRy+i2smWSuDEgm0ADOmuOrGaL/YS9GSX7GAmhhCeBjlgf m21PCmvsjNDG199rvvPMJZhPD4xXMerEjrw8BZyy1DkSivrsRkuazwX8YBIlLwWK9DMJ OF9KQ0+/a9VHeLc8zWdrq4PYLFOJ6kzP99Hk+kkkBJ8GSfsj9uSk2QYgeqoi5047Xfi5 CytQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=4wVDaEG7NefFklJ8bsVFHaxxRZwpXAR9OIML7rXBezU=; b=Wr8wuU9SgA2WWpOZ5oMbcrCKC39sZ9hrfFVx7MElnQxL7aX6JOKYbJIDw70U7HIn3G zg5XS9CsMVd1A3dVB8cbhYKtwvnpd/atM+VZbklAk1sZmXkx7/83158h1ypL1TjVLxhr 2ys2qTl/0dXOPteHl76XR9KJzR02vBsqGOSAVJMMguHfqqccGhxJyU9JF88BoPJ7rJc5 M7HUAUD/1AYcNtVH6iAOZQsl20KSf+xZj2nky1ODsMhm5nTEcxjr9lUxdEe/GrUBdOcj nf7GaRseMGILK5PgWS5RaHCt+9Yfz87VlHjRXRBvVmyrUftILSpQXAZZOf1qbMwIe2uZ YPcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ob8kwTkj; 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 a6-20020aa7d746000000b005187bd113bcsi504213eds.354.2023.06.13.16.06.02; Tue, 13 Jun 2023 16:06:28 -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=ob8kwTkj; 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 S230456AbjFMWPs (ORCPT + 99 others); Tue, 13 Jun 2023 18:15:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230017AbjFMWPq (ORCPT ); Tue, 13 Jun 2023 18:15:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 816B719A; Tue, 13 Jun 2023 15:15:45 -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 65DC062012; Tue, 13 Jun 2023 22:15:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 522D1C433C0; Tue, 13 Jun 2023 22:15:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686694543; bh=qcO5Gh4O8Q63aCjwkm3HeTPqucX4BuJEg4NLQuZYNpc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ob8kwTkjuXGGi6Ir+cBZ1TDTBMLhGcEgvPTwUfQ5At2Zag3f/sFmki0LmICMkwBWc Elp6J1hDCTuWwXfRdxul3qMkFO0IipYBWKT7FhFAHFvbt3e5MmUwiIoITaLIpI5YYN jkiuUwgayewfKYwrDY6gK0vQKuPmWpc/4FD1IwzRfVJ/4+Re290rRYoBSX5kkqs8cQ H67Kr+zHf13r8/g2+lSew1fzVgkjTsp8/Jkzmp+kN4hA9QCsf/Ia/WjUYRMB1gTcc9 8HGzRfwQciNi0UjYBbM2bVsrTMcVLK2p+KieuBu26DJEupIsYDPy0t5CNQb41VqRze nV2Un1I/YgENg== Message-ID: <45ed31e0-9ecd-56ea-c0d4-3c68a3fd8cf5@kernel.org> Date: Tue, 13 Jun 2023 17:15:41 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] nios2: Replace all non-returning strlcpy with strscpy To: Kees Cook , Azeem Shaikh Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230530162358.984149-1-azeemshaikh38@gmail.com> <202305301620.346CC541@keescook> Content-Language: en-US From: Dinh Nguyen In-Reply-To: <202305301620.346CC541@keescook> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, 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 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. >> 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#strlcpy >> [2] https://github.com/KSPP/linux/issues/89 >> >> Signed-off-by: Azeem Shaikh > > Reviewed-by: Kees Cook > Applied! Thanks, Dinh