Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3658697pxj; Tue, 15 Jun 2021 06:01:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYXaB2vRnHiaFdEvweBynduZ2jA5esivFm+BWn50i79QAcg7DTtYNSE/x9bgDY0yvMNFPO X-Received: by 2002:a6b:7d03:: with SMTP id c3mr18944835ioq.2.1623762094675; Tue, 15 Jun 2021 06:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623762094; cv=none; d=google.com; s=arc-20160816; b=RuGEOc1SZWUMCzMKAM77nppyT1y2NuVvcqycPD0sCCon55j02g8jSB/SGMP5r9hR+o 1/muSyrQ3B8v6qGtyiyufjG74/Kke/dUtyG/7DDgZ/5CvOurExE261Z6BgnwRDU1Pc7s iII62z0rQPx1RlpkyUleQTfpyFyRWVYBBr2eDbHG16NQ/4GdwP9X6DaYseWsvGK5okeC gRfOqldKdnjAQIKDvvWPv0RkWcTwtkGjt/z9zWAy/9cRzwKCqVLJu/M/pr91z4hNJdog 3sTgswg1YTNnekYMJVGhyNRIBBfa3fIs+7N/qUNQT7TzsDccr07llWpcuLwGUcbKPfkm +w5w== 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 :message-id:date:subject:cc:to:from; bh=GpKy72CIjQhbs37JV07WM2J+SgLoWpOtRcThSjgnQu4=; b=MasNqxaxeE/DscgS08B3E0/kHQHo+rdkLZDePctGaGlIha9ITZjicorlK7fqDbWFYK d7QsIuis8aqf8g9Hbe1ek9bCvNwO0mDxWfwJ4h3zSxXXn0Cf5KMRhrtD97sa/J3Hvh51 6FotjHEXL028/4ufUfwE8c3DOqN4/qRGz7AnElSS7ufWmiA+RGwYcudESq8INuVpLEA5 MkKlHSNKrifQ1iJC6qUe1AqgpJIRwEi7CK1gugKGtUX9fStoEzx/4r9DxOVAivaEbG7f HxbjeCceH+lfni8XSGZeiQovAJ3mgflxjos/JZzfQnl7/GRa3TAA7ppNz/70ELP4zG+D Ytqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w21si1242258jal.38.2021.06.15.06.01.21; Tue, 15 Jun 2021 06:01:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230239AbhFONCT (ORCPT + 99 others); Tue, 15 Jun 2021 09:02:19 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:59258 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230208AbhFONCS (ORCPT ); Tue, 15 Jun 2021 09:02:18 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lt8fs-0004x7-5k; Tue, 15 Jun 2021 13:00:12 +0000 From: Colin King To: Jens Axboe , Pavel Begunkov , io-uring@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next][V2] io_uring: Fix incorrect sizeof operator for copy_from_user call Date: Tue, 15 Jun 2021 14:00:11 +0100 Message-Id: <20210615130011.57387-1-colin.king@canonical.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King Static analysis is warning that the sizeof being used is should be of *data->tags[i] and not data->tags[i]. Although these are the same size on 64 bit systems it is not a portable assumption to assume this is true for all cases. Fix this by using a temporary pointer tag_slot to make the code a clearer. Addresses-Coverity: ("Sizeof not portable") Fixes: d878c81610e1 ("io_uring: hide rsrc tag copy into generic helpers") Signed-off-by: Colin Ian King --- V2: Use temp variable tag_slot, this makes code clearer as suggested by Pavel Begunkov. --- fs/io_uring.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index d665c9419ad3..7538d0878ff5 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -7230,8 +7230,10 @@ static int io_rsrc_data_alloc(struct io_ring_ctx *ctx, rsrc_put_fn *do_put, if (utags) { ret = -EFAULT; for (i = 0; i < nr; i++) { - if (copy_from_user(io_get_tag_slot(data, i), &utags[i], - sizeof(data->tags[i]))) + u64 *tag_slot = io_get_tag_slot(data, i); + + if (copy_from_user(tag_slot, &utags[i], + sizeof(*tag_slot))) goto fail; } } -- 2.31.1