Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5648367img; Wed, 27 Mar 2019 12:24:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKB8LWI/PmydHiBkK9ndEd/0S8lgv+wwnR1uGjhUXpI1zJUTKYSAtdPsjz5ROFRG4dgKqE X-Received: by 2002:a63:5a1d:: with SMTP id o29mr31524101pgb.320.1553714666713; Wed, 27 Mar 2019 12:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714666; cv=none; d=google.com; s=arc-20160816; b=01MBJIaUXfHGLwfFzIyDS6z1yxjeIjjVC5TX3WyURok3opBJ5aY3R6dHYCfn+xJ9St 0tesmEEwEi3K3uBVzY+N44qT+wMHyBKACKV6wGk7bC8XzeYpbtpsL90/QdZ0ErOGoivl F6j2PDqHleau/7712hEy2WfnAjhVEq+1XnLYvk09MmyjB2mbyeWL4VEVmkd4editUrBR eiPDFQWWNmHieroKzAXEoRTItyaP/CoNpZceYCq2swMLaOONnDhatU/k/f5fXyK3KNjL 2zi+GBA8siZeRqBjsmHXuCqWTLcqgwCZTZWasg4Q5fyQMRsq+y/l8lnSkahZSbQtmqJi 5CJQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GZHIsXHpPsLpKVnvG+ZjoqXuu7XSKURUApK9Ve0J4xM=; b=EFKOP6BpRP+q0PpvkynYNI1UmP5aOAn/Rabgy2y06a2E+R0PQSxmOvnbG0d/Rzc3Uj uT9vkz2BsLlpdKZdcJGNCIcvx6S6uXFwRt3MIOt9jzr0+yLUmWc6XgYHBx4VzBQvIv2O 8YvU6spiWmOwJSX/88MoLc4UKs2uVQ+teekGqjnVLsH3RwB92k847gc7KkrER3U+a/yt Gp87VdkVxaQJSBqIKCIUq1biByV183hL/yxMkK8pHH4NODjcUqpzlOV1vsBzOhuoG6Bl H5soB6BCDpN6Hvmo5rVYB9v5FV/qw9mfNarqsBBfmokGU+gU2aINBuByovdntD4JhCQs ivhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=S6ILLjqy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7si10189928pfp.156.2019.03.27.12.24.11; Wed, 27 Mar 2019 12:24:26 -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=S6ILLjqy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387851AbfC0SGE (ORCPT + 99 others); Wed, 27 Mar 2019 14:06:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:47352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387816AbfC0SF5 (ORCPT ); Wed, 27 Mar 2019 14:05:57 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A39832183F; Wed, 27 Mar 2019 18:05:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709956; bh=ixiqsnzWBhq/GarlKDTCLii+8mXyrwwAijBqCtgZYZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S6ILLjqyKNwtPvTnjJ6uLjC7ek7EcORJmJq7inGhcNNSK8A939sz/WG3XUHEGAqpT 232fN4QXRf6DUvnoTEgNkljqnc0te7Orsnh4pyXd14CQ91JQwaZRwD4wwD0o6cUHwA t6xZshgOC/lbQesPTVV7/6PL6d5U2vUd6Y/qrpMk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Aurelien Jarno , Alexander Viro , "H . J . Lu" , Sasha Levin , linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 131/262] vfs: fix preadv64v2 and pwritev64v2 compat syscalls with offset == -1 Date: Wed, 27 Mar 2019 13:59:46 -0400 Message-Id: <20190327180158.10245-131-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aurelien Jarno [ 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 ff3c5e6f87cf..27b69b85d49f 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1238,6 +1238,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 @@ -1344,6 +1347,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