Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1483799rdb; Mon, 2 Oct 2023 10:51:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKX88QjisBvr0ILLbT10hzqtQmarQFtl+3FJpFOr+uHVD+VtNVTbd0KBQH2GC/KG5b+VyQ X-Received: by 2002:a17:903:248:b0:1c6:636:e40a with SMTP id j8-20020a170903024800b001c60636e40amr12746006plh.14.1696269070993; Mon, 02 Oct 2023 10:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696269070; cv=none; d=google.com; s=arc-20160816; b=ADTA+d+OQjbjnGWB0Z3Udb9SomftIixHeLx/pKVyWCEV6Ij8vUSpIRWXgjG8KqOG6b ya/dmCYtEUW+xpvlwApDpU92DoezLFNMDH+NgYrQqnmvCVD44QouiD70q0SXy+lH+S7H ct8fToUarJ6G87K1KrAUzS3bLA4oh9OwRjYqzoGAZVdvGEYNSnQ3oOp3w4VZMJNZbZBA /LdNbIO+3UWVG/KtookYitJ2XFDggJ20aN7uInzp5R7N+DLvYP0GnX1rbzJAYXRjXHz/ g2tdqH5fjAM/BfPBM6wFtzJh59SIoJh4YYvE9Csk5GCoqEq48eGZrt4XaI0FgVChyCVH nTKQ== 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=TpVKVfOllcQbS/ZFFzm5rvtMjeszAGVS8sUGlEYlZ2I=; fh=j0lO7Te/OhW4IC4gpJLJrDYEwNJZIp/H/q2RGUDkjXE=; b=DrHYW2IgaY7thSR6ZQ76VlsV/M3HpnawwxBIeD6Vad4QOLOGunXwFN64Md3AeKa/Qt nbgXVy2y5zjIX9dg5fkvaCnmSjps3daiuVvaNQSpclQ9Fqc+el+tRFjSUXNKb+6pmqAL 59klpzN0Svabf9fFsgGHFJ5h455ki4wg2b7cLM5AlvF8ZU15/f8rXmcN6l5mfzFxSPYy BELwqhFp+gA54Yf2ThfdVQRh8XvKZmvOmrl4G50TYXCTX84H4FaeespQDHTphTtNtuJ0 mLu8PV5BGzd/72nWRoiOvrGoguNmxWBU2fnRNY3CMKVmWTmoGh87T1UXhN9aF90+llcZ XqEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jJGgYRZM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id a14-20020a170902ecce00b001bdf67d6a8fsi22761012plh.40.2023.10.02.10.51.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 10:51:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jJGgYRZM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id D29E280253AD; Mon, 2 Oct 2023 10:40:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237984AbjJBRjv (ORCPT + 99 others); Mon, 2 Oct 2023 13:39:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbjJBRju (ORCPT ); Mon, 2 Oct 2023 13:39:50 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B97B99E for ; Mon, 2 Oct 2023 10:39:47 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-69101d33315so15649b3a.3 for ; Mon, 02 Oct 2023 10:39:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696268387; x=1696873187; 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=TpVKVfOllcQbS/ZFFzm5rvtMjeszAGVS8sUGlEYlZ2I=; b=jJGgYRZMWi7/h+uboTMzxc2yPPkE10cMGTYVEXhsFt2bC1/qav9/U/CeayDNt866bJ 7wxKkpEModSLt2jVVYbuP5HLYH5itIzjpPcY2/CELldUwMheB66irN3MoodZS14uGciM 1La40tt6mBl/BuoiFFqXPUllNVzhGdoWjwc0E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696268387; x=1696873187; 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=TpVKVfOllcQbS/ZFFzm5rvtMjeszAGVS8sUGlEYlZ2I=; b=XtPAC4aUbxApSM7o/NNnfFDHw3kGj/P75BR9A9UrMhm8/CfJaaIQrVBsQWzqS54kn4 prFuGX0xAS6OnrWC3JDV4o6h4CPaW8K/ozz6zqOpTGtIhmdZwybuhcxYjwNCvW0DsCpy S+O8jHmZw+IEDAwhW5MPNXvx5JqQorWqej3Ei9lC0Iml9Akoc47bCIXejaTkA9wcGq83 o4/UProZKvGyih9JNzrKZ0mMg6SFmfO3kjC16kaD2gkhrpMvLqjYvpJFNWbKJeSSqmX4 zwibQUxt0SoBuI5rQVjWVeoV987fcMX4UmbT8thEBTO+Y3YExA6PqOKjwXpHT82ibIi/ F/LA== X-Gm-Message-State: AOJu0Ywy7Xoa86EiW6XdNkOrroLRqmu7sIDALR4vMQr0+2JEQwc/81OY v6wKDi35Dt8N4w0ph22gNKY9j+xuRkF7rhZOlOY= X-Received: by 2002:a05:6a20:948c:b0:157:7568:6796 with SMTP id hs12-20020a056a20948c00b0015775686796mr9204380pzb.60.1696268386709; Mon, 02 Oct 2023 10:39:46 -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 a6-20020a170902ee8600b001c55db80b14sm6404674pld.221.2023.10.02.10.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 10:39:46 -0700 (PDT) Date: Mon, 2 Oct 2023 10:39:39 -0700 From: Kees Cook To: Justin Stitt Cc: Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v5] hwmon: (acpi_power_meter) replace open-coded kmemdup_nul Message-ID: <202310021039.C13E217@keescook> References: <20230926-strncpy-drivers-hwmon-acpi_power_meter-c-v5-1-3fc31a9daf99@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230926-strncpy-drivers-hwmon-acpi_power_meter-c-v5-1-3fc31a9daf99@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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 02 Oct 2023 10:40:03 -0700 (PDT) On Tue, Sep 26, 2023 at 06:59:15AM +0000, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > Let's refactor this kcalloc() + strncpy() into a kmemdup_nul() which has > more obvious behavior and is less error prone. > > 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 > Signed-off-by: Justin Stitt Thanks for continue to rev this change. This looks much nicer, is more readable, etc. :) Reviewed-by: Kees Cook -- Kees Cook