Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6018434ybx; Mon, 11 Nov 2019 02:30:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxp35x+c2hJCsjX6brMGibQF73f+r6cKGwXteD17UCUu7TNDyb1Uj56oTT/E5BHs5CMHqpP X-Received: by 2002:a17:906:e2c2:: with SMTP id gr2mr22001681ejb.31.1573468217963; Mon, 11 Nov 2019 02:30:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573468217; cv=none; d=google.com; s=arc-20160816; b=KO5Jc3bk0GPmuH6WSq1A8+VgwYbE+K02JrvQdOBypQodvxdrGRXWIsyIbKsZKB+QzJ LpvNtfXDydkAdFADhKL8vPEP/yzXpod1LUQjOY7jZslMRoLYhLXZ1QlWDYHqW2DZSDm2 62QLn6By+1Fka28miXl+EIe7Uze+rqjcKuorerPXE3O51kDmSlUPI8Tzls0NMtZag5NU nm9RdLF0MC/kKB8E4bsNcT0w4UbneYym0auzGIQ1qmV9p6Gt0qolFulWErSL6J1Dramm YJNxd16VT1q6DXe3//965byYiK2zxsDhF6HiZSEff8GfbZohIw1RTiUy/gHWtKr0OJUt C2/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=pcVRVS2wigfNxAtSVYLPPaPRSK4c2t19oDRB3orBUZ8=; b=g4S4HzFXgOdzhyWyGDCCDcp3SCOMCmrqA19M9Sff7ozwyRvCBlQSUFoV+7NLZlMbyj mDJfwytx8gK8DnX6/JygWXb+lOC8dLIulfX3Qlo2Sc8Uc2jXw1CQtXV+Yq2cO/prLRjY ZouyUXNcUeog9+p5Fp6rCYHOnf9shN4/K9NjxU9VId16yWj0/3hHvMT48fVL0zi6mMHH jT7KjXcB4fV6Lpf2gIFJZ/OcguNZLaQIqQYKDXP5RiEBMdxEBUqGAaqZ7YiSaa7I49CV uQ+f/MIZEjPBAW4dzBPu2MMoR/Bxk4zskwB6I/+IyDHZWjxsRJmf/jJQODTNuyLwBI2U VL7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qu8oR+yS; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ss14si9009203ejb.195.2019.11.11.02.29.48; Mon, 11 Nov 2019 02:30:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qu8oR+yS; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726912AbfKKK32 (ORCPT + 99 others); Mon, 11 Nov 2019 05:29:28 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53207 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726810AbfKKK31 (ORCPT ); Mon, 11 Nov 2019 05:29:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573468166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pcVRVS2wigfNxAtSVYLPPaPRSK4c2t19oDRB3orBUZ8=; b=Qu8oR+yS+SqKnZKhq7MLdSGa7rTRFICVguQD0H8Odfe6wr9GUAVwXwMnBOJSX7jzKbEi5o gzUH6SjKbp9xeBjhAjRy6mERaKnfY9eSs1cQBcUOMDvMOm6UcGlBD92+7O6wB8xKtXIHXA ZrAYGJhK0OkDbK4QJiUdDjUt72GFF2s= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401-z809MnJvNym6fsK2ylp1rQ-1; Mon, 11 Nov 2019 05:29:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 531491005500; Mon, 11 Nov 2019 10:29:21 +0000 (UTC) Received: from dustball.usersys.redhat.com (unknown [10.43.17.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 640765D6A3; Mon, 11 Nov 2019 10:29:18 +0000 (UTC) From: Jan Stancek To: darrick.wong@oracle.com, naresh.kamboju@linaro.org, hch@infradead.org Cc: ltp@lists.linux.it, linux-next@vger.kernel.org, linux-fsdevel@vger.kernel.org, chrubis@suse.cz, linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, broonie@kernel.org, arnd@arndb.de, lkft-triage@lists.linaro.org, linux-ext4@vger.kernel.org, tytso@mit.edu, jstancek@redhat.com Subject: [PATCH] iomap: fix return value of iomap_dio_bio_actor on 32bit systems Date: Mon, 11 Nov 2019 11:28:10 +0100 Message-Id: In-Reply-To: <20191111083815.GA29540@infradead.org> References: <20191111083815.GA29540@infradead.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: z809MnJvNym6fsK2ylp1rQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Naresh reported LTP diotest4 failing for 32bit x86 and arm -next kernels on ext4. Same problem exists in 5.4-rc7 on xfs. The failure comes down to: openat(AT_FDCWD, "testdata-4.5918", O_RDWR|O_DIRECT) =3D 4 mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =3D 0xb7f7= b000 read(4, 0xb7f7b000, 4096) =3D 0 // expects -EFAULT Problem is conversion at iomap_dio_bio_actor() return. Ternary operator has a return type and an attempt is made to convert each of operands to the type of the other. In this case "ret" (int) is converted to type of "copied" (unsigned long). Both have size of 4 bytes: size_t copied =3D 0; int ret =3D -14; long long actor_ret =3D copied ? copied : ret; On x86_64: actor_ret =3D=3D -14; On x86 : actor_ret =3D=3D 4294967282 Replace ternary operator with 2 return statements to avoid this unwanted conversion. Fixes: 4721a6010990 ("iomap: dio data corruption and spurious errors when p= ipes fill") Reported-by: Naresh Kamboju Signed-off-by: Jan Stancek --- fs/iomap/direct-io.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 1fc28c2da279..7c58f51d7da7 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -318,7 +318,9 @@ static void iomap_dio_bio_end_io(struct bio *bio) =09=09if (pad) =09=09=09iomap_dio_zero(dio, iomap, pos, fs_block_size - pad); =09} -=09return copied ? copied : ret; +=09if (copied) +=09=09return copied; +=09return ret; } =20 static loff_t --=20 1.8.3.1