From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72839C4360F for ; Thu, 4 Apr 2019 08:52:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 438C621850 for ; Thu, 4 Apr 2019 08:52:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554367959; bh=HzJ121sbeO5/aCDy1UtsdBSed/GtvTBQwsI2/S/eRHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=FFg2C40ynFbZa0+lw6PVNUa8Im7je2d8uznefAHBbl0C06os52UxLdGWOT20FGANm Qyncvx13utvCReUBK3xqg7lqHzy1peMaW3ol0OiUG4c1UEXYA5IWAfi/RU/r8osN9R 06fs3uTFxQ2rMV7U9vodgWkT3CFly46KCYJrap3Y= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729145AbfDDIwi (ORCPT ); Thu, 4 Apr 2019 04:52:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:54730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729639AbfDDIwg (ORCPT ); Thu, 4 Apr 2019 04:52:36 -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 B30262147C; Thu, 4 Apr 2019 08:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554367955; bh=HzJ121sbeO5/aCDy1UtsdBSed/GtvTBQwsI2/S/eRHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CwH9kA9Fvq/kMPDhNUyKOZAl9rIRPF7Vs+g2a2mHo60DSFC6qL6NRuoUM9w5Ur1EN fyyqTVAWLjleCWIbMCQs+yuEG/Sk/D0TC5oqRsgGtFQffdWZlDNi/mXPc1BillJKma +48vi2K6DXlJJUnz7nGEW1ngrO68+HvwLZnnlZVU= 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.9 49/91] vfs: fix preadv64v2 and pwritev64v2 compat syscalls with offset == -1 Date: Thu, 4 Apr 2019 10:47:33 +0200 Message-Id: <20190404084538.318767285@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084535.450029272@linuxfoundation.org> References: <20190404084535.450029272@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: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.9-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 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