Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2279948rdb; Tue, 3 Oct 2023 16:44:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGWQogNqY5s/2lx4Jdbpq6fm9bhraPCdPxOCb/31bAO1X2ciSqQWAwCuebzIq8e7hddLYIQ X-Received: by 2002:a05:6a00:2e89:b0:693:3851:bd98 with SMTP id fd9-20020a056a002e8900b006933851bd98mr1061380pfb.2.1696376671587; Tue, 03 Oct 2023 16:44:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696376671; cv=none; d=google.com; s=arc-20160816; b=wbuynFNtB/ZWG2aMFmK41D0b3AnvQ0EEzNAkKa3TlgEf+xOfcQ3+9STQ7jD8uduqul Qmwgr8PmVBKk7SSvC4qw+RhALKFtS1j0w6iB/M9TM4WUBEOHAWoG5Rdn7ehlSQsabpLp /NrceQpKY6AAEYhEsC5mlS4EY/l7wluRQ8KDZVeLcLe0UMHi9LmQo3tjbvCcX3WlaWTA ubxs/d5/slwmlZH9hK/F8AhZjTXPNM+hfECR4rMEiJ5yLN2NPGoUCofGjP/sIUp9mU1i 1zco1P6rZPZOJar/w21tjf/jY3G5g48+plCYKcUdased5KjJO/pecVD350S5dzY99yDT OwMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=a4manyg4jn+tfLYFok6RJE4vtrYhKXlkYtdCzoyuohU=; fh=y5e5ZZDvSmILJk474EAYv6M6vdKM+zj/emx9dn6ir3M=; b=rHZI4fZpvBGGsYtgi9IwFNXS0OWw2+Xyu+XHALA6ZipNJLJWlxSuJvh1WBpQ27VH8l zzxPbAfkxjZ5d9/n0V6k8IEJ2IRnrXGhkHd78Ejyz7ge4Oi8OhWe29V5Y+3w0/Tx6GN0 /Kck4SqrVMS9BDoN4igNl9Z1KaFET4zOHbUY8Vrs0VR+b1HZKOlu+qxUuexsYaF9BuKZ vPgHWbGQnp/mEyOwijqOhdkIc6uzYTwrz+s/L5VRq1y6iv5zG+92pIMJi+aePgLYipt8 r93QcmCMLJ7t7G7B/Fxrfx05n6I9a7QmIS1XSMQwbxyIr8pnhQcoMujFivwE4hPWtndU N5zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="TmAyl1n/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ds4-20020a056a004ac400b0069022a03d42si2468291pfb.283.2023.10.03.16.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:44:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="TmAyl1n/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 23513819BB74; Tue, 3 Oct 2023 16:44:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237659AbjJCXoQ (ORCPT + 99 others); Tue, 3 Oct 2023 19:44:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236153AbjJCXoQ (ORCPT ); Tue, 3 Oct 2023 19:44:16 -0400 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA1C5C4 for ; Tue, 3 Oct 2023 16:44:11 -0700 (PDT) Received: by mail-yb1-xb2a.google.com with SMTP id 3f1490d57ef6-d9151fc5903so1611079276.2 for ; Tue, 03 Oct 2023 16:44:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696376651; x=1696981451; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=a4manyg4jn+tfLYFok6RJE4vtrYhKXlkYtdCzoyuohU=; b=TmAyl1n/eNsZtKfURDuoL2gUaXRF+rJFXEaqCV1I72bWyHKFuW2oHz/2rgauQL8BrG 8Vlhf9tgFn0MzonSCIdAK6qZDxR8I4slUj9+e5Cp5HZRDBYzWgT8osKyCAos/zJze+Ea jdBcMZjeROboH62HT5TehThLdfw78X2N6Nfw0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696376651; x=1696981451; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=a4manyg4jn+tfLYFok6RJE4vtrYhKXlkYtdCzoyuohU=; b=WiqL2tNL1EKN9X6PU0C0+WA8lDjoul2LTtgoRxUowTHsa1jC2HxGQsGyNpF5N0Eo9k AGrRNKOj+GfuNG3bWEJ3lf+2l2211UQoZ3CA4eiQy5RqetUArhMMNVTltedUowNcBn8L Rv0e1ospFH6k4CUB0xA1lGunu4SyAlrv5z4nVvkZA/rYgaWMmYEJv9qdgjq6vWwwfkrg GLKqLE7sVNwXzdrfpQ+Xx2uMcha9UnutyG89Saw91Z+Y+O/vr5+LSGoZdqMdwGujGMlH 5UTglvzOGRrmiEf4D+Ag0MhRnv9YttvvVIJcEVAFjg0M7gLK3ix7zqWnsXAhnHOArzaX c9Hw== X-Gm-Message-State: AOJu0YwASpZyP/dv6xURlRMrAy5Th1ZVuibAY2zx32t/F7DiG9q32dfD Ur3U1/NFVfamT/sv+XKoGLYX/Q== X-Received: by 2002:a05:6902:920:b0:d74:6c43:f32e with SMTP id bu32-20020a056902092000b00d746c43f32emr655844ybb.3.1696376651180; Tue, 03 Oct 2023 16:44:11 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id q20-20020a656a94000000b00553dcfc2179sm1735207pgu.52.2023.10.03.16.44.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:44:10 -0700 (PDT) Date: Tue, 3 Oct 2023 16:44:09 -0700 From: Kees Cook To: Justin Stitt Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2] x86/tdx: replace deprecated strncpy with strtomem_pad Message-ID: <202310031642.E858E955B2@keescook> References: <20231003-strncpy-arch-x86-coco-tdx-tdx-c-v2-1-0bd21174a217@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231003-strncpy-arch-x86-coco-tdx-tdx-c-v2-1-0bd21174a217@google.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 03 Oct 2023 16:44:29 -0700 (PDT) On Tue, Oct 03, 2023 at 09:54:59PM +0000, Justin Stitt wrote: > strncpy works perfectly here in all cases, however, it is deprecated and > as such we should prefer more robust and less ambiguous string apis. > > Let's use `strtomem_pad` as this matches the functionality of `strncpy` > and is _not_ deprecated. > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] > Link: https://github.com/KSPP/linux/issues/90 > Cc: linux-hardening@vger.kernel.org > Cc: Kees Cook > Signed-off-by: Justin Stitt Thanks for respinning this! And yeah, I'd agree the comment probably should stay. Reviewed-by: Kees Cook -- Kees Cook