Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp435853rwd; Thu, 1 Jun 2023 02:15:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4CR5SlRvO6/xo2ny3C3t5HIMIsK9e/w2zxs6J6V6i0AEjKb0//qfmZQGnBVGoS+TVwXvQY X-Received: by 2002:a17:903:1c8:b0:1b0:4af9:903d with SMTP id e8-20020a17090301c800b001b04af9903dmr8957434plh.66.1685610954925; Thu, 01 Jun 2023 02:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685610954; cv=none; d=google.com; s=arc-20160816; b=w/D/vlZNmwGeTKXH7TOB/agrUS9zzwTDoxHFWIcJu6BXkU6sIifLQ062ah4oSJIEaj zOR5jkkGKOVPV0UwrIv7jGEYNTA4p0y48mr6IWUS/aWJzylhuNhtlh2UzqBVldvCeb3h UOHYs0oJP7X3qX4Ynx+06RItDWEJP14DWRDBj+G8Tv5BZjYr4zv8+FSS9bdwqeZ0ReYr VYcX8TO4dG/+f5YLpyVXeaggaLCHPbnHXXXmyrAAIBzaHM00bLLJBLxFiCbEe+NXS6GO T7zFyt2LtAfT/LSG9rBtny/6LP4+vjMW34m+v3mQkoz7tup598u79PDwryXv/9FDJHIL BCUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=+YUAD//YlVKY5+gBa+79P7cJwXwdOQ+Jp7VlD1PAbyo=; b=I4tnMC6ub7VesbSG77UO35JUqJkCwYudvpk00ExMpcizG4Zk2ffluc35MpJO68CVBt 9RtJ4Y6s+oRJ0L17i1babbiVHwtcd7Oa/Ez/ngb0tcMAjdXmPdJqjIIkV9JxLcabUhZ0 VYznkz4ul4ylEZ3dIch14QhBxe4H4Ev9Z6F9sFQy7coYTqt0UGIYCPP4QmfKJAqlNwV9 bPMpZC13THifTPlImZRkSkn7wAMMItfRtNDIe0RcDyUeZ9F1aKRKASpLq40d6y8MHdxs RICTHcBJhkK0n7mzF1EmcnYFpVbNWWulAK9IHOFS4aCDZE8IdJeiFrau1Q56ZFc+ecSI SXRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P4bEPbdd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id je20-20020a170903265400b001a6fe422894si2363114plb.200.2023.06.01.02.15.43; Thu, 01 Jun 2023 02:15:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P4bEPbdd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232360AbjFAIhD (ORCPT + 99 others); Thu, 1 Jun 2023 04:37:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232210AbjFAIgR (ORCPT ); Thu, 1 Jun 2023 04:36:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6792192; Thu, 1 Jun 2023 01:35:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4B517641D5; Thu, 1 Jun 2023 08:35:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6921C433A1; Thu, 1 Jun 2023 08:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685608514; bh=+YUAD//YlVKY5+gBa+79P7cJwXwdOQ+Jp7VlD1PAbyo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=P4bEPbdddBPCb87kzpJv07aaMARtLmWwzjkiom41+hsHBrl62JD1r1aBz8cKHjU9c X9iu9Wm74cvVi+piVFvjrw7RVk0QYFoTynZ3NC6QR2BuP4tDEL8RlNr3ZPur330cOE Q6uVHeKmiYvhBPIOugw4mRA7dnNrWHiZzN/9fuX0WChgHkQocHT/uKqzmvR8j8a3xw dANIclAdTMyw005A1Kw25L9j1KqzX2r1j9bLbYGOxFPlY0SXFBFdPb7X1uyBilfPr9 +pNf2rydGlsyZHIev0KsctUhTFsYOZvW3tt6L2NCAtgArx6weXCnZIr4u9vMZ31IeT +ckxpbqXZSRow== Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-4f3b9755961so598204e87.0; Thu, 01 Jun 2023 01:35:14 -0700 (PDT) X-Gm-Message-State: AC+VfDwG8OUV65sSOLepcZtLPNJwOI/zgGdQPBSrfQsgACF0xvXj2iwe jgA7Le8A73OIEWq2DtcM7Weg1x/jUqEENch6P8I= X-Received: by 2002:ac2:59cf:0:b0:4f3:7b3c:2e16 with SMTP id x15-20020ac259cf000000b004f37b3c2e16mr887897lfn.39.1685608512676; Thu, 01 Jun 2023 01:35:12 -0700 (PDT) MIME-Version: 1.0 References: <20230530155501.222213-1-azeemshaikh38@gmail.com> In-Reply-To: From: Ard Biesheuvel Date: Thu, 1 Jun 2023 10:35:01 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] ARM: Replace all non-returning strlcpy with strscpy To: Linus Walleij Cc: Azeem Shaikh , Russell King , linux-hardening@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "Russell King (Oracle)" , Amit Daniel Kachhap Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Wed, 31 May 2023 at 15:30, Linus Walleij wrot= e: > > On Tue, May 30, 2023 at 5:55=E2=80=AFPM 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#strl= cpy > > [2] https://github.com/KSPP/linux/issues/89 > > > > Signed-off-by: Azeem Shaikh > > Reviewed-by: Linus Walleij > > Please put this into Russell's patch tracker: > https://www.arm.linux.org.uk/developer/patches/ > https://www.armlinux.org.uk/developer/patches/viewpatch.php?id=3D9300/1