From patchwork Fri Apr 19 14:42:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bethany Jamison X-Patchwork-Id: 1925569 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VLcn50c08z1yPJ for ; Sat, 20 Apr 2024 00:42:33 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rxpRb-0001YM-LZ; Fri, 19 Apr 2024 14:42:27 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rxpRZ-0001Wt-9v for kernel-team@lists.ubuntu.com; Fri, 19 Apr 2024 14:42:25 +0000 Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 12B283F1B4 for ; Fri, 19 Apr 2024 14:42:25 +0000 (UTC) Received: by mail-io1-f71.google.com with SMTP id ca18e2360f4ac-7c8a960bd9eso251296239f.0 for ; Fri, 19 Apr 2024 07:42:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713537743; x=1714142543; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cxzwg9Cvfcqv4hCEt9QyankNjz0k8ZUUW42ssOknQWk=; b=BNZRaN40TfOTRJLt8csvV213dcxqhKwEwMIqArdQJmfG6dhBAFjh5BDYcVIutmoWLc hUE3pTCNKTPL+emob4t0ENxbqIRFi1IDm5j/oijRQgh6YfnUMPOKMi2c0A6whxppaB1R d/LdzEo4cSUEi1jckbJloWINxEsbNr4PBYSkcs467L+39tNc0PG/SMreylJiI5t2y62G 7qLQP2R1LSxI1XpRBXOyudFcD1Q0F3ur6BLAZPgQ3R/JUqoKy2tXVPfW2xo159uQVjkP MUTziJOrZtTm3u7w5SkznBsncilGyFQtfLYntMsRyhvHLBQWxd408Lu0gapdcPIzdM9g M1dw== X-Gm-Message-State: AOJu0Ywh8ASOELIt4uJlh3L49tEZ2daRUNdd7sM+RnUn1d7gfhTr5Qk4 MIdEssNk2rNSZnlag/S+YQ/cxSY+XBkMEaxq+IOSINWEs4nQ+bf/lBFRpvH16i8woKSuplgvLi/ yoxsM+RnS2g+NJ0mIRYpKWGMIlA3EeqZXNmC6LWqoeHdohKQrV7EOLehtaq6Xnap3RF2++EhTPS rNXWmfGuOQiWjV X-Received: by 2002:a6b:e615:0:b0:7d5:c987:3239 with SMTP id g21-20020a6be615000000b007d5c9873239mr2876164ioh.16.1713537743662; Fri, 19 Apr 2024 07:42:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtyqbpEipnuVZkUyLkPxpsvx9l0E7jDx64DaJAotBlEmCPahdrNSUB9oaBozzLQY8N8uRojg== X-Received: by 2002:a6b:e615:0:b0:7d5:c987:3239 with SMTP id g21-20020a6be615000000b007d5c9873239mr2876151ioh.16.1713537743356; Fri, 19 Apr 2024 07:42:23 -0700 (PDT) Received: from smtp.gmail.com (104-218-69-129.dynamic.lnk.ne.allofiber.net. [104.218.69.129]) by smtp.gmail.com with ESMTPSA id i10-20020a05663813ca00b00482d033889csm1089235jaj.171.2024.04.19.07.42.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 07:42:22 -0700 (PDT) From: Bethany Jamison To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 1/3] packet: move from strlcpy with unused retval to strscpy Date: Fri, 19 Apr 2024 09:42:14 -0500 Message-Id: <20240419144219.21413-3-bethany.jamison@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240419144219.21413-1-bethany.jamison@canonical.com> References: <20240419144219.21413-1-bethany.jamison@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Wolfram Sang Follow the advice of the below link and prefer 'strscpy' in this subsystem. Conversion is 1:1 because the return value is not used. Generated by a coccinelle script. Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Signed-off-by: Wolfram Sang Link: https://lore.kernel.org/r/20220818210227.8611-1-wsa+renesas@sang-engineering.com Signed-off-by: Jakub Kicinski (cherry picked from commit 8fc9d51ea2d32a05f7d7cf86a25cc86ecc57eb45) CVE-2024-26733 Signed-off-by: Bethany Jamison --- net/packet/af_packet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index e7b54f7214110..d62f79cf873dd 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1874,7 +1874,7 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, */ spkt->spkt_family = dev->type; - strlcpy(spkt->spkt_device, dev->name, sizeof(spkt->spkt_device)); + strscpy(spkt->spkt_device, dev->name, sizeof(spkt->spkt_device)); spkt->spkt_protocol = skb->protocol; /* @@ -3540,7 +3540,7 @@ static int packet_getname_spkt(struct socket *sock, struct sockaddr *uaddr, rcu_read_lock(); dev = dev_get_by_index_rcu(sock_net(sk), READ_ONCE(pkt_sk(sk)->ifindex)); if (dev) - strlcpy(uaddr->sa_data, dev->name, sizeof(uaddr->sa_data)); + strscpy(uaddr->sa_data, dev->name, sizeof(uaddr->sa_data)); rcu_read_unlock(); return sizeof(*uaddr);