Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp475353rwp; Wed, 12 Jul 2023 17:00:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlEszZdAFDE57AEzTr1g4Y4OiSrOfoM+83Y7WzFAStdxx2vUmNAEnt8tMAZGvBzWylNsEwyq X-Received: by 2002:a17:907:868a:b0:991:d414:d889 with SMTP id qa10-20020a170907868a00b00991d414d889mr4950377ejc.15.1689206453483; Wed, 12 Jul 2023 17:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689206453; cv=none; d=google.com; s=arc-20160816; b=S6Bi1bc/V8l7J6dIUpga0FeHk34wGWSNNFaqOI3Lt5gdB+ZOZtoy3ep+j8HMZqy60G zecZ5qKX62UdmmxJ6e0yvty4nCdq1r1PEGGRfLlLcOgfLq+j1a22jMTw/yy44s0v8R/i 6o5shilHuekDW+gXkqU24peCnuKsu5OllKOxMsjP3YZQfjx1r79bVYocdM5qkh0h/hjG Paw1VtbePCMbDktIZlwr4BbHLTTrVRr/rml7Cuv4dKBrE/2KR9dM8R3l/2JVGTCd+fxC kg5JQADDJRzAgJBKyOSmsgdfAVAGm0ShdajySXU4U7peWURNMUuaHn2CuYLBRaDnBHA6 keRQ== 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=/vU/3bfdHl64WUkd75ReRDYfirTILS0gvYwUTQH7DSM=; fh=aqMrWk9bLk0UUapaTbn8fk9o+IR3XcO3UtTYGry/phk=; b=0aB5i2tmURDZh6vd2qwspRBj5gXyqe3nQ5uMx66vQSyUtlxEe10e8xo8Qf+R/80sIs nBcH9zFFy7y9TacyDD7cWRZ9YY6zUDm3fQmWkPb+XaHeIxt6XETT0QTN3qbvXr1FXIh5 jiwNl/T4DklbD55+QXC0gWbnKCNKMxxoYnRVwmJJK/9MCEJgZSqzHjQee9Vnk10MhbVq a2L6dT2sicAgfp8fCSoQPMpuTSSoQ7E9p9a8NcHUzQNDWnrZdmwlpYZWRGbiKE1zVkwa wtmhJb8JFGcysDu3vCYQS2eh+SmvTEPt2JCyhWD80QEq1RI+4f9ygmurwG8WZsJx9Qdm G8hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=J7alN4E4; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-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 cf13-20020a170906b2cd00b00988a7f7cd11si6397918ejb.515.2023.07.12.17.00.38; Wed, 12 Jul 2023 17:00:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=J7alN4E4; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-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 S232992AbjGLXz3 (ORCPT + 60 others); Wed, 12 Jul 2023 19:55:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232636AbjGLXz2 (ORCPT ); Wed, 12 Jul 2023 19:55:28 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A69501FC9 for ; Wed, 12 Jul 2023 16:55:26 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5577900c06bso172747a12.2 for ; Wed, 12 Jul 2023 16:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689206126; x=1691798126; 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=/vU/3bfdHl64WUkd75ReRDYfirTILS0gvYwUTQH7DSM=; b=J7alN4E4ewEYIushjF5RhD5xtHURzl5VVAKqYeqMlBLF8w84WUPewCv7Owf2hO1Sx8 s+NCKO3579s52rnAVRhkl9Bu3oO8BbS3ffYhxKwUqGrTmYDf88Wx6URNb5AOSDmk5OMZ e9iOjL4hPL/awuWYemSCQciujiFphf+0gfcEU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689206126; x=1691798126; 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=/vU/3bfdHl64WUkd75ReRDYfirTILS0gvYwUTQH7DSM=; b=lUXPiwZizO5TTY+lNbXPkHno6tTMxx3EzqXTy2JfVb6VK8CX2sxe7peoCQk0CCx8hG XLObgg7K/k351sOZV6joxl+hGkmoPwMMM0DKVeEU8ykacMYiuGLN41XZKWGTWiRMdqIM Qqb3VNDgdLLNvFIeyjwRKg6MH8DU7sx7lINVGiorvczIt/TkxppuifFQori8/FTZzgiP CxCizlDDVUo6gncWglMrf5yNdycI4twsbxcJvF4eHZGBjXNGam9Ei2ze/dBrv/1sNP0r HsQBG+VexZfWaHxeFZ61pIDB0ko2koymGxKb0eLyA7gVCeQClqhg0xbHscyAjNH2a5HE fU8g== X-Gm-Message-State: ABy/qLaLCcNPJHa6ym7DjzniOQw6UHg83/4nf2xwthHGF8X205uW+cpI +l8qWfrY9KQJHxEwAAQC0CepbQ== X-Received: by 2002:a05:6a20:3257:b0:120:1baf:e56e with SMTP id hm23-20020a056a20325700b001201bafe56emr21055274pzc.19.1689206126202; Wed, 12 Jul 2023 16:55:26 -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 j2-20020aa783c2000000b0064f76992905sm4120145pfn.202.2023.07.12.16.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 16:55:25 -0700 (PDT) Date: Wed, 12 Jul 2023 16:55:25 -0700 From: Kees Cook To: Azeem Shaikh Cc: Amitkumar Karwar , Ganapathi Bhat , Sharvari Harisangam , Xinming Hu , linux-hardening@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Kalle Valo Subject: Re: [PATCH] wifi: mwifiex: Replace strlcpy with strscpy Message-ID: <202307121655.C365BB8@keescook> References: <20230710030625.812707-1-azeemshaikh38@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230710030625.812707-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_BLOCKED,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-wireless@vger.kernel.org On Mon, Jul 10, 2023 at 03:06:25AM +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 return value of -errno > is used to check for truncation instead of sizeof(dest). > > [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