Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1023696yba; Thu, 4 Apr 2019 02:39:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6nG8TevWuuZOOy9CnwVlaRfzkf30GJaDru1SZhr8LFwV7a3Efq6mPHASdfCzwcwz+u5dk X-Received: by 2002:aa7:9151:: with SMTP id 17mr4834889pfi.192.1554370792208; Thu, 04 Apr 2019 02:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370792; cv=none; d=google.com; s=arc-20160816; b=QbdPZWz8kfoiOvDknmxS9SUoWs15mOmPbPmxQG9b1T8O53rNgmTJKukXsTq+0G7pCC C4ay0a3ejJk1yYH70W9Ls6bqlgTzCadF9jJpD/FYcSPj+AEAjVtomaD3ueOXwgNRXbP+ bBvN7Kbo5zcDoWjEAEz7YrogLazcoBZgaJMcA+g40DMQ2/rCRcT9gQnl19h3p/8s0bXE MULwHwVaT9C5dN5ISleUGQiSwSRmI697saqy5wwLR0nehimSfwytIpNuSKu3MsnMZSDL H/j+vf21S191zkcDk1g0EpoPEt/G9sQhie32LREyZBkJoZpznElWGDJxOjmLCzQ0WaIY Ssyg== 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=84BNx0NveOEZXr/Af9c38PJZYyJgolhqaMqzM+DLt3I=; b=ZNvrkRXY+O0BhpKs5Y32Rzcljg8unhXuNenAz0os/ZjcJYLgB1zW6pMXQvhexkijfR MYwPaXiPmPX9kMchWlDuLxOBGJibQChDD3YSLrGc7nuQZ2i5Cv0erXuw2b1ttmWagRFl ZpSbPip7UPlMGfMq+oCzCM8TAsgMMhk5c/GCKt11In7j0FYpq5C9NMnebgKV9QjYWqgm NmruQ+p6V0n7Nl0SGhyxSj/vScF95H3zzeM20p/uBjHQaxusbvvBMym+++XRql5co5/7 do9KblVf8CrZT+qT3ruiORwzGHoNjaSr2dWaG+R916Nizx3/bSK7LT85NgmWkOpRM9BU a1pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="mYdIN/1Z"; 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 z127si16229236pfz.214.2019.04.04.02.39.37; Thu, 04 Apr 2019 02:39:52 -0700 (PDT) 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="mYdIN/1Z"; 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 S1731940AbfDDJjG (ORCPT + 99 others); Thu, 4 Apr 2019 05:39:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:41522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731843AbfDDJDr (ORCPT ); Thu, 4 Apr 2019 05:03:47 -0400 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 6A8782184B; Thu, 4 Apr 2019 09:03:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368626; bh=KwdVpJZ+MP89vBIPPHZswq4vptUzvKKRoU+eqM2qmq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mYdIN/1Z/xaoBPwx81P+1QLCoOfgPnGdABJTo313VBM43IJNT1W3n9Y+uiAVPCy6l SQsdmEJkLbZceBvRFFANLnRtilnbgCrcwXgX3ELF5Tk0n562qT7vAKmdjkCkTbUg1H 3b5ZqAMKHXlSEHYVwxPYOxpXzXHJTHGemcoiR/Ac= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Viro , "H.J. Lu" , Aurelien Jarno , Sasha Levin Subject: [PATCH 4.19 093/187] vfs: fix preadv64v2 and pwritev64v2 compat syscalls with offset == -1 Date: Thu, 4 Apr 2019 10:47:10 +0200 Message-Id: <20190404084607.528446133@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit cc4b1242d7e3b42eed73881fc749944146493e4f ] The preadv2 and pwritev2 syscalls are supposed to emulate the readv and writev syscalls when offset == -1. Therefore the compat code should check for offset before calling do_compat_preadv64 and do_compat_pwritev64. This is the case for the preadv2 and pwritev2 syscalls, but handling of offset == -1 is missing in their 64-bit equivalent. This patch fixes that, calling do_compat_readv and do_compat_writev when offset == -1. This fixes the following glibc tests on x32: - misc/tst-preadvwritev2 - misc/tst-preadvwritev64v2 Cc: Alexander Viro Cc: H.J. Lu Signed-off-by: Aurelien Jarno Signed-off-by: Al Viro Signed-off-by: Sasha Levin --- fs/read_write.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index 8a2737f0d61d..562974a0616c 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1241,6 +1241,9 @@ COMPAT_SYSCALL_DEFINE5(preadv64v2, unsigned long, fd, const struct compat_iovec __user *,vec, unsigned long, vlen, loff_t, pos, rwf_t, flags) { + if (pos == -1) + return do_compat_readv(fd, vec, vlen, flags); + return do_compat_preadv64(fd, vec, vlen, pos, flags); } #endif @@ -1347,6 +1350,9 @@ COMPAT_SYSCALL_DEFINE5(pwritev64v2, unsigned long, fd, const struct compat_iovec __user *,vec, unsigned long, vlen, loff_t, pos, rwf_t, flags) { + if (pos == -1) + return do_compat_writev(fd, vec, vlen, flags); + return do_compat_pwritev64(fd, vec, vlen, pos, flags); } #endif -- 2.19.1