From patchwork Wed Aug 9 01:06: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: 13347281 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 A407CC04E69 for ; Wed, 9 Aug 2023 01:07:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231166AbjHIBHm (ORCPT ); Tue, 8 Aug 2023 21:07:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231371AbjHIBHm (ORCPT ); Tue, 8 Aug 2023 21:07:42 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 880E71BF0 for ; Tue, 8 Aug 2023 18:07:41 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d5e792a163dso555072276.1 for ; Tue, 08 Aug 2023 18:07:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691543261; x=1692148061; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=8kynZ2eY0/O6E/bQJdWZNL+mmpUwUSkdwurja4abucs=; b=Ol0O7ydBLmDGDB+SZ9v11BQgV4K8njIy76TSgXpaauJtbgStqpW/RYu/DWTxMxv5ZB +9MacsQSpkAhtOY9LVIFSQQtbwXVuIBhhpzOiV/EdBvEkZB/SRk8+/hM3Av3riZbSVSG QtCWUqHY7ASjZgsslXjvn1A8l6P037btB4PjAGygJPGdrTpttKYWlOta5a139Ww0nVw2 4wZvofllE9KdG42dhpE4GXt+mC+sxQs7bOpHb0LRCj1twgqrLPVTJYEBe17+KyMG8QjB UtPRDLE2isjgjcvvsvJSfiJwpN73phog9iVfBbXoVUO8z8mhgWMyyQoeNpXAgTDKPl0/ qpJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691543261; x=1692148061; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8kynZ2eY0/O6E/bQJdWZNL+mmpUwUSkdwurja4abucs=; b=K6Os8k/hpR3DOfEgt4h6P2N0FBCwEr3UOMyPLEKeTWsnFuqBWwPKh7G6KaNNg0r0oh PtvfMfzMqclJ/YSQZ4d2/U2iUOIfv9LwgShJM5IkKwJzl6n3LKh9ohyplQLH83Iuikz+ GyCciYuOXO5lBrvnwO9mXo/lPp9opc0cEwcqnwr1w7w8raZxwowYcIL9de1VfXS45jmm xYbmmJ8TTi3sJUQ01+zByfkZXgoPBzVDRgb5VbyGIR6+Pi8x3Wl/T4Z745IgU2uXfPOa tNPSlEiLZsDs5vAIE9REIN2aw5dlBqrM58W+Z4TomRHxOs5Hd4nJXR6bBekPk8EJOF9t oDUQ== X-Gm-Message-State: AOJu0YwJZYxKoUpqW/lc1K33a5kSyHMgO4NWz9gHj5pulGeeOkiW6Yce kLqOGf3dCQ5tE4QQ90A6aZxa63/OEcpFTJNBTg== X-Google-Smtp-Source: AGHT+IGWrBqKRyMPFFB9tEV4Q4dgsTSTg2iWnoP8DD7tIMTceBZqZZlfU6ptL0dqjEgU1ZHHFa6n34AN1ZEUPEROSA== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a5b:181:0:b0:d4f:d7a5:ba3b with SMTP id r1-20020a5b0181000000b00d4fd7a5ba3bmr30722ybl.8.1691543260881; Tue, 08 Aug 2023 18:07:40 -0700 (PDT) Date: Wed, 09 Aug 2023 01:06:05 +0000 In-Reply-To: <20230809-net-netfilter-v2-0-5847d707ec0a@google.com> Mime-Version: 1.0 References: <20230809-net-netfilter-v2-0-5847d707ec0a@google.com> X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1691543258; l=903; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=GfuXN5T5xhe6k6w3cRknlOVNIOtegqmz8uQBUV4/tcw=; b=GYSS0ZoTuERfJ/SVnofWzjum44puD5h0s+zSjx2gITL2EhREYqCQpVB9N07nRO0v9d+gxkHdQ SOb7icKznTnC9EnhPquUOW6p8PVJ2Ep9ughhPfdNGQsR/NcIvz+Wupm X-Mailer: b4 0.12.3 Message-ID: <20230809-net-netfilter-v2-2-5847d707ec0a@google.com> Subject: [PATCH v2 2/7] netfilter: nf_tables: 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 Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Prefer `strscpy_pad` over `strncpy`. Signed-off-by: Justin Stitt --- Note: Opt for `strscpy_pad` over `strscpy` since padding is wanted [1] Link: https://lore.kernel.org/all/20230808234001.GJ9741@breakpoint.cc/ [1] --- net/netfilter/nft_ct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c index 38958e067aa8..bbf11c4871b2 100644 --- a/net/netfilter/nft_ct.c +++ b/net/netfilter/nft_ct.c @@ -108,7 +108,7 @@ static void nft_ct_get_eval(const struct nft_expr *expr, helper = rcu_dereference(help->helper); if (helper == NULL) goto err; - strncpy((char *)dest, helper->name, NF_CT_HELPER_NAME_LEN); + strscpy_pad((char *)dest, helper->name, NF_CT_HELPER_NAME_LEN); return; #ifdef CONFIG_NF_CONNTRACK_LABELS case NFT_CT_LABELS: {