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 X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71179C31E4C for ; Fri, 14 Jun 2019 07:27:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 53ED1206BB for ; Fri, 14 Jun 2019 07:27:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726207AbfFNH1W (ORCPT ); Fri, 14 Jun 2019 03:27:22 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:36783 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbfFNH1W (ORCPT ); Fri, 14 Jun 2019 03:27:22 -0400 Received: by mail-lf1-f67.google.com with SMTP id q26so1013506lfc.3; Fri, 14 Jun 2019 00:27:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pdzPCh9Iq6DsZwmNtrM2YKJ68uEFiOmJCFPMQ9QBxhg=; b=IgBS2hKbaMLWy3bidnBSuTTGRDrXEvUkf+CHJKiR3ZDo+aohC6GjUQflWKObfWaBcw M8n3SUHSOrcoOnwHh9iXp7eZYZArhvdAgQsanPK7TpPgWe8keVpBxAeTyiXCdBHs/Tu/ v+2qWqhoT4NWEmFcBlV4qhKheqzefhDbi3KXI+cWCgvxp302SFKZYlpC/h3WG5oKt82Y ktOB2pZV4iB1KpCqoU+F3dVutr2ulLWCvL1rD8auvgbGkwAVKuMCY9mmOTGA2Cwa/Ry5 IUWYdcrTmCPCWmyXv3vJl8ZIfCk+T0pnYqrg23c/pOSPQ8XAWmijY/nGQSvSjapOK49h MySw== X-Gm-Message-State: APjAAAXT19WQ0+xz3dzOxOa8imdlVQO53iTdpp700pyJ5k9pk5sGrHAG GM3GrcaeuaB28M/w8rKC8YZw26dqd49Iu3ko4u8= X-Google-Smtp-Source: APXvYqyZPsGGwkPkWixMhMUECj/EG4qRfXowB8lnrcuhtq1khDIasqYBoWJAfAgpDFug4QWIzzNZRN21TX7Vx1y1Gng= X-Received: by 2002:ac2:597c:: with SMTP id h28mr8197569lfp.90.1560497239682; Fri, 14 Jun 2019 00:27:19 -0700 (PDT) MIME-Version: 1.0 References: <1560421215-10750-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> <1560421215-10750-5-git-send-email-yoshihiro.shimoda.uh@renesas.com> <20190614071800.GB8420@lst.de> In-Reply-To: <20190614071800.GB8420@lst.de> From: Geert Uytterhoeven Date: Fri, 14 Jun 2019 09:27:06 +0200 Message-ID: Subject: Re: [RFC PATCH v6 4/5] mmc: tmio: Use dma_max_mapping_size() instead of a workaround To: Christoph Hellwig Cc: Yoshihiro Shimoda , Joerg Roedel , Jens Axboe , Ulf Hansson , Wolfram Sang , Linux IOMMU , linux-block@vger.kernel.org, Linux MMC List , Linux-Renesas Content-Type: text/plain; charset="UTF-8" Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Hi Christoph, On Fri, Jun 14, 2019 at 9:18 AM Christoph Hellwig wrote: > On Thu, Jun 13, 2019 at 10:35:44PM +0200, Geert Uytterhoeven wrote: > > I'm always triggered by the use of min_t() and other casts: > > mmc->max_blk_size and mmc->max_blk_count are both unsigned int. > > dma_max_mapping_size() returns size_t, which can be 64-bit. > > > > 1) Can the multiplication overflow? > > Probably not, as per commit 2a55c1eac7882232 ("mmc: renesas_sdhi: > > prevent overflow for max_req_size"), but I thought I'd better ask. > > 2) In theory, dma_max_mapping_size() can return a number that doesn't > > fit in 32-bit, and will be truncated (to e.g. 0), leading to max_req_size > > is zero? > > This really should use a min_t on size_t. Otherwise the patch looks > fine: Followed by another min() to make it fit in mmc->max_req_size, which is unsigned int. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds From mboxrd@z Thu Jan 1 00:00:00 1970 From: Geert Uytterhoeven Subject: Re: [RFC PATCH v6 4/5] mmc: tmio: Use dma_max_mapping_size() instead of a workaround Date: Fri, 14 Jun 2019 09:27:06 +0200 Message-ID: References: <1560421215-10750-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> <1560421215-10750-5-git-send-email-yoshihiro.shimoda.uh@renesas.com> <20190614071800.GB8420@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20190614071800.GB8420-jcswGhMUV9g@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Christoph Hellwig Cc: Jens Axboe , Linux-Renesas , Ulf Hansson , Linux MMC List , linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Wolfram Sang , Linux IOMMU List-Id: linux-mmc@vger.kernel.org Hi Christoph, On Fri, Jun 14, 2019 at 9:18 AM Christoph Hellwig wrote: > On Thu, Jun 13, 2019 at 10:35:44PM +0200, Geert Uytterhoeven wrote: > > I'm always triggered by the use of min_t() and other casts: > > mmc->max_blk_size and mmc->max_blk_count are both unsigned int. > > dma_max_mapping_size() returns size_t, which can be 64-bit. > > > > 1) Can the multiplication overflow? > > Probably not, as per commit 2a55c1eac7882232 ("mmc: renesas_sdhi: > > prevent overflow for max_req_size"), but I thought I'd better ask. > > 2) In theory, dma_max_mapping_size() can return a number that doesn't > > fit in 32-bit, and will be truncated (to e.g. 0), leading to max_req_size > > is zero? > > This really should use a min_t on size_t. Otherwise the patch looks > fine: Followed by another min() to make it fit in mmc->max_req_size, which is unsigned int. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds 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 X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD285C31E44 for ; Fri, 14 Jun 2019 07:27:24 +0000 (UTC) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9073E2073F for ; Fri, 14 Jun 2019 07:27:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9073E2073F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 67FAFF3F; Fri, 14 Jun 2019 07:27:24 +0000 (UTC) Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 429F6F12 for ; Fri, 14 Jun 2019 07:27:22 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5A34EE5 for ; Fri, 14 Jun 2019 07:27:21 +0000 (UTC) Received: by mail-lf1-f65.google.com with SMTP id r15so982680lfm.11 for ; Fri, 14 Jun 2019 00:27:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pdzPCh9Iq6DsZwmNtrM2YKJ68uEFiOmJCFPMQ9QBxhg=; b=JbNiPkgsTDwTLGGUpS+jyLGNg2rQxFXyAniXgw21G2s7ctM7dDoUk4bEalP588qTZC UpHGPpsMfg51+0smZr2bvi4U3LmlpWc2OLsZyZI61L6eunDsafMDmEfDf53qMT4743VL JvWAgEvduFgeBdouYMoVN0Q+0ReUQgzyGZu9Uq84Z1cJZnSZkrlBDrEz0Hr495ZWUhQ6 4i7Jy8M/Cm2XTEeqOf7K31tSHDT8b+HcQe9xiWnd9PAGrpAIqEcBBPostWUPd+oGqiTs nG8M0M00UyfXh4rKCv+D9eWJjdtd2Cr0bUJXy51zzukifBX/TnmgHd+m734bCGXlCRK6 T3oQ== X-Gm-Message-State: APjAAAXl6riEaFlW0BblLmwPM7bRoqp6Z3sKAEbBxY3uWp4aBjGMUpxo ///ZI/RcBRaeuPxo2/BRxi/ZFP6Muk/TRQYBmdA= X-Google-Smtp-Source: APXvYqyZPsGGwkPkWixMhMUECj/EG4qRfXowB8lnrcuhtq1khDIasqYBoWJAfAgpDFug4QWIzzNZRN21TX7Vx1y1Gng= X-Received: by 2002:ac2:597c:: with SMTP id h28mr8197569lfp.90.1560497239682; Fri, 14 Jun 2019 00:27:19 -0700 (PDT) MIME-Version: 1.0 References: <1560421215-10750-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> <1560421215-10750-5-git-send-email-yoshihiro.shimoda.uh@renesas.com> <20190614071800.GB8420@lst.de> In-Reply-To: <20190614071800.GB8420@lst.de> From: Geert Uytterhoeven Date: Fri, 14 Jun 2019 09:27:06 +0200 Message-ID: Subject: Re: [RFC PATCH v6 4/5] mmc: tmio: Use dma_max_mapping_size() instead of a workaround To: Christoph Hellwig Cc: Jens Axboe , Linux-Renesas , Ulf Hansson , Linux MMC List , linux-block@vger.kernel.org, Wolfram Sang , Linux IOMMU X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: iommu-bounces@lists.linux-foundation.org Errors-To: iommu-bounces@lists.linux-foundation.org Hi Christoph, On Fri, Jun 14, 2019 at 9:18 AM Christoph Hellwig wrote: > On Thu, Jun 13, 2019 at 10:35:44PM +0200, Geert Uytterhoeven wrote: > > I'm always triggered by the use of min_t() and other casts: > > mmc->max_blk_size and mmc->max_blk_count are both unsigned int. > > dma_max_mapping_size() returns size_t, which can be 64-bit. > > > > 1) Can the multiplication overflow? > > Probably not, as per commit 2a55c1eac7882232 ("mmc: renesas_sdhi: > > prevent overflow for max_req_size"), but I thought I'd better ask. > > 2) In theory, dma_max_mapping_size() can return a number that doesn't > > fit in 32-bit, and will be truncated (to e.g. 0), leading to max_req_size > > is zero? > > This really should use a min_t on size_t. Otherwise the patch looks > fine: Followed by another min() to make it fit in mmc->max_req_size, which is unsigned int. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu