Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp444753rwd; Mon, 12 Jun 2023 16:33:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4cHWeO1xJB8db7jldTn8r4CZ0T+05sJdeMPb8tHmznlIS1WPSxsBwNKTR1LsNV7ouoNlQp X-Received: by 2002:a17:907:6e26:b0:96f:912d:7922 with SMTP id sd38-20020a1709076e2600b0096f912d7922mr12595021ejc.53.1686612785251; Mon, 12 Jun 2023 16:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686612785; cv=none; d=google.com; s=arc-20160816; b=MveNk1hE4GrTYXhPS4LjLVtVvvZzkB7WzqW6eEBj1nL/vqyoqY6Mf4jJooFmfdSD4Q Wb7rr6kBGGYWMJO2MEXq8BwUuCy4ILJIE1pz1H54+UjWIdtv495FpRyhSuUL5aq2enCt V/dwQqAvlD/vOLI9Vhsx5KsnhFZxz7BF7dsxi/E05B3V3AfTRYFGJO654nVtz5CuY3xv kBRuW8uO1Jf9pxft08ZHgPGxQACfsXRhXflXFk3/BNJ3yBEGFkm1/eXgbcEsYcM+oRuU lZryJrj0mOTLiwOI/NV7ZPipd0ibwkDO6fUohkLdsXucU2eEJYTkqEgO9a6azCAWvIDo RO6A== 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=dxVyUY0dadSws9d1S/zE7Uf1J0Kd9LG7pWJtcUQbE5U=; b=d782Ot0jyvZ/YDSHFvybIBeDPQkwyH8nU90o0ZYkZeat3Hfl56VePv8GFOuUSaw0BP Tuu7Ou0voY6nCo83oK8BXshzRoCCIc1xptHd1SGXeEXVNAdn1Tnqg5vZqus7a7d8u1FV wjJYkIMwX1BukiaF4sCLWkxK6JRNu+WQ5dxPbq+yAH8eu2bW7zliGBcDJ669o/b11hmt GUPoJ+uj1JZotWsigYuiU0DQS9TP3kyx/e9pNDPLx80Jfe1Q7pYXBAkmj4+6zGHgO/C4 PTtA0ubnn+ZvNUK6wf6Gh4NdzzAaxZaMa8B06ZHQbDRA0mZY7Ue4OtY9wv4i4+j3/olw ZY5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=l7zrUKkh; 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 ci23-20020a170906c35700b00977d0f01e9esi5808178ejb.477.2023.06.12.16.32.42; Mon, 12 Jun 2023 16:33:05 -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=l7zrUKkh; 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 S235251AbjFLXXV (ORCPT + 61 others); Mon, 12 Jun 2023 19:23:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjFLXXV (ORCPT ); Mon, 12 Jun 2023 19:23:21 -0400 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEB93E6B; Mon, 12 Jun 2023 16:23:18 -0700 (PDT) Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-77af28802c7so91892339f.1; Mon, 12 Jun 2023 16:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686612198; x=1689204198; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=dxVyUY0dadSws9d1S/zE7Uf1J0Kd9LG7pWJtcUQbE5U=; b=l7zrUKkhBHjs07Y20WY28bXIbFYRxRmVByeXNT1FoOAcaH2hF87Pmye9lTtnd1LCXQ vr8F6/xf4hgNG99WU8q1wSdDTpDJh1Itk/A0xCvtdo8tsAa9Pz6TAaSn8Eg30j3r6nzP OgjaQfQ8KRP9kNlQuehcIgCAiWSjBOzcg+IYHJN7/El1Za01CG4b/I7GoURkuoziMVNY BtdNw41jZeew+f1JZt60uEHet+SlSQcfqVfTfTF4uQRwRsJI6ZAU7UW2ICTT1V+1yYKy YuHlMRZd+UHSP5xpgssX2rW0QAuQJzCOptjrlRpGjoPRyWlkvE3bvSY8lvFyIvE6ebNQ KTHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686612198; x=1689204198; 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=dxVyUY0dadSws9d1S/zE7Uf1J0Kd9LG7pWJtcUQbE5U=; b=SZ3mijSlYLaALP0xloE3g9FQ2mQxl3XsHpaJzH4eXAV2q4CGJqWxhi+f1e0eOOfL1+ 2p+J1pvDjmAZC7EmFDUKdajb3V6lRhggwYFYdjZt1FxwEFAVgR/8iL2HlJOICciZC12G aIh8GnS7XqB0/RiSJifcpLgiZEMNTJiEGv38gzQ0pa+33Ow7ykseXM16wRNgW/zu9IUS edXRgDK9RV34XizjDGo6GEAopa/ovsWEJQ1E7Z9Jplx17ZjrDBuaxl8iKmsjDDboMpHH jkHlMmBTyBtauRsb6YWnXCPLE1HeiRr2Eg5HOSLIkchqrvULPsprwyk+3R9UDc/7Z5CI ZdAQ== X-Gm-Message-State: AC+VfDx1uG1cqjNN0CSbNO7Iz/Cc63F7wDG2WeOieTbQC5FK9mpMnTuJ ULw51EvzXjypNrJll6kJ8Yg= X-Received: by 2002:a6b:7614:0:b0:777:91d5:c198 with SMTP id g20-20020a6b7614000000b0077791d5c198mr8178574iom.15.1686612198179; Mon, 12 Jun 2023 16:23:18 -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 t8-20020a05663801e800b0041f4d47722csm3099563jaq.126.2023.06.12.16.23.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 16:23:17 -0700 (PDT) From: Azeem Shaikh To: Johannes Berg 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 Subject: [PATCH] cfg80211: cfg80211: strlcpy withreturn Date: Mon, 12 Jun 2023 23:23:01 +0000 Message-ID: <20230612232301.2572316-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 --- 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