From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B63FBC433FE for ; Mon, 3 Jan 2022 18:57:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235924AbiACS5p (ORCPT ); Mon, 3 Jan 2022 13:57:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230183AbiACS5o (ORCPT ); Mon, 3 Jan 2022 13:57:44 -0500 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67064C061761 for ; Mon, 3 Jan 2022 10:57:44 -0800 (PST) Received: by mail-lj1-x22d.google.com with SMTP id by39so57154379ljb.2 for ; Mon, 03 Jan 2022 10:57:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MMhWstZ09q6Cszqpd54WHd2qjsYduZF9Gp6qbEFoKEg=; b=CYPX06mYYQ2+cOhSoLGgV/rWQWqKCDXJJ9Iw+5ssEOfXIYPGzUj7v+4rgZWAs1vh9q 5dxy3dqwPKsdPh8M3wwJtoHaqrBWQUbMh0A78AgqwE65oMtsmJWN3KeAWc/54E/cAKAr Af4lQCwRkQcSkAYn+OL6rnmExbIWZFSFNvDj7/ZAPCsUj/Rz2SXUD2thJ9cfusFoDFQr QGbuXD9mOwVVPjgcFZxbjvS/9OAAV9ib3h9azZpUnhYbKgMGsSu28tLpirCWUJjnPYR+ xzbw3RM5EoVWXwBcFP6EaXw9vEwmSo8tRcQaG21dwkUF+pAPRLaunXbEMhCn4sM7w1Y6 xpLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MMhWstZ09q6Cszqpd54WHd2qjsYduZF9Gp6qbEFoKEg=; b=d5SFIUWxu+wfoWEi8lNRSaXn0zbN9myg3nxbaI9MJh0MnqxWFvUJZoS1+CMjHbVlez FqHskNOy+FLB5NiWVuBwGe/NB79NW/LIlYW0hE/o0apLch652MuFOlXTS0XJkcf9XHH6 FDa5dkQ932BehLaQPoVhfzQgX+EP1Jz0rnMTEJLDGGj+63iCTRpVQXUf8VEb2M3f7vFV Myg+cvs7mZT5rOT440AZlm8121xGkJw5QPPQvcB1j5qD2Nnvec+rpZtB7ra2PBgldkOP a9gkQ12hXF5zuKtx24S5wrC0WUEXuesve99287Hj713TSGQEg5e1cBOZ1OAtxdgnKRM/ fu0Q== X-Gm-Message-State: AOAM532RNrW1EW+rDYHG57rwh12FtllmSd+rNyYI0XqKcv28AlOLD0HA 0Cow8GBo5Qwlj3/hVfbVBh2bXmTM2HYAJ7IcZbIOvQ== X-Google-Smtp-Source: ABdhPJxESlTLF6vDjNiq9g3jYw19mn2gjb5KvscdlznFgTwwArdG339mJObBz8nFkUB+6pOx0s4aqg8oPJhp9SWaWGY= X-Received: by 2002:a2e:9b96:: with SMTP id z22mr37955720lji.427.1641236262660; Mon, 03 Jan 2022 10:57:42 -0800 (PST) MIME-Version: 1.0 References: <20211217094104.24977-1-guangming.cao@mediatek.com> <20211227095102.6054-1-guangming.cao@mediatek.com> In-Reply-To: <20211227095102.6054-1-guangming.cao@mediatek.com> From: John Stultz Date: Mon, 3 Jan 2022 10:57:30 -0800 Message-ID: Subject: Re: [PATCH v2] dma-buf: dma-heap: Add a size check for allocation To: guangming.cao@mediatek.com Cc: Sumit Semwal , Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , =?UTF-8?Q?Christian_K=C3=B6nig?= , Matthias Brugger , "open list:DMA-BUF HEAPS FRAMEWORK" , "open list:DMA-BUF HEAPS FRAMEWORK" , "moderated list:DMA-BUF HEAPS FRAMEWORK" , open list , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" , Bo Song , Libo Kang , jianjiao zeng , mingyuan ma , Yunfei Wang , wsd_upstream@mediatek.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 27, 2021 at 1:52 AM wrote: > > From: Guangming > Thanks for submitting this! > Add a size check for allcation since the allocation size is nit: "allocation" above. > always less than the total DRAM size. In general, it might be good to add more context to the commit message to better answer *why* this change is needed rather than what the change is doing. ie: What negative thing happens without this change? And so how does this change avoid or improve things? > Signed-off-by: Guangming > Signed-off-by: jianjiao zeng > --- > v2: 1. update size limitation as total_dram page size. > 2. update commit message > --- > drivers/dma-buf/dma-heap.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c > index 56bf5ad01ad5..e39d2be98d69 100644 > --- a/drivers/dma-buf/dma-heap.c > +++ b/drivers/dma-buf/dma-heap.c > @@ -55,6 +55,8 @@ static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, > struct dma_buf *dmabuf; > int fd; > > + if (len / PAGE_SIZE > totalram_pages()) > + return -EINVAL; This seems sane. I know ION used to have some 1/2 of memory cap to avoid unnecessary memory pressure on crazy allocations. Could you send again with an improved commit message? thanks -john From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E54F0C4332F for ; Mon, 3 Jan 2022 18:57:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 04BC410E12A; Mon, 3 Jan 2022 18:57:46 +0000 (UTC) Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by gabe.freedesktop.org (Postfix) with ESMTPS id 68A4910E124 for ; Mon, 3 Jan 2022 18:57:44 +0000 (UTC) Received: by mail-lj1-x232.google.com with SMTP id s4so39122832ljd.5 for ; Mon, 03 Jan 2022 10:57:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MMhWstZ09q6Cszqpd54WHd2qjsYduZF9Gp6qbEFoKEg=; b=CYPX06mYYQ2+cOhSoLGgV/rWQWqKCDXJJ9Iw+5ssEOfXIYPGzUj7v+4rgZWAs1vh9q 5dxy3dqwPKsdPh8M3wwJtoHaqrBWQUbMh0A78AgqwE65oMtsmJWN3KeAWc/54E/cAKAr Af4lQCwRkQcSkAYn+OL6rnmExbIWZFSFNvDj7/ZAPCsUj/Rz2SXUD2thJ9cfusFoDFQr QGbuXD9mOwVVPjgcFZxbjvS/9OAAV9ib3h9azZpUnhYbKgMGsSu28tLpirCWUJjnPYR+ xzbw3RM5EoVWXwBcFP6EaXw9vEwmSo8tRcQaG21dwkUF+pAPRLaunXbEMhCn4sM7w1Y6 xpLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MMhWstZ09q6Cszqpd54WHd2qjsYduZF9Gp6qbEFoKEg=; b=WoQZ3+X6DMnh3V92Jz5vc0zQsr3IXvuXH3o9Fx9GTcqlb2GCjaVasEPX8XWJQ5/2EX KmTBpfFqsudG00H1PHTUqwbOX3YHA1FCNUcsah4m0HjzrZ3cZQYPyMKgVtJAtROVSNU5 hHe/23VxhOMB7th/ewttrOtWJw4AcI2ut4WckE2+wsghJIz9UakGt1465iRwUoIvC8an WCy3OxveFl8RzwL7MOgP6VYEWbvYOTQUDHyCxZBktCYaImeIz/sqfX0WvRoifedQoZmZ 2IFZDFv+V5Z6GLq+AuwckPmpzEeXp9Yr9Bsh8lESwrXgFbBkGjLE6mNKr6yMqGnn7xOL pMow== X-Gm-Message-State: AOAM533di9NKej6xV3HTt1wCFmQiO2WXXw4fZH+wiyhnV8pbHFXVTfJy b19ATgYGd5iHRfQ5iKkAOUBt6PQm8/9cDik8swbbCQ== X-Google-Smtp-Source: ABdhPJxESlTLF6vDjNiq9g3jYw19mn2gjb5KvscdlznFgTwwArdG339mJObBz8nFkUB+6pOx0s4aqg8oPJhp9SWaWGY= X-Received: by 2002:a2e:9b96:: with SMTP id z22mr37955720lji.427.1641236262660; Mon, 03 Jan 2022 10:57:42 -0800 (PST) MIME-Version: 1.0 References: <20211217094104.24977-1-guangming.cao@mediatek.com> <20211227095102.6054-1-guangming.cao@mediatek.com> In-Reply-To: <20211227095102.6054-1-guangming.cao@mediatek.com> From: John Stultz Date: Mon, 3 Jan 2022 10:57:30 -0800 Message-ID: Subject: Re: [PATCH v2] dma-buf: dma-heap: Add a size check for allocation To: guangming.cao@mediatek.com Content-Type: text/plain; charset="UTF-8" X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wsd_upstream@mediatek.com, Libo Kang , open list , Liam Mark , "moderated list:DMA-BUF HEAPS FRAMEWORK" , jianjiao zeng , Yunfei Wang , "moderated list:ARM/Mediatek SoC support" , "open list:DMA-BUF HEAPS FRAMEWORK" , Benjamin Gaignard , Bo Song , Matthias Brugger , mingyuan ma , Laura Abbott , =?UTF-8?Q?Christian_K=C3=B6nig?= , "moderated list:ARM/Mediatek SoC support" , "open list:DMA-BUF HEAPS FRAMEWORK" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Mon, Dec 27, 2021 at 1:52 AM wrote: > > From: Guangming > Thanks for submitting this! > Add a size check for allcation since the allocation size is nit: "allocation" above. > always less than the total DRAM size. In general, it might be good to add more context to the commit message to better answer *why* this change is needed rather than what the change is doing. ie: What negative thing happens without this change? And so how does this change avoid or improve things? > Signed-off-by: Guangming > Signed-off-by: jianjiao zeng > --- > v2: 1. update size limitation as total_dram page size. > 2. update commit message > --- > drivers/dma-buf/dma-heap.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c > index 56bf5ad01ad5..e39d2be98d69 100644 > --- a/drivers/dma-buf/dma-heap.c > +++ b/drivers/dma-buf/dma-heap.c > @@ -55,6 +55,8 @@ static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, > struct dma_buf *dmabuf; > int fd; > > + if (len / PAGE_SIZE > totalram_pages()) > + return -EINVAL; This seems sane. I know ION used to have some 1/2 of memory cap to avoid unnecessary memory pressure on crazy allocations. Could you send again with an improved commit message? thanks -john From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2B83C433F5 for ; Mon, 3 Jan 2022 18:58:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZKgP/jd+HDhVZPkLRw4tBf1gjdveYiXvY8yTD+WL/PU=; b=phOs+YBX67POtm sqSs7DAT3CDl4buuMCtB60XpmrOoqiCC4if7Rx1ZbL3lM0NoZJjE4hEL5oGSAi6/wPzEtRdyXtJ5i lN5yMQyyUj8xR0d5bbVy8ABv6VQ6fFgybiXwXvF24S4WOrB2s+SsvKKnhjFersMD06FNLLW2FXanI XZxKXb6FjMD4MgyGINKUQ7/isi44G+jaDyW1csp7QR4ErMuf09ByzoJjeMQ6nisk1ACN5UbPYdTIa 4ElrKRkCurpIKJI0ICU5bcmbe2XqqLGMN4q6mrT6SqGYM6ZNMb8LFrpBwWMCGTA2UZzP9SUdUUoYv 5SFix7emo6hnuqZHF46g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4SWr-009sTq-97; Mon, 03 Jan 2022 18:57:57 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4SWf-009sRH-I5 for linux-mediatek@lists.infradead.org; Mon, 03 Jan 2022 18:57:47 +0000 Received: by mail-lj1-x233.google.com with SMTP id u22so57072132lju.7 for ; Mon, 03 Jan 2022 10:57:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MMhWstZ09q6Cszqpd54WHd2qjsYduZF9Gp6qbEFoKEg=; b=CYPX06mYYQ2+cOhSoLGgV/rWQWqKCDXJJ9Iw+5ssEOfXIYPGzUj7v+4rgZWAs1vh9q 5dxy3dqwPKsdPh8M3wwJtoHaqrBWQUbMh0A78AgqwE65oMtsmJWN3KeAWc/54E/cAKAr Af4lQCwRkQcSkAYn+OL6rnmExbIWZFSFNvDj7/ZAPCsUj/Rz2SXUD2thJ9cfusFoDFQr QGbuXD9mOwVVPjgcFZxbjvS/9OAAV9ib3h9azZpUnhYbKgMGsSu28tLpirCWUJjnPYR+ xzbw3RM5EoVWXwBcFP6EaXw9vEwmSo8tRcQaG21dwkUF+pAPRLaunXbEMhCn4sM7w1Y6 xpLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MMhWstZ09q6Cszqpd54WHd2qjsYduZF9Gp6qbEFoKEg=; b=R289Bnr8bPxvRGbfj79HTtH5Z2C6tx0lJUoBdxPOJp8Gdjen5/M8xMz3XHr3EdhM3U Adcmpz6530wGuQT8x+KCPs6YeZjjcP1f/KboJIuWoNSDKmdyAwNP98DUH+pYLPNhz2uH R/OIYLLstGpYYsVXkHPFuXI1+SZkIOZ0K9Znb+36zeN/ALoXOJb81cxbDvrUGP0KXSGk piNZARaLRAGeIdVoIpVMwOeAGgKVMw8/6GbyfFhYgKXH2rTXOK+MdjlEEjWQiMDjNU1V SUjDg2mX4AakNc6aFu0gsbqgAuOXnEbhbXxB2yT+PfjCHwUUryW3I+jgOruUdzB0cFbN 8ieQ== X-Gm-Message-State: AOAM533BbEVCYejTxNrFZicDOM907a4RVdSvVQzmyP/NS97xgsZmhdcZ Tr9PpWX2UefmTBdfL5sWZ3nZP41xC1Ed3zqOgoVOPA== X-Google-Smtp-Source: ABdhPJxESlTLF6vDjNiq9g3jYw19mn2gjb5KvscdlznFgTwwArdG339mJObBz8nFkUB+6pOx0s4aqg8oPJhp9SWaWGY= X-Received: by 2002:a2e:9b96:: with SMTP id z22mr37955720lji.427.1641236262660; Mon, 03 Jan 2022 10:57:42 -0800 (PST) MIME-Version: 1.0 References: <20211217094104.24977-1-guangming.cao@mediatek.com> <20211227095102.6054-1-guangming.cao@mediatek.com> In-Reply-To: <20211227095102.6054-1-guangming.cao@mediatek.com> From: John Stultz Date: Mon, 3 Jan 2022 10:57:30 -0800 Message-ID: Subject: Re: [PATCH v2] dma-buf: dma-heap: Add a size check for allocation To: guangming.cao@mediatek.com Cc: Sumit Semwal , Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , =?UTF-8?Q?Christian_K=C3=B6nig?= , Matthias Brugger , "open list:DMA-BUF HEAPS FRAMEWORK" , "open list:DMA-BUF HEAPS FRAMEWORK" , "moderated list:DMA-BUF HEAPS FRAMEWORK" , open list , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" , Bo Song , Libo Kang , jianjiao zeng , mingyuan ma , Yunfei Wang , wsd_upstream@mediatek.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220103_105745_607975_1485D4B8 X-CRM114-Status: GOOD ( 17.05 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org On Mon, Dec 27, 2021 at 1:52 AM wrote: > > From: Guangming > Thanks for submitting this! > Add a size check for allcation since the allocation size is nit: "allocation" above. > always less than the total DRAM size. In general, it might be good to add more context to the commit message to better answer *why* this change is needed rather than what the change is doing. ie: What negative thing happens without this change? And so how does this change avoid or improve things? > Signed-off-by: Guangming > Signed-off-by: jianjiao zeng > --- > v2: 1. update size limitation as total_dram page size. > 2. update commit message > --- > drivers/dma-buf/dma-heap.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c > index 56bf5ad01ad5..e39d2be98d69 100644 > --- a/drivers/dma-buf/dma-heap.c > +++ b/drivers/dma-buf/dma-heap.c > @@ -55,6 +55,8 @@ static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, > struct dma_buf *dmabuf; > int fd; > > + if (len / PAGE_SIZE > totalram_pages()) > + return -EINVAL; This seems sane. I know ION used to have some 1/2 of memory cap to avoid unnecessary memory pressure on crazy allocations. Could you send again with an improved commit message? thanks -john _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4006BC433F5 for ; Mon, 3 Jan 2022 18:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/Pt6alU/6qFtMDiXByF54lEbZFroJ+Kg4ZX3xUhk4pQ=; b=1IeSM821raaZXh FIWBGfahaSMWWRkSioEjnJqlNgGVMKvKYuEEbujy/M/pxWE5W/4JXVHYLSoi4/oMYDQgM2GnCUyZQ sKQ6EhqyUP1MWS3/78wVbQg1trnYtGISssMiTpO+bLyGM7sr7X6i0JTrm5pRQrQNs63rE5QzhOmqQ KMPE8cnzpyW4nL1VEgIxzGx9YT0Fd5lwmK6Xhf3J8ErA1iAcYXOB6gy1UlRg9JAmlWFpksvOVv7iD MXuk+LuFrBOxWfG0Y7wuF72p22pOoAn3cHzUs19y/xd5xYZIhsvnqTAUve4Z3xlK0ZuBqSGfpWBdX TrHWM72Z/bb33xib4IAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4SWi-009sT8-Ub; Mon, 03 Jan 2022 18:57:49 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n4SWf-009sRI-EI for linux-arm-kernel@lists.infradead.org; Mon, 03 Jan 2022 18:57:46 +0000 Received: by mail-lj1-x229.google.com with SMTP id h15so43716025ljh.12 for ; Mon, 03 Jan 2022 10:57:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MMhWstZ09q6Cszqpd54WHd2qjsYduZF9Gp6qbEFoKEg=; b=CYPX06mYYQ2+cOhSoLGgV/rWQWqKCDXJJ9Iw+5ssEOfXIYPGzUj7v+4rgZWAs1vh9q 5dxy3dqwPKsdPh8M3wwJtoHaqrBWQUbMh0A78AgqwE65oMtsmJWN3KeAWc/54E/cAKAr Af4lQCwRkQcSkAYn+OL6rnmExbIWZFSFNvDj7/ZAPCsUj/Rz2SXUD2thJ9cfusFoDFQr QGbuXD9mOwVVPjgcFZxbjvS/9OAAV9ib3h9azZpUnhYbKgMGsSu28tLpirCWUJjnPYR+ xzbw3RM5EoVWXwBcFP6EaXw9vEwmSo8tRcQaG21dwkUF+pAPRLaunXbEMhCn4sM7w1Y6 xpLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MMhWstZ09q6Cszqpd54WHd2qjsYduZF9Gp6qbEFoKEg=; b=2X3au+R7z3lPkimJVBje0SDsSY+jym5g0VIj4yiDnS+U8D6J6PVHkTm2/FN6k3glcs Xk6/I6pREh4FF+RLB267N6+N8nwxLqpbQXmeFXvSFCJHpZnubTQSVBhRVrTiCfKdAE6m sKuyBDcgLPDZOkrI4XtPbRMrkqD4KvtO3RsIePLm49mXwzKBa+DmQ7m+O+dt68GT0QvN T7NtuPecL2AymGW4JPJ2PBxFgaOFJHx1RMO7k/F787N7PixnKBY82MvB5SwyotGMtw2L d13VgDledZQ22519h1aX0RCWWCs8nm80Ih1PO1zlHCf0hr7mCAMSQDr58aeFxznrCvtv l7ZQ== X-Gm-Message-State: AOAM530Vx5GihwJToVJ1waUEfyLC/hH89x2kugrbEFKhc1dtgTnPsPuI 0W7/s8F9Xgebi683yyZN0/55/1g6+MgKj6r7kjUxSg== X-Google-Smtp-Source: ABdhPJxESlTLF6vDjNiq9g3jYw19mn2gjb5KvscdlznFgTwwArdG339mJObBz8nFkUB+6pOx0s4aqg8oPJhp9SWaWGY= X-Received: by 2002:a2e:9b96:: with SMTP id z22mr37955720lji.427.1641236262660; Mon, 03 Jan 2022 10:57:42 -0800 (PST) MIME-Version: 1.0 References: <20211217094104.24977-1-guangming.cao@mediatek.com> <20211227095102.6054-1-guangming.cao@mediatek.com> In-Reply-To: <20211227095102.6054-1-guangming.cao@mediatek.com> From: John Stultz Date: Mon, 3 Jan 2022 10:57:30 -0800 Message-ID: Subject: Re: [PATCH v2] dma-buf: dma-heap: Add a size check for allocation To: guangming.cao@mediatek.com Cc: Sumit Semwal , Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , =?UTF-8?Q?Christian_K=C3=B6nig?= , Matthias Brugger , "open list:DMA-BUF HEAPS FRAMEWORK" , "open list:DMA-BUF HEAPS FRAMEWORK" , "moderated list:DMA-BUF HEAPS FRAMEWORK" , open list , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" , Bo Song , Libo Kang , jianjiao zeng , mingyuan ma , Yunfei Wang , wsd_upstream@mediatek.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220103_105745_502038_23710DD3 X-CRM114-Status: GOOD ( 18.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Dec 27, 2021 at 1:52 AM wrote: > > From: Guangming > Thanks for submitting this! > Add a size check for allcation since the allocation size is nit: "allocation" above. > always less than the total DRAM size. In general, it might be good to add more context to the commit message to better answer *why* this change is needed rather than what the change is doing. ie: What negative thing happens without this change? And so how does this change avoid or improve things? > Signed-off-by: Guangming > Signed-off-by: jianjiao zeng > --- > v2: 1. update size limitation as total_dram page size. > 2. update commit message > --- > drivers/dma-buf/dma-heap.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c > index 56bf5ad01ad5..e39d2be98d69 100644 > --- a/drivers/dma-buf/dma-heap.c > +++ b/drivers/dma-buf/dma-heap.c > @@ -55,6 +55,8 @@ static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, > struct dma_buf *dmabuf; > int fd; > > + if (len / PAGE_SIZE > totalram_pages()) > + return -EINVAL; This seems sane. I know ION used to have some 1/2 of memory cap to avoid unnecessary memory pressure on crazy allocations. Could you send again with an improved commit message? thanks -john _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel