Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1736034rwd; Fri, 9 Jun 2023 01:05:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ68uSPKkJlLiouumR3t1BMAWftd41eU0vx36A2i5IuhFmaGKzUYATF2bvKGRXskNNQlMrSe X-Received: by 2002:a05:6a00:2484:b0:63d:4752:4da3 with SMTP id c4-20020a056a00248400b0063d47524da3mr444092pfv.25.1686297957522; Fri, 09 Jun 2023 01:05:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686297957; cv=none; d=google.com; s=arc-20160816; b=jPkMrtLnnpQUmvMYcsCBCa5kDU5y6xn4uXiNY//5L5sbXhJ6xmUCON9SmETVlILRm0 RsiJBHqruOv7j6cKNz8+7lHrAF7+KHvrxmGGi/WaC00io7dMHGQ8NcANLDraDPy/cgmc WR87EW+35Z7MsRWaxN4C4OwaP/kij0fZJLpjBNQhv/5v8LhRpTDMQisH+DluIdZe2mXV cZgbxs4LLRnCI1YbXgo7goKcLabaW9WBdUN+6T5UZtVTxtbcz6rjqD2jQFwpngoQcR4h iciHKXSIDZPy14zl8r351mzmJqNtgoJpJ1WKqQdmn+/B4S4R36NMgCe9sLX+bOVb4d73 p3/Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0wYOGjo01By5N6ypk4T/kszJYngB2yHKY4BDovVrGlY=; b=efM9ywZ7a+4WnUE1/VT350mpzZhQa6aN9VctL4lBNC3EnaIbsxA5ccdbdkGNy4O0fU 7Vr+olBGLZg4Fwj3NI31VPgoNokzFFPyg6ST40yEEk9iWYX5w/WkxhdBcopXGxOCtuXK EHmrXhxIVFegg7lUNBs5bdmv80DFGA0y7OQHlg8yHcmDIenWn+8Q0HN9qm0Zxj+HEBV2 ocAOhLVigFUCiK83vjXW7dYSS5ER1DI2dfL6fUq1vtzOxLt9bX7jyQebnEKacT6ATW4i OLn3x0CbjMR34+jP/9HksouJlh0Rbbp0Nlpy4aq97gwWbszVHCxzvbqDlXtsqhIX7ItU y4Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=O7G+H0Sb; 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 e17-20020aa798d1000000b0065caa80ad8csi2071590pfm.398.2023.06.09.01.05.43; Fri, 09 Jun 2023 01:05:57 -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=O7G+H0Sb; 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 S239473AbjFIH6a (ORCPT + 99 others); Fri, 9 Jun 2023 03:58:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239372AbjFIH5x (ORCPT ); Fri, 9 Jun 2023 03:57:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A13F6423C for ; Fri, 9 Jun 2023 00:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686297384; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0wYOGjo01By5N6ypk4T/kszJYngB2yHKY4BDovVrGlY=; b=O7G+H0SbD04zNIRChWZD/Ck4riOoFzaosmzUb5px7vcfZPxULGkmUIGX/QD2vt1kCOSkjr nBLsCx9AtPj7s5kk4EvGXVG6GRlnI2NKdRFvUyxfapPq3EXodAT8bmzphJZ6/EWWDRCtK8 tTvn9YHiIVshpx6p7ZNtkfgmDCeTZrc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-468-G5FEyEG6MS-Y-nyIC9k_aA-1; Fri, 09 Jun 2023 03:56:20 -0400 X-MC-Unique: G5FEyEG6MS-Y-nyIC9k_aA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D69A4811E7C; Fri, 9 Jun 2023 07:56:19 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47A0A20268C6; Fri, 9 Jun 2023 07:56:13 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, arnd@arndb.de, christophe.leroy@csgroup.eu, hch@lst.de, rppt@kernel.org, willy@infradead.org, agordeev@linux.ibm.com, wangkefeng.wang@huawei.com, schnelle@linux.ibm.com, David.Laight@ACULAB.COM, shorne@gmail.com, deller@gmx.de, Baoquan He Subject: [PATCH v6 06/19] mm/ioremap: add slab availability checking in ioremap_prot Date: Fri, 9 Jun 2023 15:55:15 +0800 Message-Id: <20230609075528.9390-7-bhe@redhat.com> In-Reply-To: <20230609075528.9390-1-bhe@redhat.com> References: <20230609075528.9390-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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_H5,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 Several architectures has done checking if slab if available in ioremap_prot(). In fact it should be done in generic ioremap_prot() since on any architecutre, slab allocator must be available before get_vm_area_caller() and vunmap() are used. Add the checking into generic_ioremap_prot(). Suggested-by: Christophe Leroy Signed-off-by: Baoquan He Reviewed-by: Christoph Hellwig Reviewed-by: Kefeng Wang Reviewed-by: Mike Rapoport (IBM) --- v5-v6: Add WARN_ON_ONCE to aid debugging - Christoph. mm/ioremap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/ioremap.c b/mm/ioremap.c index 9f34a8f90b58..86b82ec27d2b 100644 --- a/mm/ioremap.c +++ b/mm/ioremap.c @@ -18,6 +18,10 @@ void __iomem *generic_ioremap_prot(phys_addr_t phys_addr, size_t size, phys_addr_t last_addr; struct vm_struct *area; + /* An early platform driver might end up here */ + if (WARN_ON_ONCE(!slab_is_available())) + return NULL; + /* Disallow wrap-around or zero size */ last_addr = phys_addr + size - 1; if (!size || last_addr < phys_addr) -- 2.34.1