Message ID | 20221013175148.108672139@linuxfoundation.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp407530wrs; Thu, 13 Oct 2022 11:02:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7vILuEe5QuOCKLKFZwYBjTlARfDnDzv49cev4qxKB6eB3oSdKpGnPfFk69UlB924HYKTmy X-Received: by 2002:a17:906:9753:b0:787:8e6a:103c with SMTP id o19-20020a170906975300b007878e6a103cmr707899ejy.337.1665684128551; Thu, 13 Oct 2022 11:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684128; cv=none; d=google.com; s=arc-20160816; b=QHHRK5p85/J8aMc6RVJlpget+RQAxt6TcDeBlUL5O166twIrCYTmEeCAgKt5hrk/uc LQ764SMB2oPlao1YGTsiTA3q7rD49iZD3Y51EbmebIe0WV1qBUrWt3xRVmqoHTSvYbEu 7YxCFv6QxOvcx4HJeuxPCeCEcPF5d7qeF+LVEeh86Ou2Ib1432AbaUESKnUpGtqJMJXF /x+XkT3lCUy4/c6KZfwcurSrIo6s3Xib0yRSombt1K1gAWLw9kSX+iH1eZLF1rYbKZ0E Ut82Uvt+EtIu+40Xz/Jk297+HkdvV41pLFOPPvkF4cO42+CcPPa46Ls5WWGoPRVJLU89 Ja9w== 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=/99HhorlSEtRK1O8lF2dwiBzQkiIMdwAYwHSdrKnUc4=; b=I8p6f8lQl6MpemRgLm+UAZApt1Tz4mYNShG6VmyLd1SQEJgWDY1GxTJVqmFN/sj5VC b1rNVqLViv35k2rmnpG//U9boTK8sl+ZgZQSakeABjAFmiX1WJy6NucTEgceXxaPLRfu nEj26wzqbzMLPy37I7X9Nct+QSnZv8MAEh7wRWH2teAgA8Bn6dLzvhKat9Q8iqCcg4P9 zZvTz7uIla0rg+l9lN3q4nc33MrvUX4nIh4iEOuYYgH/5Jj4KVBban/ssOpYP/hjMg2r +t20PgbtGL9CRihNEKNV/sgvSEJpcYzmBRoMP/wZRum+huTn2fzVstb58cddizZfXZDC PjFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PnysIAxe; 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 l17-20020a170906415100b0078d3babe59bsi235621ejk.401.2022.10.13.11.01.38; Thu, 13 Oct 2022 11:02: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=PnysIAxe; 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 S230293AbiJMSBJ (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Thu, 13 Oct 2022 14:01:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbiJMSBF (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 13 Oct 2022 14:01:05 -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 5A42B255B1; Thu, 13 Oct 2022 11:00:54 -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 9B8F66190B; Thu, 13 Oct 2022 17:55:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3DF5C433C1; Thu, 13 Oct 2022 17:55:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683732; bh=xxDHkhWXn9LWoUKnTOuFYR63Zphxmul0hUMh47XisPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PnysIAxeMTukX14hAjCRhUcVThUG2k5u2mnZtA/UTCehYME6OCSIYpcLdxk50I81R /HRrC0hqcUW7Ga2LVbu7Pxu0Q+TfQjH9S3p98FKjcE+TSVRHqqKaLP6sqzD0oSRC2P pCKy7tdCUtFuwXDpE2GFawSOc7Ms3gWd4BhFHk6U= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org, "Dmitry Vyukov" <dvyukov@google.com>, stable <stable@kernel.org>, syzbot+23f57c5ae902429285d7@syzkaller.appspotmail.com, Tadeusz Struk <tadeusz.struk@linaro.org>, PaX Team <pageexec@freemail.hu> Subject: [PATCH 5.10 31/54] usb: mon: make mmapped memory read only Date: Thu, 13 Oct 2022 19:52:25 +0200 Message-Id: <20221013175148.108672139@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175147.337501757@linuxfoundation.org> References: <20221013175147.337501757@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596400708274926?= X-GMAIL-MSGID: =?utf-8?q?1746596400708274926?= |
Series |
None
|
|
Commit Message
Greg KH
Oct. 13, 2022, 5:52 p.m. UTC
From: Tadeusz Struk <tadeusz.struk@linaro.org> commit a659daf63d16aa883be42f3f34ff84235c302198 upstream. Syzbot found an issue in usbmon module, where the user space client can corrupt the monitor's internal memory, causing the usbmon module to crash the kernel with segfault, UAF, etc. The reproducer mmaps the /dev/usbmon memory to user space, and overwrites it with arbitrary data, which causes all kinds of issues. Return an -EPERM error from mon_bin_mmap() if the flag VM_WRTIE is set. Also clear VM_MAYWRITE to make it impossible to change it to writable later. Cc: "Dmitry Vyukov" <dvyukov@google.com> Cc: stable <stable@kernel.org> Fixes: 6f23ee1fefdc ("USB: add binary API to usbmon") Suggested-by: PaX Team <pageexec@freemail.hu> # for the VM_MAYRITE portion Link: https://syzkaller.appspot.com/bug?id=2eb1f35d6525fa4a74d75b4244971e5b1411c95a Reported-by: syzbot+23f57c5ae902429285d7@syzkaller.appspotmail.com Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org> Link: https://lore.kernel.org/r/20220919215957.205681-1-tadeusz.struk@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- drivers/usb/mon/mon_bin.c | 5 +++++ 1 file changed, 5 insertions(+)
--- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c @@ -1268,6 +1268,11 @@ static int mon_bin_mmap(struct file *fil { /* don't do anything here: "fault" will set up page table entries */ vma->vm_ops = &mon_bin_vm_ops; + + if (vma->vm_flags & VM_WRITE) + return -EPERM; + + vma->vm_flags &= ~VM_MAYWRITE; vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; vma->vm_private_data = filp->private_data; mon_bin_vma_open(vma);