From patchwork Wed Nov 8 15:44:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shigeru Yoshida X-Patchwork-Id: 163093 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp999991vqo; Wed, 8 Nov 2023 07:46:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGoh/nigRTmwbi2tiJEfATnt2wVVH2vv8xyz1buFYMSfu6zjChcvojDeBsgb0tI+C8wzM65 X-Received: by 2002:a05:6a21:78a6:b0:180:e3f1:4f60 with SMTP id bf38-20020a056a2178a600b00180e3f14f60mr2496472pzc.45.1699458383909; Wed, 08 Nov 2023 07:46:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699458383; cv=none; d=google.com; s=arc-20160816; b=wWv4vN6/FLCnXZUfY9iNlaYatfl9O+o+apmZrAy7Vku0+6xMBVaN59J+L1IZGROGJk FaHXRYD+5bw7Qks3FNepAZh3zmDPDP+AEM6mQgiZdPxuGwcAZBeZEw19ibpbPsZ21dUs WLI1bkI4NXl3xr9qHxeTqQnwiScVGz8Pzt2DywiGutydX2HUYkG9xI3omg5AsDx1xinN RiXiNqEOL/CE3wHlDPVaac30lHbG1xULSpKabPL/S+gkj69yOnrK/JaMRUmrXPC4HsKN PP+v8AdmJF1VMCRlKJiOo9ftwzRd3tAnngJWjZ9KdMsa1J3b9gm1h3F5CKsL1i/20HYC zcRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=9pfTamduDuXvj1ycdmEqtqmHUJQLMXtDuZ7PUu6n6YA=; fh=lOeNfBabuFR7PEru4M84sDwlfGl7O1modqGPeM+8LEc=; b=a0E+J1xJfnO7Uo8Ya2zoTG/qMzCsaj6/SYywjp7IhnV7vFtq/rG/xrwmk7HtcwQ0D/ 1WPKBXocOIG7cbcJYfjo+rTGCw8GGQBopk5NULNKmh5JBYx9QShPZ0+z00+g1iReTrCB 8FBu3yptunjcicvqDGTjXqoQ4UAXIA7tUNCR6R4dxjjpu8ncnrTLvqnb/c8HOpR68F50 3seZ3K1ZAdIX+SV/zfq6NSrLNE2DVZmricnODI7YAmPcsZB5nBSXP8TmU2rL78COJZ7Q yJl8kYNU/9WXb15hSYD5IF98NNZ3cM33yy6dlPJvG+v1Vbz9uK/bkDuYOVkEjVbX4ADp gzxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="jREken/x"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id ka8-20020a056a00938800b0068e4a646d2csi13055963pfb.252.2023.11.08.07.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 07:46:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="jREken/x"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id AECD98120444; Wed, 8 Nov 2023 07:46:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234704AbjKHPp1 (ORCPT + 32 others); Wed, 8 Nov 2023 10:45:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233454AbjKHPpS (ORCPT ); Wed, 8 Nov 2023 10:45:18 -0500 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 432101FDA for ; Wed, 8 Nov 2023 07:44:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699458268; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=9pfTamduDuXvj1ycdmEqtqmHUJQLMXtDuZ7PUu6n6YA=; b=jREken/xfshM5fckfCQh7onDDbyjPRPAdvl1S909c91VnU4tZ5Y66O8+1LuN5p51ipLVzO Ubm4Jga0iIBfZko18dX5cLrfMWp0d7/SEwTOy+rpqZJJ/Z/negrBpXpDNA+rQnpxmYPKaw Ft/y1pSFE9gd4MZSEaKN/Vkhcfw9YkY= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-453-Xlh4_8-ROE-tRAOkbIkl0w-1; Wed, 08 Nov 2023 10:44:27 -0500 X-MC-Unique: Xlh4_8-ROE-tRAOkbIkl0w-1 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-6b1f7baa5ceso4960315b3a.2 for ; Wed, 08 Nov 2023 07:44:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699458266; x=1700063066; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9pfTamduDuXvj1ycdmEqtqmHUJQLMXtDuZ7PUu6n6YA=; b=FXrH0Ew9vUGmGxr2mvM5OCdA4WNWrd/Uu9LNsecVf+vNpdl9YB/Yg3tRhtHd9rAyCq uVVVCmYWGMat6FkPP+PImxx5Gr8hIvc1A0SVrer8Zij4jXgBt6U3slZ94VdidNbCewOv Vr5Tho7Mz7tK8AWTnxtZxH8tKUTmKHAfbDQ173PEdJYNPfkFrirNIro4nd4Jn/vHSL9r CKi1NsvHF3SEIv2s1FXLHP8iBDxG73dLUcgj6I5HjH/TX4RN9s7A8DHt79evYtElvz8m TMB4PDfWJ95QR37ZcyFalRu8ctkJj1kTiMOisEJKLySjKf1lo+OLXgZ+20zx678TTHG6 xKSQ== X-Gm-Message-State: AOJu0YzRcfZCkApfu8f9cPsI1udf0LVPrFClmFRYr9bu1fLv1rul5OCz 1e4n1wgpLO+3d7dN1FtvhNE3O2zGPWIge0i1M/IQR3iU7L/bpMiy5mAnDoUgqJBF+9atUIi7GNy kpofva/qljKHnMgBfNKBIp9HN X-Received: by 2002:a05:6a20:7349:b0:181:7aa7:de46 with SMTP id v9-20020a056a20734900b001817aa7de46mr1945368pzc.8.1699458265961; Wed, 08 Nov 2023 07:44:25 -0800 (PST) X-Received: by 2002:a05:6a20:7349:b0:181:7aa7:de46 with SMTP id v9-20020a056a20734900b001817aa7de46mr1945350pzc.8.1699458265661; Wed, 08 Nov 2023 07:44:25 -0800 (PST) Received: from kernel-devel.local ([240d:1a:c0d:9f00:245e:16ff:fe87:c960]) by smtp.gmail.com with ESMTPSA id ei4-20020a056a0080c400b006c31b4d5e57sm9161068pfb.184.2023.11.08.07.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 07:44:25 -0800 (PST) From: Shigeru Yoshida To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux-ppp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Shigeru Yoshida Subject: [PATCH net] tty: Fix uninit-value access in ppp_sync_receive() Date: Thu, 9 Nov 2023 00:44:20 +0900 Message-ID: <20231108154420.1474853-1-syoshida@redhat.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 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 (groat.vger.email [0.0.0.0]); Wed, 08 Nov 2023 07:46:13 -0800 (PST) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782011274698516333 X-GMAIL-MSGID: 1782011274698516333 KMSAN reported the following uninit-value access issue: ===================================================== BUG: KMSAN: uninit-value in ppp_sync_input drivers/net/ppp/ppp_synctty.c:690 [inline] BUG: KMSAN: uninit-value in ppp_sync_receive+0xdc9/0xe70 drivers/net/ppp/ppp_synctty.c:334 ppp_sync_input drivers/net/ppp/ppp_synctty.c:690 [inline] ppp_sync_receive+0xdc9/0xe70 drivers/net/ppp/ppp_synctty.c:334 tiocsti+0x328/0x450 drivers/tty/tty_io.c:2295 tty_ioctl+0x808/0x1920 drivers/tty/tty_io.c:2694 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:871 [inline] __se_sys_ioctl+0x211/0x400 fs/ioctl.c:857 __x64_sys_ioctl+0x97/0xe0 fs/ioctl.c:857 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x63/0x6b Uninit was created at: __alloc_pages+0x75d/0xe80 mm/page_alloc.c:4591 __alloc_pages_node include/linux/gfp.h:238 [inline] alloc_pages_node include/linux/gfp.h:261 [inline] __page_frag_cache_refill+0x9a/0x2c0 mm/page_alloc.c:4691 page_frag_alloc_align+0x91/0x5d0 mm/page_alloc.c:4722 page_frag_alloc include/linux/gfp.h:322 [inline] __netdev_alloc_skb+0x215/0x6d0 net/core/skbuff.c:728 netdev_alloc_skb include/linux/skbuff.h:3225 [inline] dev_alloc_skb include/linux/skbuff.h:3238 [inline] ppp_sync_input drivers/net/ppp/ppp_synctty.c:669 [inline] ppp_sync_receive+0x237/0xe70 drivers/net/ppp/ppp_synctty.c:334 tiocsti+0x328/0x450 drivers/tty/tty_io.c:2295 tty_ioctl+0x808/0x1920 drivers/tty/tty_io.c:2694 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:871 [inline] __se_sys_ioctl+0x211/0x400 fs/ioctl.c:857 __x64_sys_ioctl+0x97/0xe0 fs/ioctl.c:857 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x63/0x6b CPU: 0 PID: 12950 Comm: syz-executor.1 Not tainted 6.6.0-14500-g1c41041124bd #10 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc38 04/01/2014 ===================================================== ppp_sync_input() checks the first 2 bytes of the data are PPP_ALLSTATIONS and PPP_UI. However, if the data length is 1 and the first byte is PPP_ALLSTATIONS, an access to an uninitialized value occurs when checking PPP_UI. This patch resolves this issue by checking the data length. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Shigeru Yoshida Reviewed-by: Simon Horman --- drivers/net/ppp/ppp_synctty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c index ebcdffdf4f0e..ea261a628786 100644 --- a/drivers/net/ppp/ppp_synctty.c +++ b/drivers/net/ppp/ppp_synctty.c @@ -687,7 +687,7 @@ ppp_sync_input(struct syncppp *ap, const u8 *buf, const u8 *flags, int count) /* strip address/control field if present */ p = skb->data; - if (p[0] == PPP_ALLSTATIONS && p[1] == PPP_UI) { + if (skb->len >= 2 && p[0] == PPP_ALLSTATIONS && p[1] == PPP_UI) { /* chop off address/control */ if (skb->len < 3) goto err;