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 181D8C04A6A for ; Thu, 27 Jul 2023 17:02:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229997AbjG0RCd (ORCPT ); Thu, 27 Jul 2023 13:02:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229961AbjG0RCa (ORCPT ); Thu, 27 Jul 2023 13:02:30 -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 8CC149E for ; Thu, 27 Jul 2023 10:02:29 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1b9c5e07c1bso9613045ad.2 for ; Thu, 27 Jul 2023 10:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690477349; x=1691082149; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=wT/ZsiiDZwcgiQgl4DELrnCzGmHF+3XYDdWiMBrFYvo=; b=K0phnEYk/GVAqF5YbTQkVwMdPv8mpH4CuAkx7IsfmRJ5aLTp4xG8IBBDRxwU3rp18M H3sZi0bD5d69IgZnJX0pGk+67CRDZxTrseYrgwlMhuP5Q9J4PWS82sWweo8TAt9iHOuR rX1q8/lxZ76BFQzEOl67eODr84NVHK31gql9s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690477349; x=1691082149; h=in-reply-to:content-transfer-encoding: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=wT/ZsiiDZwcgiQgl4DELrnCzGmHF+3XYDdWiMBrFYvo=; b=Q5Pm5MfgmSzq0rv20gpTM/dRuDGJ50/YLYlrSCwZthYksxhBVUab4LDdVN2ZpGiVjX THikoNOoNLfTH7t5zgZ7w32tUCkrdADG70Bh4XDXesTNoSzutIuXPzY5wHiQ/w2tIcTv 9sxfKz/jj857VpdcOnmOvhO8lPITQ+eKduTuCpxM57t6dauQtfIRWGejRvpG+QDZqG2p JLIzOdjPx5NTtWuiaD0t9RdxWblX4kFS3o6IqIZ4Wnnbl6jWRqY7chARERE7znWOpRpU V9+zTV0RRjE8cMo8UYbqBEeCFwb96d3HzvUBRHHwClXb2DqgaPRLRT2RzAkRUoIAqT6v MGkg== X-Gm-Message-State: ABy/qLaCuY1SYetc6ky62AHaC+yddRQ+pRwQCe6xCBAVuOTW/dlPElx/ D3T05iL9+8VNZPe2Jj/iWfnsFA== X-Google-Smtp-Source: APBJJlEJpUVqcSMnFLWNvhMQvBdF6RrGYz2iohHdmUVWppDCrgiBB6p74K9WRtxaVJoGd8oU9n28vw== X-Received: by 2002:a17:902:dac4:b0:1bb:cd10:8209 with SMTP id q4-20020a170902dac400b001bbcd108209mr5653824plx.50.1690477348974; Thu, 27 Jul 2023 10:02:28 -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 e2-20020a170902d38200b001ac7f583f72sm1879688pld.209.2023.07.27.10.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 10:02:28 -0700 (PDT) Date: Thu, 27 Jul 2023 10:02:28 -0700 From: Kees Cook To: Azeem Shaikh Cc: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , linux-hardening@vger.kernel.org, Shayne Chen , Sean Wang , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Kalle Valo , Matthias Brugger , AngeloGioacchino Del Regno , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH] wifi: mt76: Replace strlcpy with strscpy Message-ID: <202307271001.13EA5FB@keescook> References: <20230703181256.3712079-1-azeemshaikh38@gmail.com> <202307121653.4A9C69C655@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 18, 2023 at 12:38:37AM -0400, Azeem Shaikh wrote: > On Wed, Jul 12, 2023 at 7:54 PM Kees Cook wrote: > > > > On Mon, Jul 03, 2023 at 06:12:56PM +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(). > > > > > > Direct replacement is safe here since DEV_ASSIGN is only used by > > > TRACE macros and the return values are ignored. > > > > > > [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 > > > > Looks good -- thing is using return values from the macros. > > Just to confirm, you mean *not* using return values from the macros? I thought I'd replied to this, but I see it didn't happen: yes, I meant "not using return values". Sorry for the confusion! -- Kees Cook