From patchwork Tue Aug 8 22:48:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Stitt X-Patchwork-Id: 13339 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2455078vqr; Tue, 8 Aug 2023 16:27:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrHRUYrQPcv+tYivS278yO1yPcj6s+hXgnSst53EizY00kmPzs02Lu1LCz7F1Al4q7hLhH X-Received: by 2002:a17:90a:d906:b0:268:2746:5c07 with SMTP id c6-20020a17090ad90600b0026827465c07mr818765pjv.43.1691537245457; Tue, 08 Aug 2023 16:27:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691537245; cv=none; d=google.com; s=arc-20160816; b=tIBuUI+efQURR+7xofmCtCORiqFsQIKdMrhtjL7vLbuNl2l6R3cHuIcJRBS6+eDLmk oIftJ2Mq31srbvNkpYCL/V7/0vScMcttfvvY1GT5We7U8D8xYqaMGeSYA28F9h1rKsNc 3lWswMQvIT6JcmD5Tfo7+zuv1wYBqRP5aFnmt522Sye16s4dsk++t0jVHZ6CnIYNMjyj gj5Okp9H42ixYQvW1jzHhunqZCtXnrf/SceJQIxxOfP9YHORCJTm6j1LyF+ed7CxxiEb 7r6xNQbI5eAX4PynsWDqcbfdJ+gc9v+pkxPzd+SJzK5WTFyPcuyZjGt8UYJkFsbB2Ra+ 2z+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=w6IYf4nshxor0R0BfWz4JihwJzXUnsgpsQ8Bx+FCm50=; fh=XKPrIMXRcymmuVm42EqALpL6e4c/4tr+JJaDiplPt4I=; b=N8HrTwoU9gCnNsv9bLmWLFBwZIGwi35KuRrL3PWHp/B6UBlahcpxVypqj05j5JicQZ 1MyVEWRtXEzJGhRV423PYkcZPqjp+T0DPXpvWloMbfxGQmEqXUPRZyhfdWjCv3oe2/2Y maotbSR1gvZxOs49ncRPglDCJqNVYoeJQ4QvFz2WCdAy3NiV6om7B7zIjxM06mLOgLwL i51ubsCqlJv+0OrXMfPZZrucsUz1wJdrBcpZuXRQ/TeQsK3F/M7k4Tkq3sv4PJVR/ZAK cZLFo/ftuXkB3od0fFvaGVeKLefKKnEc5Z/KoWNPPt2z9PJrs/ZWIaIFC5kHW7RBj0dq nC8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="v/F4rK8C"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ct17-20020a17090af59100b00262f7dccaecsi144091pjb.170.2023.08.08.16.27.11; Tue, 08 Aug 2023 16:27:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@google.com header.s=20221208 header.b="v/F4rK8C"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbjHHWsh (ORCPT + 99 others); Tue, 8 Aug 2023 18:48:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230173AbjHHWsf (ORCPT ); Tue, 8 Aug 2023 18:48:35 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1333C114 for ; Tue, 8 Aug 2023 15:48:34 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-583312344e7so77595457b3.1 for ; Tue, 08 Aug 2023 15:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691534913; x=1692139713; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=w6IYf4nshxor0R0BfWz4JihwJzXUnsgpsQ8Bx+FCm50=; b=v/F4rK8C1c6Y8YTaAeOsPAc5rlC8DfTsdhN2NcOQy8xZRaoS9cvitj9HgolcvWE5XN ZCiP+oEC5RA+WP6fZlEU1CnM2RNWG7JAxRMbaAZFn9uJ6EZdyRVTLnMIFZmpJ0leHpqh 7spA+UxF93A8SpFyC9uM2L+GVmrc2Oz7NekmEKSBkf/D0u4FLjt9CTUbtd+8gtFhaZz7 k18znWmvXCXpii8KvsTYg2aJQtU0osYwWxLYMWbgCMw6nzwrDCkx//Fl2Uaf3ok/PA19 fBUF7829XdzW7mM47blfRSu0JxMy05t+IbWe2W6Sq0zG9sswyCnMVFGIHsZd252DX9zq QYqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691534913; x=1692139713; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=w6IYf4nshxor0R0BfWz4JihwJzXUnsgpsQ8Bx+FCm50=; b=E/ue6+Tg18UFnxxIQesTGemDiM8Q2dgbcMNCXWEMup+9IowZ4EmSFH9bcNqkWb5xc3 kpLEBIWxpTO4QNvbliU14EN4SOYTHcTU9TfRuleSthI/78vD1VUqOGMkW9FmuMrULQoG ZqpPoHDjKoe+Xx2UKobITmUV0Ls5viPj92QQT/7yHq8zeEU8MS2wSQl1kuS2pJk7F5dT BQwporcJ5enaLlzxWlHV9cI/l0TxpbkYy/fBQdnLRo+b/CaX9TbqbZYLP8wW7cNGtoxh Fw50dAkTVSP/wqo31uRC5aCOQIa4i9Y/UUj90Vq1eOYfefoCC/i1Z/nDrNggOi3eYwKZ LGUg== X-Gm-Message-State: AOJu0Yz5OfuF4TfLQs3Q059quA1O0iWqsA0i7pJV12JbwJeYf+E2qn8d OttLJdm+RcuQW+wIsZIMpHERSKC+Livwqay02w== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a81:aa0b:0:b0:586:4eae:b942 with SMTP id i11-20020a81aa0b000000b005864eaeb942mr25570ywh.4.1691534913334; Tue, 08 Aug 2023 15:48:33 -0700 (PDT) Date: Tue, 08 Aug 2023 22:48:05 +0000 Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIACXG0mQC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDI2MDCwNz3bzUEhBOy8wpSS3SNTEwMjcytExKMks1VwLqKShKTcusAJsXHVt bCwBxh7PoXwAAAA== X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1691534912; l=1704; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=ZOPiCy7w2pT1kz3c5DhiCZiV+zTmBFI8xyOrhaHPkq8=; b=35hLj7PJ6DP6/IdiB2Ylc5Y2G6xQ/3oI1SXKLWZ4BpDIns5/qOxf/7y6WjAKgN2o0Nv1hmmKZ 7RXdFr4FcSnA1LghMYnhNj8402rOA1pYEJ9KZdZBr1W0Mso8AV+M+KL X-Mailer: b4 0.12.3 Message-ID: <20230808-net-netfilter-v1-0-efbbe4ec60af@google.com> Subject: [PATCH 0/7] netfilter: refactor deprecated strncpy From: Justin Stitt To: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-hardening@vger.kernel.org, Kees Cook , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Justin Stitt X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773705358696632241 X-GMAIL-MSGID: 1773705358696632241 `strncpy` is deprecated for use on NUL-terminated destination strings [1]. A suitable replacement is `strscpy` [2] due to the fact that it guarantees NUL-termination on its destination buffer argument which is _not_ the case for `strncpy`! This series of patches aims to swap out `strncpy` for more robust and less ambiguous interfaces like `strscpy` and `strtomem`. This patch series, if applied in its entirety, removes most if not all instances of `strncpy` in the `net/netfilter` directory. [1]: www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [2]: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html Link: https://github.com/KSPP/linux/issues/90 --- Justin Stitt (7): netfilter: ipset: refactor deprecated strncpy netfilter: nf_tables: refactor deprecated strncpy netfilter: nf_tables: refactor deprecated strncpy netfilter: nft_meta: refactor deprecated strncpy netfilter: nft_osf: refactor deprecated strncpy to strscpy netfilter: x_tables: refactor deprecated strncpy netfilter: xtables: refactor deprecated strncpy net/netfilter/ipset/ip_set_core.c | 10 +++++----- net/netfilter/nft_ct.c | 2 +- net/netfilter/nft_fib.c | 2 +- net/netfilter/nft_meta.c | 6 +++--- net/netfilter/nft_osf.c | 6 +++--- net/netfilter/x_tables.c | 5 ++--- net/netfilter/xt_repldata.h | 2 +- 7 files changed, 16 insertions(+), 17 deletions(-) --- base-commit: 14f9643dc90adea074a0ffb7a17d337eafc6a5cc change-id: 20230807-net-netfilter-4027219bb6e7 Best regards, -- Justin Stitt