From patchwork Tue Oct 17 20:11:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Stitt X-Patchwork-Id: 13425974 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 A9143CDB474 for ; Tue, 17 Oct 2023 20:11:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230017AbjJQULc (ORCPT ); Tue, 17 Oct 2023 16:11:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbjJQULb (ORCPT ); Tue, 17 Oct 2023 16:11:31 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97F8A6FAB for ; Tue, 17 Oct 2023 13:11:29 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59b5a586da6so46201937b3.1 for ; Tue, 17 Oct 2023 13:11:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697573489; x=1698178289; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=46uGEBVZYP60+QlvEII0CTGZBlglU94CwFi36yzEJK0=; b=AeVtC2BSNpT8MtYUSkZrW8w/3ODWpmPxbbm5cApqPOQSvPO7gpWubgFc7NY0L3fe+9 5vLqEngKLXZHvJ7u+ZfDE3jKt/Z19nQKMaLQHmgoNwPChNVCWtDELGtkrkS0kLAhk+ho tMti36yuHPrk9yCcbfgcOUOVqlaLATBWM6H/orinkDfqQLl72QEanTne7tjBgV+BxYiZ 0dxKlAbBum/K6cBAdc3+QtCJkXOOo1x4yGOCUjgRnfSbupkj+BNLxpcEWKrZoG/UHg6J jq70bBYizPgNKFEvzj0Mb6X5jPvnFN8JLmuTRPMDQ+cUwgtppx+LN048rBK96bmQ6f5W x41g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697573489; x=1698178289; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=46uGEBVZYP60+QlvEII0CTGZBlglU94CwFi36yzEJK0=; b=KYixvjAnF/4XSSJsXC3NRrOY0J1EfJ8PG87PDuOZzU+gbveMijNBfX5t9/Ow3TkZ6a U+jParQblxtuB1aLBV7bk3qYho+QduJRUZ0CYQAg049tfecn9vAfgnJ5Wyp5eV1IuXcP 6z/S2JpDniEaH10g1VBkxC3WfBJWlJqASiRzC5liQpeNwXDGT4UqEITHsXF9drRm3xJ9 iYyAAnGUCbRbHUT+qcG0cvC51djaHy4sn2xV5Au575VxfTc31w389yPy16GsOZkaZH6g ZycYvhB8R8xyqkhK7xbTS5dhW9VqT7LfcbyJiwA11IWTYLWaM/NA6sbZEOEaWjR1pI+q S7og== X-Gm-Message-State: AOJu0Yz+c1B7oYTRxCb2ChOq3ygZ75Yppy0lciRmtfzdHZo3BdGbseg2 RXcBqfVUOBPw+JhKTaAp2WLGotysIF6/L/n1zA== X-Google-Smtp-Source: AGHT+IEfJLWMLoOm4C5rtgg3wHRXpdPuCDymBXGKzRp1SsYn6OfhPJ/L9Vc3+vwyzmjrpHdHSKS0VUjS83Q/Y+1Wlw== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a05:690c:2e87:b0:5a7:b95c:a58f with SMTP id eu7-20020a05690c2e8700b005a7b95ca58fmr71164ywb.1.1697573488855; Tue, 17 Oct 2023 13:11:28 -0700 (PDT) Date: Tue, 17 Oct 2023 20:11:27 +0000 Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAG/qLmUC/7WOwQ6CMBBEf8X07JpuQWg8+R/GQ10WaALUbEnVG P7diifveps3yeTNU0UWz1EdNk8lnHz0YcpQbDeKejd1DL7JrIw2BWqsIM4y0fUBjfjEEmHiGW5 eeOAY4SLBNRTGHGi02iCuqR0dAbXdpyFwRqO2pcHK7lU2XYVbf19fnM6Zex/nII/1VMJ3+1t/Q kAoTVFaXZPTNR+7ELqBd3mq3geS+YPUZGlF9b6qGZviYr+ky7K8AFHQlQeMAQAA X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1697573487; l=2149; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=IYHa4GmWLvGCvatbI5bBzz5yNCmTjMuR/IQRybWbAVA=; b=92S9SAvX+VpKkETDSsphUKuxpQoOMQ38sXOjPqap5XFBJDgU6idJpjDTsAT6xQE5WhuPekvyN ZGd3Vn32yiOB+ntaW9DlkyRHaWbxMNkQ7hltpgq0KkZV8Pz03ozInsQ X-Mailer: b4 0.12.3 Message-ID: <20231017-strncpy-drivers-net-wireless-broadcom-brcm80211-brcmfmac-cfg80211-c-v3-0-af780d74ae38@google.com> Subject: [PATCH v3 0/2] wifi: brcm80211: replace deprecated strncpy From: Justin Stitt To: Arend van Spriel , Franky Lin , Hante Meuleman , Kalle Valo Cc: linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Justin Stitt Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Hi, This series used to be just one patch in [v2] but I've split it into two separate patches. The motivation behind this series is that strncpy() is deprecated for use on NUL-terminated destination strings [1] and as such we should prefer more robust and less ambiguous string interfaces. In cases where we expect the destination buffer to be NUL-terminated let's opt for strscpy() as this guarantees NUL-termination. Other cases are just simple byte copies with pre-determined bounds; for these let's use plain-ol' memcpy(). Each change is detailed in its accompanying patch message. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2] Link: https://github.com/KSPP/linux/issues/90 Signed-off-by: Justin Stitt Reviewed-by: Franky Lin Acked-by: Arend van Spriel --- Changes in v3: - split up into two separate patches (thanks Franky) - use better subject line (thanks Franky + Kalle) - Link to v2: https://lore.kernel.org/r/20231016-strncpy-drivers-net-wireless-broadcom-brcm80211-brcmfmac-cfg80211-c-v2-1-6c7567e1d3b8@google.com Changes in v2: - add other strncpy replacements - Link to v1: https://lore.kernel.org/r/20231016-strncpy-drivers-net-wireless-broadcom-brcm80211-brcmfmac-cfg80211-c-v1-1-4234807ca07e@google.com --- Justin Stitt (2): wifi: brcm80211: replace deprecated strncpy with strscpy wifi: brcmsmac: replace deprecated strncpy with memcpy drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 2 +- drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | 2 +- drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c | 6 +++--- drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c | 3 +-- drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c | 4 ++-- 5 files changed, 8 insertions(+), 9 deletions(-) --- base-commit: cbf3a2cb156a2c911d8f38d8247814b4c07f49a2 change-id: 20231016-strncpy-drivers-net-wireless-broadcom-brcm80211-brcmfmac-cfg80211-c-a20108421685 Best regards, -- Justin Stitt