Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp856852lqh; Thu, 28 Mar 2024 21:05:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXtsBzJcuFtrO9QjH1H7uP8sdZydFqymRqZYZ0x1ttCDyFKevwQCVQ0LuI+g94+yA4zqOuyTk+7OAwBd0kt2p8U5JqAu1FCljPUfb5bow== X-Google-Smtp-Source: AGHT+IH110cgQpzauE/zyvcsweQVsITh+IwlmaCdUnbw7yvpxoIVe2cJaXsnMz1YuFcUKKagY8zj X-Received: by 2002:a17:906:6808:b0:a4d:faa3:af20 with SMTP id k8-20020a170906680800b00a4dfaa3af20mr624834ejr.65.1711685100535; Thu, 28 Mar 2024 21:05:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711685100; cv=pass; d=google.com; s=arc-20160816; b=Hqelo+Ye87Alq579mLKnugs6SaZlTgi9fKMcnNPYZ2C3UyJy51dTfX81pomO/bfKST uRW0aO2J6eoibSn4VpyjupcjM297aDyJDgezneixIFglhHpgBzkfv+EajFG7LP0cH6vq mVBl2RHswYnxvqcSRBdoBH9jyE9G1DtQbjfHdS87gE+jPqse9o5mSusTu05kvU16LXKL APwkjC0hZl9xhnH7nJ0RpRtXjOkT9E1nPmJ3YMgIbkNJGdx+CgA30uTVFVMGwdvsqNsN P/NBhlCmOswjIDqX1gpPa8ZCOMs+z9JwMzWA5usGnQL5IITRE2lUpzHYnHgxDH68Q1y5 275Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=69VUW1JBrC64hXBRbspWF21+J8tNtsC9yt2uIqIg1HQ=; fh=RjC3SwPdViJK/jDEsHKnCqB0EDaME0R7embIV+ilt8s=; b=No1MHI2lLytuhlXE8KkbvOEb7QZ2KG2Wo2RbOnZufeguReb9L2ncu/6dmNsHZzt3l/ ZlNRdrRkuFyeCz3u64H1RTpx7SIlcYcm2yGQcGhuKCHXeD+6g9CcL6nYOdJir5cpekn5 I0C1o7+M2v8NEglx3AY5rNnmp9S+EOPARHTMSLtCvRNwDOzdgYulLjUiKvUcWD6pK1Ri EWrziVdO5aO+Fv1RnsxKdgyl7kPU8G/IGB6nS3frIRGvfOdJ800uayhb8zvQ9ySr0OsR gezIN2mMgvXfqfsaereM4WLsWdt4m4JSraWKdnt361kW7gciXP3hJ/mX8/wwu8AgsETY NjDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ARKkytZx; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-124104-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124104-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id sh34-20020a1709076ea200b00a4e26dd56b5si1053364ejc.413.2024.03.28.21.05.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 21:05:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124104-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ARKkytZx; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-124104-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124104-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3B05F1F22565 for ; Fri, 29 Mar 2024 04:05:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41DC33A1A2; Fri, 29 Mar 2024 04:04:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ARKkytZx" Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E0363B293 for ; Fri, 29 Mar 2024 04:04:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711685093; cv=none; b=KuJIb2PdOKHd9QY4Rvoe5cK8CoBkIMEk5OLDW75hZAS76LORxoUOXGy86kueshrasjGxTtZUfO7ViMmLrTN12Mnz4jufzWb4smKJj9yfC1EjLHnW46dXVLVatFRiW9OLHUilC4gDmoZCRc5GMUuD82NhD4uyjcryX/s0zvZ6Z5Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711685093; c=relaxed/simple; bh=fx75aDeb//DCFTHJW3dMQvi5gnKmJfUkKWLKThTPR94=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=orJcPK0vyAECBXa+lBuSZqXBQqJwpfwUC/RX5R8d2Tg6ltGQkTUHOxFfEcEdQSvTjz9H4GZ0ElbfcPT8e8qqMtGL4AUHhK4xpuCXBXH9h338bjyWGSEvhS8HeuXXAXpRu3j87aCttE0ZyWF7XK7YuwrSsY6pbaBkYL4YJnB9XRA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=ARKkytZx; arc=none smtp.client-ip=209.85.160.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-2220a3b3871so599452fac.2 for ; Thu, 28 Mar 2024 21:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1711685091; x=1712289891; 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=69VUW1JBrC64hXBRbspWF21+J8tNtsC9yt2uIqIg1HQ=; b=ARKkytZx7biCoF4FdX911rnJCexBt0iG+IlY+ojHC5xM8lHiSpUIq2CG8gJaeSlMWT nsPMe9VyQDwpIYZliclOQHQOr8os5bQJU+hkKiu5pDe0HCp7R83QzE1+NtEO/eFNqPUG JPNX8VuAh1HeKMTvaQyumwnHeGervw7jYlD3Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711685091; x=1712289891; 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=69VUW1JBrC64hXBRbspWF21+J8tNtsC9yt2uIqIg1HQ=; b=tMUjwftHfbhxqmgFLQf8lkryRh5kfsR4QfcrqlnUhCLmgx+Pz2n5pDSFc79abBcAQk hBJJxtyO85T6QXXYFvrCdiBfsFxubFhLxIu6jCFkA81VIn0Gw+HHWBZI09pwak6ld1u+ t20A7QVKfrWKbl18SD1DMuSHrHe4+40UEOIOZXRYj5MZf++SrfIWILaScLI7GOQlClzc qZ+6jNUetAhcN2XpiJZGufvMeLqLi+LhRGy6sQYHfmtbsAyJ9vQrlzIiOurCKzElfDK7 tqVWgMhE+83kS+d7kLOYShBnmkc60HihkvGabmhXcb7Lj3RRNjCTj001h66xO0ofz+jg tKiQ== X-Forwarded-Encrypted: i=1; AJvYcCV4m5VKt44jxDhQhxNWxJU464K8A/3MNm6dwedVh0TrJ3qHBQNItPLs5G18Yz5ZRcUDry4o3TSwQDdRBkbmP8Sw+FLOwyxslSvUFXZM X-Gm-Message-State: AOJu0Ywe0uBJISSHfe3U9dUH7T9IPYyVoxzOPAfGGfhZJkNGebOEglgz AenrpXSbqejJKrEddW450b88sXSzfS4uCqviQ5xpATRJqawUDOp3k6uO77/CFelqgoE1r9yE8Vg = X-Received: by 2002:a05:6870:c34f:b0:229:c1d4:83bf with SMTP id e15-20020a056870c34f00b00229c1d483bfmr1130237oak.8.1711685091224; Thu, 28 Mar 2024 21:04:51 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id q14-20020aa7982e000000b006e73508485bsm2159777pfl.100.2024.03.28.21.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 21:04:50 -0700 (PDT) Date: Thu, 28 Mar 2024 21:04:50 -0700 From: Kees Cook To: Justin Stitt Cc: Helge Deller , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] video/hdmi: prefer length specifier in format over string copying Message-ID: <202403282104.CC17451@keescook> References: <20240320-strncpy-drivers-video-hdmi-c-v1-1-f9a08168cdaf@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240320-strncpy-drivers-video-hdmi-c-v1-1-f9a08168cdaf@google.com> On Wed, Mar 20, 2024 at 11:22:02PM +0000, Justin Stitt wrote: > strncpy() is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > > It looks like the main use of strncpy() here is to limit the amount of > bytes printed from hdmi_log() by using a tmp buffer and limiting the > number of bytes copied. Really, we should use the %.s format > qualifier to achieve this. > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] > Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html > Link: https://github.com/KSPP/linux/issues/90 > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Justin Stitt Reviewed-by: Kees Cook -- Kees Cook