Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4873666rdb; Fri, 15 Sep 2023 15:21:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkVugPepFaxkD81+fsVpwxgMG+d/v2pb36eIc1BjCbFs5xgv/0wSoHq4OX1P+hiyo7blmE X-Received: by 2002:a05:6358:93a6:b0:134:e549:50d6 with SMTP id h38-20020a05635893a600b00134e54950d6mr3419239rwb.10.1694816477732; Fri, 15 Sep 2023 15:21:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694816477; cv=none; d=google.com; s=arc-20160816; b=vgq+jc/qwft+oM34a6CWVATAoBRkJO0i38j6+570he95TG7UbBjzD1oHCQJTXkjqJc CN04UY3AbMfV6f2XJ12SpXgnfiPEhLMFK7d6VZqV9KZaXmFkQSXK821LOCn1wTV1RSUV LBlsNNtIquQ5ZJeLtcVL4isQbRk+LmP9YWmQun8ofe4JiEcshLlNaqrZPaTjEpXmLb6b xjyi9tnVswK+qoYtdWwK8nxV1ks8pELHuzCLPjLQEeKjDY4rYYrgab8qSeFUVtcEEOc5 9/j6aXZnqOFowH6q+GhljKh/OoTAud7HJKyehp2kT1ApN9m3feW1SX6Dbo8VuKR3B0Sr 4ShA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:organization:references:in-reply-to:date :cc:to:from:subject:message-id:dkim-signature; bh=3iRbWt1YTt0h4sdUmK03Vi+q52/EZN5SzHkBsDxopwQ=; fh=tQFpNHfz9z2Xwub0zZiwKowc0QVbwoaUYH+4On7mJMA=; b=G/T1r/FBqdAYUWaQPqSvB0cQ0TFCzhW8es1Em7NHrkaskEq1H0/+kBtdUPfAMEOWSX ccby9NJ00n/Mpx/0vncGlteJlojhapaCcg58G5NeGlhvTNqUhf+TnINWca6wLzFmEsuV 4KK7heZ1IHV7egckCQfdROPb+5ocfi9Ds7sYGUMIg6ekx/S6rVWESPk8O8gzuL4Ev9sf N83UXhZp22VpcB9KdQRVmOg4jW0GWRf9BgXhDIqCRmuS3vwsSn3hwNSmjM9Tkq4a3Ufj XPDYAsgGh/m6XkWJosDct98V7k6uS0Ih9O7iEQatVJl/YdQvuL4zD6eO29wCq7P/Z6nQ hMig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=biVaaXNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id j70-20020a638049000000b00573fe94635asi3883389pgd.642.2023.09.15.15.21.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 15:21:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=biVaaXNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 95B4080BC13C; Fri, 15 Sep 2023 10:36:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234048AbjIORfh (ORCPT + 99 others); Fri, 15 Sep 2023 13:35:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235386AbjIORfM (ORCPT ); Fri, 15 Sep 2023 13:35:12 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 95D293598 for ; Fri, 15 Sep 2023 10:32:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694799174; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3iRbWt1YTt0h4sdUmK03Vi+q52/EZN5SzHkBsDxopwQ=; b=biVaaXNg3dY2s0Fcp5PeLWFiePscsdY4wZvaY8ZdVbFCiAVGMGLJD6DahQWdVZPrO4hdGx qTrT/Ob4KujIjGtYVijVWmctXzux/E94bVN2f5D45+LTFT+AvSPf0It8KDlp25YW9Dc6Zd bYBZJgC4dJi4R76+8mctdM3AzZUw30c= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-214-mHrvW0HoPWCC-7YGg1CGoQ-1; Fri, 15 Sep 2023 13:32:52 -0400 X-MC-Unique: mHrvW0HoPWCC-7YGg1CGoQ-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-76de9c09746so323402885a.3 for ; Fri, 15 Sep 2023 10:32:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694799172; x=1695403972; h=mime-version:user-agent:content-transfer-encoding:organization :references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3iRbWt1YTt0h4sdUmK03Vi+q52/EZN5SzHkBsDxopwQ=; b=lSviokKHEJWgUzux3u0q7D3QsVqW2h/v6NC4XUT4dmb017OJkMbuQiN2aohpsEDjLd XYG42QgLzcpvS/oU3mPH/dwHHK1fqrGGc+aiDuz2enKF1Q5r3NPJZregso2QlQxMSHlL uVr1VmPyUoKKrFdWTsMfx7yJw9iO3pnVd6uzkQxXEfnnB32iWMhbQDd3Fw6yq7ReDN+T 1P7eNaNTBmHto/iemWkrVALL6CCVWOBVyNLWMsqKJ6yxRcuX0B0VRbz9/Hw+Px5ZTMxO rUYID/4p+z1SjrNcyGEZRYJc3EU4q7694kf0oFR7yohq2pRercO3IQaaS5brbPe2CYgQ o0tg== X-Gm-Message-State: AOJu0YwriRf2KTCUq7MpSIFufi9+e6fdkH9h1qvSmYJz+E0oXxVBm0G8 d47nk7GqgyWTtbYxuG+qmj69QGe5dbiIyTJF9ocJgMK5w1KjsMAk1m5khiIj+3BvCF4jpCebaV9 oAinRZaVQpiFsmL/01fD6VHJ1 X-Received: by 2002:a05:620a:450b:b0:76c:a9fb:6d07 with SMTP id t11-20020a05620a450b00b0076ca9fb6d07mr2820431qkp.2.1694799171852; Fri, 15 Sep 2023 10:32:51 -0700 (PDT) X-Received: by 2002:a05:620a:450b:b0:76c:a9fb:6d07 with SMTP id t11-20020a05620a450b00b0076ca9fb6d07mr2820408qkp.2.1694799171623; Fri, 15 Sep 2023 10:32:51 -0700 (PDT) Received: from ?IPv6:2600:4040:5c6c:a300::feb? ([2600:4040:5c6c:a300::feb]) by smtp.gmail.com with ESMTPSA id pa9-20020a05620a830900b00767d572d651sm1364433qkn.87.2023.09.15.10.32.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 10:32:51 -0700 (PDT) Message-ID: <43da274f22acaae8b917f51f6e62376928163e8f.camel@redhat.com> Subject: Re: [PATCH] drm/nouveau/pm: refactor deprecated strncpy From: Lyude Paul To: Kees Cook , Justin Stitt Cc: Ben Skeggs , Karol Herbst , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Date: Fri, 15 Sep 2023 13:32:50 -0400 In-Reply-To: <202309142158.59A6C62F@keescook> References: <20230914-strncpy-drivers-gpu-drm-nouveau-nvkm-engine-pm-base-c-v1-1-4b09ed453f84@google.com> <202309142158.59A6C62F@keescook> Organization: Red Hat Inc. Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 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 pete.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 (pete.vger.email [0.0.0.0]); Fri, 15 Sep 2023 10:36:13 -0700 (PDT) Nice catch! Reviewed-by: Lyude Paul Will push in just a moment On Thu, 2023-09-14 at 21:59 -0700, Kees Cook wrote: > On Thu, Sep 14, 2023 at 10:17:08PM +0000, Justin Stitt wrote: > > `strncpy` is deprecated for use on NUL-terminated destination strings [= 1]. > >=20 > > We should prefer more robust and less ambiguous string interfaces. > >=20 > > A suitable replacement is `strscpy` [2] due to the fact that it guarant= ees > > NUL-termination on the destination buffer without unnecessarily NUL-pad= ding. > >=20 > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#st= rncpy-on-nul-terminated-strings [1] > > Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en= .html [2] > > Link: https://github.com/KSPP/linux/issues/90 > > Cc: linux-hardening@vger.kernel.org > > Signed-off-by: Justin Stitt >=20 > The "- 1" use in the original code is strong evidence for this being a > sane conversion. :) >=20 > Reviewed-by: Kees Cook >=20 --=20 Cheers, Lyude Paul (she/her) Software Engineer at Red Hat