Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp887115rwb; Fri, 28 Jul 2023 01:02:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlEzoPg0a8YyQ7QBIHxPVVfoggWM3iW+ye80NbnUz2wVWpIYQMbJqaaFAx2We6TagU4j2DZ5 X-Received: by 2002:a17:903:24f:b0:1bb:94ed:20a with SMTP id j15-20020a170903024f00b001bb94ed020amr913242plh.24.1690531351564; Fri, 28 Jul 2023 01:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690531351; cv=none; d=google.com; s=arc-20160816; b=cIeA2PvcFI9V/xj7oFXTzu4ET3bhTTnqkUaEjL4jnCAYYSMiiGzzWfnWQ75IVV3vO+ pDeMpS0n1vzfORTU3prWsyQNyYnxGLTJWE94ReufUC3ygNGioYRpLTRCSa5imlyV7lqU aH3w3NRjdHG104K7RKRPGpesS7FQsZ6B1xJSkKhNUHYlmf2W8amlMsD1Vg0caJSNLXLN pUGIeBQsadK5XH4vRN7B0ivFGJrh1NGofPFDL3nfPu92SjYRYuKn4aMz56iaLP8cx6R/ NDBD2hTb8ybyhyRmoPfAAXIVW2MRqMbfGXliGbNdyafdJV0U+T+fos2u/h5qOlQ9vx41 fE6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=BD044lTlj7rwbRv6ZfiORHHK6QURk2L1R485ZfvK5Io=; fh=dAv1Ib71aGpKrsjFCnb/v7cCBPWI3V3Mal2wSsxq0c0=; b=EzTcXZKzvbNmmvNvqEocwAZY9AleApDX6e0DDvclw99UWLKyUg24xrlqDm7ze/qcQl AARkMLxXkNids+70+ijIeW35ESUS2U8HVg1sferVa9HYx6WEMElT4kWPMyPiw0pjBx4e EbcZsraDwHzVcR53vg0OwXvPsAYONHpyEY+4tXzG/uClZA1Hc8XMjrjpvvz7lLf32XA5 8mv+HLd7/5eFfjxUGVvOfV5btfWCNbxg1H/SCnGBy+BEoebxHzFPR/lMPT0Pheyrj5yP aAFFOcF0J+2MUKN5KtKpitIRreg79H5na3NtoIhFCAzYadYNR7l36aQRCMByYd6/aOhM 5f0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Xb1+pkES; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kl5-20020a170903074500b001b895a2c09esi2556181plb.381.2023.07.28.01.02.19; Fri, 28 Jul 2023 01:02:31 -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=@redhat.com header.s=mimecast20190719 header.b=Xb1+pkES; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233450AbjG1G7M (ORCPT + 99 others); Fri, 28 Jul 2023 02:59:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232339AbjG1G7J (ORCPT ); Fri, 28 Jul 2023 02:59:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 170431984 for ; Thu, 27 Jul 2023 23:58:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690527504; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=BD044lTlj7rwbRv6ZfiORHHK6QURk2L1R485ZfvK5Io=; b=Xb1+pkESj/YeUaRfT/ZWurTSgAIHUKVTv5TLG5MW1MPPF/Klbm5rW3NNnYhs3e+JbfoCKk 1Oc71URxYBwMI9bvA0YGuZ+qh+IzvFfqg5DFnU9+81vb1qwaiMOiVziKZocHa+2zPNYJFg aWeI+AMwK17WIlSvlzbM81ppCbp9JPE= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-211-wzRbNYeNOHWfKbi6qkDEMA-1; Fri, 28 Jul 2023 02:58:20 -0400 X-MC-Unique: wzRbNYeNOHWfKbi6qkDEMA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27F963C025CE; Fri, 28 Jul 2023 06:58:20 +0000 (UTC) Received: from localhost (unknown [10.45.224.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCDACF7830; Fri, 28 Jul 2023 06:58:19 +0000 (UTC) From: Oleksandr Natalenko To: linux-kernel@vger.kernel.org Cc: linux-scsi@vger.kernel.org, Saurav Kashyap , Johannes Thumshirn , GR-QLogic-Storage-Upstream@marvell.com, "James E.J. Bottomley" , "Martin K. Petersen" , Jozef Bacik , Laurence Oberman , Rob Evers Subject: [PATCH 0/3] scsi: qedf: sanitise uaccess Date: Fri, 28 Jul 2023 08:58:16 +0200 Message-ID: <20230728065819.139694-1-oleksandr@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 qedf driver, debugfs part of it specifically, touches __user pointers directly for printing out info to userspace via sprintf(), which may cause crash like this: BUG: unable to handle kernel paging request at 00007ffd1d6b43a0 IP: [] string.isra.7+0x6a/0xf0 Oops: 0003 [#1] SMP Call Trace: [] vsnprintf+0x201/0x6a0 [] sprintf+0x56/0x80 [] qedf_dbg_stop_io_on_error_cmd_read+0x6d/0x90 [qedf] [] vfs_read+0x9f/0x170 [] SyS_pread64+0x92/0xc0 Avoid this by preparing the info in a kernel buffer first, either allocated on stack for small printouts, or via vmalloc() for big ones, and then copying it to the userspace properly. Previous submission is an RFC: [1]. There are no code changes since then. The RFC prefix is dropped. The Tested-by tag from Laurence is added. There's similar submission from Saurav [2], but we agreed I could nack it and proceed with my one. [1] https://lore.kernel.org/linux-scsi/20230724120241.40495-1-oleksandr@redhat.com/ [2] https://lore.kernel.org/linux-scsi/20230726101236.11922-1-skashyap@marvell.com/ Oleksandr Natalenko (3): scsi: qedf: do not touch __user pointer in qedf_dbg_stop_io_on_error_cmd_read() directly scsi: qedf: do not touch __user pointer in qedf_dbg_debug_cmd_read() directly scsi: qedf: do not touch __user pointer in qedf_dbg_fp_int_cmd_read() directly drivers/scsi/qedf/qedf_dbg.h | 2 ++ drivers/scsi/qedf/qedf_debugfs.c | 35 +++++++++++++++++++------------- 2 files changed, 23 insertions(+), 14 deletions(-) -- 2.41.0