Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp857057lqh; Thu, 28 Mar 2024 21:05:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVY98E9AITWEecL5Q4+2JdOTtY7BbB2e2dqXvDRQWMYSjP2ey707j7Cxics0AZXDjRsu4JhW1pCjxr9tXJOVQNgIDKNT446r2SkQsAs2Q== X-Google-Smtp-Source: AGHT+IH7Q5l0oGW1oG9U9c7Y46TT5x+10NwcarPd5w8UhUosVLPPtLENRCERtmsWMzXm2CeX/XLY X-Received: by 2002:a17:906:ccc3:b0:a47:4b3e:a966 with SMTP id ot3-20020a170906ccc300b00a474b3ea966mr656878ejb.75.1711685140509; Thu, 28 Mar 2024 21:05:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711685140; cv=pass; d=google.com; s=arc-20160816; b=Ld1iId4DUCNWcgAH1p0rosNervWz0uNwHPeM4djhxO88QqOK15EfoJae0GEca2Vo+4 8zo/zniI1OuQspEBpZT8I0h/SmctC3Fc5bEc6LXBIR3jOJmeJvg/ZxkjCB2zP3xCAzpJ bef5rBEy+uJxJb5Qzr0wYstl7GaaRki0UfOqH6O0DuFMSKvFRx5ooWA0FOgmoHkSzMDZ 0sm2m3N8yIi8iRfG8YKXHsuVTKd/UIOPo22qRUjkI/4wh43H9HZPxcbOe3KG+mqowI/m +R3UklV/ChDFGMQXKMmTdqVBF4W9lbBvZRUupRc/7U7AUrYDbMywC37/VUv/R2BF+7ty 4LTA== 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=+BfIDju2MLKQM1ZH/SmKqeg1WOOWWWQIwZEViiqCej8=; fh=gbQZi84XUpfAQzWWLfCcjS5ZjuYsQ5J2iAQ4+kq7Ggw=; b=H0aHVPjO6p274jpF7zxVROG2HZXNUhUINK4qAPK6hfO4CxFX53h9cyXeliWPPd10H3 vxjsTk/iswRH4WGAW6npei7NCGK7fOTueVYqKAQXvDlV72/U6retj51kznRCEa5P1BqY 7NkkIFjBLFwAfHaTKBvDHa1Mpy+ZYpu3/96sIDOYW0/+ihB5KpPPNtF+3yEvIpeJFM5o 8fnUQaj+IeGjBOQtIaPpLuwQJ1e+nugPva2chsI1izsg760YRi7J3jKAydCqPoX2YrLc sX0UYJnN3mxpcE5zbWiil39owafT0XoJbeIsb9XmESyDW5AarGuHFTqK8u/hvbo5PL97 Picw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=F46zPyhk; 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-124105-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124105-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. [147.75.80.249]) by mx.google.com with ESMTPS id m19-20020a170906235300b00a4df7996a3esi1334214eja.461.2024.03.28.21.05.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 21:05:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124105-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=F46zPyhk; 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-124105-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124105-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 339121F22572 for ; Fri, 29 Mar 2024 04:05:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E74AF3A1B5; Fri, 29 Mar 2024 04:05:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="F46zPyhk" Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 BDFE6381A1 for ; Fri, 29 Mar 2024 04:05:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711685133; cv=none; b=YaS+9hGzoeHemt2lAh/u52pWX8zi6Yb5imdWiZZorevLWaWHSegLZc+R23+Py2x54ier2dQ1Vo0DncBrqejKI1oCFcOcW5NNHdIm1gdJN7D0ON+L2jbTYm29FYPYC6udxBG0NB9A+QMfoW/Cdtg2/swTqXjyuJearkigtDbbI4A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711685133; c=relaxed/simple; bh=oFGr6hCM3PzxNaylrf42uZzkAP51fUMJrt0ornlm2/I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZzHdlvxyGU8BY88Y9wJfv1RhbsgMXm8hxFth5v2EtWeKuZj1Fl0UoduDbpG+r2Tx/EZBbMlogSmdFR0x6DKDKl6i6IZZZdRpVzzBKMKl77zEtGXQZ2f130tQyjgdtg/zNi7eOtSufAH3VA0hOjOI9rFYRQ4tBRk45c8iCW3dGuY= 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=F46zPyhk; arc=none smtp.client-ip=209.85.210.172 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-pf1-f172.google.com with SMTP id d2e1a72fcca58-6e88e4c8500so1379629b3a.2 for ; Thu, 28 Mar 2024 21:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1711685131; x=1712289931; 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=+BfIDju2MLKQM1ZH/SmKqeg1WOOWWWQIwZEViiqCej8=; b=F46zPyhkiex/ObTJC0fXHTuWO3KfNC1hSQ6fdU/Y68yuIDiWcD9pM+I/i1VDZNjKVp kIgeEL0TXlnOZ3gsHiHR5xyJLHIbQR2jKO3Tb0CPa/ZJsq3MZvauGQjpXqZNahENgr7s y4f/Q4L3Cp9idb9VUSGfPnNbJxIawZUCtMqQo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711685131; x=1712289931; 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=+BfIDju2MLKQM1ZH/SmKqeg1WOOWWWQIwZEViiqCej8=; b=JbX2WuAAd+brfWS/TIPB31cIa28fpmAJPYH/+0KQ05Z/T1K+WIBiyt0NnboBbBUOG/ qP3HNYXwWapvbD9LXKfe5j15/ezw+RE2uyWUWIM4RJezU8XCP2cESEC3oL+eQBc+E055 eTQSPITnSyQocfOfsViwy6Xer+tDut7nYtxH5ju9Nh6htrsZHLqVOBB97nJPt5cUYGRT EE1/aKyalZCp8kBbSFXhzVVMBJLUXFTd3THofk/ysQZhjmiJccQHLzEb0jPIITldpW83 v3M73AAh/4ob+NFNVBTzpk16mGtAgezumSbMw8PwqMr8Eezn+8U8GIWYWnm876noRoZ7 GjIQ== X-Forwarded-Encrypted: i=1; AJvYcCUglcOmWA86dVPyBG2DtQkZQoqt5dPrFnF/S/ZpHA8Ya6pz/srgPXI1GBLFgFImpNY2W8bq8TAkCswZVlBOXuVs8TbIsCdPCEEC42g+ X-Gm-Message-State: AOJu0Yy2KBPqWVqVQJQE3ZX1xNrE2KmmADwerPEVYIdLx5/Tw0bpCgrF qB6coxUJqhBKAPjw6Wd15xaVm/6HEfVkmtMN/Wdons73YDN409AntIWJ6EhQfQ== X-Received: by 2002:a05:6a20:d396:b0:1a3:aea1:bc7d with SMTP id iq22-20020a056a20d39600b001a3aea1bc7dmr1177152pzb.30.1711685130989; Thu, 28 Mar 2024 21:05:30 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id f15-20020a170902ce8f00b001e0fcf995easm2458362plg.202.2024.03.28.21.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 21:05:30 -0700 (PDT) Date: Thu, 28 Mar 2024 21:05:29 -0700 From: Kees Cook To: Justin Stitt Cc: Michal Januszewski , 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] fbdev: uvesafb: replace deprecated strncpy with strscpy_pad Message-ID: <202403282105.574E19BFA@keescook> References: <20240320-strncpy-drivers-video-fbdev-uvesafb-c-v1-1-fd6af3766c80@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-fbdev-uvesafb-c-v1-1-fd6af3766c80@google.com> On Wed, Mar 20, 2024 at 11:04:44PM +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. > > We expect v86d_path to be NUL-terminated based on its use with the > C-string format specifier in printf-likes: > | pr_err("failed to execute %s\n", v86d_path); > and > | return snprintf(buf, PAGE_SIZE, "%s\n", v86d_path); > > Let's also opt to pad v86d_path since it may get used in and around > userspace: > | return call_usermodehelper(v86d_path, argv, envp, UMH_WAIT_PROC); > > Considering the above, strscpy_pad() is the best replacement as it > guarantees both NUL-termination and NUL-padding on the destination > buffer. > > Note that this patch relies on the _new_ 2-argument versions of > strscpy() and strscpy_pad() introduced in Commit e6584c3964f2f ("string: > Allow 2-argument strscpy()"). > > 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