From mboxrd@z Thu Jan 1 00:00:00 1970 From: William Kucharski Date: Thu, 01 Nov 2018 08:28:55 +0000 Subject: Re: [PATCH] mm/gup_benchmark: prevent integer overflow in ioctl Message-Id: List-Id: References: <20181025061546.hnhkv33diogf2uis@kili.mountain> <20181101071613.7x3smxwz5wo57n2m@mwanda> In-Reply-To: <20181101071613.7x3smxwz5wo57n2m@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Dan Carpenter Cc: Andrew Morton , "Kirill A. Shutemov" , Stephen Rothwell , Keith Busch , "Michael S. Tsirkin" , Kees Cook , YueHaibing , linux-mm@kvack.org, kernel-janitors@vger.kernel.org > On Nov 1, 2018, at 1:16 AM, Dan Carpenter wrote: > > My patch lets people allocate 4MB. (U32_MAX / 4096 * sizeof(void *)). > Surely, that's enough? I liked my check because it avoids the divide so > it's faster and it is a no-op on 64bit systems. It should be enough, and you're right, it does avoid extra math. However, in that case I'd like to see a comment added so that anyone looking at the code in the future knows why you limited the allocation to ULONG_MAX bytes. Thanks, William Kucharski From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-f69.google.com (mail-yw1-f69.google.com [209.85.161.69]) by kanga.kvack.org (Postfix) with ESMTP id 4CD746B0005 for ; Thu, 1 Nov 2018 04:29:18 -0400 (EDT) Received: by mail-yw1-f69.google.com with SMTP id i64-v6so13456091ywa.22 for ; Thu, 01 Nov 2018 01:29:18 -0700 (PDT) Received: from aserp2120.oracle.com (aserp2120.oracle.com. [141.146.126.78]) by mx.google.com with ESMTPS id l123-v6si18103405ywg.238.2018.11.01.01.29.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Nov 2018 01:29:16 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.1 \(3445.101.1\)) Subject: Re: [PATCH] mm/gup_benchmark: prevent integer overflow in ioctl From: William Kucharski In-Reply-To: <20181101071613.7x3smxwz5wo57n2m@mwanda> Date: Thu, 1 Nov 2018 02:28:55 -0600 Content-Transfer-Encoding: 7bit Message-Id: References: <20181025061546.hnhkv33diogf2uis@kili.mountain> <20181101071613.7x3smxwz5wo57n2m@mwanda> Sender: owner-linux-mm@kvack.org List-ID: To: Dan Carpenter Cc: Andrew Morton , "Kirill A. Shutemov" , Stephen Rothwell , Keith Busch , "Michael S. Tsirkin" , Kees Cook , YueHaibing , linux-mm@kvack.org, kernel-janitors@vger.kernel.org > On Nov 1, 2018, at 1:16 AM, Dan Carpenter wrote: > > My patch lets people allocate 4MB. (U32_MAX / 4096 * sizeof(void *)). > Surely, that's enough? I liked my check because it avoids the divide so > it's faster and it is a no-op on 64bit systems. It should be enough, and you're right, it does avoid extra math. However, in that case I'd like to see a comment added so that anyone looking at the code in the future knows why you limited the allocation to ULONG_MAX bytes. Thanks, William Kucharski