From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FDB1C7EE22 for ; Thu, 11 May 2023 16:25:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238800AbjEKQZv (ORCPT ); Thu, 11 May 2023 12:25:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237852AbjEKQZu (ORCPT ); Thu, 11 May 2023 12:25:50 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95CC83C18 for ; Thu, 11 May 2023 09:25:49 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1addac3de73so1360735ad.1 for ; Thu, 11 May 2023 09:25:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683822349; x=1686414349; 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=fBL8bhBy0L4WzzJgjFN8jfCCTqySRrwPrRB44wIqevQ=; b=OQgPu4YfTZL7qqqkSJj4wN2FQ1E0myYUr2GFLGfFuX6XttnvbpHBEg86DJXLw/zJc2 r5yBNAb5iPFZaPKz9C15Oc0wI6tD9mpl63JET8HQkFgrBl6aODupG7GbTSHEfekv9OD+ zfK69uhe02+gc+45mfBMcsowVM04C0/mv07TI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683822349; x=1686414349; 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=fBL8bhBy0L4WzzJgjFN8jfCCTqySRrwPrRB44wIqevQ=; b=YFCcCZMhy7hhNQcrOqc6zRxNGm1vcmVebG06egkyx9kysvSSZiptQEL0ZHwfnMiWFU LEKkNKzDKPj8aGUunXXsIrlFhFigSlu1IcHpqAqKB82cEdzZH6v4N8iDJEFev/tvPLUf i68DprJPro5G4iHvNrOfcvoneLheyMY2sczAjJaOvK9V/lh9rE3wACEHHPLeFq64zafW 7O9XYgc7BoPqcOkVxnGRkaj4IblMzL0PZPV2+yYn7NjYm9Tn2oNYbtF+/8/yOnAJaEwR 4EXEQxiQs5a6A3tMezwQt09nPIz5GFlvkJ/jkxW321yqgsCa3IgJ6r7nsHnQKCNLlzcY yaPQ== X-Gm-Message-State: AC+VfDwkonIbLflhvXwKQfNfEBXFLWFV2dTipleBO7mqhlDMEAzWmE7V XaaiXyd0tnCyUfYefjIQkrIN3Q== X-Google-Smtp-Source: ACHHUZ5YybjzuwHfar2HV5/lx275nqiclRLoLzKA8d50fZnsezq6TRfbkoiOP0AKkYFTBZcU2VXqSg== X-Received: by 2002:a17:902:c946:b0:1a5:22a:165c with SMTP id i6-20020a170902c94600b001a5022a165cmr27425021pla.0.1683822349131; Thu, 11 May 2023 09:25:49 -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 jh19-20020a170903329300b001ac7af57fd4sm6144610plb.86.2023.05.11.09.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 09:25:48 -0700 (PDT) Date: Thu, 11 May 2023 09:25:48 -0700 From: Kees Cook To: Azeem Shaikh Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton , Lorenzo Stoakes , Baoquan He , David Hildenbrand , Liu Shixin , Kefeng Wang Subject: Re: [PATCH] procfs: Replace all non-returning strlcpy with strscpy Message-ID: <202305110925.22DF454F7F@keescook> References: <20230510212457.3491385-1-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230510212457.3491385-1-azeemshaikh38@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, May 10, 2023 at 09:24:57PM +0000, Azeem Shaikh wrote: > strlcpy() reads the entire source buffer first. > This read may exceed the destination size limit. > This is both inefficient and can lead to linear read > overflows if a source string is not NUL-terminated [1]. > In an effort to remove strlcpy() completely [2], replace > strlcpy() here with strscpy(). > No return values were used, so direct replacement is safe. > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy > [2] https://github.com/KSPP/linux/issues/89 > > Signed-off-by: Azeem Shaikh Reviewed-by: Kees Cook -- Kees Cook