Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2739063rwd; Wed, 14 Jun 2023 06:53:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6BXfhppBWnJMMlizKnpIteGRuRXXWrtSZjpxuTv2BKa3PtqyOaIZasGjmSKDAYrcu0HEpq X-Received: by 2002:a05:6a20:151:b0:10c:6dbc:2810 with SMTP id 17-20020a056a20015100b0010c6dbc2810mr1655636pzs.62.1686750791065; Wed, 14 Jun 2023 06:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686750791; cv=none; d=google.com; s=arc-20160816; b=gcBjezWsGUGJTLE7WoxA2WPV54TYCt6teXJWpHklm7w9UjYTyaGZYuThi2BCvF5MdM xfLnpDS9AMrE4x8Gd7H1pRHOQlneqi41HLukMXK7Ogx2wbXbd2/ms2G5l5b1968U3I1g RpDKn8n80s//27kDRDTMWbfJjDbgoqFiHmFbSjkT7J7fSCa3/mBlPIuiMfKVD5iIVBUJ pZhdCYPnh+mORUL4iDYvxDNCU9FLdD2sP/+5tI7ZY0YCKS0Brgg/IS7T3OB8VAHyPeOe 9gvG376xI+UsPColg6iet26aUiQnt3F5lIRryzHScQ9lKbLjxAaAb+JmMErSc/0HFCi4 Xn4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ZEPuphakaNp1fYcyZ4pObojDdVaUBwTgM8okY278g5E=; b=eP3CxiVnFlgjSJzR3Gza5d1D/42J1tVhKpUcNzAsynDcAXHQj0qfAT/z0hC/IUwFUr QF3URQbY/gOWhUDemgwYg6S40i0v/5HrCbHuXvWmRasnpKxp7h9V540CtcAZybjzoB3k m9cC8K6K+p94vB4jQ4KMNuTpI8uxJ6ZlbUNl8akO9bt69k81FiBQZIZ1t0ZVNhjQOBrs eDTXcoEvs7u9/8cq6gdcoXK9fmE2NCZbxIuREgE+27w4585FfD8NHSQ8VxvSJLgEg2T2 aZXdzWcXCUoN0lkJVNNCSZEQ4cDXWW/0LTlWtewrWnhdIZ7K6erGHSoPy/Usq4NPAkd2 OzkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ipsgnUCS; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b12-20020a170902d50c00b001b3d4af4457si5290115plg.248.2023.06.14.06.51.30; Wed, 14 Jun 2023 06:53:11 -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=@gmail.com header.s=20221208 header.b=ipsgnUCS; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245236AbjFNNuP (ORCPT + 61 others); Wed, 14 Jun 2023 09:50:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245203AbjFNNuL (ORCPT ); Wed, 14 Jun 2023 09:50:11 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34E691FF7; Wed, 14 Jun 2023 06:50:00 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-340a05c22deso2187135ab.1; Wed, 14 Jun 2023 06:50:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686750599; x=1689342599; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZEPuphakaNp1fYcyZ4pObojDdVaUBwTgM8okY278g5E=; b=ipsgnUCS9NMIbr5fKQnk6kUv67E3x/wY8Rq+aGR0dr6qp/ctIpczO2KxLo1i9Cez3l y8qlys4Sx5KpiBn9Nnjg44K0M0X/fQ3mvM5r9ErMiOAADRI5WwBa5rpflBHNJ87ta5qN Vj33y4B2iKVL/rP7Wi/cm2uV+G8nxboYFqLXVv1CuqLQ/MJq23RcFH3XD7OUkDBvQJCc Wt/8MaUcl1t5faWXnbe3x198W8AabOJRZ0a+UaFI+MjqVfGYlZceaEqLt/FpCCw0q+co /m0OOa1RD0pmujC8dngUrmQcYCRaL/5JGUqS9jRI14oY9K361mymCboKbWJACZHWfH02 cXWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686750599; x=1689342599; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZEPuphakaNp1fYcyZ4pObojDdVaUBwTgM8okY278g5E=; b=foYcaPNq4OHEIJ7vwPJaMP7oIgoOOR2VBZiw8NERWdIhAK476WqfF6CUXexdpjjBIJ B/mMs+6y2Tf96NCzZnuEfxLDNnvo2wM6jSexljXxNg0sxy3rkK6wtEi0nHtl6xx5C0e5 0MJegbbFAxxGYbbeRlRWDrsiZAltPs2pkaQzXbTgZ9kWe2pA+kWsEmyIMmKSwNAsxG8a Hm2nr7DMzFCmGt0qJbwUNfoQtiNQdHRawxLcJUrY4eDAdeqNx1/WnGGymswGQJgXNMFE mPhbv+Aj5cRdV8xf7JDBvYlC3yfIiDjdUGg/Xl0ux/uWju0MCoD6Vx4YziH+/Qaqky0L h3Ng== X-Gm-Message-State: AC+VfDwud9kqottb5ItIQTftJp0p7DEsGXnq2+jY1ECHIP0R6kawTJL4 gL1QnPi1q23lyMIxy0mhcf0= X-Received: by 2002:a92:cacd:0:b0:33a:5bb5:f8f6 with SMTP id m13-20020a92cacd000000b0033a5bb5f8f6mr11581580ilq.18.1686750599414; Wed, 14 Jun 2023 06:49:59 -0700 (PDT) Received: from azeems-kspp.c.googlers.com.com (54.70.188.35.bc.googleusercontent.com. [35.188.70.54]) by smtp.gmail.com with ESMTPSA id a26-20020a056638019a00b004182f88c368sm5072190jaq.67.2023.06.14.06.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 06:49:59 -0700 (PDT) From: Azeem Shaikh To: Kalle Valo Cc: linux-hardening@vger.kernel.org, Azeem Shaikh , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, Johannes Berg Subject: [PATCH v3] wifi: cfg80211: replace strlcpy() with strscpy() Date: Wed, 14 Jun 2023 13:49:56 +0000 Message-ID: <20230614134956.2109252-1-azeemshaikh38@gmail.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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-wireless@vger.kernel.org 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 WIPHY_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 --- v1: https://lore.kernel.org/all/20230612232301.2572316-1-azeemshaikh38@gmail.com/ v2: https://lore.kernel.org/all/20230614134552.2108471-1-azeemshaikh38@gmail.com/ Changes from v1 and v2 - updated patch title. net/wireless/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/wireless/trace.h b/net/wireless/trace.h index 716a1fa70069..a00da3ebfed5 100644 --- a/net/wireless/trace.h +++ b/net/wireless/trace.h @@ -22,7 +22,7 @@ #define MAXNAME 32 #define WIPHY_ENTRY __array(char, wiphy_name, 32) -#define WIPHY_ASSIGN strlcpy(__entry->wiphy_name, wiphy_name(wiphy), MAXNAME) +#define WIPHY_ASSIGN strscpy(__entry->wiphy_name, wiphy_name(wiphy), MAXNAME) #define WIPHY_PR_FMT "%s" #define WIPHY_PR_ARG __entry->wiphy_name -- 2.41.0.162.gfafddb0af9-goog