Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5596679img; Wed, 27 Mar 2019 11:22:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbtD3OqJ8Fv42i3gykr3aGm6IikjekKZoIOmtUn5V0Zt29kvvn0OaAz9XuKupKnbklN2Nb X-Received: by 2002:a17:902:b948:: with SMTP id h8mr9233524pls.39.1553710967165; Wed, 27 Mar 2019 11:22:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710967; cv=none; d=google.com; s=arc-20160816; b=GRrEbCN+/YHsPrzTGN/64d2tktijPo6B4EERFbnosVT0GV0Awx5VVRsWONbeAq46E5 hgR4Gakw/ZLAzDTHrsT+O5bUUMKHSXkRNQvoJS1HN303SP6exq8JWZ2MAqiMR8sM5P4G i+PerQSkD+B8ekxaFLM6sgeBjVgBbYRmPjgvxhGteF+ttXw6aPbpMDUD63i9TNZqSp36 otQQNE7glF5JSnz5H4se50P4iJ95yNnwAL6FKi9hBFLnkMPHyn/vbizqweE8Veh2suUh mPdw1wOTjTl+MKff+BRwL1oqF9uoh6SweOPHulopwWs/tRDuOSmSxL5uxHzzHQLgTBrf ++hg== 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=oQKMzQuN2uz5fT83sthx5ogah/Jl8HptAVN8TEACwaU=; b=gdfxpugBiHKzomMifhfKLHieY+6iewqhaueH/wOt+oJkq/Ru9STZDzxxDyCpITVcJP R4pl/we3Wa/4TfqMo1xaTPkZgfMCiHLMJ0qqbFmLpb5WSKN9rjzpeAVMxp8kCNGD3C5w bZBul5ImplHGQsx19DCmiC/RC4o9JnT7TcZ02J95UWBW+atm/9iq+iUOZaB9tI2HeKsn PfuxuZC4yi9Q8WgeHZ9+M62eKIOreSW5ffg9bu1cxFsZHoSWuGH5PWE29jkqYxnL7xz0 LS3KbowU3AAy+w5tMQ9hftnAHeBpwyBUouphZ1aXKwaq4oBZ3Mt9yZ/0tb8hAYMt2d/+ tB7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FThvKf5x; 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 x6si18119847pge.211.2019.03.27.11.22.31; Wed, 27 Mar 2019 11:22:47 -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=FThvKf5x; 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 S2403783AbfC0SV7 (ORCPT + 99 others); Wed, 27 Mar 2019 14:21:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:39874 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391242AbfC0SVx (ORCPT ); Wed, 27 Mar 2019 14:21:53 -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 BBC1D20449; Wed, 27 Mar 2019 18:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710912; bh=Eyh49VM6KiZsg7ILW3mv3eS0ykT4JNSXNdBuqlqujR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FThvKf5x3boCVeV8Xo8lSmpNSnObnvdJC1d3NwYfXqlwq73scytY5dHOQTVanNq2y vSUv76MKbsG37XlBDWInj/CobhjLTqszOGbiC5LPAm7fhoBDZu+9dHyQtwzT+E4ZnE d+bbAlQcwTr6HljjiK0cODrB/8fo9heGlrjkErcU= 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 4.9 43/87] vfs: fix preadv64v2 and pwritev64v2 compat syscalls with offset == -1 Date: Wed, 27 Mar 2019 14:19:56 -0400 Message-Id: <20190327182040.17444-43-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-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 9819f7c6c8c5..6ab67b860159 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1204,6 +1204,9 @@ COMPAT_SYSCALL_DEFINE5(preadv64v2, unsigned long, fd, const struct compat_iovec __user *,vec, unsigned long, vlen, loff_t, pos, int, flags) { + if (pos == -1) + return do_compat_readv(fd, vec, vlen, flags); + return do_compat_preadv64(fd, vec, vlen, pos, flags); } #endif @@ -1310,6 +1313,9 @@ COMPAT_SYSCALL_DEFINE5(pwritev64v2, unsigned long, fd, const struct compat_iovec __user *,vec, unsigned long, vlen, loff_t, pos, int, 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