Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1824775rdb; Tue, 3 Oct 2023 02:00:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGI53nJB/ZeuOq8A38W7YAiEsK+TvE0CY/vByEQxeqwSwS6TfeMeYK3PRsx8IngdUkph2cz X-Received: by 2002:a17:90a:7bcf:b0:274:8951:b5ed with SMTP id d15-20020a17090a7bcf00b002748951b5edmr3250236pjl.20.1696323600710; Tue, 03 Oct 2023 02:00:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696323600; cv=none; d=google.com; s=arc-20160816; b=Sp5HB7rcO2n+h1ESSX/zXeoJQdWky6NvxSFUGv7pfdyBevgaIqok9kb4rcYfCo8nsN JK406n0fNaxdzSP0nk/6kOM3GJCvRrD3qahxEMnYleoHYn9HkYqmSZ/dFAaigm0hbXDs GfJG2m951PggrotOcAhNMMSG22TGUpoapRQwvEpJ+q7iiYIwNKmAEVbPmuMpNNcii40a 3Wr2JXmxT9WsNm9LrR6i3x0S+rDeyBYhwC2cYmVv3tUkbjCQxw1mjYETwibczPV4VWvf s3jmhxyn5OCA1lpMDS/BNBC/6EfNxEQfRES3eebD9EoB2NCOqnL6RPxSfa2tHWtDgDtl sr8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=v3nmu3krFFKLD3v68LyglQg7qgblXckqiH4dxOfI2bk=; fh=e+BxkHVRsQjHu73I3E79ck3utvan9FK2iFITrRfNBXs=; b=cb92VvMnAoolddhiQV/AHa2UAXRyNonj/qvCDkl0ykHG5tvPJSGp9N1/K50vYKdJan s5BcG/YqX+CAj019Yr2GtOchU4LwP/zKVC2/MDZBs0vL+vhn7xwgqyhkVoG+trMDkjf1 jHmVNqQeppjLdND9dWA3VzZxhnfRsok7Bgg/uJWYx3PGS0T/HdWmuaBKPFvrITUIBN63 0Nuu1oaxr502gTpAEZonvV14LIaa9KwU/cgrFUugfnaM38OBJK1eZEI0+BhIVrPeb6GC 33ubudYxThaapw1vx7z+3CKPDtb7FGuIX4gwesXqPT2GAMB4NkieSGvxSg2eCvf59zbg yqEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZJitK2gp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id gb22-20020a17090b061600b00277382d4803si9222774pjb.173.2023.10.03.02.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 02:00:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZJitK2gp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id A5EA78271429; Tue, 3 Oct 2023 01:59:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231136AbjJCI7w (ORCPT + 99 others); Tue, 3 Oct 2023 04:59:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239315AbjJCI7u (ORCPT ); Tue, 3 Oct 2023 04:59:50 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F4F4EB for ; Tue, 3 Oct 2023 01:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696323540; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v3nmu3krFFKLD3v68LyglQg7qgblXckqiH4dxOfI2bk=; b=ZJitK2gpuSMO1DzNomlqTwmOncpzu1kwo2I5zbe+tRzV05X+CyZSCRpDRUTYuFkIgnOfP/ 32JYDIdYCZyNN+xAB1CbAAu1jZrj4oFWluD0OBHrs55helDzdNwycn2NlKAaFPsEKL1tTc noo3Xwd0MwOQBCw6hPQLD7q32xx7sEg= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-iUJWnKshN2KCtgRyUTlcfA-1; Tue, 03 Oct 2023 04:58:59 -0400 X-MC-Unique: iUJWnKshN2KCtgRyUTlcfA-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-9ae56805c41so17130966b.0 for ; Tue, 03 Oct 2023 01:58:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696323537; x=1696928337; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=v3nmu3krFFKLD3v68LyglQg7qgblXckqiH4dxOfI2bk=; b=PkP5Dc0564ESqjO3erokvBYI6ndz79fwzwlTDjXbNkRIgVhG5Eh+1bSxRHpU5Utrw7 ho/nOIXzae3hML3KsjpDGTg4PkKXzEFcL0sUpONp1YaKHNFMH9t4KQ84+gGEH7CFgwF4 D2EuwEYObgdDPHL+Qbl8TOXmS1oo6TCiW1AFvAp1RNOa88TgUasu7TYxvGELl+QN+HUM I7bTVjLnpi1TlZ8kupyS8jPuqE5JSroI6QfD0XaWInqd/DPRSnkxfZg42kPVbBvyERMg zkHTSOblo2d9AxTcBQW65bAhOzQZc/Gt6KnUb0Z12+Arv/zD0NzNcgcrh17E488ZHbI0 6LnQ== X-Gm-Message-State: AOJu0YwzPvL9Ju05hx1WHA+TgXSeYJknV4KgD2uJKBGkJjb2B5H/rX4U eY3Fsmn4CENPi/kIpJ5LJnUqt9A22FVo78kYzyQT4BgoHIAKLhjlRFui7Up0lRKt1Fh3wQpE2Y4 wxfHfbv+Bn5AfOt7/4j0lXq2K6uNrxxMI X-Received: by 2002:a17:906:104e:b0:9b2:bf2d:6b66 with SMTP id j14-20020a170906104e00b009b2bf2d6b66mr11343752ejj.7.1696323537100; Tue, 03 Oct 2023 01:58:57 -0700 (PDT) X-Received: by 2002:a17:906:104e:b0:9b2:bf2d:6b66 with SMTP id j14-20020a170906104e00b009b2bf2d6b66mr11343741ejj.7.1696323536738; Tue, 03 Oct 2023 01:58:56 -0700 (PDT) Received: from gerbillo.redhat.com (146-241-232-193.dyn.eolo.it. [146.241.232.193]) by smtp.gmail.com with ESMTPSA id si13-20020a170906cecd00b009ad850d4760sm690402ejb.219.2023.10.03.01.58.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 01:58:56 -0700 (PDT) Message-ID: <3666c3b4628d6d82ccff593d051706db3896e5af.camel@redhat.com> Subject: Re: [PATCH] tipc: Fix uninit-value access in tipc_nl_node_reset_link_stats() From: Paolo Abeni To: Shigeru Yoshida , jmaloy@redhat.com, ying.xue@windriver.com Cc: netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, syzbot+5138ca807af9d2b42574@syzkaller.appspotmail.com Date: Tue, 03 Oct 2023 10:58:54 +0200 In-Reply-To: <20230924060325.3779150-1-syoshida@redhat.com> References: <20230924060325.3779150-1-syoshida@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE 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-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 01:59:59 -0700 (PDT) On Sun, 2023-09-24 at 15:03 +0900, Shigeru Yoshida wrote: > syzbot reported the following uninit-value access issue: >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > BUG: KMSAN: uninit-value in strlen lib/string.c:418 [inline] > BUG: KMSAN: uninit-value in strstr+0xb8/0x2f0 lib/string.c:756 > strlen lib/string.c:418 [inline] > strstr+0xb8/0x2f0 lib/string.c:756 > tipc_nl_node_reset_link_stats+0x3ea/0xb50 net/tipc/node.c:2595 > genl_family_rcv_msg_doit net/netlink/genetlink.c:971 [inline] > genl_family_rcv_msg net/netlink/genetlink.c:1051 [inline] > genl_rcv_msg+0x11ec/0x1290 net/netlink/genetlink.c:1066 > netlink_rcv_skb+0x371/0x650 net/netlink/af_netlink.c:2545 > genl_rcv+0x40/0x60 net/netlink/genetlink.c:1075 > netlink_unicast_kernel net/netlink/af_netlink.c:1342 [inline] > netlink_unicast+0xf47/0x1250 net/netlink/af_netlink.c:1368 > netlink_sendmsg+0x1238/0x13d0 net/netlink/af_netlink.c:1910 > sock_sendmsg_nosec net/socket.c:730 [inline] > sock_sendmsg net/socket.c:753 [inline] > ____sys_sendmsg+0x9c2/0xd60 net/socket.c:2541 > ___sys_sendmsg+0x28d/0x3c0 net/socket.c:2595 > __sys_sendmsg net/socket.c:2624 [inline] > __do_sys_sendmsg net/socket.c:2633 [inline] > __se_sys_sendmsg net/socket.c:2631 [inline] > __x64_sys_sendmsg+0x307/0x490 net/socket.c:2631 > do_syscall_x64 arch/x86/entry/common.c:50 [inline] > do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 > entry_SYSCALL_64_after_hwframe+0x63/0xcd >=20 > Uninit was created at: > slab_post_alloc_hook+0x12f/0xb70 mm/slab.h:767 > slab_alloc_node mm/slub.c:3478 [inline] > kmem_cache_alloc_node+0x577/0xa80 mm/slub.c:3523 > kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:559 > __alloc_skb+0x318/0x740 net/core/skbuff.c:650 > alloc_skb include/linux/skbuff.h:1286 [inline] > netlink_alloc_large_skb net/netlink/af_netlink.c:1214 [inline] > netlink_sendmsg+0xb34/0x13d0 net/netlink/af_netlink.c:1885 > sock_sendmsg_nosec net/socket.c:730 [inline] > sock_sendmsg net/socket.c:753 [inline] > ____sys_sendmsg+0x9c2/0xd60 net/socket.c:2541 > ___sys_sendmsg+0x28d/0x3c0 net/socket.c:2595 > __sys_sendmsg net/socket.c:2624 [inline] > __do_sys_sendmsg net/socket.c:2633 [inline] > __se_sys_sendmsg net/socket.c:2631 [inline] > __x64_sys_sendmsg+0x307/0x490 net/socket.c:2631 > do_syscall_x64 arch/x86/entry/common.c:50 [inline] > do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 > entry_SYSCALL_64_after_hwframe+0x63/0xcd >=20 > Link names must be null-terminated strings. If a link name which is not > null-terminated is passed through netlink, strstr() and similar functions > can cause buffer overrun. This causes the above issue. >=20 > This patch fixes this issue by returning -EINVAL if a non-null-terminated > link name is passed. >=20 > Fixes: ae36342b50a9 ("tipc: add link stat reset to new netlink api") > Reported-and-tested-by: syzbot+5138ca807af9d2b42574@syzkaller.appspotmail= .com > Closes: https://syzkaller.appspot.com/bug?extid=3D5138ca807af9d2b42574 > Signed-off-by: Shigeru Yoshida > --- > net/tipc/node.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/net/tipc/node.c b/net/tipc/node.c > index 3105abe97bb9..f167bdafc034 100644 > --- a/net/tipc/node.c > +++ b/net/tipc/node.c > @@ -2586,6 +2586,10 @@ int tipc_nl_node_reset_link_stats(struct sk_buff *= skb, struct genl_info *info) > =20 > link_name =3D nla_data(attrs[TIPC_NLA_LINK_NAME]); > =20 > + if (link_name[strnlen(link_name, > + nla_len(attrs[TIPC_NLA_LINK_NAME]))] !=3D '\0') > + return -EINVAL; I have the same comment as for the other tipc patch, please use nla_strscpy instead, thanks! Paolo