From patchwork Wed Jun 1 01:48:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hoang Huu Le X-Patchwork-Id: 12866293 X-Patchwork-Delegate: kuba@kernel.org 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 59679C433F5 for ; Wed, 1 Jun 2022 01:49:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349038AbiFABtN (ORCPT ); Tue, 31 May 2022 21:49:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231584AbiFABtN (ORCPT ); Tue, 31 May 2022 21:49:13 -0400 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20112.outbound.protection.outlook.com [40.107.2.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E6F88DDE0 for ; Tue, 31 May 2022 18:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fUQuyXhpJW7kWJE13W07CtscDXe0RZAQnKkIKiMk20Ka8T3FOR4BTRd8lSPok2NeEHPyIMHB0v/JixMlyp+diaMuZ/85IfEiYNK7oi60UwjBJs8qAwp8jrG9CU8yOljhBNETd/YQFPCIMmD7U8zhJaVsVVKXnjB6QWyYMUYln90yIlW5ZiAUpgL5/qL+a3awnZjExuCoyh20WGngFM9E+Y17P8FMe408yyE4ZydYAWEjTOg1dcm52f92vJHjWVTXMb9YsDg2FJcWi5yiR6yPXCDuyKpWy/MwaMMM2MyC0guE9WYRn72AIwYCnvP5gFOYirmMw/b94njxLqIG7hCrMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1MV7zhXjLAZejUu+fXaByXEEJzTQFk6yfQpKcEstC0c=; b=QnAga8AspuyBrp/Z12PXY0IIVnMRjdFjJsuxHFSNkNAZd4i+Oe7+5BaMKES56Zl6xd5W/cWseu2JiDTlNkybm3d0cscFoyDbxT+LDdo8Bb1PL6WjUJcyqo1IvFE9FCVoUP2HgGY+8nEink8tkQJfka+3+/+/kk8WYdzV4A4Wg1bwIdenrKYkQ9XESpBkqzNP7NXNQBzniB2qM93cxQzAFbGdqKSd+xpDdfcifSP7mtNmZLT/YsdqPWB9LdTXYsQ+w9BYBdQLBukTMFAwW/+iAIB6zUCtDxJuJiEmiG+77subOj1wjgQFyKUIyIUGyxyPKAnUEF8hOwmYm8Ts3D5Q/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=dektech.com.au; dmarc=pass action=none header.from=dektech.com.au; dkim=pass header.d=dektech.com.au; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dektech.com.au; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1MV7zhXjLAZejUu+fXaByXEEJzTQFk6yfQpKcEstC0c=; b=hGFG66YpF4CJ/cWFABTCpVxxJDFCCDKABmSt20Ybu8LooQil2HjQla5UE0hKP0wJJETA/7m9S4e253k8tnPU23drOO5noWs2uEopNAY96S0xKdvFjx2FdbR7uNhjmNRKKnQOThNJLEJA4szt2EmFxWRDzWfhBn41MYL5MtTh/kw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=dektech.com.au; Received: from DB9PR05MB7641.eurprd05.prod.outlook.com (2603:10a6:10:21f::6) by DB9PR05MB8059.eurprd05.prod.outlook.com (2603:10a6:10:257::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Wed, 1 Jun 2022 01:49:07 +0000 Received: from DB9PR05MB7641.eurprd05.prod.outlook.com ([fe80::84e0:5f1b:9fe2:34f8]) by DB9PR05MB7641.eurprd05.prod.outlook.com ([fe80::84e0:5f1b:9fe2:34f8%2]) with mapi id 15.20.5314.013; Wed, 1 Jun 2022 01:49:07 +0000 From: Hoang Le To: jmaloy@redhat.com, maloy@donjonn.com, ying.xue@windriver.com, tung.q.nguyen@dektech.com.au, kuba@kernel.org, netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net Cc: syzbot+e820fdc8ce362f2dea51@syzkaller.appspotmail.com Subject: [net] tipc: check attribute length for bearer name Date: Wed, 1 Jun 2022 08:48:53 +0700 Message-Id: <20220601014853.4904-1-hoang.h.le@dektech.com.au> X-Mailer: git-send-email 2.30.2 X-ClientProxiedBy: SG2PR02CA0067.apcprd02.prod.outlook.com (2603:1096:4:54::31) To DB9PR05MB7641.eurprd05.prod.outlook.com (2603:10a6:10:21f::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7935cb79-e19c-4a6b-5419-08da4370e9e7 X-MS-TrafficTypeDiagnostic: DB9PR05MB8059:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2CJtF2X4bb0jXT99ZtkAmnzpislKwB19QA0kd47ICbU1xRUBjFvqMtG7usnjiE63HlkHxnl0zV796bQOZfZgPGlfWQW+A6PvYXFjVrbzlybTLfHesQzi+a1CDe0yMTiHNGWJzGfX8xMM8ji7olfiVVbx0oZ8FinyHLoGnQaTtyfZsnnWE+mdP7dPzNKCEoFqLHjlZPU1OpSKRDFNhn5r8hfdnt/QTliHEKQUGgk+JPY7p2M+1Vlpe3ROoHueTjxFXCYs2b+P4LuLkJ7n90Elq/2b1adhqUeaN2ZUKS2BYNVEA5PkO3FNH9u4l5MKBfZXcj5B4x9EV38Wg8o220g9+YHKkQkjLnp5ChiprCLN6hOY2ZVC4z/k47XtT+8jxxkgfexVR/XgkJlTM6y+dIrmHIdP86V06WC6lf2nIQDZDGhdGN36Wps/jvH14F8WIvCtwqLhOFeFfG6DW5Qc4SarqMEyVVVfbXeg1FcV3kF5fPu/RE6enJzTZuUQagY8UeXgzWMhSV6uhLUhV75TA3PMkaVsQUTk5B5Km7qw0LUrOx+hfWcz2PRET/K7kpZTe4IEaeoxL96yte3Frsrjn2GJJRXteFdhuYG6v63+njFpoMy6VEIuW4ZS03fkryxZs2yiTUArSeJzuKWTAqpUoK+lhNAhn65bbEPHAe4GMgGDONxfB1LCJ8xOR8fyWqD/jN0n X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR05MB7641.eurprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(136003)(376002)(39850400004)(346002)(396003)(366004)(38100700002)(186003)(103116003)(66946007)(66476007)(66556008)(36756003)(2616005)(8936002)(8676002)(5660300002)(38350700002)(41300700001)(1076003)(26005)(6506007)(83380400001)(508600001)(55236004)(52116002)(6512007)(86362001)(6666004)(6486002)(2906002)(4326008)(316002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OqDxQdvFK7UcQYd8OL94DDYWN//O0UBrzjOMSYX0DC7KD02V9Ok1zZJBne5/FKIslKQb9XiU248vHxM0JpEaZ3KgSsjmS3cWYrhEp2bQYcvpGnEE9WoLKWxShbkmxTzblG8hMMKm+sFkklYi1zT8Y/y5qW31e2ggNA+f9XWzk0EGnpMKAKZTBYczonPRYygN2JLZ4iPfH4QkAUeN/EJtIyusb5EiG6z6R+JKBYOXR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ejKJ6vlZ7C2egttNictYopm5xbGknbVDqpCGXWBz3BuAcoLjMrWvAHrT1nSIEi+sZdkB3NeOUlZCSo4GgTX6cuFKU48dvMFEIUcLwqvvIer0APQp91x9Kt/e9W0PJzohF1gnAzCBHHViKjd8WlxAqppUunLrNzmcWZdXLWfJINYq8fgVISALC/irRkR84SZ7qgSZk3Ajyz69QqXZBykvi4nuBzkkk4aelyOQHR/sQVn43jjbGsREXrh/SUvQWa41BvYAAQaZXjO1wsdEaa32b3E0nRAd/lttlaYrV9ozmlzpGeBLQc8MOHc+Nv9H1ZtSkGbwuPmYnUQwzZL6qctwmz4G7ayEyp62Z1tNLag+Nb36TVFmBFZK5utUvyfg29hFVG0/M/h3UbVYm9JW9ukRne/bFmW2fspPAniUZqZb/xWOxDOvUHjuYFk0/5AzVUBBpu+XDikNjLgA7g= X-OriginatorOrg: dektech.com.au X-MS-Exchange-CrossTenant-Network-Message-Id: 7935cb79-e19c-4a6b-5419-08da4370e9e7 X-MS-Exchange-CrossTenant-AuthSource: DB9PR05MB7641.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2022 01:49:07.0057 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 1957ea50-0dd8-4360-8db0-c9530df996b2 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FQoRA6zoN3He2VK0e2JmKm83SbuXEen9Oa3djqfr4EU7MnWgg2CCdvrCvjZCfBz2MdAceB2tyaPNtr2VGwPdJ71z/a/7QMRfjxuzIaEAMw0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR05MB8059 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org syzbot reported uninit-value: ===================================================== BUG: KMSAN: uninit-value in string_nocheck lib/vsprintf.c:644 [inline] BUG: KMSAN: uninit-value in string+0x4f9/0x6f0 lib/vsprintf.c:725 string_nocheck lib/vsprintf.c:644 [inline] string+0x4f9/0x6f0 lib/vsprintf.c:725 vsnprintf+0x2222/0x3650 lib/vsprintf.c:2806 vprintk_store+0x537/0x2150 kernel/printk/printk.c:2158 vprintk_emit+0x28b/0xab0 kernel/printk/printk.c:2256 vprintk_default+0x86/0xa0 kernel/printk/printk.c:2283 vprintk+0x15f/0x180 kernel/printk/printk_safe.c:50 _printk+0x18d/0x1cf kernel/printk/printk.c:2293 tipc_enable_bearer net/tipc/bearer.c:371 [inline] __tipc_nl_bearer_enable+0x2022/0x22a0 net/tipc/bearer.c:1033 tipc_nl_bearer_enable+0x6c/0xb0 net/tipc/bearer.c:1042 genl_family_rcv_msg_doit net/netlink/genetlink.c:731 [inline] - Do sanity check the attribute length for TIPC_NLA_BEARER_NAME. - Do not use 'illegal name' in printing message. Reported-by: syzbot+e820fdc8ce362f2dea51@syzkaller.appspotmail.com Acked-by: Jon Maloy Signed-off-by: Hoang Le --- net/tipc/bearer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 6d39ca05f249..0fd7554c7cde 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c @@ -258,10 +258,10 @@ static int tipc_enable_bearer(struct net *net, const char *name, char *errstr = ""; u32 i; - if (!bearer_name_validate(name, &b_names)) { - errstr = "illegal name"; + if (strlen(name) > TIPC_MAX_BEARER_NAME || + !bearer_name_validate(name, &b_names)) { NL_SET_ERR_MSG(extack, "Illegal name"); - goto rejected; + return res; } if (prio > TIPC_MAX_LINK_PRI && prio != TIPC_MEDIA_LINK_PRI) {