Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17928604ybl; Thu, 2 Jan 2020 15:01:04 -0800 (PST) X-Google-Smtp-Source: APXvYqw2Hp2JDrrLJSdFaRb7XRWxSw/LJ7WTTzF1bD0S8Yg+Xahey5fB+SwdAZLc3OIKlxxEoW8C X-Received: by 2002:a05:6830:184:: with SMTP id q4mr78013805ota.232.1578006064121; Thu, 02 Jan 2020 15:01:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578006064; cv=none; d=google.com; s=arc-20160816; b=QtDXB9OVYQi+/6pAcRuVoQj+o7snPkLHuDLCu8yoDACUPzPXADA3zJr2vmChnE2Swb wlA4sV7omw3BHvNOYiTNuPkdYOtdZHobRZazqzBaY0Oo8d2oHw+VmURh7/gSN/hu2zht KsUIBcgNydtV6k+Y2AB9kfMfwwsD9pqijd9N+33oLeeAydOIGOLwDeKlIar+HtkUZFC7 Z1h/Og1RYHBM4jdbEy1hP0WfkR088sgqmjWdsU27xl8/xVSLtMI9i6XlZ5xS3im5V1tB I/X793y7t8LY3GQwRoyn8K9V2I/4OCl1wy/0Ssyhq7gMp9eS/mybjT5SgtDQt9T5JXZ+ pwVQ== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oLMtiiHtLaZNR9J119WPLyVLVFAGSbgn775plOhufGM=; b=XChjH4R24X6TNApjP/RCuNHdpLHBunyyIaxngw7UUhoCSWnFPts2twNWDPDfbgRvK0 7f6VctD7AxGSYH9+hCP9lUQEqFXFzv8hUJtCo0dDCsWgZX+cZZAOLJV7CaRrkYPbk4Rg ap6jWHayBZvNS71ir9ZPFeyf6vpFhUHKBnCwHTGzvDdS/DnDmFqIPZwxtZhffmmfMWsx HhV3kriXQG8zqj5ZCeH+Ql0H8w1OtnZ7WGRwbFNcGeRIVl5hvvwilbVojaA7G0BNHMso Tg3vJXGqQiBOnmbjCnySqQ7ZhEYM6ZppE9Qiw7lyTa+yuHT5NOHqDabz64ha//ZxOlyW aRRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="pG3Qt/y1"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si26771998otr.102.2020.01.02.15.00.52; Thu, 02 Jan 2020 15:01:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b="pG3Qt/y1"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727524AbgABW7k (ORCPT + 99 others); Thu, 2 Jan 2020 17:59:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:54064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727797AbgABWN5 (ORCPT ); Thu, 2 Jan 2020 17:13:57 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B8EF522525; Thu, 2 Jan 2020 22:13:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003237; bh=YhmOiMled1/G2x2INpuYgJq0C1R/wZfIFZZcOdQCIao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pG3Qt/y1UdCIMkgDAjLxaCXpCZqXNmM7gTY1Mo1Co5J3BfvXRRMkDXZZ2POTCrpXs E/FfAA3VhvNa6ru9Zx/CvlUikadUHRc7kAmrras7DoJj1/03T+9RuOywLmW9LK4ujo bxELBjGrQMt58vLHw/3KMmRsKcuPS9AUt0hJjXa4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Naresh Kamboju , Jan Stancek , Christoph Hellwig , "Darrick J. Wong" , Sasha Levin Subject: [PATCH 5.4 059/191] iomap: fix return value of iomap_dio_bio_actor on 32bit systems Date: Thu, 2 Jan 2020 23:05:41 +0100 Message-Id: <20200102215836.298398377@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102215829.911231638@linuxfoundation.org> References: <20200102215829.911231638@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Stancek [ Upstream commit e9f930ac88a8936ccc2d021110c98810cf5aa810 ] 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) = 4 mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f7b000 read(4, 0xb7f7b000, 4096) = 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 = 0; int ret = -14; long long actor_ret = copied ? copied : ret; On x86_64: actor_ret == -14; On x86 : actor_ret == 4294967282 Replace ternary operator with 2 return statements to avoid this unwanted conversion. Fixes: 4721a6010990 ("iomap: dio data corruption and spurious errors when pipes fill") Reported-by: Naresh Kamboju Signed-off-by: Jan Stancek Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Sasha Levin --- 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 fd46ec83cb04..7b5f76efef02 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -318,7 +318,9 @@ zero_tail: if (pad) iomap_dio_zero(dio, iomap, pos, fs_block_size - pad); } - return copied ? copied : ret; + if (copied) + return copied; + return ret; } static loff_t -- 2.20.1