Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp476916rdh; Sat, 23 Sep 2023 20:57:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHe1+6g5/8N5Wm48/TeDZSH8yMpd6N3y4X5g5i8+RsJnLkWG1BFmekPWwUu3hggjtiQaTj8 X-Received: by 2002:a05:6870:d68c:b0:1d1:2605:bb0a with SMTP id z12-20020a056870d68c00b001d12605bb0amr5309412oap.26.1695527878408; Sat, 23 Sep 2023 20:57:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695527878; cv=none; d=google.com; s=arc-20160816; b=hd0/EQovu4hZh+y3mVqK3cYv3BHsASgLmseW6RfRTJQTy4wAPYmV0MeYEAllFlzosC HSfK5/Qq49qhcZNnQQpC3f7rPXxXJuI27WQwc0h3aGPRsJ+TRSRlZzW1yQAZ4f2tnhsH Ye2WluvbWTPY8vrI58+1aZ7ZjNmKgwM43eGZqGGGwbHSEobCb1CwMCkRp3WlXZzFXetR V4aKeBFMGvxO45U9Yzy/kaxNubIlM55sJtM9iPAoF8gceKdGUU2WzW6hs9hQpdKTSS09 YSW75toEux1IOkU+3gdVTq8X/Co03nU/qp9XB5gxIdeA/tZCM+/I1XoTpJHTa9bNjssW Zf3A== 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=qoxOpoYwwbcXvP8AhdHBWCEQ7XvmIo4NgjxEavDKJS0=; fh=RyPj9z4SW3AdsMguhuP9vAjcBLIaDZcw5a4HP/zQad8=; b=hZ4PvLGuWuxK8P+GDac7aZ68QPrOkDBeg28Z5u+FXyYAk8f8qdUyzHnqKUgjw1Visk iXclUUy+Arvg1hOl8tUp1G8VNOYUjpuJLQob9Gqcx1a0e7JIVWh75EDt7GDZPgKNFz7+ k7XC3McnRVtiTexbMG83Fuurs4+8WisswItmCxSZOJV7k0jeyB+NjVwEOy7hosDcxt5Z rG2qA8zvuSWMgbjra3Utz5ijdZfMApUjetCLdRdnuc1Vhg05GZmw2i+rk5POvkzE6oKa yLguqwxPq8OPWrFTNIsYqfKD0KKyH7DQn7RJEtHBcis+/CVyrgJRdkizDFTaJkUVbpkF IpKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R7+78uPj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ki12-20020a170903068c00b001bb23874273si2223211plb.220.2023.09.23.20.57.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 20:57:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R7+78uPj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 2B7C18313016; Sat, 23 Sep 2023 19:52:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229757AbjIXCwI (ORCPT + 99 others); Sat, 23 Sep 2023 22:52:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjIXCwH (ORCPT ); Sat, 23 Sep 2023 22:52:07 -0400 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 896F0127 for ; Sat, 23 Sep 2023 19:52:00 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3adc3d94f66so2956572b6e.1 for ; Sat, 23 Sep 2023 19:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695523920; x=1696128720; 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=qoxOpoYwwbcXvP8AhdHBWCEQ7XvmIo4NgjxEavDKJS0=; b=R7+78uPj1vsN9ArLH0OMzIGPyTzfVp7iVwptGLxavDM/4VWGPINkimkMWDGhYsJLLA KPLMZ/osNzryQT/bOFE2YrFLhsv5W1qWrGIgc+K6wycrLBQMNxtGOYN15t0Ewsl6cHcD nCBea44ociJPStjlivuIrUJ/jNR6rTgPiY/E0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695523920; x=1696128720; 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=qoxOpoYwwbcXvP8AhdHBWCEQ7XvmIo4NgjxEavDKJS0=; b=w1Te6wprrAVXM4iYjgrXgWueB0BnxU+mQqgB08alrTOUuLxtmD4wx0BXBEs7gpKbwq uCc7hjtzZzQJpfris8MgXAWGsgndaFcdEhth1qPzBwd3W0pyDGSmMXSKmOWty/ry+aZN 75AQ1Q6qiBI9Z7Txrqeupg18eJMLGzTLaZhB9Z13l4veIx18ZDJRTT9c/oQDK8A+AlCq dI/YH3DUO6GpKdRHCvwNBNt8WvD23YClUyhghUQ61Oh49xEwG2tXrQrxatNFFDGIDEXz eCrTeQAxlS/zjFNEDQH4ayrkwbDPx//2Un+0CTzKRac9vUtEnm4prOvT2/XMhQX7BsE4 uEaQ== X-Gm-Message-State: AOJu0YwLX5WYm86AfpT2mXTbquXi7hwqnqqhNSVWow4puALhRxwS+Tjo 9OwtBmI4i66wmOdc3kj+6sJO/w== X-Received: by 2002:aca:1c14:0:b0:3a7:aa1:f883 with SMTP id c20-20020aca1c14000000b003a70aa1f883mr3738720oic.29.1695523919867; Sat, 23 Sep 2023 19:51:59 -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 jg13-20020a17090326cd00b001bba669a7eesm6038250plb.52.2023.09.23.19.51.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 19:51:58 -0700 (PDT) Date: Sat, 23 Sep 2023 19:51:58 -0700 From: Kees Cook To: Justin Stitt Cc: Borislav Petkov , Tony Luck , James Morse , Mauro Carvalho Chehab , Robert Richter , linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v4] EDAC/mc_sysfs: refactor deprecated strncpy Message-ID: <202309231950.698026E687@keescook> References: <20230918-strncpy-drivers-edac-edac_mc_sysfs-c-v4-1-38a23d2fcdd8@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230918-strncpy-drivers-edac-edac_mc_sysfs-c-v4-1-38a23d2fcdd8@google.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Sat, 23 Sep 2023 19:52:14 -0700 (PDT) On Mon, Sep 18, 2023 at 07:47:29AM +0000, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > We've already calculated bounds, possible truncation with '\0' or '\n' > and manually NUL-terminated. The situation is now just a literal byte > copy from one buffer to another, let's treat it as such and use a less > ambiguous interface in memcpy. > > 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 Yeah, I think this looks good now. If a v5 is needed, a tiny improvement would be to update the Subject: to "...: replace strncpy with memcpy". Reviewed-by: Kees Cook -Kees -- Kees Cook