From patchwork Thu Oct 13 17:52:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2187 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp408695wrs; Thu, 13 Oct 2022 11:03:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM435D1yAovsLmSbn6lePZs45PAfNWv8K7eBHSBEQu69FBzAES0wdCsbaV2I4yWGCLduvD37 X-Received: by 2002:a63:e254:0:b0:459:a2cd:cbfc with SMTP id y20-20020a63e254000000b00459a2cdcbfcmr962856pgj.275.1665684227122; Thu, 13 Oct 2022 11:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684227; cv=none; d=google.com; s=arc-20160816; b=eJnWR4pvqGAlUmTqWPhiKi8CRxtGRIExjD8yqpVp88NblgHoOtK7NetHuVGBqCES2y J08zrHWi9uKNylj6iGmQe31x5azgc/CLFFMNV3Am9oT4TVE3+u8lGiBUlI3Enobd3Bdp YoIjsBIIUvfOr4cR0280ml3i4mBVC611TraWUd7hm1mxN/HDqw3wnOADTixyok9yIsg6 VN7YUTzZfMFxiCoFvmVFKAYkrLY/DAC+RTq3miVaFqkCzAZ/1wvnQAMAKiWaoOLxEKO8 H2b/YGdaDPflIZxsl5QxBiy6pT9jNvVutR7xDdYM8UtEl9nEizt1qsFMHlDaU1MWRYk2 ddqQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gr70zjtQ5jas1vsdeVG/L1D1vspGliz/Fs9Dp0vmGK4=; b=DFqBQlrlDCzavmzQKtijT50ia35bdpLMyYBEKbOEKnhdcBRrxz5dUxfrU0wugEdkPm Pffkw6kvc/Wbemd8I4hchVCSv+rN6aSMg5RlfcjfYrjK/SKOoBqhrsh8hNv6D6VNNr+T cgWN9aynqpZXwEiHjOfY2yojqts0V0ohKt7x/W0mW/yvveSIAKecfncDPAhe8/ZEnspR B9YAIH1QpXwsl6HlT0/mnLu8rSvBEvJy3E7IB5QRMwMEnDgJOuzCzN9HkMZLUyXxlJ8Z fZHv4djZUim7pl3q7i0natzQ9Pw12pypxJcKefbpWJAFHizmuKiKF4K6i5mbVZEBkwVz +IeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MUaGzmNV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a170902e94500b00174ab1a7deasi353527pll.316.2022.10.13.11.03.14; Thu, 13 Oct 2022 11:03:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MUaGzmNV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230364AbiJMSBw (ORCPT + 99 others); Thu, 13 Oct 2022 14:01:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230349AbiJMSBf (ORCPT ); Thu, 13 Oct 2022 14:01:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF7F6252B2; Thu, 13 Oct 2022 11:01:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BA0CD61912; Thu, 13 Oct 2022 17:57:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5C7CC433C1; Thu, 13 Oct 2022 17:57:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683844; bh=WxTjm5MReSjYjJAxBKI25pFq0/+t7woJOCT/OnWP32o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MUaGzmNVfpvWgEh1fEzyyu7MiZLWmpuFdLz6uh6xuYMPIXBjyKtgxwqej0dsP47cT wvKBdRmir/8fkA2YQ74B3FHaCWbTrXs0QPIHAxI+gxH6HS5CZxrsHUHJvA0AMnwvQT oV2vdj6KaksCDxRtLDZMgJK51yq5CUePAuFV81Dk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ryusuke Konishi , syzbot+b8c672b0e22615c80fe0@syzkaller.appspotmail.com, Khalid Masum , Andrew Morton Subject: [PATCH 5.15 02/27] nilfs2: fix use-after-free bug of struct nilfs_root Date: Thu, 13 Oct 2022 19:52:31 +0200 Message-Id: <20221013175143.616232783@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596504238011806?= X-GMAIL-MSGID: =?utf-8?q?1746596504238011806?= From: Ryusuke Konishi commit d325dc6eb763c10f591c239550b8c7e5466a5d09 upstream. If the beginning of the inode bitmap area is corrupted on disk, an inode with the same inode number as the root inode can be allocated and fail soon after. In this case, the subsequent call to nilfs_clear_inode() on that bogus root inode will wrongly decrement the reference counter of struct nilfs_root, and this will erroneously free struct nilfs_root, causing kernel oopses. This fixes the problem by changing nilfs_new_inode() to skip reserved inode numbers while repairing the inode bitmap. Link: https://lkml.kernel.org/r/20221003150519.39789-1-konishi.ryusuke@gmail.com Signed-off-by: Ryusuke Konishi Reported-by: syzbot+b8c672b0e22615c80fe0@syzkaller.appspotmail.com Reported-by: Khalid Masum Tested-by: Ryusuke Konishi Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/nilfs2/inode.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -332,6 +332,7 @@ struct inode *nilfs_new_inode(struct ino struct inode *inode; struct nilfs_inode_info *ii; struct nilfs_root *root; + struct buffer_head *bh; int err = -ENOMEM; ino_t ino; @@ -347,11 +348,25 @@ struct inode *nilfs_new_inode(struct ino ii->i_state = BIT(NILFS_I_NEW); ii->i_root = root; - err = nilfs_ifile_create_inode(root->ifile, &ino, &ii->i_bh); + err = nilfs_ifile_create_inode(root->ifile, &ino, &bh); if (unlikely(err)) goto failed_ifile_create_inode; /* reference count of i_bh inherits from nilfs_mdt_read_block() */ + if (unlikely(ino < NILFS_USER_INO)) { + nilfs_warn(sb, + "inode bitmap is inconsistent for reserved inodes"); + do { + brelse(bh); + err = nilfs_ifile_create_inode(root->ifile, &ino, &bh); + if (unlikely(err)) + goto failed_ifile_create_inode; + } while (ino < NILFS_USER_INO); + + nilfs_info(sb, "repaired inode bitmap for reserved inodes"); + } + ii->i_bh = bh; + atomic64_inc(&root->inodes_count); inode_init_owner(&init_user_ns, inode, dir, mode); inode->i_ino = ino; From patchwork Thu Oct 13 17:52:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp407241wrs; Thu, 13 Oct 2022 11:01:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6/TPjIcdKtRDCEa69pRb4+9ALGSuaHQP+LXcXa4ad3/Xxpatpq1OR8DgjR9mIYG9ZKSe0g X-Received: by 2002:aa7:cd10:0:b0:45c:2c83:1208 with SMTP id b16-20020aa7cd10000000b0045c2c831208mr815150edw.81.1665684104787; Thu, 13 Oct 2022 11:01:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684104; cv=none; d=google.com; s=arc-20160816; b=DhvQRmCpIejPjtDZTeippcFFcQWbErMxOUBYNChOAsjPbmgSLhJANPjwmBgy/DWm4s CeX2EfnHPbl3fgiYpDYAqFaL9DNoU5L8mq5w13wkKQX/WSKxzKKiHywko3Pp46A4TlNT Qk/WloaOqGfDd3+llFjI6qGFRCxDBnl7RioTTevfUYUQVKra4zRCTcT67afm778VcyIg dlQm+MosbllvNz+l4ArC5ONTlprW4bvG8bBhQMc5pEF1qvO+1wfiV4bJHHXqV9waxe8/ wJ7i7KRMb2hMVSGtsyoDJKNxWzOfin1gx1bIg7Pzt7PSJ8dYmKdpke0YdT8ztGZi+iJC pzFA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2b2/wfbgbXHKU9tF9t50KaWRwLvzMNyAJEdOZl2R4UA=; b=So+XkaVT9DXq4jnC0Exg7y5jVgsm1BpFZFJbI89uORJE0nSsM14QxSN4PNKDKUshIr 18NXWB+uYermKJaxZ+N+8OiPrjjIV+vvzpCcRh3WzVGSIZhDs47q1MynKIxPiNnAHN6A zC7JsDXahprQKiTTkkXuN3yf7SyUSxrd8lkGrVQuG24o0EQse34dVi0QM9n8kUP+CPNa yAMw0TxxvpeFMJBfm0O4d0YZhOuzMebpaQxmtimiDXlrp4xbVhZ8dH5T0dPRMW5rOXng Ih3QTjOzsrrhXB3oWKPwEd7z0s14SG+E3oFfzCyxLNNgm0PHc05WUy8R9+Ipzo4hNlPJ Lxcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Uu6Z791w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dk11-20020a0564021d8b00b004544518b7dasi300885edb.148.2022.10.13.11.01.14; Thu, 13 Oct 2022 11:01:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Uu6Z791w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230281AbiJMR7H (ORCPT + 99 others); Thu, 13 Oct 2022 13:59:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229958AbiJMR6O (ORCPT ); Thu, 13 Oct 2022 13:58:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA2CF786FB; Thu, 13 Oct 2022 10:57:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EB118B82049; Thu, 13 Oct 2022 17:57:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54FCAC433D7; Thu, 13 Oct 2022 17:57:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683877; bh=4/0gbWRoGgXhcpCItadg29FCqoOIDIWdJPHkOeinRzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uu6Z791wqe4g26G/Zjx4yFKFpQfBeekyhVZukkqOZ92SWnRWH4KGvwNkMrCNqcW77 nG7ZNIfhsCRIEfN6AtqDEjKmjy3r8byBfPOde95lymedRRyprilRPInuwLvwGOlt9w qhKh8CZs96hybsRXoYYhqrjG7qePKCT1M7O9b7Rc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ryusuke Konishi , syzbot+7381dc4ad60658ca4c05@syzkaller.appspotmail.com, Andrew Morton Subject: [PATCH 5.15 03/27] nilfs2: fix leak of nilfs_root in case of writer thread creation failure Date: Thu, 13 Oct 2022 19:52:32 +0200 Message-Id: <20221013175143.653197774@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596376279948555?= X-GMAIL-MSGID: =?utf-8?q?1746596376279948555?= From: Ryusuke Konishi commit d0d51a97063db4704a5ef6bc978dddab1636a306 upstream. If nilfs_attach_log_writer() failed to create a log writer thread, it frees a data structure of the log writer without any cleanup. After commit e912a5b66837 ("nilfs2: use root object to get ifile"), this causes a leak of struct nilfs_root, which started to leak an ifile metadata inode and a kobject on that struct. In addition, if the kernel is booted with panic_on_warn, the above ifile metadata inode leak will cause the following panic when the nilfs2 kernel module is removed: kmem_cache_destroy nilfs2_inode_cache: Slab cache still has objects when called from nilfs_destroy_cachep+0x16/0x3a [nilfs2] WARNING: CPU: 8 PID: 1464 at mm/slab_common.c:494 kmem_cache_destroy+0x138/0x140 ... RIP: 0010:kmem_cache_destroy+0x138/0x140 Code: 00 20 00 00 e8 a9 55 d8 ff e9 76 ff ff ff 48 8b 53 60 48 c7 c6 20 70 65 86 48 c7 c7 d8 69 9c 86 48 8b 4c 24 28 e8 ef 71 c7 00 <0f> 0b e9 53 ff ff ff c3 48 81 ff ff 0f 00 00 77 03 31 c0 c3 53 48 ... Call Trace: ? nilfs_palloc_freev.cold.24+0x58/0x58 [nilfs2] nilfs_destroy_cachep+0x16/0x3a [nilfs2] exit_nilfs_fs+0xa/0x1b [nilfs2] __x64_sys_delete_module+0x1d9/0x3a0 ? __sanitizer_cov_trace_pc+0x1a/0x50 ? syscall_trace_enter.isra.19+0x119/0x190 do_syscall_64+0x34/0x80 entry_SYSCALL_64_after_hwframe+0x63/0xcd ... Kernel panic - not syncing: panic_on_warn set ... This patch fixes these issues by calling nilfs_detach_log_writer() cleanup function if spawning the log writer thread fails. Link: https://lkml.kernel.org/r/20221007085226.57667-1-konishi.ryusuke@gmail.com Fixes: e912a5b66837 ("nilfs2: use root object to get ifile") Signed-off-by: Ryusuke Konishi Reported-by: syzbot+7381dc4ad60658ca4c05@syzkaller.appspotmail.com Tested-by: Ryusuke Konishi Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/nilfs2/segment.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -2786,10 +2786,9 @@ int nilfs_attach_log_writer(struct super inode_attach_wb(nilfs->ns_bdev->bd_inode, NULL); err = nilfs_segctor_start_thread(nilfs->ns_writer); - if (err) { - kfree(nilfs->ns_writer); - nilfs->ns_writer = NULL; - } + if (unlikely(err)) + nilfs_detach_log_writer(sb); + return err; } From patchwork Thu Oct 13 17:52:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2222 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp411387wrs; Thu, 13 Oct 2022 11:08:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Yixxbwmtkpda3DNtXQjjFHNx2GuccC7PfMdwUGf8BLqSTp2Y3AsOpSwtcVUKo9eepf+6b X-Received: by 2002:a65:5886:0:b0:439:8dd3:18d4 with SMTP id d6-20020a655886000000b004398dd318d4mr976552pgu.430.1665684508190; Thu, 13 Oct 2022 11:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684508; cv=none; d=google.com; s=arc-20160816; b=BxKmZHMnbgqkEu6NDtZH2en4Y3mkKkNw0KAZ1fB5GPfKNzEnGfdZC9gToTdFdld185 VjgCfYdvqG8e/X59+7b+VVkEffMeX8HR9BxZ1/RmkiRFN/xcPeogdqLlD21N/K7O8A/x qZpIJcUUM8nA76yoaAkr8B3W2ZbG/9zl21RsrKqQ+aJlY9k4mW+pjbsgulyH/JzpgUAy 91onqSD4SsG60NAWeQ/rfOthoyPopukKdnPRtmP8s1wIaRyZplm5qfgHclXfIKp0oEkd cdW6izzOxRXQ0WJ/ezZBE3B5dPyK2A2pO3j0wJPbAMLSIrhu/7ZvCJhW0Yxw9RwxFLs+ d06g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aNgRi6K6QlKRGK4Ipwa6FfNJWusnQAp2ZBui43ru6fM=; b=PMFPNuGQWyxh9P5O6ScLF2uq9TDBXGKx66gjDbri3XWMq1NFab7m70yk0wo2Pb5ciP bDBYO5Q8f6IegwQQkLO7MdKELAkjY6w+I2IxVuotCesYjlDO+CAhplmjMNxl40S6CKuM c5ocbROVxiPCBDJPqkOyEq71lJSzLP/KPD0Q773Z4+MFdgF+Y5vrkMBRwA4wJqDBLlS0 hXqkJGmx17mVIyVZvAUUHCNkz/ULOWotgPugIScbV7NQLUdvAO18CBRyr0k0d/PShlzK NGSuOW8OHtX+uNUWNFx0pl6zQTi8DB9qURgKY24fvwMApyf3wqf8mseFLDYMEwhg/Vmh 2yAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x1foWNh7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c13-20020a170903234d00b0017f685b47b8si453473plh.151.2022.10.13.11.08.15; Thu, 13 Oct 2022 11:08:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x1foWNh7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbiJMSGj (ORCPT + 99 others); Thu, 13 Oct 2022 14:06:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbiJMSEV (ORCPT ); Thu, 13 Oct 2022 14:04:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6957615B313; Thu, 13 Oct 2022 11:04:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F214E61921; Thu, 13 Oct 2022 17:58:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A014C433C1; Thu, 13 Oct 2022 17:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683910; bh=T5hUlJubGs9iN1Cr22GehC2ffTzgTKc0wkupXsH0j3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x1foWNh7k21DgB0UnQgNC36KTILZOU3Dhtc/3U1mv8Aby3ou+XaOnWHin8vVmtYyk lBKHadawNIpLf9p5/e7rUfWfNR/XSHwrvr1KH6QLAi81yHitR5H5ky2SjEjydqI5Iv /7nj4ELJQ5caFuWFV0xkQGqk3OVyiT/kFCqbCAKY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ryusuke Konishi , syzbot+fbb3e0b24e8dae5a16ee@syzkaller.appspotmail.com, Andrew Morton Subject: [PATCH 5.15 04/27] nilfs2: replace WARN_ONs by nilfs_error for checkpoint acquisition failure Date: Thu, 13 Oct 2022 19:52:33 +0200 Message-Id: <20221013175143.690903420@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596799269469568?= X-GMAIL-MSGID: =?utf-8?q?1746596799269469568?= From: Ryusuke Konishi commit 723ac751208f6d6540191689cfbf6c77135a7a1b upstream. If creation or finalization of a checkpoint fails due to anomalies in the checkpoint metadata on disk, a kernel warning is generated. This patch replaces the WARN_ONs by nilfs_error, so that a kernel, booted with panic_on_warn, does not panic. A nilfs_error is appropriate here to handle the abnormal filesystem condition. This also replaces the detected error codes with an I/O error so that neither of the internal error codes is returned to callers. Link: https://lkml.kernel.org/r/20220929123330.19658-1-konishi.ryusuke@gmail.com Signed-off-by: Ryusuke Konishi Reported-by: syzbot+fbb3e0b24e8dae5a16ee@syzkaller.appspotmail.com Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/nilfs2/segment.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -875,9 +875,11 @@ static int nilfs_segctor_create_checkpoi nilfs_mdt_mark_dirty(nilfs->ns_cpfile); nilfs_cpfile_put_checkpoint( nilfs->ns_cpfile, nilfs->ns_cno, bh_cp); - } else - WARN_ON(err == -EINVAL || err == -ENOENT); - + } else if (err == -EINVAL || err == -ENOENT) { + nilfs_error(sci->sc_super, + "checkpoint creation failed due to metadata corruption."); + err = -EIO; + } return err; } @@ -891,7 +893,11 @@ static int nilfs_segctor_fill_in_checkpo err = nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, nilfs->ns_cno, 0, &raw_cp, &bh_cp); if (unlikely(err)) { - WARN_ON(err == -EINVAL || err == -ENOENT); + if (err == -EINVAL || err == -ENOENT) { + nilfs_error(sci->sc_super, + "checkpoint finalization failed due to metadata corruption."); + err = -EIO; + } goto failed_ibh; } raw_cp->cp_snapshot_list.ssl_next = 0; From patchwork Thu Oct 13 17:52:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2219 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp411164wrs; Thu, 13 Oct 2022 11:08:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM59XAIX4AFOnmoYBQsOI7cV0LCjJzTPtYybZItiNCvVIieOO3ELtANoPH0fzorpTzDpSkRC X-Received: by 2002:a63:470b:0:b0:442:24d7:578 with SMTP id u11-20020a63470b000000b0044224d70578mr1014665pga.198.1665684488242; Thu, 13 Oct 2022 11:08:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684488; cv=none; d=google.com; s=arc-20160816; b=PioiUoMchlUZEqDsYNxW0cQkCj/VjBXm3KXF+P7PuvDqX5meDFhhmNHyXSNH13Omsm Y7Z9vU245dNGmfv3HvimxhoKnARE8v9DHMUi/FD8fYlZKCv7PtbjA06cuIuCJbJq4R3U 7MFCKIpSQ1Plto8Nb5GmpUEZPUKwiX07EE4Lyhjk7kGV0fYMrKUhmhhH/dFouCs0/USU CSuE5Pfx137Ly8NbbTwikMbCutA95a2gpZHhxTmjuUuBPSetUks89NNxAOPXWcfawsNJ xc+7nPxUEglsZ+K45jFxHn7F/TJzMMuLvlHcpTP0wG0L3K6C5dzSQbkUB9Qs3+fM/uUX WCdw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Y51dPL2dJcW8XornZKwyih6E7MaPSTDNxdV4RZ67VRc=; b=Pg3mFQDpQeKxmf9qWvHol37XDptkTrPYbsUTJXM/gaUb9fRRQhL8qhrwIlcXvaPTRx LzvUkxGAT1M346agcUhAiwVOjE+2ESxEtdI2fQ0MUEnD8RxUqT49JqIIS6aVp6oaXAjS v4sdiBvekR/DxEhFgsNYUQQvQoIK62/+JPchr862pncQjxihxDiqMIXVh9/+H6t9WaJs PXoSWsLY6O2yrCI4UDNcwhINB2+d45KegPBkYsFoxwHAH28DOaF2ERzk7c69MP85+bDb h35HZ6RZCv8Uye8GAesy5UBUNf06AKpkzPj4l9F/QMy7P1/7enxJ/g4gkqtFq4LXlyvQ 7OSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OgCHOc6R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h189-20020a6383c6000000b0045feab44f0dsi17855pge.693.2022.10.13.11.07.55; Thu, 13 Oct 2022 11:08:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OgCHOc6R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231578AbiJMSH2 (ORCPT + 99 others); Thu, 13 Oct 2022 14:07:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231197AbiJMSFh (ORCPT ); Thu, 13 Oct 2022 14:05:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3F15286F3; Thu, 13 Oct 2022 11:04:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8D278B82051; Thu, 13 Oct 2022 17:58:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFA1AC43147; Thu, 13 Oct 2022 17:58:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683913; bh=/ENOfpenacNUYYlNZFJ88DSGQqTjUSJmaDxMQfCiVZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OgCHOc6R5vhgK6fUQCNEPYEwOQjJe1IfVVwPEt1RrD5XPeXUjPGKrY9riwVVDwxoQ iYNZNCJPrJDE/4W/XI7RaViG3DBbHAsYKtRvkAq3h4hXl8MO22T1mFrUTm3VIU+byj c8spqCC650WuobdzZpnUKV4wmgHMpQ6ro68lpFJ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hu Weiwen , Xiubo Li , Ilya Dryomov Subject: [PATCH 5.15 05/27] ceph: dont truncate file in atomic_open Date: Thu, 13 Oct 2022 19:52:34 +0200 Message-Id: <20221013175143.724210164@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596778094240121?= X-GMAIL-MSGID: =?utf-8?q?1746596778094240121?= From: Hu Weiwen commit 7cb9994754f8a36ae9e5ec4597c5c4c2d6c03832 upstream. Clear O_TRUNC from the flags sent in the MDS create request. `atomic_open' is called before permission check. We should not do any modification to the file here. The caller will do the truncation afterward. Fixes: 124e68e74099 ("ceph: file operations") Signed-off-by: Hu Weiwen Reviewed-by: Xiubo Li Signed-off-by: Ilya Dryomov [Xiubo: fixed a trivial conflict for 5.19 backport] Signed-off-by: Xiubo Li Signed-off-by: Greg Kroah-Hartman --- fs/ceph/file.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -703,6 +703,12 @@ int ceph_atomic_open(struct inode *dir, if (dentry->d_name.len > NAME_MAX) return -ENAMETOOLONG; + /* + * Do not truncate the file, since atomic_open is called before the + * permission check. The caller will do the truncation afterward. + */ + flags &= ~O_TRUNC; + if (flags & O_CREAT) { if (ceph_quota_is_max_files_exceeded(dir)) return -EDQUOT; @@ -770,9 +776,7 @@ retry: } set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); - err = ceph_mdsc_do_request(mdsc, - (flags & (O_CREAT|O_TRUNC)) ? dir : NULL, - req); + err = ceph_mdsc_do_request(mdsc, (flags & O_CREAT) ? dir : NULL, req); if (err == -ENOENT) { dentry = ceph_handle_snapdir(req, dentry); if (IS_ERR(dentry)) { From patchwork Thu Oct 13 17:52:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2274 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp417844wrs; Thu, 13 Oct 2022 11:24:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6SEWB08wc0Z7TH16bBTX+dWB4ic6IJgso5Y8xEmNP2WKgOGd7ROIrdktfxj5etXJf3qn9V X-Received: by 2002:a17:90b:110c:b0:205:cfeb:cfb with SMTP id gi12-20020a17090b110c00b00205cfeb0cfbmr1185258pjb.75.1665685462527; Thu, 13 Oct 2022 11:24:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665685462; cv=none; d=google.com; s=arc-20160816; b=eoJtMd9Ou0W5MSWftmfJrAHolOANlH2H/LeDrZ39en7z5GnXQJasVN84EuZQVhZkqH jFnWVErmHKj1g4Ilqkpd1ZXQ6/qXci6Fzp7K0ZyRH1OKvSKeTw6xbU6Grm81FiAiY/MV b9bSmROnNVlmYKAHeV/DgnP82yDGIhUlusavbmwjcXgLr+TJqaKGoZNcuTmFbeL2xb9y cFdi+SIoN3L1OP3uzj51wrYCCNLMGxokOq4xBzH5qUc3MS3bVYQ20px/gGHMIrGhEdHP PrKJnWWb0HajxOm0cjPLsl3bCGl3Vmg6JpbcLxnx6P3u3/BcEMMkMPKObwLlOv9YPiOS BJwA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QCCP4Ow6nByYUD6+A0Ve+foJp3blDAILnckBc6Uq/uU=; b=KEytziOoUBnUQMxvwBd8wUdiMjnrO8hCPiTamrrVM+TlRZfK0NTUyStqFBiPOGxWmj cO0ZzwdfIu8lIZYLPOU83kJaac3/Yxf7YzNCzWO/6CeX3WzAjHR8O6RkhHdSr5c+nTjh yXRu2FyMY2GmVmOsT8RxDDccq6+91lWx+v55kVwNIGMzsMjGZXKFvAFfFoPoxkpSEpMG Z1Xzf06QLQW5FnwwcYSM7j5cR/SSDYzizWEJvr6roGeUVSCj4pJSBtt4QZgyXLRNeS29 LEa77dDW5+Go8XjgsTc2FPK7A4q+hY4YdG6EiB8qGi/riPVg1caB3m/011yONlVOv80b llIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O4DlYXgo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t14-20020a63954e000000b0046ae2a8ea9csi43219pgn.733.2022.10.13.11.24.05; Thu, 13 Oct 2022 11:24:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O4DlYXgo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229746AbiJMST3 (ORCPT + 99 others); Thu, 13 Oct 2022 14:19:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbiJMSST (ORCPT ); Thu, 13 Oct 2022 14:18:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6928116C221; Thu, 13 Oct 2022 11:13:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B98B4B8204E; Thu, 13 Oct 2022 17:58:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 132D5C433D6; Thu, 13 Oct 2022 17:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683916; bh=LXvBMZgQGW5rg2p6e0YwUu2ffKqKQwDfqB6k048ZkgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O4DlYXgoF4nGpiwBTbKJ0JGmy46s3yDEVNZ7r8cRvd81eAnvjmAN19q5k2/oMhw8B qNxv9xH4zb1LMFayxgHkmYGfX9jKqy6w4ApVqrz3M3t4WtB4K0bU43weqLKwKjnQms iRIZmjqpPd9v11yy9nQUU62ntXC+PVuBwcVLDqsQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guozihua , Zhongguohua , Al Viro , Theodore Tso , Andrew Lutomirski , "Jason A. Donenfeld" Subject: [PATCH 5.15 06/27] random: restore O_NONBLOCK support Date: Thu, 13 Oct 2022 19:52:35 +0200 Message-Id: <20221013175143.753815853@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597799244198878?= X-GMAIL-MSGID: =?utf-8?q?1746597799244198878?= From: Jason A. Donenfeld commit cd4f24ae9404fd31fc461066e57889be3b68641b upstream. Prior to 5.6, when /dev/random was opened with O_NONBLOCK, it would return -EAGAIN if there was no entropy. When the pools were unified in 5.6, this was lost. The post 5.6 behavior of blocking until the pool is initialized, and ignoring O_NONBLOCK in the process, went unnoticed, with no reports about the regression received for two and a half years. However, eventually this indeed did break somebody's userspace. So we restore the old behavior, by returning -EAGAIN if the pool is not initialized. Unlike the old /dev/random, this can only occur during early boot, after which it never blocks again. In order to make this O_NONBLOCK behavior consistent with other expectations, also respect users reading with preadv2(RWF_NOWAIT) and similar. Fixes: 30c08efec888 ("random: make /dev/random be almost like /dev/urandom") Reported-by: Guozihua Reported-by: Zhongguohua Cc: Al Viro Cc: Theodore Ts'o Cc: Andrew Lutomirski Cc: stable@vger.kernel.org Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/mem.c | 4 ++-- drivers/char/random.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -702,8 +702,8 @@ static const struct memdev { #endif [5] = { "zero", 0666, &zero_fops, 0 }, [7] = { "full", 0666, &full_fops, 0 }, - [8] = { "random", 0666, &random_fops, 0 }, - [9] = { "urandom", 0666, &urandom_fops, 0 }, + [8] = { "random", 0666, &random_fops, FMODE_NOWAIT }, + [9] = { "urandom", 0666, &urandom_fops, FMODE_NOWAIT }, #ifdef CONFIG_PRINTK [11] = { "kmsg", 0644, &kmsg_fops, 0 }, #endif --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1298,6 +1298,11 @@ static ssize_t random_read_iter(struct k { int ret; + if (!crng_ready() && + ((kiocb->ki_flags & (IOCB_NOWAIT | IOCB_NOIO)) || + (kiocb->ki_filp->f_flags & O_NONBLOCK))) + return -EAGAIN; + ret = wait_for_random_bytes(); if (ret != 0) return ret; From patchwork Thu Oct 13 17:52:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2189 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp409476wrs; Thu, 13 Oct 2022 11:04:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM676y0xWKzH+epmoPc36BvsBouUb/qCs26DRWUhlozDSt4GsNW9WCPMoinLF9+En7Jh4BhV X-Received: by 2002:a05:6a00:3493:b0:562:f7c0:cbd9 with SMTP id cp19-20020a056a00349300b00562f7c0cbd9mr773756pfb.4.1665684292977; Thu, 13 Oct 2022 11:04:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684292; cv=none; d=google.com; s=arc-20160816; b=qifAm6oDECnWlVVKfbfn5PPEgdzyApdvviFaMao+MsRif/WM5XeuiJdXM9dITuPibB Bpc7yOd17+6Uug7QVSyf1PPq7ok/LmSymwOch8ocXwzrvVqsQqSn+zIMmVgU2dpoC6Cx yKOZCh+E6LJtJiDEbiYWPhbghhgjiolSYHoaTplhyzctFADQmTxAUZNV7HshYFCPxfQT 6YzhB0r/MU9b+fCrqgLXaVm7JQBwQBl/cYo5bNSl9e+uhM4JJVY8+KxpBGxdsLR2ix7l JGwBvzo+Zt6lw9fDjsJsiSsv0cvSzC4VMV9WonIdLScy93MhGs6AIpyylb6lqG2QUgMh Mrvw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TEa+9wcQTN6Oqv9c5QlN+buJsl5atb3Xa06GanWXoKg=; b=bhuMcCO54INw0+xtkMmeTQVk81qbPBXLfiY7qVKNzIqqjKOTDj7ozc9GVL2U+HLfKI bq+27I6sG2SGSY5R/wU/Ioz/x+945pGA5/VUXEhc5sKrRPh4p8VNQgyPO+mA3WQQZiCY JrHGuH8w4ecNe9FQiUhjmEjlvQinToCEHr8wc8Qne31tQ+1F6WAbXqvJYBEPLKbk1CNh 5xx2PUvNj41BHZVkDXFdyTHYFDxy8vxSuYOOFnlBJPSCQcDuO5Avczyzj2mcBX+JtwH8 CxDhV6CS9e5FwRKauBm/icb0uSfe79eBkGZdQFX8WIsjAyy84b4AgI7RPpGPdlA0g6Od 7FkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="LS2mzlz/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16-20020a170902dad000b00177568a0e53si451664plx.252.2022.10.13.11.04.39; Thu, 13 Oct 2022 11:04:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="LS2mzlz/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230463AbiJMSC4 (ORCPT + 99 others); Thu, 13 Oct 2022 14:02:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230453AbiJMSC3 (ORCPT ); Thu, 13 Oct 2022 14:02:29 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 780C611465; Thu, 13 Oct 2022 11:02:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 98879B82050; Thu, 13 Oct 2022 17:58:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9A31C433D6; Thu, 13 Oct 2022 17:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683919; bh=SzjUWlrxdx6dSBn+CgiQOoaJon3rIv0huAMKubMWhmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LS2mzlz/b5Kdya9N8IqyEurfMDytA4edDfDeSbIDYL3REvu4ea7HDWrPj8vFLd6Sn TdOXRbLBTAF1LUTA/HjeeiuBSMt2+4of6iUHoPJRV6dIZVdMLa2FfYkkd7p2JzbDMS bsC1whr5v7gOQELPhVJfCWdhmlmAMs0XB2H/xyfk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 5.15 07/27] random: clamp credited irq bits to maximum mixed Date: Thu, 13 Oct 2022 19:52:36 +0200 Message-Id: <20221013175143.791866092@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596573141075566?= X-GMAIL-MSGID: =?utf-8?q?1746596573141075566?= From: Jason A. Donenfeld commit e78a802a7b4febf53f2a92842f494b01062d85a8 upstream. Since the most that's mixed into the pool is sizeof(long)*2, don't credit more than that many bytes of entropy. Fixes: e3e33fc2ea7f ("random: do not use input pool from hard IRQs") Cc: stable@vger.kernel.org Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -980,7 +980,7 @@ static void mix_interrupt_randomness(str local_irq_enable(); mix_pool_bytes(pool, sizeof(pool)); - credit_init_bits(max(1u, (count & U16_MAX) / 64)); + credit_init_bits(clamp_t(unsigned int, (count & U16_MAX) / 64, 1, sizeof(pool) * 8)); memzero_explicit(pool, sizeof(pool)); } From patchwork Thu Oct 13 17:52:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2194 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp409723wrs; Thu, 13 Oct 2022 11:05:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7isZvU0VBSuyoY2dNBsQryTTsnBf8eT8cza+11inEzcBZ6txYvvNz/8M9mnHNPL4XRwlJx X-Received: by 2002:a17:90b:1f86:b0:205:d3d0:1931 with SMTP id so6-20020a17090b1f8600b00205d3d01931mr1080234pjb.211.1665684314844; Thu, 13 Oct 2022 11:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684314; cv=none; d=google.com; s=arc-20160816; b=iw7BkYJgdKZIhu1Jf0vaEmMyepTo6y/Z83zqTIUP2IDuck6IIwhziAVAPFkuDU0Joo +gL0VZ6TUQxGCciUBDpm1vBgcilOw8PFREW/ZTDcIYJZDxfa1Oii9H56iutII5yKbIuU Me2+6jsi6e/b22vxbqtRYXuON26tYenGuJXhoVD/8fo2zi973asS+ymXfq22fTFsSDMf J9C3qzohwZ8d54A0T8qUVTwmw7HN3R1/uxtwoqsi21FEG3mTt9WrSrpDWIMnZbWYN6pO DpGvsv8fjzzxuEHC+nR3LudaZRQZsoQYD/MDxo+HxKDOkgm1ebH7AdQSIAcu/jDlUQHr +xxw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UeROimL2JBj3ORyRnFXpE92Ln68hTJGi5N/vUqTIDyM=; b=ctmkJMR+zzwMS/jsqOlJPhRspRE5t6QGVq0iw0ypInVvzM6bnEc9PMyaX4a4BMXjVH MC7SOvTB5cIzl3yW0Hxx4ArdAn0rHmZs3fX+CJ3hA2I2kssytyqdTpjyrIK05RJbOQW7 JbhcuKazb9F3WWRejDdlCOjtN9IrzBehES/dqbnjhVGnk2ib6DIxBvbPiX9MFJZdRGUQ SgdKOQFwnEBQ9WmdpraO4S6ViUeNR929DYdN59t5yJaNogB2kSzo/0UqrmCcQ/ZxCRKC 7pNlXaeUUmFgAEHgDEigaPfIaGQ4piiqsjaXOPtyU1PILzNvtnno+a3lEsYvhYA+yw7R nMSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ag5Of/KA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k3-20020a636f03000000b0044ed39c6858si91284pgc.66.2022.10.13.11.04.59; Thu, 13 Oct 2022 11:05:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ag5Of/KA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230491AbiJMSDI (ORCPT + 99 others); Thu, 13 Oct 2022 14:03:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230379AbiJMSCn (ORCPT ); Thu, 13 Oct 2022 14:02:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ADA916F426; Thu, 13 Oct 2022 11:02:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 807FAB82049; Thu, 13 Oct 2022 17:58:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9611C433D7; Thu, 13 Oct 2022 17:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683922; bh=VG1Ib82ny6UYrmzLQZzTBUrQrO8XhzWhgh+5XQUH54w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ag5Of/KA63u7kufQNaGnbndbprrHG+hA/plb2tpNidkUcIE4CHL8C2sfFjLMCiNZV /3U1itKqsDnKLUQrSM3DCvylnx/hVrFNmEBWaHD7g6lWBkOBbdXSDhmR1ajn1wibRK NUXJcE3OhXV7eZJ7OiRUoYyKmQEgNPPh17SKyA2M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai , Hans de Goede Subject: [PATCH 5.15 08/27] ALSA: hda: Fix position reporting on Poulsbo Date: Thu, 13 Oct 2022 19:52:37 +0200 Message-Id: <20221013175143.828749143@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596596202349410?= X-GMAIL-MSGID: =?utf-8?q?1746596596202349410?= From: Takashi Iwai commit 56e696c0f0c71b77fff921fc94b58a02f0445b2c upstream. Hans reported that his Sony VAIO VPX11S1E showed the broken sound behavior at the start of the stream for a couple of seconds, and it turned out that the position_fix=1 option fixes the issue. It implies that the position reporting is inaccurate, and very likely hitting on all Poulsbo devices. The patch applies the workaround for Poulsbo generically to switch to LPIB mode instead of the default position buffer. Reported-and-tested-by: Hans de Goede Cc: Link: https://lore.kernel.org/r/3e8697e1-87c6-7a7b-d2e8-b21f1d2f181b@redhat.com Link: https://lore.kernel.org/r/20221001142124.7241-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/hda/hda_intel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2523,7 +2523,8 @@ static const struct pci_device_id azx_id .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_NOPM }, /* Poulsbo */ { PCI_DEVICE(0x8086, 0x811b), - .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_BASE }, + .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_BASE | + AZX_DCAPS_POSFIX_LPIB }, /* Oaktrail */ { PCI_DEVICE(0x8086, 0x080a), .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_BASE }, From patchwork Thu Oct 13 17:52:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2301 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp428537wrs; Thu, 13 Oct 2022 11:52:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4BWn5PqGbyXNHWEaUOuuX5ylvXPb3SA/uq94/nYvPLNdeZkA0miOPuBKlrCyyuNNtam1Rj X-Received: by 2002:a17:902:6b88:b0:17e:f177:400 with SMTP id p8-20020a1709026b8800b0017ef1770400mr1325641plk.72.1665687135905; Thu, 13 Oct 2022 11:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665687135; cv=none; d=google.com; s=arc-20160816; b=Y+5NxRYot2ZYcENsgTf5bYkJqiHD3Uben69Ukoi9TYrq0MN9zdYwiDUmzQb9ajCUf6 lCb4AbjotpiAofumZYzoUpfDou25bwEpAgWemsWqjh9ZKy/5E01Mx7dK6RxaWtVIOC+x 3K7vFv+SWv+t4quNnROE6jboMARrVQ3cVWkiF6YF/TWUKDGjIXzIjtO4rYoMbwhjp/vy uE+auJ0hGSMma6rSRx+CBce8G1pF0SdFY/nLelXla3U9Wi/U5wJHGj4WHo0lQ20lMmoN UtZbL4H04NMcISIrkxtH08zc/3P0IqKZiYgQiYq8PovDxn1myJOAbQTW+IOkZ0nzlIif GBew== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GQHBuiutrtStC6ceZygwsbSmjMEFY7gOuWdC36dWwLk=; b=oWTDeKs3bewTpenLyX4DQkGwgOqP1dUXsZHkTFLqPz47J7rDRgrnAFGcYxgKAHFmlQ VmmRvsw75QmhLW0+NE9oaEgepF5AWWdZd8AbAGta/YOOwHHfuUMHyhtNbxlLZmz5J5sJ YMQTlGuBZRcMvoPMil7Jx9QFAR1PyQmYd2MScOwdSi28UdMdYlPhujXXDJQvdtcJyuOG NbpRcMug768fOK6id0Myasg0KE6SGwCqZANxk65TfHVOO04QYQwL2kqQzJJnwA/iJZsh jyL1uxUT4MNPxwzuFn5XhslWXevRbry6jaPRlwzeuCaLSML8o1s8Tb4YaEIC8HCHUWMg /mqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VUlXjfSz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q32-20020a17090a4fa300b00202c7f4631esi6474683pjh.19.2022.10.13.11.52.03; Thu, 13 Oct 2022 11:52:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VUlXjfSz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231968AbiJMShm (ORCPT + 99 others); Thu, 13 Oct 2022 14:37:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231173AbiJMShV (ORCPT ); Thu, 13 Oct 2022 14:37:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F208E43152; Thu, 13 Oct 2022 11:33:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BC095618B8; Thu, 13 Oct 2022 17:58:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5756C433D7; Thu, 13 Oct 2022 17:58:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683925; bh=OEVHSmyP6ry9HP1rzqnCniac1P21E4uC7zWTb3gHzHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VUlXjfSzjP666S5HT/BvcAftShfsD9mOw84ULE51yyeXtvXw9vI2iqULTWBjuXTJS Gg9TzK8KbSIQAoqkCrD5+pUZUnrQY6Ihnbo44w4kJsc60/PorP0Mj9xewJRQcKBPBb TPljA4VUSxRtetDM9WEcORuFovgEH3BLwKMJvnTo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aditya Garg , Samuel Jiang , Orlando Chamberlain , Mimi Zohar Subject: [PATCH 5.15 09/27] efi: Correct Macmini DMI match in uefi cert quirk Date: Thu, 13 Oct 2022 19:52:38 +0200 Message-Id: <20221013175143.863780029@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746599554440676968?= X-GMAIL-MSGID: =?utf-8?q?1746599554440676968?= From: Orlando Chamberlain commit bab715bdaa9ebf28d99a6d1efb2704a30125e96d upstream. It turns out Apple doesn't capitalise the "mini" in "Macmini" in DMI, which is inconsistent with other model line names. Correct the capitalisation of Macmini in the quirk for skipping loading platform certs on T2 Macs. Currently users get: ------------[ cut here ]------------ [Firmware Bug]: Page fault caused by firmware at PA: 0xffffa30640054000 WARNING: CPU: 1 PID: 8 at arch/x86/platform/efi/quirks.c:735 efi_crash_gracefully_on_page_fault+0x55/0xe0 Modules linked in: CPU: 1 PID: 8 Comm: kworker/u12:0 Not tainted 5.18.14-arch1-2-t2 #1 4535eb3fc40fd08edab32a509fbf4c9bc52d111e Hardware name: Apple Inc. Macmini8,1/Mac-7BA5B2DFE22DDD8C, BIOS 1731.120.10.0.0 (iBridge: 19.16.15071.0.0,0) 04/24/2022 Workqueue: efi_rts_wq efi_call_rts ... ---[ end trace 0000000000000000 ]--- efi: Froze efi_rts_wq and disabled EFI Runtime Services integrity: Couldn't get size: 0x8000000000000015 integrity: MODSIGN: Couldn't get UEFI db list efi: EFI Runtime Services are disabled! integrity: Couldn't get size: 0x8000000000000015 integrity: Couldn't get UEFI dbx list Fixes: 155ca952c7ca ("efi: Do not import certificates from UEFI Secure Boot for T2 Macs") Cc: stable@vger.kernel.org Cc: Aditya Garg Tested-by: Samuel Jiang Signed-off-by: Orlando Chamberlain Signed-off-by: Mimi Zohar Signed-off-by: Greg Kroah-Hartman --- security/integrity/platform_certs/load_uefi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/security/integrity/platform_certs/load_uefi.c +++ b/security/integrity/platform_certs/load_uefi.c @@ -30,7 +30,7 @@ static const struct dmi_system_id uefi_s { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookAir8,1") }, { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookAir8,2") }, { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacBookAir9,1") }, - { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacMini8,1") }, + { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "Macmini8,1") }, { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "MacPro7,1") }, { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "iMac20,1") }, { UEFI_QUIRK_SKIP_CERT("Apple Inc.", "iMac20,2") }, From patchwork Thu Oct 13 17:52:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp428879wrs; Thu, 13 Oct 2022 11:53:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ddwIWvlWnlezhHQKrcm71xI48DUadtvtP/PQQyIYqskbda+s6xRKs2yxH0Jvv5PldrP3w X-Received: by 2002:a05:6a00:148a:b0:566:10d8:9404 with SMTP id v10-20020a056a00148a00b0056610d89404mr983261pfu.84.1665687187997; Thu, 13 Oct 2022 11:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665687187; cv=none; d=google.com; s=arc-20160816; b=aU7PGpTyRYvqcmL++MmSGEkY+pxe5lVa1zRVIpgowsIQGzCeR+e+v6EM5YadQgYYPu EzBytpklflV6w/+mrf8QvzTM4xcI8e7wthQHtT+FE0W7mY2Qwqu+GodWlSl1qXF6FngS qHwJsu3zoUqRW9DBqAOEEz74KMUGC6JEoembKu3UrBQJKzMoSYGhB1SB6cIQk+EyBKdW 7pbmiDPrzubmNy8nQbMJoZtZyulo9XBdCKMQo4d/nSOZmC4QENN0Z4k9Cm+5NmANWRLc hdnwVjjTc9N/PfJPsLlLLRgh5dJwJYESPdb6AELa6ACMhSeQDUmtARhELjkWQjNMeNlv x1JQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ff1sfhbYt4wNMZToMMqfoJz0Tp7CspPLS6z4qn8xybY=; b=LWJ2eDtATBA5j68qU1eUEThJHDHDXw/sYov63usCbNjCgyPdYNQNtNN3lYwLC1tEC1 tkMY8UoBFUQVexIKiaTRqruiLFTEReJ6bFpteEO69IvLlvOshIf9PAlKucg5ZX1+U2HA WMCalR0HVXmXjXMjfh2uiVHFLWUpSnkWo3XwrdyXEBuWgljA59IB0AdtqkcAUlZOc23l lv/9rfcYTiawyXlh4x6ePdgoAQ0UrqCpVOKocoKEpyh9naFfqt2dxH6Amizh0fXBZ2zJ +vutmH3xsrOHZYrDSJX6wV+nQIUwXhclAgjFeQKazrcDXX/3EZ7sO+71eV/49f4kt75k XRhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A+ApL6v5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 32-20020a631160000000b0044ca7935603si121097pgr.723.2022.10.13.11.52.55; Thu, 13 Oct 2022 11:53:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A+ApL6v5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230362AbiJMSha (ORCPT + 99 others); Thu, 13 Oct 2022 14:37:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230521AbiJMShO (ORCPT ); Thu, 13 Oct 2022 14:37:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CDBA5A179; Thu, 13 Oct 2022 11:33:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C0434618F6; Thu, 13 Oct 2022 17:58:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE6F1C433D6; Thu, 13 Oct 2022 17:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683928; bh=x7A1adjUptimaKDZhEh8tjdedfNekZQ065ZaBO3l1Ig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A+ApL6v5gwMiuD7nXnHz9Kkbmk48bBOyCBUeMZXgi55qlSwYutwrR8JB/WSnV9Jbi ihvHwG4c8rYW8NE+J/9tT73NLsEK1bPoFO4YCLxdszRR9SrbJoYaUw66FQ8pUOiFfL DyHZICZUHXdfjZh+g8YdHrh8diJcOhOsMzRxCtYI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, "James E.J. Bottomley" , "Martin K. Petersen" , Dan Carpenter , hdthky , Linus Torvalds Subject: [PATCH 5.15 10/27] scsi: stex: Properly zero out the passthrough command structure Date: Thu, 13 Oct 2022 19:52:39 +0200 Message-Id: <20221013175143.903886116@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746599609343948893?= X-GMAIL-MSGID: =?utf-8?q?1746599609343948893?= From: Linus Torvalds commit 6022f210461fef67e6e676fd8544ca02d1bcfa7a upstream. The passthrough structure is declared off of the stack, so it needs to be set to zero before copied back to userspace to prevent any unintentional data leakage. Switch things to be statically allocated which will fill the unused fields with 0 automatically. Link: https://lore.kernel.org/r/YxrjN3OOw2HHl9tx@kroah.com Cc: stable@kernel.org Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: Dan Carpenter Reported-by: hdthky Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/stex.c | 17 +++++++++-------- include/scsi/scsi_cmnd.h | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -665,16 +665,17 @@ stex_queuecommand_lck(struct scsi_cmnd * return 0; case PASSTHRU_CMD: if (cmd->cmnd[1] == PASSTHRU_GET_DRVVER) { - struct st_drvver ver; + const struct st_drvver ver = { + .major = ST_VER_MAJOR, + .minor = ST_VER_MINOR, + .oem = ST_OEM, + .build = ST_BUILD_VER, + .signature[0] = PASSTHRU_SIGNATURE, + .console_id = host->max_id - 1, + .host_no = hba->host->host_no, + }; size_t cp_len = sizeof(ver); - ver.major = ST_VER_MAJOR; - ver.minor = ST_VER_MINOR; - ver.oem = ST_OEM; - ver.build = ST_BUILD_VER; - ver.signature[0] = PASSTHRU_SIGNATURE; - ver.console_id = host->max_id - 1; - ver.host_no = hba->host->host_no; cp_len = scsi_sg_copy_from_buffer(cmd, &ver, cp_len); if (sizeof(ver) == cp_len) cmd->result = DID_OK << 16; --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -211,7 +211,7 @@ static inline unsigned int scsi_get_resi for_each_sg(scsi_sglist(cmd), sg, nseg, __i) static inline int scsi_sg_copy_from_buffer(struct scsi_cmnd *cmd, - void *buf, int buflen) + const void *buf, int buflen) { return sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, buflen); From patchwork Thu Oct 13 17:52:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp406911wrs; Thu, 13 Oct 2022 11:01:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7UEW8W5eV8c+V4zmjNNsfElGtvq/FPVMgcBGr1fsVM8XE24nTuZVxU0ibJXZ+MrETb8ZJl X-Received: by 2002:a17:907:2e01:b0:78d:e768:e845 with SMTP id ig1-20020a1709072e0100b0078de768e845mr715550ejc.484.1665684072446; Thu, 13 Oct 2022 11:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684072; cv=none; d=google.com; s=arc-20160816; b=pF4tBxhRn4IYKzY/QqLkz4vp9OFi5StfYYRIVADzgaBThkHpR8PF89bvFxPEBAbtaq hbkYu+NXlRSXw+z7uRsvPrcshmVhc9UrdkufG5yhZHj7THAeii8aYrd6CEzWR+uia0C7 ejGx+h825puu0aJPJt3N3A7AeLF9cDtNeg+umeveUI3nDv4r95KDUrLifzaPAE4LThrv gLE1hz6XxJ2S/M68k7Cza8eFCG5Xx6zz2krmhwxaYr6S2SrW4oVNfiBSBTnnyld+Rywt IUKAV1cZ4vs16k7/7VkiuiOa5Y528nuLhKawGpxLFOwRx5kSfMoIr9KxLkUlNcoKofU7 tKjg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=n94YcU9eJvk4YYatYbbgQVbMk25EJupsfQK6OtcSIF8=; b=QINCVM0aDuLmDNeIIccpl1X/nfQPI0gMGa7fs85jQCsacM+KKR+v5ARJhM9dHL5NZQ irsFOmWID4Y0WynDto/7eWHBbNOuCizsYvmii1CCSQbr/zfRDW/izGrP5d/zkz64IpZs UlM5x/kIkBozELSfNy2rUek6p1nxI7Jz6TIkcyIr2OaLO5isIQAx9D66ENuG3sg59VBM w5+RMcs2LOYzNqVOPIHBWtYIl9WYGFJ9QAoHvZDK+v53XqWS3NX+6lWKqx1RwPae0eev VcoY8v920xnDhAM5G5izQjW4oxMtSzJ0zayHp0tfUDVWsKn6smcPaj/3/0KgIChbQ/Id 6aig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T+6JDauS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gr1-20020a170906e2c100b00782069599b8si285194ejb.379.2022.10.13.11.00.45; Thu, 13 Oct 2022 11:01:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T+6JDauS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230185AbiJMR64 (ORCPT + 99 others); Thu, 13 Oct 2022 13:58:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230052AbiJMR5q (ORCPT ); Thu, 13 Oct 2022 13:57:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A54FD2A402; Thu, 13 Oct 2022 10:57:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 295B7B8203B; Thu, 13 Oct 2022 17:57:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DF8CC4347C; Thu, 13 Oct 2022 17:57:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683846; bh=xm4dJk+a4xXbTCFuEdRLmVRDxS983Q+yBTlQeFFvqXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T+6JDauS7rR3SyM6uDki3eRbxDG/QTnDtpTIWtV2UBPmmZM0s7J9l0YAtiVhtjJ3w 1Au94s1j48AFVjACdueM1RqWCvX/mctCgxBGV6Cv+F7l/gbnxcaG7zeEgl9D9UNmCG MOiQjLdch7an4uzh6VcUI6Ok+n32gJeU01lmqEP8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Frank Wunderlich , Johan Hovold Subject: [PATCH 5.15 11/27] USB: serial: qcserial: add new usb-id for Dell branded EM7455 Date: Thu, 13 Oct 2022 19:52:40 +0200 Message-Id: <20221013175143.932991932@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596341590111608?= X-GMAIL-MSGID: =?utf-8?q?1746596341590111608?= From: Frank Wunderlich commit eee48781ea199e32c1d0c4732641c494833788ca upstream. Add support for Dell 5811e (EM7455) with USB-id 0x413c:0x81c2. Signed-off-by: Frank Wunderlich Cc: stable@vger.kernel.org Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/qcserial.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/usb/serial/qcserial.c +++ b/drivers/usb/serial/qcserial.c @@ -177,6 +177,7 @@ static const struct usb_device_id id_tab {DEVICE_SWI(0x413c, 0x81b3)}, /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */ {DEVICE_SWI(0x413c, 0x81b5)}, /* Dell Wireless 5811e QDL */ {DEVICE_SWI(0x413c, 0x81b6)}, /* Dell Wireless 5811e QDL */ + {DEVICE_SWI(0x413c, 0x81c2)}, /* Dell Wireless 5811e */ {DEVICE_SWI(0x413c, 0x81cb)}, /* Dell Wireless 5816e QDL */ {DEVICE_SWI(0x413c, 0x81cc)}, /* Dell Wireless 5816e */ {DEVICE_SWI(0x413c, 0x81cf)}, /* Dell Wireless 5819 */ From patchwork Thu Oct 13 17:52:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2210 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp410774wrs; Thu, 13 Oct 2022 11:07:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5EhuK6n2+JtNdRo9ptXdt9W+/wKVpwrKO6tXKRAC1Cj797/vztrPN6eijO7lhZDii5OZK8 X-Received: by 2002:a17:90b:4c42:b0:20d:7820:2e4e with SMTP id np2-20020a17090b4c4200b0020d78202e4emr12652809pjb.40.1665684437983; Thu, 13 Oct 2022 11:07:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684437; cv=none; d=google.com; s=arc-20160816; b=eITSDOPHvSu2x/4vcomzedDDzYdUrMFX7IOODUxzpQuhdIYRpZ8daAyl0QouDA+/ly Q7ZNLMvs9WoqiLFaNWIL8v/0bQbnS+RphAlZMTAKIVtm/J2EPx6ign6uFNRHu6XHp22o vavH8KbP0BAYpwX0PRzQKCToCybYfK65krOkYJJLsoj5kmSd1YvErHTAvMhMnKX/ylpF 5AnqVotlF/hvr5UR5qx9LBdF1vCv7D4v3ldOh35u9pLUqhgty6NqiwitJ44q9waAc8IU moZvx2o+eKxdme5zRDszIpDZjXCmUSeERqb6RRB1wwmlyYMAlntVhprBFLVhLm95iczC WuCg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Uz+RyNsS+go1ZbLhkzdgwEcAqfPLi2Lf4yZKSc6tEkk=; b=X1AHkveeuQIO9+BcUc8KEBYFIQF3670K+7kuTBbF4p3n1/uBKB6bYKTbXDygOLP8Nn CsobKGnxd4Zj7ly8tOKWb/FffrvccdTN1+sYxMKqiB8QL/VfMkixex64JLmg9rP+oGST +L6f3GsAYz6ZBGLdQ8iy7NHhEr+nWEsDWo84i33zz1trkkgmdxazbBug7V82fSlTZelE GgvSnD75VKOHA6hX0/aJW8YZcj2ZjXGDG8udyTtJtvEk2i3hABMjYZZ9PLGgSbgJ53di cyJpxSP4gl/p0koOxG1MlN5l5hXDldEPAxRzn5jvp7SvDOuvEZ01lJyAICtMYfY/9pZs VX/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y6bhWpZF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c25-20020aa78c19000000b00562714a9910si35892pfd.167.2022.10.13.11.07.05; Thu, 13 Oct 2022 11:07:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y6bhWpZF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231529AbiJMSGu (ORCPT + 99 others); Thu, 13 Oct 2022 14:06:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231452AbiJMSEb (ORCPT ); Thu, 13 Oct 2022 14:04:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4604B157F62; Thu, 13 Oct 2022 11:04:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4415161919; Thu, 13 Oct 2022 17:57:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EF34C433C1; Thu, 13 Oct 2022 17:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683849; bh=mXhdPbsQTSlDSdHzMbWqLkbt/D0WiZFIBjndHtuQ1Xc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y6bhWpZFyoyxCww0EK0CdsaH8dWs2eWP0jxClQkXioRfg80Bfo9y0qb1x9otKePVS e59c0kV7c9mjfmmOtGZ7Hj3KSxbqCDPt6A3vrP6EOXSvRrUWPFvlEjMZ16ANclHWfl D5tA9uhZdGYARAw+toQw7L9oegF37mBDnioOqel8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nathan Lynch , Laurent Dufour , Michael Ellerman Subject: [PATCH 5.15 12/27] Revert "powerpc/rtas: Implement reentrant rtas call" Date: Thu, 13 Oct 2022 19:52:41 +0200 Message-Id: <20221013175143.968972809@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596725186528765?= X-GMAIL-MSGID: =?utf-8?q?1746596725186528765?= From: Nathan Lynch commit f88aabad33ea22be2ce1c60d8901942e4e2a9edb upstream. At the time this was submitted by Leonardo, I confirmed -- or thought I had confirmed -- with PowerVM partition firmware development that the following RTAS functions: - ibm,get-xive - ibm,int-off - ibm,int-on - ibm,set-xive were safe to call on multiple CPUs simultaneously, not only with respect to themselves as indicated by PAPR, but with arbitrary other RTAS calls: https://lore.kernel.org/linuxppc-dev/875zcy2v8o.fsf@linux.ibm.com/ Recent discussion with firmware development makes it clear that this is not true, and that the code in commit b664db8e3f97 ("powerpc/rtas: Implement reentrant rtas call") is unsafe, likely explaining several strange bugs we've seen in internal testing involving DLPAR and LPM. These scenarios use ibm,configure-connector, whose internal state can be corrupted by the concurrent use of the "reentrant" functions, leading to symptoms like endless busy statuses from RTAS. Fixes: b664db8e3f97 ("powerpc/rtas: Implement reentrant rtas call") Cc: stable@vger.kernel.org # v5.8+ Signed-off-by: Nathan Lynch Reviewed-by: Laurent Dufour Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220907220111.223267-1-nathanl@linux.ibm.com Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/include/asm/paca.h | 1 arch/powerpc/include/asm/rtas.h | 1 arch/powerpc/kernel/paca.c | 32 --------------------- arch/powerpc/kernel/rtas.c | 54 ------------------------------------ arch/powerpc/sysdev/xics/ics-rtas.c | 22 +++++++------- 5 files changed, 11 insertions(+), 99 deletions(-) --- a/arch/powerpc/include/asm/paca.h +++ b/arch/powerpc/include/asm/paca.h @@ -263,7 +263,6 @@ struct paca_struct { u64 l1d_flush_size; #endif #ifdef CONFIG_PPC_PSERIES - struct rtas_args *rtas_args_reentrant; u8 *mce_data_buf; /* buffer to hold per cpu rtas errlog */ #endif /* CONFIG_PPC_PSERIES */ --- a/arch/powerpc/include/asm/rtas.h +++ b/arch/powerpc/include/asm/rtas.h @@ -240,7 +240,6 @@ extern struct rtas_t rtas; extern int rtas_token(const char *service); extern int rtas_service_present(const char *service); extern int rtas_call(int token, int, int, int *, ...); -int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...); void rtas_call_unlocked(struct rtas_args *args, int token, int nargs, int nret, ...); extern void __noreturn rtas_restart(char *cmd); --- a/arch/powerpc/kernel/paca.c +++ b/arch/powerpc/kernel/paca.c @@ -16,7 +16,6 @@ #include #include #include -#include #include "setup.h" @@ -172,30 +171,6 @@ static struct slb_shadow * __init new_sl #endif /* CONFIG_PPC_BOOK3S_64 */ -#ifdef CONFIG_PPC_PSERIES -/** - * new_rtas_args() - Allocates rtas args - * @cpu: CPU number - * @limit: Memory limit for this allocation - * - * Allocates a struct rtas_args and return it's pointer, - * if not in Hypervisor mode - * - * Return: Pointer to allocated rtas_args - * NULL if CPU in Hypervisor Mode - */ -static struct rtas_args * __init new_rtas_args(int cpu, unsigned long limit) -{ - limit = min_t(unsigned long, limit, RTAS_INSTANTIATE_MAX); - - if (early_cpu_has_feature(CPU_FTR_HVMODE)) - return NULL; - - return alloc_paca_data(sizeof(struct rtas_args), L1_CACHE_BYTES, - limit, cpu); -} -#endif /* CONFIG_PPC_PSERIES */ - /* The Paca is an array with one entry per processor. Each contains an * lppaca, which contains the information shared between the * hypervisor and Linux. @@ -234,10 +209,6 @@ void __init initialise_paca(struct paca_ /* For now -- if we have threads this will be adjusted later */ new_paca->tcd_ptr = &new_paca->tcd; #endif - -#ifdef CONFIG_PPC_PSERIES - new_paca->rtas_args_reentrant = NULL; -#endif } /* Put the paca pointer into r13 and SPRG_PACA */ @@ -310,9 +281,6 @@ void __init allocate_paca(int cpu) #ifdef CONFIG_PPC_BOOK3S_64 paca->slb_shadow_ptr = new_slb_shadow(cpu, limit); #endif -#ifdef CONFIG_PPC_PSERIES - paca->rtas_args_reentrant = new_rtas_args(cpu, limit); -#endif paca_struct_size += sizeof(struct paca_struct); } --- a/arch/powerpc/kernel/rtas.c +++ b/arch/powerpc/kernel/rtas.c @@ -42,7 +42,6 @@ #include #include #include -#include /* This is here deliberately so it's only used in this file */ void enter_rtas(unsigned long); @@ -845,59 +844,6 @@ void rtas_activate_firmware(void) pr_err("ibm,activate-firmware failed (%i)\n", fwrc); } -#ifdef CONFIG_PPC_PSERIES -/** - * rtas_call_reentrant() - Used for reentrant rtas calls - * @token: Token for desired reentrant RTAS call - * @nargs: Number of Input Parameters - * @nret: Number of Output Parameters - * @outputs: Array of outputs - * @...: Inputs for desired RTAS call - * - * According to LoPAR documentation, only "ibm,int-on", "ibm,int-off", - * "ibm,get-xive" and "ibm,set-xive" are currently reentrant. - * Reentrant calls need their own rtas_args buffer, so not using rtas.args, but - * PACA one instead. - * - * Return: -1 on error, - * First output value of RTAS call if (nret > 0), - * 0 otherwise, - */ -int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...) -{ - va_list list; - struct rtas_args *args; - unsigned long flags; - int i, ret = 0; - - if (!rtas.entry || token == RTAS_UNKNOWN_SERVICE) - return -1; - - local_irq_save(flags); - preempt_disable(); - - /* We use the per-cpu (PACA) rtas args buffer */ - args = local_paca->rtas_args_reentrant; - - va_start(list, outputs); - va_rtas_call_unlocked(args, token, nargs, nret, list); - va_end(list); - - if (nret > 1 && outputs) - for (i = 0; i < nret - 1; ++i) - outputs[i] = be32_to_cpu(args->rets[i + 1]); - - if (nret > 0) - ret = be32_to_cpu(args->rets[0]); - - local_irq_restore(flags); - preempt_enable(); - - return ret; -} - -#endif /* CONFIG_PPC_PSERIES */ - /** * Find a specific pseries error log in an RTAS extended event log. * @log: RTAS error/event log --- a/arch/powerpc/sysdev/xics/ics-rtas.c +++ b/arch/powerpc/sysdev/xics/ics-rtas.c @@ -37,8 +37,8 @@ static void ics_rtas_unmask_irq(struct i server = xics_get_irq_server(d->irq, irq_data_get_affinity_mask(d), 0); - call_status = rtas_call_reentrant(ibm_set_xive, 3, 1, NULL, hw_irq, - server, DEFAULT_PRIORITY); + call_status = rtas_call(ibm_set_xive, 3, 1, NULL, hw_irq, server, + DEFAULT_PRIORITY); if (call_status != 0) { printk(KERN_ERR "%s: ibm_set_xive irq %u server %x returned %d\n", @@ -47,7 +47,7 @@ static void ics_rtas_unmask_irq(struct i } /* Now unmask the interrupt (often a no-op) */ - call_status = rtas_call_reentrant(ibm_int_on, 1, 1, NULL, hw_irq); + call_status = rtas_call(ibm_int_on, 1, 1, NULL, hw_irq); if (call_status != 0) { printk(KERN_ERR "%s: ibm_int_on irq=%u returned %d\n", __func__, hw_irq, call_status); @@ -69,7 +69,7 @@ static void ics_rtas_mask_real_irq(unsig if (hw_irq == XICS_IPI) return; - call_status = rtas_call_reentrant(ibm_int_off, 1, 1, NULL, hw_irq); + call_status = rtas_call(ibm_int_off, 1, 1, NULL, hw_irq); if (call_status != 0) { printk(KERN_ERR "%s: ibm_int_off irq=%u returned %d\n", __func__, hw_irq, call_status); @@ -77,8 +77,8 @@ static void ics_rtas_mask_real_irq(unsig } /* Have to set XIVE to 0xff to be able to remove a slot */ - call_status = rtas_call_reentrant(ibm_set_xive, 3, 1, NULL, hw_irq, - xics_default_server, 0xff); + call_status = rtas_call(ibm_set_xive, 3, 1, NULL, hw_irq, + xics_default_server, 0xff); if (call_status != 0) { printk(KERN_ERR "%s: ibm_set_xive(0xff) irq=%u returned %d\n", __func__, hw_irq, call_status); @@ -109,7 +109,7 @@ static int ics_rtas_set_affinity(struct if (hw_irq == XICS_IPI || hw_irq == XICS_IRQ_SPURIOUS) return -1; - status = rtas_call_reentrant(ibm_get_xive, 1, 3, xics_status, hw_irq); + status = rtas_call(ibm_get_xive, 1, 3, xics_status, hw_irq); if (status) { printk(KERN_ERR "%s: ibm,get-xive irq=%u returns %d\n", @@ -127,8 +127,8 @@ static int ics_rtas_set_affinity(struct pr_debug("%s: irq %d [hw 0x%x] server: 0x%x\n", __func__, d->irq, hw_irq, irq_server); - status = rtas_call_reentrant(ibm_set_xive, 3, 1, NULL, - hw_irq, irq_server, xics_status[1]); + status = rtas_call(ibm_set_xive, 3, 1, NULL, + hw_irq, irq_server, xics_status[1]); if (status) { printk(KERN_ERR "%s: ibm,set-xive irq=%u returns %d\n", @@ -159,7 +159,7 @@ static int ics_rtas_check(struct ics *ic return -EINVAL; /* Check if RTAS knows about this interrupt */ - rc = rtas_call_reentrant(ibm_get_xive, 1, 3, status, hw_irq); + rc = rtas_call(ibm_get_xive, 1, 3, status, hw_irq); if (rc) return -ENXIO; @@ -175,7 +175,7 @@ static long ics_rtas_get_server(struct i { int rc, status[2]; - rc = rtas_call_reentrant(ibm_get_xive, 1, 3, status, vec); + rc = rtas_call(ibm_get_xive, 1, 3, status, vec); if (rc) return -1; return status[0]; From patchwork Thu Oct 13 17:52:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2180 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp407895wrs; Thu, 13 Oct 2022 11:02:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4JTdAhsUFr2HzBiB6URD0XQ6kbYOliUiGA/v8gFhzRUX9JhXCch0NsPUwD53GU7JIvgPT9 X-Received: by 2002:a17:90b:48c9:b0:20a:f2f5:45c8 with SMTP id li9-20020a17090b48c900b0020af2f545c8mr12330179pjb.18.1665684161119; Thu, 13 Oct 2022 11:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684161; cv=none; d=google.com; s=arc-20160816; b=McYrO9uqM4aHBKpTzNKTjRvCIS19bQFYbTqjg4fOpIRZITboSsc3Tn7UrEa+7bk5om /44L2ssxzrUCbAlYlfiHLqoIrcj++brEkTf5G8lH6Kd3SrBKNvBUSgQMcwSZaD20TxX+ Toly6VHx13nHmwqb27Gs6jzEPB9ncaoklpCIS4MJsbTEH06S/zH++HXQNZKCsM3WAzeS PAcdlGHJP3oYEVg3AHuLvAu3IT3ZJ/cqMda9FLHHlXlGtcuZztmu99e6Gup71kPSIRkZ pkrg2oKK2pBxRNem7wQpYH0fyR+A5jHBNKP2n3zqIuKbDX+PAfvMgxqdPa1jQQNymM0q cdIA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VDFdoGO/7z5YKhVQtioMncEKxb1vm6XVAHHTKcsmt88=; b=zh077p3v972MD4ro7gR1qvFzAWo/yDbEfJRDpw3x0+MD/Cl9/2tGXHvmC3V6V7Mxy5 ICCTzj2V13jVIjsldvbxlEDQkSfbwwYrZ3qivxsLKiGluXOs9tYbetX3uscbirvw7FCQ yqT33iuzato4ktEcCt4UspXdj1SI9APHRht66wTxNWhIvzzQM8cpawYzXKP49Ez4ZM7T CAKm+N5PfcXqJjuLr6inB4eyHAjK5zpn1m+Wcqnl1DLQ/WxJy3fYq9W0bXN6XZ48+rPy CtXTcA2fhJau4cvzehnyr47FgS0dj/SFj+sF3zH/B5uADlQ1wtYHAQfsR6ZRhJfT8Z5s TcVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TlL+2xlr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x11-20020a65538b000000b0045c398db4e6si15542pgq.600.2022.10.13.11.02.20; Thu, 13 Oct 2022 11:02:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TlL+2xlr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230351AbiJMSBr (ORCPT + 99 others); Thu, 13 Oct 2022 14:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230354AbiJMSBf (ORCPT ); Thu, 13 Oct 2022 14:01:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ED9144CFC; Thu, 13 Oct 2022 11:01:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1E36C61929; Thu, 13 Oct 2022 17:57:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EC87C43146; Thu, 13 Oct 2022 17:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683852; bh=C8RVSQSnVvD2a6CALdlWYB/J8V4HItUTJlCctPy9068=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TlL+2xlrfCGu3BrYNWiRzzl7rsN+zFAxJnguHxNmLxxewZ1xbwXMtumSdUtkHudQc xBmFDtms5IL/6+Ns8hhKrdEbmK5fI7Wz7gGBDrdPVwCdl0ZTxRCL4UJJrI1fFqVveQ LkpCVA6sdyMPokTleaaonZus+ykn5t9RQc6ndK78= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Herbert Xu , Giovanni Cabiddu Subject: [PATCH 5.15 13/27] Revert "crypto: qat - reduce size of mapped region" Date: Thu, 13 Oct 2022 19:52:42 +0200 Message-Id: <20221013175144.014828758@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596434837043103?= X-GMAIL-MSGID: =?utf-8?q?1746596434837043103?= From: Giovanni Cabiddu commit 9c5f21b198d259bfe1191b1fedf08e2eab15b33b upstream. This reverts commit e48767c17718067ba21fb2ef461779ec2506f845. In an attempt to resolve a set of warnings reported by the static analyzer Smatch, the reverted commit improperly reduced the sizes of the DMA mappings used for the input and output parameters for both RSA and DH creating a mismatch (map size=8 bytes, unmap size=64 bytes). This issue is reported when CONFIG_DMA_API_DEBUG is selected, when the crypto self test is run. The function dma_unmap_single() reports a warning similar to the one below, saying that the `device driver frees DMA memory with different size`. DMA-API: 4xxx 0000:06:00.0: device driver frees DMA memory with different size [device address=0x0000000123206c80] [map size=8 bytes] [unmap size=64 bytes] WARNING: CPU: 0 PID: 0 at kernel/dma/debug.c:973 check_unmap+0x3d0/0x8c0\ ... Call Trace: debug_dma_unmap_page+0x5c/0x60 qat_dh_cb+0xd7/0x110 [intel_qat] qat_alg_asym_callback+0x1a/0x30 [intel_qat] adf_response_handler+0xbd/0x1a0 [intel_qat] tasklet_action_common.constprop.0+0xcd/0xe0 __do_softirq+0xf8/0x30c __irq_exit_rcu+0xbf/0x140 common_interrupt+0xb9/0xd0 The original commit was correct. Cc: Reported-by: Herbert Xu Signed-off-by: Giovanni Cabiddu Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/qat/qat_common/qat_asym_algs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -332,13 +332,13 @@ static int qat_dh_compute_value(struct k qat_req->out.dh.out_tab[1] = 0; /* Mapping in.in.b or in.in_g2.xa is the same */ qat_req->phy_in = dma_map_single(dev, &qat_req->in.dh.in.b, - sizeof(qat_req->in.dh.in.b), + sizeof(struct qat_dh_input_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_in))) goto unmap_dst; qat_req->phy_out = dma_map_single(dev, &qat_req->out.dh.r, - sizeof(qat_req->out.dh.r), + sizeof(struct qat_dh_output_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_out))) goto unmap_in_params; @@ -728,13 +728,13 @@ static int qat_rsa_enc(struct akcipher_r qat_req->in.rsa.in_tab[3] = 0; qat_req->out.rsa.out_tab[1] = 0; qat_req->phy_in = dma_map_single(dev, &qat_req->in.rsa.enc.m, - sizeof(qat_req->in.rsa.enc.m), + sizeof(struct qat_rsa_input_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_in))) goto unmap_dst; qat_req->phy_out = dma_map_single(dev, &qat_req->out.rsa.enc.c, - sizeof(qat_req->out.rsa.enc.c), + sizeof(struct qat_rsa_output_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_out))) goto unmap_in_params; @@ -873,13 +873,13 @@ static int qat_rsa_dec(struct akcipher_r qat_req->in.rsa.in_tab[3] = 0; qat_req->out.rsa.out_tab[1] = 0; qat_req->phy_in = dma_map_single(dev, &qat_req->in.rsa.dec.c, - sizeof(qat_req->in.rsa.dec.c), + sizeof(struct qat_rsa_input_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_in))) goto unmap_dst; qat_req->phy_out = dma_map_single(dev, &qat_req->out.rsa.dec.m, - sizeof(qat_req->out.rsa.dec.m), + sizeof(struct qat_rsa_output_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_out))) goto unmap_in_params; From patchwork Thu Oct 13 17:52:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2184 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp408177wrs; Thu, 13 Oct 2022 11:03:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM64MyFLZsbOyyYhJOE59SAydUHcH2aUfQiRYZ20FHLajAsfU+YTkftoOoEm5l2JBFOKZVEh X-Received: by 2002:a17:90b:4b8e:b0:20a:f240:9b23 with SMTP id lr14-20020a17090b4b8e00b0020af2409b23mr1088694pjb.19.1665684188919; Thu, 13 Oct 2022 11:03:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684188; cv=none; d=google.com; s=arc-20160816; b=UjKSTXjHjUaEuusBE+XFIfSJWkxoe/ryvBuQmZ0jnFnzce8ac8YqzWOdSzGiY/CK4x 9P7VdD689QGXuCAhPu5aHjOPOFRhlc6Wg2UsDw8DdsnX18nA3OUV/+jgkrCzapUqgwMi KmUYVL8M3768mdR/vhE7c1/UfWOUDYq8Ez8XjPueyqxV6Ux226UWdkaLLIvfH1RcWX92 cQpUER43WfXzoSU1ZZZrWnkG8cr73xfXtAZGRT+us5UHqvi6dR1lT/e8PyDDJl9POhxI +Qdt7N52ywbjGIZSJZFyxq39cyeEBMuuuKlnPlWWcbbYy/bhzpbx5JccZR1W3oUNjPbl 8MkQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=be4krze8fi3jrAWps/1TqsPhv0IlBqBO/1heeMPclsY=; b=IAs/QzpdJdR8pwIoiiKDvSClpd2Vjki9pnSfpWH11QwyWaG97/NXlUxBNQuLWe8hOr 1yjGBKoQ4nZOuC1mj66Zc2DnX230ODkCn3FioG4c+JINaga3qCVd9TFwFqbnnNDPlA6O /IE+J+kNtwWF1eqYzJCpH1iPyO2yTrG+q76pEBgsbr41Fn8SIhMwM1IRMWM92i+c9Yns VcXcj4MIGEfRkfBoDuRDjS+ccM2gbUa+gHEJfgIcA+1j3iQhKYFLcNbzY7oEPk3Xfh8F he22Bi2aJjt2dquhxWrKfrqj74FJCF24gNQ5bHAWImjEB1D2d+3mmq7+76DBHVzL2H7w aAtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=X8kWtT6W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s16-20020a63e810000000b0046248881576si80118pgh.157.2022.10.13.11.02.49; Thu, 13 Oct 2022 11:03:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=X8kWtT6W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230433AbiJMSCL (ORCPT + 99 others); Thu, 13 Oct 2022 14:02:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230384AbiJMSBs (ORCPT ); Thu, 13 Oct 2022 14:01:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62595160EDF; Thu, 13 Oct 2022 11:01:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 281516192D; Thu, 13 Oct 2022 17:57:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30B6EC433C1; Thu, 13 Oct 2022 17:57:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683855; bh=uIlkY5Zeiam6CYpFKVqUgIhLspxK9NxVICIPnnLsybs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X8kWtT6WKEzCMZbkPgJ82m8le34k7usL7pfm8iF1FVl1LOY5Hq2Yuf4yzZXGtCHy7 /rlH+71TLCAzLctgaME4w7oP06OyBAto8i5jKeB+xLF7nzYZw78KdupufLHPGMfqRj mbSjeSJOhOx8vb4PovHiw8TI5mMHGhDtX85hzVYs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sebastian Andrzej Siewior , "Jason A. Donenfeld" Subject: [PATCH 5.15 14/27] random: avoid reading two cache lines on irq randomness Date: Thu, 13 Oct 2022 19:52:43 +0200 Message-Id: <20221013175144.060241859@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596464121320055?= X-GMAIL-MSGID: =?utf-8?q?1746596464121320055?= From: Jason A. Donenfeld commit 9ee0507e896b45af6d65408c77815800bce30008 upstream. In order to avoid reading and dirtying two cache lines on every IRQ, move the work_struct to the bottom of the fast_pool struct. add_ interrupt_randomness() always touches .pool and .count, which are currently split, because .mix pushes everything down. Instead, move .mix to the bottom, so that .pool and .count are always in the first cache line, since .mix is only accessed when the pool is full. Fixes: 58340f8e952b ("random: defer fast pool mixing to worker") Reviewed-by: Sebastian Andrzej Siewior Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -894,10 +894,10 @@ void __init add_bootloader_randomness(co } struct fast_pool { - struct work_struct mix; unsigned long pool[4]; unsigned long last; unsigned int count; + struct work_struct mix; }; static DEFINE_PER_CPU(struct fast_pool, irq_randomness) = { From patchwork Thu Oct 13 17:52:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2245 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp413090wrs; Thu, 13 Oct 2022 11:12:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7q5J6r3syunhTn0X8wk/mM7YclvWi+FRD0cxO+Ao5ehWAWAiMMuj9ilSIZLQi6qTemKz8l X-Received: by 2002:a17:902:e80f:b0:178:fee:c5fe with SMTP id u15-20020a170902e80f00b001780feec5femr1181262plg.85.1665684741403; Thu, 13 Oct 2022 11:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684741; cv=none; d=google.com; s=arc-20160816; b=IKm/FecazhDm/edsfNtIHhahYrQ/hkgZ/1NvstHa1OLs8xXS6GUmwue02MjKhcMJW0 Jkk+lMrmnFakvyjCdz/dhYT7G/eDNKPLFoth8u0msFMoCdgBlbnQAO5AQfGc8jfBMRXV DcnAgy/xDYlejM7RQuaNoHNPVEZ1XeZuTMZW0Dg4r88rSWqItyQB2pGKfpECQrDuLfkD Aus+l0j+3H48eqPUGs3mAVm9/iDXvOo5t6m5cxWzar6xbIJUh5jT8AMnfnu+Tkrsuv+w m7jjafCLTcz7AqBP2oHi3Y+TzCkWxkVLljSCv7rBvEatg7tJz1OuZ38ky4/5zITawhkW gJFQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=G7ZUAiDmeN3PWKMpe+ClNrn5JS25V0tYAfgs2/yNl28=; b=D9bOtF3K8CPIpzanmgmkt54jrFJNuOLV6o0BjgS2vdU6YyJrvR8shrP+7x3uYhrEcM xQ7vXHvggx++kqWMnxBDHhRRZum7b859iV4OejDbm7h+KMSbvlK0oI8qH1GZvjMcQBrP qyIZG85AVTUNGWfqUD2KO4Db7+4CfztkqT6zR57Yy5wfPKWCoFDJ0zRZEAdYICpsiYpA xAvX8o0pRWCBdTsPjus7I9eh36UUxMYayxIz6HnHwTJwpUaA8l5qRvSLbA87GapbUUOO Q8KQ7JcCWUVtKlHHls7w4d/tENrsNYIXwIQsYNXhx5m/FQfQgyfM5HUTQtorzq6sZWpW y7aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=W+vaPGHr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ja21-20020a170902efd500b001751a9de12esi359682plb.288.2022.10.13.11.12.09; Thu, 13 Oct 2022 11:12:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=W+vaPGHr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231136AbiJMSLv (ORCPT + 99 others); Thu, 13 Oct 2022 14:11:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231637AbiJMSK5 (ORCPT ); Thu, 13 Oct 2022 14:10:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51F241757A7; Thu, 13 Oct 2022 11:08:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D1F49618DE; Thu, 13 Oct 2022 17:57:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B88FDC433D7; Thu, 13 Oct 2022 17:57:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683858; bh=Uookn0v1XD1N29cP0O883ohBRJMgB84+zVG1F9DR7z8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W+vaPGHrmcHJto+BPy11zllou1GEFLVKB6ontuJCvZ2os//2QqctDF8Pc35mUulFB Yi3ttxjRClU5PxUAFJ4fAZZ/oFxIbjUDBIpRqzPm9Nah6nOvznSLcCZ58kVxxoi4xL ETsw3QEusbWto9xZ6UIqQuN+TVoKQjlmUPqoJFNo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sherry Yang , Paul Webb , Phillip Goerl , Jack Vogel , Nicky Veitch , Colm Harrington , Ramanan Govindarajan , Sebastian Andrzej Siewior , Dominik Brodowski , Tejun Heo , Sultan Alsawaf , "Jason A. Donenfeld" Subject: [PATCH 5.15 15/27] random: use expired timer rather than wq for mixing fast pool Date: Thu, 13 Oct 2022 19:52:44 +0200 Message-Id: <20221013175144.105087131@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597043144736288?= X-GMAIL-MSGID: =?utf-8?q?1746597043144736288?= From: Jason A. Donenfeld commit 748bc4dd9e663f23448d8ad7e58c011a67ea1eca upstream. Previously, the fast pool was dumped into the main pool periodically in the fast pool's hard IRQ handler. This worked fine and there weren't problems with it, until RT came around. Since RT converts spinlocks into sleeping locks, problems cropped up. Rather than switching to raw spinlocks, the RT developers preferred we make the transformation from originally doing: do_some_stuff() spin_lock() do_some_other_stuff() spin_unlock() to doing: do_some_stuff() queue_work_on(some_other_stuff_worker) This is an ordinary pattern done all over the kernel. However, Sherry noticed a 10% performance regression in qperf TCP over a 40gbps InfiniBand card. Quoting her message: > MT27500 Family [ConnectX-3] cards: > Infiniband device 'mlx4_0' port 1 status: > default gid: fe80:0000:0000:0000:0010:e000:0178:9eb1 > base lid: 0x6 > sm lid: 0x1 > state: 4: ACTIVE > phys state: 5: LinkUp > rate: 40 Gb/sec (4X QDR) > link_layer: InfiniBand > > Cards are configured with IP addresses on private subnet for IPoIB > performance testing. > Regression identified in this bug is in TCP latency in this stack as reported > by qperf tcp_lat metric: > > We have one system listen as a qperf server: > [root@yourQperfServer ~]# qperf > > Have the other system connect to qperf server as a client (in this > case, it’s X7 server with Mellanox card): > [root@yourQperfClient ~]# numactl -m0 -N0 qperf 20.20.20.101 -v -uu -ub --time 60 --wait_server 20 -oo msg_size:4K:1024K:*2 tcp_lat Rather than incur the scheduling latency from queue_work_on, we can instead switch to running on the next timer tick, on the same core. This also batches things a bit more -- once per jiffy -- which is okay now that mix_interrupt_randomness() can credit multiple bits at once. Reported-by: Sherry Yang Tested-by: Paul Webb Cc: Sherry Yang Cc: Phillip Goerl Cc: Jack Vogel Cc: Nicky Veitch Cc: Colm Harrington Cc: Ramanan Govindarajan Cc: Sebastian Andrzej Siewior Cc: Dominik Brodowski Cc: Tejun Heo Cc: Sultan Alsawaf Cc: stable@vger.kernel.org Fixes: 58340f8e952b ("random: defer fast pool mixing to worker") Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -897,17 +897,20 @@ struct fast_pool { unsigned long pool[4]; unsigned long last; unsigned int count; - struct work_struct mix; + struct timer_list mix; }; +static void mix_interrupt_randomness(struct timer_list *work); + static DEFINE_PER_CPU(struct fast_pool, irq_randomness) = { #ifdef CONFIG_64BIT #define FASTMIX_PERM SIPHASH_PERMUTATION - .pool = { SIPHASH_CONST_0, SIPHASH_CONST_1, SIPHASH_CONST_2, SIPHASH_CONST_3 } + .pool = { SIPHASH_CONST_0, SIPHASH_CONST_1, SIPHASH_CONST_2, SIPHASH_CONST_3 }, #else #define FASTMIX_PERM HSIPHASH_PERMUTATION - .pool = { HSIPHASH_CONST_0, HSIPHASH_CONST_1, HSIPHASH_CONST_2, HSIPHASH_CONST_3 } + .pool = { HSIPHASH_CONST_0, HSIPHASH_CONST_1, HSIPHASH_CONST_2, HSIPHASH_CONST_3 }, #endif + .mix = __TIMER_INITIALIZER(mix_interrupt_randomness, 0) }; /* @@ -949,7 +952,7 @@ int __cold random_online_cpu(unsigned in } #endif -static void mix_interrupt_randomness(struct work_struct *work) +static void mix_interrupt_randomness(struct timer_list *work) { struct fast_pool *fast_pool = container_of(work, struct fast_pool, mix); /* @@ -1003,10 +1006,11 @@ void add_interrupt_randomness(int irq) if (new_count < 1024 && !time_is_before_jiffies(fast_pool->last + HZ)) return; - if (unlikely(!fast_pool->mix.func)) - INIT_WORK(&fast_pool->mix, mix_interrupt_randomness); fast_pool->count |= MIX_INFLIGHT; - queue_work_on(raw_smp_processor_id(), system_highpri_wq, &fast_pool->mix); + if (!timer_pending(&fast_pool->mix)) { + fast_pool->mix.expires = jiffies; + add_timer_on(&fast_pool->mix, raw_smp_processor_id()); + } } EXPORT_SYMBOL_GPL(add_interrupt_randomness); From patchwork Thu Oct 13 17:52:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2268 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp414877wrs; Thu, 13 Oct 2022 11:16:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5W1Yp2MnnjY/mx2SrrMNIimhIlN11i6ICBv7Zlp9C/y5j3ZmIRd1x1O/qci5BWIaxU7DHv X-Received: by 2002:a17:903:2d1:b0:183:2b26:575d with SMTP id s17-20020a17090302d100b001832b26575dmr978956plk.77.1665684982943; Thu, 13 Oct 2022 11:16:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684982; cv=none; d=google.com; s=arc-20160816; b=b680fiWSkOxbtmRsYrfa+3n8wNrhPm+8K6GnJHvveWrqmqjkDCGnHKxzNCzb24hOLN D2qXd95J/NaT/NrFex3ng8zwZcKfG5/FDWC0OwYA815mC2cZSE+l/O/qTZ3WgJuJ65uH iiyzRvWnO3gTftTRmz1CY5TgKso9JZy7a2PWhsdgmR3NfP2I6OngbRm8KweVUM4jHKu1 2q9n1R/CRBiC5cJmAsRfcHnsltEk60wsx0eUTu7hzvibTmekqHcy3Ap0PbBWdm2T0/kp 3h9I1X/zNpkxan6XF/sr2KfCLq6xn+hnY8brO8dLU5rayvcvRsnX2R9OldTdcp7pXfD4 pJEw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ek4IOQ2Vw+tVTR7ZdXdlL2dAUPCNm5z6ll38c5AkmnU=; b=NPh+gIV4Omy3RE46x8WtV183nX2XgN3lxV5/q0KQ52ipPEHuNLDAyVU+36OUI3kZaZ W8Y8Enb2s2ClOjbwpGFmXvdBI0qQHXW3PNY7DDn1Rf9Fovn5yduIJfttduROAVZwxh+V wdXXOP1FLtQxMgG+LGji63XD3ir/C4TfUZ283HtaoL8xrQhIKPkn3wLKjEh0S82eVGaG i70q5oX/9XgrjXxhEZ2pktp7ZlDqZW9PvfCZpECkt6yfIj3jV8zUgSCkAdKgBlK2qhIc bfnUMhHXhDBQg7elQkJpMVpqGxh1HLuLo42enYdZHu3n2sijFua3ORIIi0AeTW2nVTV7 jNgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aurWYMP6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s9-20020a17090302c900b0017f5ea214a8si376492plk.462.2022.10.13.11.16.10; Thu, 13 Oct 2022 11:16:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aurWYMP6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231678AbiJMSPr (ORCPT + 99 others); Thu, 13 Oct 2022 14:15:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231838AbiJMSMx (ORCPT ); Thu, 13 Oct 2022 14:12:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF619B1C8; Thu, 13 Oct 2022 11:09:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4A1A9B82020; Thu, 13 Oct 2022 17:57:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA6F0C433C1; Thu, 13 Oct 2022 17:57:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683861; bh=r9PM8b6YrYqEAMH8Yyhr2eZC2Q2EKssexz0N1yrdbq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aurWYMP6g4VvU3Io4HXTAzU1l49APAKD1xZjBunXOnPGWFarBkvlqiCVx6XQEH9cz Wfw+wj2h4n2zzqFL0I/RHBEMd8GlPCe8+6yq8xgBNt4HKejm+gaBVKasNnswnCDqIh 5QgCPW1d1vU/ZKBurEEthSMpIsTC5PiV9zEkVdGk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Soenke Huster , Kees Cook , Johannes Berg Subject: [PATCH 5.15 16/27] wifi: cfg80211: fix u8 overflow in cfg80211_update_notlisted_nontrans() Date: Thu, 13 Oct 2022 19:52:45 +0200 Message-Id: <20221013175144.139483450@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597297006178569?= X-GMAIL-MSGID: =?utf-8?q?1746597297006178569?= From: Johannes Berg commit aebe9f4639b13a1f4e9a6b42cdd2e38c617b442d upstream. In the copy code of the elements, we do the following calculation to reach the end of the MBSSID element: /* copy the IEs after MBSSID */ cpy_len = mbssid[1] + 2; This looks fine, however, cpy_len is a u8, the same as mbssid[1], so the addition of two can overflow. In this case the subsequent memcpy() will overflow the allocated buffer, since it copies 256 bytes too much due to the way the allocation and memcpy() sizes are calculated. Fix this by using size_t for the cpy_len variable. This fixes CVE-2022-41674. Reported-by: Soenke Huster Tested-by: Soenke Huster Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Reviewed-by: Kees Cook Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -2238,7 +2238,7 @@ cfg80211_update_notlisted_nontrans(struc size_t new_ie_len; struct cfg80211_bss_ies *new_ies; const struct cfg80211_bss_ies *old; - u8 cpy_len; + size_t cpy_len; lockdep_assert_held(&wiphy_to_rdev(wiphy)->bss_lock); From patchwork Thu Oct 13 17:52:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2276 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp420584wrs; Thu, 13 Oct 2022 11:31:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7HCyxBXhmWbPeAtF8Sz3uUH/C0ep7x9yYYWcutq9QdW75b6plCTIHOOviblAhMgxng9KeE X-Received: by 2002:a63:86c7:0:b0:459:437c:ca90 with SMTP id x190-20020a6386c7000000b00459437cca90mr1073446pgd.33.1665685902246; Thu, 13 Oct 2022 11:31:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665685902; cv=none; d=google.com; s=arc-20160816; b=HSPJpWsk9FoZWnUw9IvE8hjEFtd7tt0fSdLbCWtUABxIEwQl1W35Rkwz4ErQ1LAEQk c96GOtHM78o9JCfL5R/wrK3HHWZ/uKvNI8enNe3TCURy2HtfN3Z6XuPVECQAdgEitiBa AmyFZED2Rw/Mzu3ydkAeXNARE3xtxbDyGjYpv8rhHGIM18i71hk/tb0BkmVr36zHPzZP Zli3/nSq6PL0IsJZxdepQ3+tBprwkttO9aATOKeRqsC3opwin3MrRZD391SmwFHWDPVl zJ+UxChS9lQZlD7Vcdz4uzlf026lVDwPXpV6PbrbCi7D7kokXUbu2QZAzsO/biOFDj1p E1aA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3fnqahB3pEL8yH+lvrZc7SIR6p/cnxCKjJbkZQptMgg=; b=ZiQk+2opN/FgA8LHESWi4P9rVN6nOt0Vq1FUDhwr9/oYULxxze0fj4wdIPMRMDrIG4 XHCJnQENtzG3fr9Cjv/PsW9m9JUn5SBGMflj6eWvly+JafGLg53BG8Hk/VAwSA7MAk9m P5n9XjEVCsLWYH7oqZUqWWCvevsHN4Gz2nELEFH+TMJ/0tGXphsMMukd9wCdbl1PkLSY nmmLfS4GqnByEaGbfb5MdzZWMJIHbH2F8pLKPJP5BOD+9ObhL3y06QfytSMJX+84goVg /2Q0lOoZ8K1DxEeCBtGp+i2SLmR++UO8mL+7y1x+f5rifk3psR+KuUKKaodxMaBYiQmc Z4Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2NciiWDz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pc3-20020a17090b3b8300b001fe4eebefe5si7055277pjb.135.2022.10.13.11.31.29; Thu, 13 Oct 2022 11:31:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2NciiWDz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229550AbiJMSTe (ORCPT + 99 others); Thu, 13 Oct 2022 14:19:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232107AbiJMSTE (ORCPT ); Thu, 13 Oct 2022 14:19:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC09E2FFF7; Thu, 13 Oct 2022 11:14:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7DD0F6192B; Thu, 13 Oct 2022 17:57:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80B9DC433C1; Thu, 13 Oct 2022 17:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683863; bh=+1JS/ScgbebCTbepqx7MKXQYJzZPylwvLEfDVcFSmgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2NciiWDzoCeeGnz1c4DbYz1+DGxYavr8jZTfiRjujYJkiecrL5lEdBt1PZq6L1nDg oJ2cvPGykw1U3YVZcsp5xEgowt3+YMgrSDczCV6S17KpUoMwz+vCgbDmxhljnW/H+f s4qHx0oSkRPzv/v0ZaKw5J1rdgX+Eiusmz3pQEnk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Johannes Berg Subject: [PATCH 5.15 17/27] wifi: cfg80211/mac80211: reject bad MBSSID elements Date: Thu, 13 Oct 2022 19:52:46 +0200 Message-Id: <20221013175144.181064984@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746598260478880630?= X-GMAIL-MSGID: =?utf-8?q?1746598260478880630?= From: Johannes Berg commit 8f033d2becc24aa6bfd2a5c104407963560caabc upstream. Per spec, the maximum value for the MaxBSSID ('n') indicator is 8, and the minimum is 1 since a multiple BSSID set with just one BSSID doesn't make sense (the # of BSSIDs is limited by 2^n). Limit this in the parsing in both cfg80211 and mac80211, rejecting any elements with an invalid value. This fixes potentially bad shifts in the processing of these inside the cfg80211_gen_new_bssid() function later. I found this during the investigation of CVE-2022-41674 fixed by the previous patch. Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Fixes: 78ac51f81532 ("mac80211: support multi-bssid") Reviewed-by: Kees Cook Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/mac80211/util.c | 2 ++ net/wireless/scan.c | 2 ++ 2 files changed, 4 insertions(+) --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1414,6 +1414,8 @@ static size_t ieee802_11_find_bssid_prof for_each_element_id(elem, WLAN_EID_MULTIPLE_BSSID, start, len) { if (elem->datalen < 2) continue; + if (elem->data[0] < 1 || elem->data[0] > 8) + continue; for_each_element(sub, elem->data + 1, elem->datalen - 1) { u8 new_bssid[ETH_ALEN]; --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -2103,6 +2103,8 @@ static void cfg80211_parse_mbssid_data(s for_each_element_id(elem, WLAN_EID_MULTIPLE_BSSID, ie, ielen) { if (elem->datalen < 4) continue; + if (elem->data[0] < 1 || (int)elem->data[0] > 8) + continue; for_each_element(sub, elem->data + 1, elem->datalen - 1) { u8 profile_len; From patchwork Thu Oct 13 17:52:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp415113wrs; Thu, 13 Oct 2022 11:16:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6arNErSEU1gYskD/i0CFRGlLBCm4WLkzzi4jEwzC3lVQCW0gtMBykeN3KUXS1bmhEXvKM/ X-Received: by 2002:a17:902:d34d:b0:17f:9018:6 with SMTP id l13-20020a170902d34d00b0017f90180006mr1178092plk.112.1665685009334; Thu, 13 Oct 2022 11:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665685009; cv=none; d=google.com; s=arc-20160816; b=wNPQYarduUacJUtc8avueEyivwSgB/523PPMuoaR2er69A3jMDrEm3SSoWkhoBFtqH 5faqD7LBlnFzQJI4rpWtPl1i7t7+G6SR4g5B+28EeN4Pc4Z25wdqDfWd6rz1Rt9E9Hx1 sfzcVoWho1ShyfSt/VXMxBYO3gu3DHy8IF0ZF0QAZ741ObpghPsMYczKrgrvQ4CuMKo4 QpzqnGChC9t2itCOwUJD01LeN6HwvSGeHOtak4SnyAN93D6whtTR9JYo5RwdQgBqdLj+ 9MINE+SlIejb+/ogPRaZhkjxyPXC3B17o+D9V3ihxdwswYa/L8q0uQLKHeYan0Z6vfDA iU3w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+sj+1pjDe2qwAtycRwj/aoNEuIQNSsbr+6RKm1o559g=; b=p7QsaoUsgZPojcelaB8dc4V4HvjOeJX907juZam8xvRb3K9tSmePITYgruhIArbpCR LD3MkhduwgXvXKaoCkztWcVLb4bFuurFvh1gVB/0h7ErCGAh5D2oY2UQDthl6vXDL1ex NhfDU+R4gyW2MUn383wmpWKtzrmarGrZwik+id/2FV/wh4IaJgmdsUokGOICYKs6Bvke BUOExTRwuMIUwbSQM9X7ZSoncVZ2Wh9g4gDzoczEMjfdDWHMJl38fm+ubaD4bl7tAM4e 7Vsk58gRQRU5mlR+NNfHCOE6Tz7VdNp4s5m5Rs9OuVRtG+Kq7B3arZ1NyC7xTG2ajpKO GKAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=C0HkR4ks; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q8-20020a17090311c800b00179e66b5d2csi432221plh.398.2022.10.13.11.16.36; Thu, 13 Oct 2022 11:16:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=C0HkR4ks; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231439AbiJMSQO (ORCPT + 99 others); Thu, 13 Oct 2022 14:16:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231939AbiJMSNt (ORCPT ); Thu, 13 Oct 2022 14:13:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBC271E3F5; Thu, 13 Oct 2022 11:09:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 11EF8B82037; Thu, 13 Oct 2022 17:57:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DA49C433C1; Thu, 13 Oct 2022 17:57:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683866; bh=7ADSkhJgMzgbvEfxkGhKSmMII+dlmQ0WYUlz4phgh+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C0HkR4ksKlDOH4IuZYHQIwV+8Ot+KgCk49OMZs4AUmTGE469myq93agaylRPbnUDm T8VKq8wx1QSomvZeCan0mrN/NQsUeiW9c9cB7qtpN8Q7V85kjylDFLV95M+ZkvhSqn TJpJsmobZlEC7mpAGW3FzwHCpU/GeHL6faLtesPk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Soenke Huster , Johannes Berg Subject: [PATCH 5.15 18/27] wifi: cfg80211: ensure length byte is present before access Date: Thu, 13 Oct 2022 19:52:47 +0200 Message-Id: <20221013175144.224834735@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597324348715279?= X-GMAIL-MSGID: =?utf-8?q?1746597324348715279?= From: Johannes Berg commit 567e14e39e8f8c6997a1378bc3be615afca86063 upstream. When iterating the elements here, ensure the length byte is present before checking it to see if the entire element will fit into the buffer. Longer term, we should rewrite this code using the type-safe element iteration macros that check all of this. Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Reported-by: Soenke Huster Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/scan.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -304,7 +304,8 @@ static size_t cfg80211_gen_new_ie(const tmp_old = cfg80211_find_ie(WLAN_EID_SSID, ie, ielen); tmp_old = (tmp_old) ? tmp_old + tmp_old[1] + 2 : ie; - while (tmp_old + tmp_old[1] + 2 - ie <= ielen) { + while (tmp_old + 2 - ie <= ielen && + tmp_old + tmp_old[1] + 2 - ie <= ielen) { if (tmp_old[0] == 0) { tmp_old++; continue; @@ -364,7 +365,8 @@ static size_t cfg80211_gen_new_ie(const * copied to new ie, skip ssid, capability, bssid-index ie */ tmp_new = sub_copy; - while (tmp_new + tmp_new[1] + 2 - sub_copy <= subie_len) { + while (tmp_new + 2 - sub_copy <= subie_len && + tmp_new + tmp_new[1] + 2 - sub_copy <= subie_len) { if (!(tmp_new[0] == WLAN_EID_NON_TX_BSSID_CAP || tmp_new[0] == WLAN_EID_SSID)) { memcpy(pos, tmp_new, tmp_new[1] + 2); From patchwork Thu Oct 13 17:52:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp414675wrs; Thu, 13 Oct 2022 11:16:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM61eE6nW8L0Ga+6rorSrycJmQNQ5EjlVuPoj/TQd9fRGgLjZwONJ9yAPJ6sJh8F3a0QpPDp X-Received: by 2002:a17:902:8b83:b0:17f:5de5:c5ff with SMTP id ay3-20020a1709028b8300b0017f5de5c5ffmr1204983plb.52.1665684961257; Thu, 13 Oct 2022 11:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684961; cv=none; d=google.com; s=arc-20160816; b=Y08CHM5SIeJd2aOQykoGm3Z4qIevLZ5BO1LshsIuGahnWb7ZkveY4YuMUzXAnBAqw3 rjXR+btqEcMOQMP/X+XKuh3onIl6UcEADtdChCl+/mqdKJbYlwukGW6E6tB+Bz5VNstf yGau+glwIDXR7ftu5BaeiqS37qzyhvFhSd7NLJ4ERrDdRAtuJG4BXejRSN7fZ6rqMkyR KI5W4y8uiIqe1s24MS0mSh5o2YKFVB0z8opwLFXm4+cl+hIxxQiijvq50Lvsg2XdBqUt VwcntR4INhaw9rm92GVaA4WtIicM13PcLib6hIcTWRbTZLB/7gyclZVhzOJ/RtP76Gca I+GA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=a+7PRlP5UNZu8nSDspwfYcZi3RM9aA2i0H5XK5v5LmI=; b=dSpSF+g3E8O8G+29AHUIkHZbYS+mkJh+yR2h35V/BsuWVMFPyv58EcfTZAJqi5zzFo KGhA1ZEMx5R7E2qquEpD3lTIdUTveg0oZYMUal/riImIA16MA5BabJURb4/N2+vkSM8B SCYazCnxDmn2VdKVxgauFX80IRuF5DerQnENanP2CJ56SzT4FOoW07Hs1tVIk1K2jWXD Tz6qQs6yyZWAzbab7hEXr0t2jhuDskgOwepM/JBaBe1TJin2YNkl+XcAeIKPeSLRgUU+ Kr4fIfCoUQpLzhH61cKD1jpDHX86NmsrWRMrh26SMsRxcGUp6Ihjvm+81hSZ9lIfAJnz wd+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A3E07aXz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt19-20020a17090af2d300b0020053614bd0si5383554pjb.148.2022.10.13.11.15.48; Thu, 13 Oct 2022 11:16:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A3E07aXz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232088AbiJMSOF (ORCPT + 99 others); Thu, 13 Oct 2022 14:14:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231670AbiJMSMn (ORCPT ); Thu, 13 Oct 2022 14:12:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 567F1DBE4C; Thu, 13 Oct 2022 11:09:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 56568B8203C; Thu, 13 Oct 2022 17:57:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A147C433D6; Thu, 13 Oct 2022 17:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683870; bh=UKF8TMaennwEzj2kTNFiz0KGvFT3hjGwzvVddy+SOcg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A3E07aXzG0ntnBrpvnFPDxASLylelmTEnaY94F7hy1+ZF5CdT1W4trDNVZnqjG+Rr Ko2NUUY4kbuKcpdxnSKgrncU6M7tqw8P+uWoZ8oA/Pi2c2hFTib+qlrOLX+QtQRdLe 3E+SpGXqo5wsWHEfOm2731F2BWNA6tJ5lrULnAu4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?S=C3=B6nke_Huster?= , Johannes Berg Subject: [PATCH 5.15 19/27] wifi: cfg80211: fix BSS refcounting bugs Date: Thu, 13 Oct 2022 19:52:48 +0200 Message-Id: <20221013175144.261946484@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597273431539900?= X-GMAIL-MSGID: =?utf-8?q?1746597273431539900?= From: Johannes Berg commit 0b7808818cb9df6680f98996b8e9a439fa7bcc2f upstream. There are multiple refcounting bugs related to multi-BSSID: - In bss_ref_get(), if the BSS has a hidden_beacon_bss, then the bss pointer is overwritten before checking for the transmitted BSS, which is clearly wrong. Fix this by using the bss_from_pub() macro. - In cfg80211_bss_update() we copy the transmitted_bss pointer from tmp into new, but then if we release new, we'll unref it erroneously. We already set the pointer and ref it, but need to NULL it since it was copied from the tmp data. - In cfg80211_inform_single_bss_data(), if adding to the non- transmitted list fails, we unlink the BSS and yet still we return it, but this results in returning an entry without a reference. We shouldn't return it anyway if it was broken enough to not get added there. This fixes CVE-2022-42720. Reported-by: Sönke Huster Tested-by: Sönke Huster Fixes: a3584f56de1c ("cfg80211: Properly track transmitting and non-transmitting BSS") Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/scan.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -143,18 +143,12 @@ static inline void bss_ref_get(struct cf lockdep_assert_held(&rdev->bss_lock); bss->refcount++; - if (bss->pub.hidden_beacon_bss) { - bss = container_of(bss->pub.hidden_beacon_bss, - struct cfg80211_internal_bss, - pub); - bss->refcount++; - } - if (bss->pub.transmitted_bss) { - bss = container_of(bss->pub.transmitted_bss, - struct cfg80211_internal_bss, - pub); - bss->refcount++; - } + + if (bss->pub.hidden_beacon_bss) + bss_from_pub(bss->pub.hidden_beacon_bss)->refcount++; + + if (bss->pub.transmitted_bss) + bss_from_pub(bss->pub.transmitted_bss)->refcount++; } static inline void bss_ref_put(struct cfg80211_registered_device *rdev, @@ -1743,6 +1737,8 @@ cfg80211_bss_update(struct cfg80211_regi new->refcount = 1; INIT_LIST_HEAD(&new->hidden_list); INIT_LIST_HEAD(&new->pub.nontrans_list); + /* we'll set this later if it was non-NULL */ + new->pub.transmitted_bss = NULL; if (rcu_access_pointer(tmp->pub.proberesp_ies)) { hidden = rb_find_bss(rdev, tmp, BSS_CMP_HIDE_ZLEN); @@ -1983,10 +1979,15 @@ cfg80211_inform_single_bss_data(struct w spin_lock_bh(&rdev->bss_lock); if (cfg80211_add_nontrans_list(non_tx_data->tx_bss, &res->pub)) { - if (__cfg80211_unlink_bss(rdev, res)) + if (__cfg80211_unlink_bss(rdev, res)) { rdev->bss_generation++; + res = NULL; + } } spin_unlock_bh(&rdev->bss_lock); + + if (!res) + return NULL; } trace_cfg80211_return_bss(&res->pub); From patchwork Thu Oct 13 17:52:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2182 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp408140wrs; Thu, 13 Oct 2022 11:03:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WSAnRL/WIFPTWB5y9KjQlmcaapaMfXgDt9J25KY5f06LA60Re1WeTRAE2Re+5hKRrRuTw X-Received: by 2002:a17:90b:390b:b0:20d:2c45:84e3 with SMTP id ob11-20020a17090b390b00b0020d2c4584e3mr1062319pjb.161.1665684185809; Thu, 13 Oct 2022 11:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684185; cv=none; d=google.com; s=arc-20160816; b=Qsok/XMGBud5aMmqY3k9TGRdwkfP6/YzwaQRjHPeylFMAoS/b3jKLKEnoo7jDNG7Ln oMInS+v41p/BrXBK1BWTto/D3Gk3X0hvrhmyoyQsRiwoCX+4SWyKjYfBgjIN9zEMUJI/ RTmNvO9pRGwJqzgTMXMBxoMsoVW6mMg/Xl38nknLtE44I4LhsN6rkZWsfKeBdXvLYx2M Md/RBc4RIGndo4YwVvQxEPxPbbdUVY7GY5FYw6N4b+Rcwl0ae5Xuj5dAJX7VyUm/l0El QrcCI+Qja5/CDkUuMOfRGXp/47KvhBNbXyXW4thGD2frJvKvz6SqVZvFp3/et428Ti4W 7MzQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zA4hmFjbp1+Z1cJgLhJ7yUJxLdNmtdAgfhPM66Q/sd8=; b=OgTI4mjIXaQdMzwObX3006aUsxSODKzx74iOjn2svv4BGINJpd9oy4V2LGvlAyQmY3 FLcHtfE8FHGAXCHxLTsn/WXLn6lD/6Ywg9oMPTsv3FVsvkkL2LMMyYV2FgvoGlLEO2xK Ik8E7ZqemAWY+aZtvrVcrqmKdstGBfcLqKLR/rQDJzHAYNPzo4yI4qLwBeoJdoD2DZFo 7bnlR/KMfkhl6DSJKiGKw07KsZQF7+BWjHGjtQrkyW44r+5V+LY6Hhr1ah3QfN+ilIe3 lf0d/23oXeIpuR6v+nXu2N3oCteCc+ZpWcE2octEHditTH/zAz0PYPuYwKruImHYIIuR /rbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JCt9YA7+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020aa78e4b000000b005659a66d652si8282pfr.229.2022.10.13.11.02.46; Thu, 13 Oct 2022 11:03:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JCt9YA7+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230411AbiJMSCA (ORCPT + 99 others); Thu, 13 Oct 2022 14:02:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbiJMSBn (ORCPT ); Thu, 13 Oct 2022 14:01:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 595BD11A96A; Thu, 13 Oct 2022 11:01:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id AD40FB8203D; Thu, 13 Oct 2022 17:57:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A044DC433C1; Thu, 13 Oct 2022 17:57:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683874; bh=CK8zW69mYsVe631d9uSwXr4sBV2nDL15Y8aevweb+n8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JCt9YA7+mf3S6njE2rQl7Bm65YRMAyKRMa9Me5sOecoUmN7OrO16PutpNAz1byaw1 ma0RZX1AVsW7WNjZAFRY0CmYH4/ZiSWLM8f8YnRBUuHoHpXL/yppil0uTz8FS1N5hu 0ycLRGyOvQcwJradcGk+qCkMNfBO2l03+pbB6QgE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?S=C3=B6nke_Huster?= , Johannes Berg Subject: [PATCH 5.15 20/27] wifi: cfg80211: avoid nontransmitted BSS list corruption Date: Thu, 13 Oct 2022 19:52:49 +0200 Message-Id: <20221013175144.290858350@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596460692215493?= X-GMAIL-MSGID: =?utf-8?q?1746596460692215493?= From: Johannes Berg commit bcca852027e5878aec911a347407ecc88d6fff7f upstream. If a non-transmitted BSS shares enough information (both SSID and BSSID!) with another non-transmitted BSS of a different AP, then we can find and update it, and then try to add it to the non-transmitted BSS list. We do a search for it on the transmitted BSS, but if it's not there (but belongs to another transmitted BSS), the list gets corrupted. Since this is an erroneous situation, simply fail the list insertion in this case and free the non-transmitted BSS. This fixes CVE-2022-42721. Reported-by: Sönke Huster Tested-by: Sönke Huster Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/scan.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -425,6 +425,15 @@ cfg80211_add_nontrans_list(struct cfg802 rcu_read_unlock(); + /* + * This is a bit weird - it's not on the list, but already on another + * one! The only way that could happen is if there's some BSSID/SSID + * shared by multiple APs in their multi-BSSID profiles, potentially + * with hidden SSID mixed in ... ignore it. + */ + if (!list_empty(&nontrans_bss->nontrans_list)) + return -EINVAL; + /* add to the list */ list_add_tail(&nontrans_bss->nontrans_list, &trans_bss->nontrans_list); return 0; From patchwork Thu Oct 13 17:52:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2348 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp443854wrs; Thu, 13 Oct 2022 12:28:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Hg/xlQYRc/gfWUIYslQx5aoSk4TPTfYnGy+fx+p5nPb7ko273NCXy026Rv0YJLWdEm6Et X-Received: by 2002:a63:6cc6:0:b0:457:5f5f:9dff with SMTP id h189-20020a636cc6000000b004575f5f9dffmr1211355pgc.493.1665689320055; Thu, 13 Oct 2022 12:28:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665689320; cv=none; d=google.com; s=arc-20160816; b=FDyUTE3ij+lIx7m4zaIJkWvY6Z/59ZkmETWsPz2c4FL4rnbrdfzved0SsDZprLNdxs tkj9CtsN4alYHv6tO2R4AfqhJ/IquSwKYUHrvrVEPpMMe+vJvCtOr8L9lUKAddjtRby1 odIvBujulJQ/b/z2jVyugBneenq/Ecb2K3rE7bMUy+VOcs1nzoPnJWCOoKBNQe2oZfxC nownfvBnYQRTvLfptKqgui6gITPtzMNpeuqTm5kRzyNL8aITOntaZ0RuIJLiflbC5dm7 VTj2FSfceD6Z3NlE6L5nDK2iDaAuV3a04hzLgDjKMlvviLu/6BG8D6m2vRk+C9K+CD92 DO4w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HzMJJalQwb7HxWA603kQeO1cH4xqQ74/CblSq3eq7Ns=; b=LQJOHHWQQR6mOC9/vw7z2BJgSOkJrscSRGbbdSEx6R4KD3kU5lrGdymVEp0ygUJ/mB iPn+FOhGE/4hCDAbgeelVh6iq8hQKlrNSsjbTnl7fMF3AFri3UaJKnUalaALnrzcsC97 lLZf3xBSMYAcIRxuay6JIXYrwFyeycZnlhH3WnrTHdp2Ki5cKI3xYoNN4Tk/fFobGG8I Pw3k3b5aFj5ZR4OjOb1uUDVnspAkObzwjbtKiMyyMzTtGr6sjakAOZeEl0khnbYZGS+R dQW6gTCMA2Hjhb/KCtRAwZFo24H58tNCU4DDA64c4cz3eLPCgRPJfRLKJrokU1fV8R3m /M6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vyf1yqgZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a70-20020a639049000000b004611cfaca6asi236596pge.381.2022.10.13.12.28.27; Thu, 13 Oct 2022 12:28:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vyf1yqgZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229740AbiJMTMm (ORCPT + 99 others); Thu, 13 Oct 2022 15:12:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229972AbiJMTMZ (ORCPT ); Thu, 13 Oct 2022 15:12:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED5D23A4AA; Thu, 13 Oct 2022 12:12:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 29D3C61938; Thu, 13 Oct 2022 17:58:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C16CC433D7; Thu, 13 Oct 2022 17:57:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683880; bh=iSU4oNQTGikY1NG5fAAZBCNpZVckUY3c/pPdJ+jMIKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vyf1yqgZ+LTTc0hge2FYKEgVTJVDWaXcukYQvs01TEkxnlk6iCyAg6m9HpeVP1JYc Ma5MH01/L13d62XJVom4TR9kvRnqod3XWjp7xAE8AMIbO1rO0b944CU8a4oU8l8HE4 0/+KyUL0bz/mv9SoaUmoQ6rJK7q5uRijbwfXBWwc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?S=C3=B6nke_Huster?= , Johannes Berg Subject: [PATCH 5.15 21/27] wifi: mac80211_hwsim: avoid mac80211 warning on bad rate Date: Thu, 13 Oct 2022 19:52:50 +0200 Message-Id: <20221013175144.324918092@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746601844781958950?= X-GMAIL-MSGID: =?utf-8?q?1746601844781958950?= From: Johannes Berg commit 1833b6f46d7e2830251a063935ab464256defe22 upstream. If the tool on the other side (e.g. wmediumd) gets confused about the rate, we hit a warning in mac80211. Silence that by effectively duplicating the check here and dropping the frame silently (in mac80211 it's dropped with the warning). Reported-by: Sönke Huster Tested-by: Sönke Huster Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/mac80211_hwsim.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -3749,6 +3749,8 @@ static int hwsim_cloned_frame_received_n rx_status.band = channel->band; rx_status.rate_idx = nla_get_u32(info->attrs[HWSIM_ATTR_RX_RATE]); + if (rx_status.rate_idx >= data2->hw->wiphy->bands[rx_status.band]->n_bitrates) + goto out; rx_status.signal = nla_get_u32(info->attrs[HWSIM_ATTR_SIGNAL]); hdr = (void *)skb->data; From patchwork Thu Oct 13 17:52:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2185 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp408215wrs; Thu, 13 Oct 2022 11:03:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7JP5Fij+4ER+KNZ1W5ZwYXYoB+Y8DLYu/qAbdRRiojojeMEbaxMEaQIMjYTi6lzn4I1nFn X-Received: by 2002:a05:6a00:998:b0:563:3428:65a0 with SMTP id u24-20020a056a00099800b00563342865a0mr747011pfg.22.1665684191888; Thu, 13 Oct 2022 11:03:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684191; cv=none; d=google.com; s=arc-20160816; b=ERxnRd2qCtW+IAcjT8NnfFGIxnwYCpbgad8/LJbgMdzo+8d7enlPjUWGpS0LTiZXOe ngiFIRngjxIvT7jqhGZLb3dx/6orAOq8Vjhzt2EJ+bG7RA4K855D5BJ5PGkj3GLtR5ok 450fbTMjhtAqhgIIyIAf/q4BOdoi28LmbJQhBgsC2UqEyZ85w3RNeVuPl+mcWxr+5/WO Z9MrL7oK73DKPOqpn3xq8CFa/x2dE/VO7WV2YZUQ/AVQBDbmhr9bc9ioKtB05BeJpOcG UIrLVZMutIlRRL1KMCMLZCQKRylp/ntD75z2he98PZaECnmCtVy4fDOIHGkkANuZjWcm 8V5A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d8H3DV7xi74etblbwK73F6pSSbsNRQ+RqZ3eh6MjtR4=; b=jgiCH+4MdvRkSMGuuteo71tPQsL3yTzNSSfDuxOz0xgXCEgHvv9aaMJxF5s+dz+9Vx EOpGdOpV7w2dAr3qThBatCZboxDN84fRF3+vwxkrsH8xBiCoQCUaxifOqotlo7A5JtU9 hd/+b+XKWh+QwfeIoS0ktdvH4zYsJFfYFfJg3OrewMHwHMON2ZNWU1yUDXJWB1f2A1tW Xn5nbMgXY8suNrsesySiic6PKVZ+ilS1vTk1oauumKj6YTpUy4drMpAtpO8zpHzvxU8d Wvg/FWIgy5gxlFBrpzGSLjc6ZntpuKJfbbGCMhMb/PEWopraPfInCpYyoThJ3SeQ8SEp teUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Of1Xo8nD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s12-20020a632c0c000000b0043bed49f325si93145pgs.13.2022.10.13.11.02.53; Thu, 13 Oct 2022 11:03:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Of1Xo8nD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230401AbiJMSCS (ORCPT + 99 others); Thu, 13 Oct 2022 14:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230387AbiJMSBt (ORCPT ); Thu, 13 Oct 2022 14:01:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A894B160EC4; Thu, 13 Oct 2022 11:01:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DD12061910; Thu, 13 Oct 2022 17:58:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F191DC433D6; Thu, 13 Oct 2022 17:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683893; bh=GA/zqaLurWyQIiyR2z2ZlBS2lsSicER8WDIT2Epwul8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Of1Xo8nD/8wzWLzJe6CM7sCJ7q81OoepH71qHILM7UYexwIk7wMg9lo4DoHCKHF1l AHSZypu8EBZUxMlLPfuGhWgHRZO7YmYw6LIu/ZmBUIQwAWtczQs+KsEWEE/g4pdQb8 cBAPSOMtECIFVe/KEdHOSAvnrbvP5HKJ+3twfRTM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?S=C3=B6nke_Huster?= , Johannes Berg Subject: [PATCH 5.15 22/27] wifi: mac80211: fix crash in beacon protection for P2P-device Date: Thu, 13 Oct 2022 19:52:51 +0200 Message-Id: <20221013175144.356052246@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596467482411028?= X-GMAIL-MSGID: =?utf-8?q?1746596467482411028?= From: Johannes Berg commit b2d03cabe2b2e150ff5a381731ea0355459be09f upstream. If beacon protection is active but the beacon cannot be decrypted or is otherwise malformed, we call the cfg80211 API to report this to userspace, but that uses a netdev pointer, which isn't present for P2P-Device. Fix this to call it only conditionally to ensure cfg80211 won't crash in the case of P2P-Device. This fixes CVE-2022-42722. Reported-by: Sönke Huster Fixes: 9eaf183af741 ("mac80211: Report beacon protection failures to user space") Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/mac80211/rx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -1982,10 +1982,11 @@ ieee80211_rx_h_decrypt(struct ieee80211_ if (mmie_keyidx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS || mmie_keyidx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS + - NUM_DEFAULT_BEACON_KEYS) { - cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, - skb->data, - skb->len); + NUM_DEFAULT_BEACON_KEYS) { + if (rx->sdata->dev) + cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, + skb->data, + skb->len); return RX_DROP_MONITOR; /* unexpected BIP keyidx */ } @@ -2133,7 +2134,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_ /* either the frame has been decrypted or will be dropped */ status->flag |= RX_FLAG_DECRYPTED; - if (unlikely(ieee80211_is_beacon(fc) && result == RX_DROP_UNUSABLE)) + if (unlikely(ieee80211_is_beacon(fc) && result == RX_DROP_UNUSABLE && + rx->sdata->dev)) cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev, skb->data, skb->len); From patchwork Thu Oct 13 17:52:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2259 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp414469wrs; Thu, 13 Oct 2022 11:15:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4+uZ9RzN42YWQCjL1fCjKDbp/CU1qIns2w3D9gOvev+/hufzgTgVn0uymQBzt2gOXKVwC+ X-Received: by 2002:a63:df03:0:b0:462:cfa2:2871 with SMTP id u3-20020a63df03000000b00462cfa22871mr970901pgg.225.1665684926330; Thu, 13 Oct 2022 11:15:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684926; cv=none; d=google.com; s=arc-20160816; b=iPoWekoy0yT+2QPycu/+0/ypfNaz6Wif1XndUqNggk5x32I2pmmowgAOjQEOSarMED Qcf7TlmY4qjnB1rk175e1riVCAkdJz4XPgGpN78ObS7OCTMpy+tV+0XOpNraS3NXgulw FXsy6KMRrwIOx+ZT/l5JR1ju42hl0vovEEKWGxhRU+xq5TsPKbrhynQYaZar83xU+XB+ GYv34lZludOd9JS6K0dbjY07Pyr6DDts5/OsjzROiq3BWo0iYaoLo1Tx2oU8dOfZq1+v ttNeEIasGXiDo6QSwRxtkkIfLen8HfSzNBoQGIX0lz2ifCpIdLInv8KeN3QzN7T0IRzj IvtA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JG7ZWaoeTOylZfqZiuII2mkdTcd2ePXcBWm+skZIpv0=; b=GxvRaxi5tpas2yzz1wKzIlU4FQW6Hurm4B741xLBvc4z/Bx5Llc++AXwTnxXZNGJ68 Q9LqyqRWiQ5r8hueQSEKpxYukc2MLaYWo0K8yPDWV39PMdbIPQYQ5ckTCWo6nAX8uEne UfCnRHJAHTz1woAKxdju/bkxxz/PYIC5qYSKsm6lX/BaMoC5evgRu0bvVSS0Lrhnxc0S lr2nETKMJ7VuuL+IjPsER70iwyvDfPMlot5ge0TSkutpHepki1VgZUT9kKxy6H9XhIkF m9nW9xrUD90qB8+srCBGGJ54qCNY8UaHYzqtAhrZcWXz8AFSNDY+B4ipkHaSdQbtTBCz fNmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M+Lpco07; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c1-20020a170903234100b00180680b8f1bsi484280plh.264.2022.10.13.11.15.12; Thu, 13 Oct 2022 11:15:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M+Lpco07; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232007AbiJMSN5 (ORCPT + 99 others); Thu, 13 Oct 2022 14:13:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231524AbiJMSMn (ORCPT ); Thu, 13 Oct 2022 14:12:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D26FE170DF4; Thu, 13 Oct 2022 11:09:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 56CC0B82035; Thu, 13 Oct 2022 17:58:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADD0AC433C1; Thu, 13 Oct 2022 17:58:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683896; bh=cJQs9i7XIYPlZuA7D9TEzytPMEnPOPWZP3TKAyK7eCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M+Lpco07SMBWlS9An3BAEFpcdJGjcQj5Q33IBI+bxrlBOtGLZwBxe3luQjcRqGBlP E38Sf95FDroou5I2bjjbHU88ceB7Cs+8qzD7BnJ/cpQunPda1qOn1wYHQ3M43LOgKQ 139hS7NJ2CJCglCizB2X2cz9d9pGRw3LSuzZNJUk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?S=C3=B6nke_Huster?= , Johannes Berg Subject: [PATCH 5.15 23/27] wifi: cfg80211: update hidden BSSes to avoid WARN_ON Date: Thu, 13 Oct 2022 19:52:52 +0200 Message-Id: <20221013175144.394551591@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597237234150659?= X-GMAIL-MSGID: =?utf-8?q?1746597237234150659?= From: Johannes Berg commit c90b93b5b782891ebfda49d4e5da36632fefd5d1 upstream. When updating beacon elements in a non-transmitted BSS, also update the hidden sub-entries to the same beacon elements, so that a future update through other paths won't trigger a WARN_ON(). The warning is triggered because the beacon elements in the hidden BSSes that are children of the BSS should always be the same as in the parent. Reported-by: Sönke Huster Tested-by: Sönke Huster Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/scan.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -1609,6 +1609,23 @@ struct cfg80211_non_tx_bss { u8 bssid_index; }; +static void cfg80211_update_hidden_bsses(struct cfg80211_internal_bss *known, + const struct cfg80211_bss_ies *new_ies, + const struct cfg80211_bss_ies *old_ies) +{ + struct cfg80211_internal_bss *bss; + + /* Assign beacon IEs to all sub entries */ + list_for_each_entry(bss, &known->hidden_list, hidden_list) { + const struct cfg80211_bss_ies *ies; + + ies = rcu_access_pointer(bss->pub.beacon_ies); + WARN_ON(ies != old_ies); + + rcu_assign_pointer(bss->pub.beacon_ies, new_ies); + } +} + static bool cfg80211_update_known_bss(struct cfg80211_registered_device *rdev, struct cfg80211_internal_bss *known, @@ -1632,7 +1649,6 @@ cfg80211_update_known_bss(struct cfg8021 kfree_rcu((struct cfg80211_bss_ies *)old, rcu_head); } else if (rcu_access_pointer(new->pub.beacon_ies)) { const struct cfg80211_bss_ies *old; - struct cfg80211_internal_bss *bss; if (known->pub.hidden_beacon_bss && !list_empty(&known->hidden_list)) { @@ -1660,16 +1676,7 @@ cfg80211_update_known_bss(struct cfg8021 if (old == rcu_access_pointer(known->pub.ies)) rcu_assign_pointer(known->pub.ies, new->pub.beacon_ies); - /* Assign beacon IEs to all sub entries */ - list_for_each_entry(bss, &known->hidden_list, hidden_list) { - const struct cfg80211_bss_ies *ies; - - ies = rcu_access_pointer(bss->pub.beacon_ies); - WARN_ON(ies != old); - - rcu_assign_pointer(bss->pub.beacon_ies, - new->pub.beacon_ies); - } + cfg80211_update_hidden_bsses(known, new->pub.beacon_ies, old); if (old) kfree_rcu((struct cfg80211_bss_ies *)old, rcu_head); @@ -2319,6 +2326,8 @@ cfg80211_update_notlisted_nontrans(struc } else { old = rcu_access_pointer(nontrans_bss->beacon_ies); rcu_assign_pointer(nontrans_bss->beacon_ies, new_ies); + cfg80211_update_hidden_bsses(bss_from_pub(nontrans_bss), + new_ies, old); rcu_assign_pointer(nontrans_bss->ies, new_ies); if (old) kfree_rcu((struct cfg80211_bss_ies *)old, rcu_head); From patchwork Thu Oct 13 17:52:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2275 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp417985wrs; Thu, 13 Oct 2022 11:24:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7repzyvjnrh9gfAS56ntT/Z5hcpL8bwePldZoydyE4IQbnrhm25vEolA+cBn9SSEAn0FKC X-Received: by 2002:a63:4753:0:b0:462:b3f0:a984 with SMTP id w19-20020a634753000000b00462b3f0a984mr973798pgk.501.1665685482932; Thu, 13 Oct 2022 11:24:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665685482; cv=none; d=google.com; s=arc-20160816; b=Xo+kuorFxsbBotxEEcQ57d8r2y27Tfwr8j5l+WDAE6d6SskrB3YoWIFqrsk+UvPYS8 eeI6kDjgD7d59Xe61+aBuW7QTXXXYIkiX3u/Ns21yH273dU3KOXBXQ8Wlaj7D4kAYvGg gEQjTGVACyGJFy1tfgmB8jkhDrwev9ukgiHTl2D0u/2VeQNYjG3VhVte986ZonbvnqX3 Yj7uH6003pjjGRKDnRMKu6ujVVTNXGtaoUUpBn/cRieC0nu5ZXu5oP6NqYzNEkCEETu7 KX7GnulWIGCx1ArvcDyH6BP0+cnBjlgsfIv0fv+I4ackPRoAmCVaDIVITEAZj0MvlMoU uxEw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FF+oA7C4BHy0usZcW/zh7Gm6QjQ7dJ+f1p72HLJmg80=; b=Yu+1DfPcS6Zy5HsepYiuqN3mmXbM/+2Gri03e5E3G+kjaJBM1J0mWLIhHcXp5/q0Uo SyQlb+ShOeDyE51D0JiSbs6hIkJ586mP1oJLryK8mXSm7RFYH9+4NODN1MlszD8CqwsI kZJoaxChogyCZmjZ/XO1DjAL7pipm4C6wGfbmDsDREOvYskqTChXBYAn9QtuTdYJflgC f8BJsS8PAJBvylgcyVgydxwDpSGKPyfUWC2GYQ9yVgp1Gt5dhOyzGILEZczrYDuo6JS8 PSSw3nyDO8IlYRC/y7MeF6sO4qEEPejqPKUgihpmkO+zeFXbwUZK9bgyNV8ywGATTjmu y43A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z9j+72EC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f13-20020a056a00228d00b00556c1c66b61si98418pfe.143.2022.10.13.11.24.31; Thu, 13 Oct 2022 11:24:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z9j+72EC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231881AbiJMSQo (ORCPT + 99 others); Thu, 13 Oct 2022 14:16:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232358AbiJMSOq (ORCPT ); Thu, 13 Oct 2022 14:14:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E521B1669BD; Thu, 13 Oct 2022 11:11:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 702EDB8203B; Thu, 13 Oct 2022 17:58:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D000FC43149; Thu, 13 Oct 2022 17:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683899; bh=/HRpr7EII9h229SUlP4Dmlr4MvLxTEfPUsGzRLuyqhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z9j+72ECQrHX4+mbcqPZyWKd4RfWfdOFhfTwY6+++ewZL6dBSviRdGc1AMorDWAu4 gpa3TPjxHWGhT+VikbWk8+kirZJeEzHuTnEwuzdWq1MhVZp7T8Z9dhc/L0rrmRiA8Z 1SH6dk05Fh0I1XS5FaDIkmDOR4G48NBwpfb3/eJU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jasper Poppe , Jeremy Palmer , Ruineka , Cleber de Mattos Casali , Kyle Gospodnetich , Pavel Rojtberg , Dmitry Torokhov Subject: [PATCH 5.15 24/27] Input: xpad - add supported devices as contributed on github Date: Thu, 13 Oct 2022 19:52:53 +0200 Message-Id: <20221013175144.426935817@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746597821019200328?= X-GMAIL-MSGID: =?utf-8?q?1746597821019200328?= From: Pavel Rojtberg commit b382c5e37344883dc97525d05f1f6b788f549985 upstream. This is based on multiple commits at https://github.com/paroj/xpad Cc: stable@vger.kernel.org Signed-off-by: Jasper Poppe Signed-off-by: Jeremy Palmer Signed-off-by: Ruineka Signed-off-by: Cleber de Mattos Casali Signed-off-by: Kyle Gospodnetich Signed-off-by: Pavel Rojtberg Link: https://lore.kernel.org/r/20220818154411.510308-2-rojtberg@gmail.com Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/joystick/xpad.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -113,6 +113,8 @@ static const struct xpad_device { u8 xtype; } xpad_device[] = { { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 }, + { 0x03eb, 0xff01, "Wooting One (Legacy)", 0, XTYPE_XBOX360 }, + { 0x03eb, 0xff02, "Wooting Two (Legacy)", 0, XTYPE_XBOX360 }, { 0x044f, 0x0f00, "Thrustmaster Wheel", 0, XTYPE_XBOX }, { 0x044f, 0x0f03, "Thrustmaster Wheel", 0, XTYPE_XBOX }, { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, @@ -244,6 +246,7 @@ static const struct xpad_device { { 0x0f0d, 0x0063, "Hori Real Arcade Pro Hayabusa (USA) Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, { 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE }, { 0x0f0d, 0x0078, "Hori Real Arcade Pro V Kai Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, + { 0x0f0d, 0x00c5, "Hori Fighting Commander ONE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, { 0x0f30, 0x010b, "Philips Recoil", 0, XTYPE_XBOX }, { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX }, { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX }, @@ -260,6 +263,7 @@ static const struct xpad_device { { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, { 0x1430, 0xf801, "RedOctane Controller", 0, XTYPE_XBOX360 }, { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 }, + { 0x146b, 0x0604, "Bigben Interactive DAIJA Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 }, { 0x1532, 0x0a00, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, { 0x1532, 0x0a03, "Razer Wildcat", 0, XTYPE_XBOXONE }, @@ -325,6 +329,7 @@ static const struct xpad_device { { 0x24c6, 0x5502, "Hori Fighting Stick VX Alt", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x24c6, 0x5503, "Hori Fighting Edge", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x24c6, 0x5506, "Hori SOULCALIBUR V Stick", 0, XTYPE_XBOX360 }, + { 0x24c6, 0x5510, "Hori Fighting Commander ONE (Xbox 360/PC Mode)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x24c6, 0x550d, "Hori GEM Xbox controller", 0, XTYPE_XBOX360 }, { 0x24c6, 0x550e, "Hori Real Arcade Pro V Kai 360", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, { 0x24c6, 0x551a, "PowerA FUSION Pro Controller", 0, XTYPE_XBOXONE }, @@ -334,6 +339,14 @@ static const struct xpad_device { { 0x24c6, 0x5b03, "Thrustmaster Ferrari 458 Racing Wheel", 0, XTYPE_XBOX360 }, { 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 }, { 0x24c6, 0xfafe, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 }, + { 0x2563, 0x058d, "OneXPlayer Gamepad", 0, XTYPE_XBOX360 }, + { 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE }, + { 0x31e3, 0x1100, "Wooting One", 0, XTYPE_XBOX360 }, + { 0x31e3, 0x1200, "Wooting Two", 0, XTYPE_XBOX360 }, + { 0x31e3, 0x1210, "Wooting Lekker", 0, XTYPE_XBOX360 }, + { 0x31e3, 0x1220, "Wooting Two HE", 0, XTYPE_XBOX360 }, + { 0x31e3, 0x1300, "Wooting 60HE (AVR)", 0, XTYPE_XBOX360 }, + { 0x31e3, 0x1310, "Wooting 60HE (ARM)", 0, XTYPE_XBOX360 }, { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 }, { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, @@ -419,6 +432,7 @@ static const signed short xpad_abs_trigg static const struct usb_device_id xpad_table[] = { { USB_INTERFACE_INFO('X', 'B', 0) }, /* X-Box USB-IF not approved class */ XPAD_XBOX360_VENDOR(0x0079), /* GPD Win 2 Controller */ + XPAD_XBOX360_VENDOR(0x03eb), /* Wooting Keyboards (Legacy) */ XPAD_XBOX360_VENDOR(0x044f), /* Thrustmaster X-Box 360 controllers */ XPAD_XBOX360_VENDOR(0x045e), /* Microsoft X-Box 360 controllers */ XPAD_XBOXONE_VENDOR(0x045e), /* Microsoft X-Box One controllers */ @@ -429,6 +443,7 @@ static const struct usb_device_id xpad_t { USB_DEVICE(0x0738, 0x4540) }, /* Mad Catz Beat Pad */ XPAD_XBOXONE_VENDOR(0x0738), /* Mad Catz FightStick TE 2 */ XPAD_XBOX360_VENDOR(0x07ff), /* Mad Catz GamePad */ + XPAD_XBOX360_VENDOR(0x0c12), /* Zeroplus X-Box 360 controllers */ XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */ XPAD_XBOXONE_VENDOR(0x0e6f), /* 0x0e6f X-Box One controllers */ XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */ @@ -450,8 +465,12 @@ static const struct usb_device_id xpad_t XPAD_XBOXONE_VENDOR(0x20d6), /* PowerA Controllers */ XPAD_XBOX360_VENDOR(0x24c6), /* PowerA Controllers */ XPAD_XBOXONE_VENDOR(0x24c6), /* PowerA Controllers */ + XPAD_XBOX360_VENDOR(0x2563), /* OneXPlayer Gamepad */ + XPAD_XBOX360_VENDOR(0x260d), /* Dareu H101 */ + XPAD_XBOXONE_VENDOR(0x2dc8), /* 8BitDo Pro 2 Wired Controller for Xbox */ XPAD_XBOXONE_VENDOR(0x2e24), /* Hyperkin Duke X-Box One pad */ XPAD_XBOX360_VENDOR(0x2f24), /* GameSir Controllers */ + XPAD_XBOX360_VENDOR(0x31e3), /* Wooting Keyboards */ XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */ { } }; From patchwork Thu Oct 13 17:52:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2344 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp435233wrs; Thu, 13 Oct 2022 12:07:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM68CKWOAbOhE21Yh0fgLVeoTua5siqIxGYGPuHmVzzyBhamtGOjjU2Cfdn/4LEdB8ODuHJ6 X-Received: by 2002:a05:6402:268a:b0:45c:c38d:ed70 with SMTP id w10-20020a056402268a00b0045cc38ded70mr1112717edd.62.1665688026798; Thu, 13 Oct 2022 12:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665688026; cv=none; d=google.com; s=arc-20160816; b=ITVEqnrAT972yr/K93sQRxTeRyOEK2Omysv/nmvCX8f2M4m9LqL9Kf2Wmq8Z6MlbtF 677MXN3UKyb5/u5CKRHqoiz6DQr06S3s84vQlHVP+Y5uYgJwbea2yt4VX4kGZ/Id8DBH HzANU6OQSNYpZ0F3/8xAK5E8LcvsdqPoD0CwcI2IkB5yDbFX20lyRk004OP79gjcR2mg CbXsoeeJjqkZaXNqIxXutGFgc0gf/0G/KUfkckySdT6Ha/Tr14/EJBr90hu15HVrhoex BrRXluqubymMdpx1BOOCrVhr19yLXtIm7OxpoXSHXerPyytQgVcjiX9KahxyVYj0DvZl 9CfA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FZ1YaeSNy/pNi3dcImhxesDJb5g81XsNXUAZ07POFWY=; b=DLZT1E5MJhc5tmHxjmvEgFjgKIzQXSsLZspyseGqya/WQll1V21ymZOPxX5F+x3UuR Be2Y8mUrdZZsdjNRMfk7Q7IM3zEpj3wYZbzFdOf0o8nEqIoVt7irSM3X/Q9UDqBLiCMY 5DmKy4kq1ngAqFea61emEmsn9eEYtg3zQnh/Kk/ZjUOVygckIrE9CpFCShUaW1a0BVQn TgrJVpMGs28DP4y5+lPUy6mXqihwa9p63dxD5MYp2bgctp+FfcO+v4XICjlpF8s2ANpZ rMgN/nKl/J4ed02w+3k4W0WetnzRT0+AYHplG6GPH3QF0cimLB70pgJIMlILMDSAtPi/ SRkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gMVSl6Bd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hh6-20020a170906a94600b00781b67df7f6si478268ejb.167.2022.10.13.12.06.39; Thu, 13 Oct 2022 12:07:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gMVSl6Bd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229671AbiJMTGD (ORCPT + 99 others); Thu, 13 Oct 2022 15:06:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbiJMTGA (ORCPT ); Thu, 13 Oct 2022 15:06:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4303D63CE; Thu, 13 Oct 2022 12:05:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 59912B82034; Thu, 13 Oct 2022 17:58:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1687C433C1; Thu, 13 Oct 2022 17:58:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683902; bh=45B25suZiRTyMNLHbM6xw8qTu27E00Fp19ufaiOX5r0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gMVSl6Bd+cHXpjEVfdlF8o+AabboTQLXF7SrryLfl41KF6iKzgCENlGkme75nb61u fZqvnXsooImKbXKiRKgrIHw4zt3rn/5tCdg4IYnIia4HItti2MS3gDnB4aC+S8FtqX 9tQ0/WsnaPR2dYqm9qzy8oWt/BPeB3zTt9rYOkTs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cameron Gutman , Pavel Rojtberg , Dmitry Torokhov Subject: [PATCH 5.15 25/27] Input: xpad - fix wireless 360 controller breaking after suspend Date: Thu, 13 Oct 2022 19:52:54 +0200 Message-Id: <20221013175144.475451252@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746600488209863128?= X-GMAIL-MSGID: =?utf-8?q?1746600488209863128?= From: Cameron Gutman commit a17b9841152e7f4621619902b347e2cc39c32996 upstream. Suspending and resuming the system can sometimes cause the out URB to get hung after a reset_resume. This causes LED setting and force feedback to break on resume. To avoid this, just drop the reset_resume callback so the USB core rebinds xpad to the wireless pads on resume if a reset happened. A nice side effect of this change is the LED ring on wireless controllers is now set correctly on system resume. Cc: stable@vger.kernel.org Fixes: 4220f7db1e42 ("Input: xpad - workaround dead irq_out after suspend/ resume") Signed-off-by: Cameron Gutman Signed-off-by: Pavel Rojtberg Link: https://lore.kernel.org/r/20220818154411.510308-3-rojtberg@gmail.com Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/joystick/xpad.c | 1 - 1 file changed, 1 deletion(-) --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -1991,7 +1991,6 @@ static struct usb_driver xpad_driver = { .disconnect = xpad_disconnect, .suspend = xpad_suspend, .resume = xpad_resume, - .reset_resume = xpad_resume, .id_table = xpad_table, }; From patchwork Thu Oct 13 17:52:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2188 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp408696wrs; Thu, 13 Oct 2022 11:03:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4d8msZrYOKZxelIWkskN26O4BetsZMvgDM097rIu7me9iRToMdsm0mV3tkq922RfQX5J4E X-Received: by 2002:a63:1e05:0:b0:451:31d0:8c0f with SMTP id e5-20020a631e05000000b0045131d08c0fmr928326pge.227.1665684227146; Thu, 13 Oct 2022 11:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684227; cv=none; d=google.com; s=arc-20160816; b=TsgUrNCKDWG5ubgtVi+am9GbiAqXcgwFMNB0YzPhc0zOnTey/fdPHi+cTUxN36e6Y6 5zlpCsu1MmEVc9QweWh6z+RVOPrlZVCAD4f73rWBWimKL6KCm7+L82/jAvvsmjZ2R5Xt k2qXgvkHYMU4DKfK0f5o+XsiJBwQnJ1HzSuVF+xLsRneq1qVH1cpQKGhbJI2uSFZ2e2m OU1W5E4tpI5O0rTKi8pRSUEFTN4A3YbkAmt4s7WkjYeCKyztE2JZySnkK2LUk1BtmNyZ OpHITmMSq413tLWHbw977B6xXZqQRUcWhmGDD1Ug0IWXM0C6tP6NQwYxSeh69AJSPCKs GRiw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nZhZQXfCKk7bnYk3QDLtn3RiiucS6JTrEp045IGadhE=; b=d4ClI5h1bsN3OwIhcSJCcD7NllKPMkoJJ7qS6VPpMxzjw3+4QFzagACU3Y10NJtCD6 wXhLgnuSlp2/22xzh59IoWhfjanXybb8EyyUrZrFaJMSeOHWkrz7RRRT8oTSocVlON5x TWLfdUW3Kzl+cbC6MUaqCmuyMfQO/yAlNLPOZfILuzZNpX262s2ripVXb8XKsVecWuaY DH2/9W1el8mrxSZCdWYrl1c75HX+ppFY6su7NdxJrT/qY9g8JNuqFTTRreEbxxhDhxi6 A/Bj9i4+Avdi1imKf/qsKpTZzA36E/c0LwAwnX+aVIn/qOxXjG2f2zqQFb9Grz/kL4fI xAIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=INVcvf42; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bb7-20020a17090b008700b00203246e4383si172423pjb.145.2022.10.13.11.03.14; Thu, 13 Oct 2022 11:03:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=INVcvf42; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230380AbiJMSCX (ORCPT + 99 others); Thu, 13 Oct 2022 14:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230406AbiJMSB6 (ORCPT ); Thu, 13 Oct 2022 14:01:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF1A4160EC5; Thu, 13 Oct 2022 11:01:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6EE5A6191C; Thu, 13 Oct 2022 17:58:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 755E8C433C1; Thu, 13 Oct 2022 17:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683904; bh=d76VYFuP2IkY/Fd+zNHwxmqro3iVPoBaVndsGkcmcJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=INVcvf42sHoMsvXZN0w3cEG90Vn9uK3TRsQcMYKQPDVlo9vKNczRPBKh7kY0+Aa6z O7mU0hk2El/lygsFG+fj0/FdszeCUR9gSyul7itRbdCchqVUjDZZh8JiP/9LgeXjCP vJGT5klaCAXKyobvMWFkgm6MsMEF6Ox14ak6sns8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shunsuke Mie , stable Subject: [PATCH 5.15 26/27] misc: pci_endpoint_test: Aggregate params checking for xfer Date: Thu, 13 Oct 2022 19:52:55 +0200 Message-Id: <20221013175144.511915824@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596504150185053?= X-GMAIL-MSGID: =?utf-8?q?1746596504150185053?= From: Shunsuke Mie commit 3e42deaac06567c7e86d287c305ccda24db4ae3d upstream. Each transfer test functions have same parameter checking code. This patch unites those to an introduced function. Signed-off-by: Shunsuke Mie Cc: stable Link: https://lore.kernel.org/r/20220907020100.122588-1-mie@igel.co.jp Signed-off-by: Greg Kroah-Hartman --- drivers/misc/pci_endpoint_test.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -332,6 +332,17 @@ static bool pci_endpoint_test_msi_irq(st return false; } +static int pci_endpoint_test_validate_xfer_params(struct device *dev, + struct pci_endpoint_test_xfer_param *param, size_t alignment) +{ + if (param->size > SIZE_MAX - alignment) { + dev_dbg(dev, "Maximum transfer data size exceeded\n"); + return -EINVAL; + } + + return 0; +} + static bool pci_endpoint_test_copy(struct pci_endpoint_test *test, unsigned long arg) { @@ -363,9 +374,11 @@ static bool pci_endpoint_test_copy(struc return false; } + err = pci_endpoint_test_validate_xfer_params(dev, ¶m, alignment); + if (err) + return false; + size = param.size; - if (size > SIZE_MAX - alignment) - goto err; use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); if (use_dma) @@ -497,9 +510,11 @@ static bool pci_endpoint_test_write(stru return false; } + err = pci_endpoint_test_validate_xfer_params(dev, ¶m, alignment); + if (err) + return false; + size = param.size; - if (size > SIZE_MAX - alignment) - goto err; use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); if (use_dma) @@ -595,9 +610,11 @@ static bool pci_endpoint_test_read(struc return false; } + err = pci_endpoint_test_validate_xfer_params(dev, ¶m, alignment); + if (err) + return false; + size = param.size; - if (size > SIZE_MAX - alignment) - goto err; use_dma = !!(param.flags & PCITEST_FLAGS_USE_DMA); if (use_dma) From patchwork Thu Oct 13 17:52:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2186 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp408677wrs; Thu, 13 Oct 2022 11:03:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Zurip2+sQ6dnHbe7lGYx7S4LXocfetbex5a/paNCbQB+pPY1sFMmIdCsn71hPooH4u8nh X-Received: by 2002:a63:4517:0:b0:464:4f06:a0f1 with SMTP id s23-20020a634517000000b004644f06a0f1mr889104pga.509.1665684225089; Thu, 13 Oct 2022 11:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684225; cv=none; d=google.com; s=arc-20160816; b=BVeN833zO4xL+27XrPJy+6s40adDW8tu3wRcyLMdgZ2FnJ5VeyFBzdXtJoDYSE2uz0 OXgoAVZSGg5JkqtzlRIUSFMSD4ruRIX6FCuUUd+lWB+ylKyRjIXi7rqqHXjdtsmV8xi7 ysJ4bVmoc5HhvXygwDqWV7djAXvBXQM4X0aBwok+fcdBEqhkuHkBhX4ZCd1vxyuBsH3G vSXwKU6dXueDcHuu+8PDTBPwoaVUGh/+csDDxTloijYz9QaUDr0MkTvXUyPmSezsypAi UrQh1g2KqfhadpThVReD5thg6NOfo62/a3bMIl8hQJ1YVM0PdZXb00nUQ50DjgR0nl5A DONQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ha0SroDg8oCcYjRNVcCRTHCyD5k0ka8z4g6fTvXDinE=; b=B4kZ27kfYX7MfgP7LFp6Kj5+Bz70cWlFZOxmBPAsvwLG/xsLzqAO2xGvBayXHMgoM7 g6gFESgwaLvcfhHZmSpwmIOi8JWc6AQMOchuMiwWIUVsEXk7tIpHGf5Hgh5DAEgkg8Vl W59tt3KGy4q8Ib+//77o+SY7WNGvm4haATnMlKkem/hfwfajHmheXYSGOtJa9tj4DT5U oLZ6df6VsQtScR1LXaROowJ+NbsQgoDTg7BOKKz5eIXg/St4oT3mF7goZ7oTqRHvWOc3 0OrxC5EDB28Cvh0vdf6GtKQeeAD0BOEsBt9KHvL03H/P5AudxN1GcPtvYc78A02Iet1+ TkWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EQNge9eN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a056a00244500b005618039550fsi25154969pfj.271.2022.10.13.11.03.17; Thu, 13 Oct 2022 11:03:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EQNge9eN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230414AbiJMSCq (ORCPT + 99 others); Thu, 13 Oct 2022 14:02:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230441AbiJMSCV (ORCPT ); Thu, 13 Oct 2022 14:02:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C48FB4E1AC; Thu, 13 Oct 2022 11:01:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C854BB8201C; Thu, 13 Oct 2022 17:58:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BE0CC433C1; Thu, 13 Oct 2022 17:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683907; bh=5ZgFuOtpNeu9B5tS5zB18GvxrieiEtS9AebSGSuoKG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EQNge9eNKW/O0bQ0pqlIGJHdmdpzcM1WWiR1SIRkmMxbtYNMWyNEMT/yF8x5Vjma3 q7BjSWCulaNcTMg1hXCr9wIpaxgG3soUJZ7/rjYsWfS+2r08c4nkDH5ZBOp9ARezI2 +28IGsx07R53qo0zOX1A3UIvHLLoXEUFDf3HFWHM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Shunsuke Mie Subject: [PATCH 5.15 27/27] misc: pci_endpoint_test: Fix pci_endpoint_test_{copy,write,read}() panic Date: Thu, 13 Oct 2022 19:52:56 +0200 Message-Id: <20221013175144.554486928@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596502016888213?= X-GMAIL-MSGID: =?utf-8?q?1746596502016888213?= From: Shunsuke Mie commit 8e30538eca016de8e252bef174beadecd64239f0 upstream. The dma_map_single() doesn't permit zero length mapping. It causes a follow panic. A panic was reported on arm64: [ 60.137988] ------------[ cut here ]------------ [ 60.142630] kernel BUG at kernel/dma/swiotlb.c:624! [ 60.147508] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP [ 60.152992] Modules linked in: dw_hdmi_cec crct10dif_ce simple_bridge rcar_fdp1 vsp1 rcar_vin videobuf2_vmalloc rcar_csi2 v4l 2_mem2mem videobuf2_dma_contig videobuf2_memops pci_endpoint_test videobuf2_v4l2 videobuf2_common rcar_fcp v4l2_fwnode v4l2_asyn c videodev mc gpio_bd9571mwv max9611 pwm_rcar ccree at24 authenc libdes phy_rcar_gen3_usb3 usb_dmac display_connector pwm_bl [ 60.186252] CPU: 0 PID: 508 Comm: pcitest Not tainted 6.0.0-rc1rpci-dev+ #237 [ 60.193387] Hardware name: Renesas Salvator-X 2nd version board based on r8a77951 (DT) [ 60.201302] pstate: 00000005 (nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 60.208263] pc : swiotlb_tbl_map_single+0x2c0/0x590 [ 60.213149] lr : swiotlb_map+0x88/0x1f0 [ 60.216982] sp : ffff80000a883bc0 [ 60.220292] x29: ffff80000a883bc0 x28: 0000000000000000 x27: 0000000000000000 [ 60.227430] x26: 0000000000000000 x25: ffff0004c0da20d0 x24: ffff80000a1f77c0 [ 60.234567] x23: 0000000000000002 x22: 0001000040000010 x21: 000000007a000000 [ 60.241703] x20: 0000000000200000 x19: 0000000000000000 x18: 0000000000000000 [ 60.248840] x17: 0000000000000000 x16: 0000000000000000 x15: ffff0006ff7b9180 [ 60.255977] x14: ffff0006ff7b9180 x13: 0000000000000000 x12: 0000000000000000 [ 60.263113] x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000000 [ 60.270249] x8 : 0001000000000010 x7 : ffff0004c6754b20 x6 : 0000000000000000 [ 60.277385] x5 : ffff0004c0da2090 x4 : 0000000000000000 x3 : 0000000000000001 [ 60.284521] x2 : 0000000040000000 x1 : 0000000000000000 x0 : 0000000040000010 [ 60.291658] Call trace: [ 60.294100] swiotlb_tbl_map_single+0x2c0/0x590 [ 60.298629] swiotlb_map+0x88/0x1f0 [ 60.302115] dma_map_page_attrs+0x188/0x230 [ 60.306299] pci_endpoint_test_ioctl+0x5e4/0xd90 [pci_endpoint_test] [ 60.312660] __arm64_sys_ioctl+0xa8/0xf0 [ 60.316583] invoke_syscall+0x44/0x108 [ 60.320334] el0_svc_common.constprop.0+0xcc/0xf0 [ 60.325038] do_el0_svc+0x2c/0xb8 [ 60.328351] el0_svc+0x2c/0x88 [ 60.331406] el0t_64_sync_handler+0xb8/0xc0 [ 60.335587] el0t_64_sync+0x18c/0x190 [ 60.339251] Code: 52800013 d2e00414 35fff45c d503201f (d4210000) [ 60.345344] ---[ end trace 0000000000000000 ]--- To fix it, this patch adds a checking the payload length if it is zero. Fixes: 343dc693f7b7 ("misc: pci_endpoint_test: Prevent some integer overflows") Cc: stable Signed-off-by: Shunsuke Mie Link: https://lore.kernel.org/r/20220907020100.122588-2-mie@igel.co.jp Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/misc/pci_endpoint_test.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -335,6 +335,11 @@ static bool pci_endpoint_test_msi_irq(st static int pci_endpoint_test_validate_xfer_params(struct device *dev, struct pci_endpoint_test_xfer_param *param, size_t alignment) { + if (!param->size) { + dev_dbg(dev, "Data size is zero\n"); + return -EINVAL; + } + if (param->size > SIZE_MAX - alignment) { dev_dbg(dev, "Maximum transfer data size exceeded\n"); return -EINVAL;