Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4671936rwd; Tue, 23 May 2023 10:43:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ45WqUpe9g7UH3g4BCLqRMv8vmZl6VCBzho5mNL31qsfse3z7BKyuJtaqXxLTMCahHQ0wfa X-Received: by 2002:a17:902:c20c:b0:1aa:ef83:34be with SMTP id 12-20020a170902c20c00b001aaef8334bemr14509321pll.47.1684863830813; Tue, 23 May 2023 10:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684863830; cv=none; d=google.com; s=arc-20160816; b=oPQdVin83sh2EnSazjupdVpJJXCelsNYWZUzTB+g4VN7dOMyzrNFdgw8yqIZF0HqH5 kGEUcUW8VOV8BLU852m/apmTIurrWqPILKPEx/xbkdVA/N+noMEo9XxMdb8w8K9NBG00 HjMFkoJZ4B35+58eVws34blfoow3qQkvKy20P3U/y/0Rn5yR+B0mTTO/nkLf1ACIv5Pj WjjPjFurZM3qmSnpIWRkNOHHXDyILCkXOFPUhh0WiOkKkuQkHxdxaTlyk2y0ij6uunug 7mABPWHRlYO4mBmQ07OCJhNGRdK6UyCCCrCv33VqI41I/J8zmB2OLSNdjiNayqWuFkT3 SpMQ== 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=X5TaiMEFaVRXBBXmrOT5rVhJkyEwfpcOBFjZH1D7ygU=; b=kkHbW7EHfcqHWp19/nxolFMci/Pgq7svaZEIxLxXsj/EpXhinB9/o9MapuaBw6s+Mw 80tq0BigZu+b23lBr0Q1rL9GBxO5d3GnPfGpZyb4fX3pgii3y1/UnUX38KBeDOvvNuCT 8dD/KgLzd8RwgIeuEOWo7Smq2EOqxsWkcrF9AxRfdq5RpFPmtR25f/7IwOSwwyfox32i YqPa3lmdhiKEIN+FKl1MShGr/i6k+6SQWANspNMJNKFx/VxhZXQuKGRkM2cVvAoI6IVN QVkC+mb7x9l0Yr4cfVcNIGcjJKRfq3APQsEYroDPIsdPdMAVK7/ileTS73mUixg1exM5 f0lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Myk//XnL"; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s2-20020a170902c64200b001ac91ece0dasi1227176pls.7.2023.05.23.10.43.38; Tue, 23 May 2023 10:43:50 -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=@chromium.org header.s=google header.b="Myk//XnL"; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237681AbjEWReF (ORCPT + 99 others); Tue, 23 May 2023 13:34:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237797AbjEWReD (ORCPT ); Tue, 23 May 2023 13:34:03 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E331EE71 for ; Tue, 23 May 2023 10:33:37 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1ae454844edso53929375ad.1 for ; Tue, 23 May 2023 10:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1684863216; x=1687455216; 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=X5TaiMEFaVRXBBXmrOT5rVhJkyEwfpcOBFjZH1D7ygU=; b=Myk//XnL+kcfvxEiu6r+DEazWtDYHot8a7HGhSgrCLT9b1EVVnsag052Ai+KzdXHoi 1nNww3UZcbHk7SCmfSTINJ4IyaPi7b6r1OSROire4HNLINsmBtaJWqinJ6DoaLbeUtTW /UxiVGHhvdzOV1dasHhaBpQAj/fGwcY+PYVKY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684863216; x=1687455216; 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=X5TaiMEFaVRXBBXmrOT5rVhJkyEwfpcOBFjZH1D7ygU=; b=d1PLXk+YC5kAOLLRCtgmq9sn44H//hHSDq5AMYKVAaYpYfQHMdFtLWe8WOw4Zj7YUI nVhrLblqZVqajx14xUTGCmWH/IGNByaoJAggUK5D4ckTwrvzCOmMpweiQ07FVZX31pTe fzR35TszLe46dcOiKhVo3eouaM6L1mk2nzxdcHDybrDzFAsNdy/SEw5MLCm/OjwN4D8A mLE4hxb0shXOyOSEL0ZKHjLc9lo1nfH4s1cMxGY704VS+OJ52dQcBnscoEBCqjOP1aI2 w1K0mmFOEMJexW34lxfRCPHURHg2WU9usBznRCmxZE3pgwYvQijJb8XrJfYHQfXbCW5y w1Rg== X-Gm-Message-State: AC+VfDwCqyQG9DCgS0bWHsPu9KAmKyh+ADXEg6nHpHS3E02+lkpv3mpL oUsPsIk/vQgL81JDkmofqX1NXcLNUC3FM2FtQN4= X-Received: by 2002:a17:903:248:b0:1a9:3b64:3747 with SMTP id j8-20020a170903024800b001a93b643747mr18446929plh.17.1684863216117; Tue, 23 May 2023 10:33:36 -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 q7-20020a170902dac700b001a2104d706fsm7052433plx.225.2023.05.23.10.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 10:33:35 -0700 (PDT) Date: Tue, 23 May 2023 10:33:35 -0700 From: Kees Cook To: Azeem Shaikh Cc: Sakari Ailus , linux-hardening@vger.kernel.org, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, Sakari Ailus , Pavel Machek , Lee Jones Subject: Re: [PATCH] i2c: Replace all non-returning strlcpy with strscpy Message-ID: <202305231033.2842F1500C@keescook> References: <20230523021150.2406032-1-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230523021150.2406032-1-azeemshaikh38@gmail.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_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Tue, May 23, 2023 at 02:11:50AM +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