Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2750951pxb; Thu, 10 Feb 2022 04:56:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFvAbp8HJQXSiefBoNTnm9PqWOHb78TXf1gdD5y0xJQa02+7fs3w2m5WD1dOn1dlKC66HD X-Received: by 2002:a63:6aca:: with SMTP id f193mr6056045pgc.85.1644497803436; Thu, 10 Feb 2022 04:56:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644497803; cv=none; d=google.com; s=arc-20160816; b=xddTD740XmsDLcaShexDKP/lYWGMQNjJpQr6RZsI3YjpoofVEGs0RtHQGlw5wVT2QQ DtTv6aWdWa+41JCQCCI0Yduzbf3bM7EesQc5c4nvLhyrFLvepyXT8fTfnRuc7qfA2yJt 1Lj2QcykAjHhWE78Bu++N4un7vw9aHtOJIGfb8MDc8QaTwIjSlDRwr+/0Yw2sBE0HTxZ KKeVO+/d+zCYnwWKC+CouMbeb/tv/9HGMSmp3sPP0iTntHqIbbiVjizW/ABhz6kw3Y7A QcvZfBD8UfZ1fNWrjlS74XXC/aLHF4wQsBvmHvSClS6nDU5vp09me97KYTTKXJsPE67s Iv3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=+zd9auT3HssB3vmnXTaFoDUwPtc9+1KGpXTepwnTS58=; b=yMVEveqECNqlJhtsU4qrYlEWHDl+0zdTJG9vBJSINcbgqMRXY7x1GXSeGiGLDcPvWl FLlZmLnD8ni3LJZcSib+mA6k1vbBf+4j10Xo8Go4+b/WHMhQeuOjal9EOpxSA1jRbfBR esmFBaahRkm8N+ScwxbcDQuSmVVyJ4P8pKDRCExwASOlsGbcLng3wGCKk5BXAPVbUn41 XZLM7n3Kh6VB8oLsdW9SDDytGrhu7XWfGJrzKeaWQkYMrTmbxci1KWj8wVrX7RWHg7mV Nbw4IshFByM2+zh/1Ys0HEtEjuiDFYN+spBaxwdYMZ6OFJ+02da7czJ41HDms+GBFm5t qU9A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9si2249380plz.460.2022.02.10.04.56.28; Thu, 10 Feb 2022 04:56:43 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238627AbiBJJgo convert rfc822-to-8bit (ORCPT + 99 others); Thu, 10 Feb 2022 04:36:44 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:56650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234258AbiBJJgn (ORCPT ); Thu, 10 Feb 2022 04:36:43 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1B5AEC64 for ; Thu, 10 Feb 2022 01:36:44 -0800 (PST) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-78-7VZKaTpWPSS90nYkjpkWNg-1; Thu, 10 Feb 2022 09:36:42 +0000 X-MC-Unique: 7VZKaTpWPSS90nYkjpkWNg-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.28; Thu, 10 Feb 2022 09:36:41 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.028; Thu, 10 Feb 2022 09:36:41 +0000 From: David Laight To: 'Arnd Bergmann' , Michal Simek CC: Christoph Hellwig , Arnd Bergmann , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] microblaze: remove CONFIG_SET_FS Thread-Topic: [PATCH] microblaze: remove CONFIG_SET_FS Thread-Index: AQHYHcQ6EgAhsRrDe0u1y8RgHhFzdayMhlsA Date: Thu, 10 Feb 2022 09:36:41 +0000 Message-ID: <80c6df0717014472aa81093ae3894d39@AcuMS.aculab.com> References: <20220209144910.1484686-1-arnd@kernel.org> In-Reply-To: <20220209144910.1484686-1-arnd@kernel.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, 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 From: Arnd > Sent: 09 February 2022 14:49 > > Remove the address space override API set_fs(). The microblaze user > address space is now limited to TASK_SIZE. > > To support this we implement and wire in __get_kernel_nofault and > __set_kernel_nofault. > > The function user_addr_max is removed as there is a default definition > provided when CONFIG_SET_FS is not used. ... > static inline int access_ok(const void __user *addr, unsigned long size) > { > if (!size) > goto ok; > > - if ((get_fs().seg < ((unsigned long)addr)) || > - (get_fs().seg < ((unsigned long)addr + size - 1))) { > - pr_devel("ACCESS fail at 0x%08x (size 0x%x), seg 0x%08x\n", > - (__force u32)addr, (u32)size, > - (u32)get_fs().seg); > + if ((((unsigned long)addr) > TASK_SIZE) || > + (((unsigned long)addr + size - 1) > TASK_SIZE)) { > + pr_devel("ACCESS fail at 0x%08x (size 0x%x)", > + (__force u32)addr, (u32)size); > return 0; Isn't that the wrong check? If 'size' is big 'addr + size' can wrap. It needs to be (addr >= TASK_SIZE || size > TASK_SIZE - addr) Which is pretty much a generic version. Although typical 64bit architectures can use the faster: ((addr | size) >> 62) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)