From nobody Sat May 18 23:44:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) ARC-Seal: i=2; a=rsa-sha256; t=1598297944; cv=pass; d=zohomail.com; s=zohoarc; b=WwATfscuXT72yRY+khF6+rmoye6DVcOQZjwzibXV8EWU7LcDsOY67pjbMUWL3ckAsC1xyx9eyEBIUmy/86rGB+Om9z12wg98bNHmF//Ddl5gHbkYtKNkXNQpshJJWOMvqOPsbsT7PeDrNp0G9ZLLzYzYy1B9FRC+hClpiDDBovw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598297944; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L73sbuiC7bnu+oJjs8tKLD0o+bknCPalISJpmNd5ujw=; b=UOUMfGkWFbDdm+p83APZtRts7IfxM0SIpcPEgd9TMfIDfrTjjMvRf/Y56+Fb/wD6EVYxrTbLEQelT1dJm8e2UC7IAwSFfN+9zdBjZtWcZq0OAhlNyANmzIcqalXEXUVp4e0FoLqBKIZs690ZIfRh/u0KFrY+Da/ayqQCzT32FKk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598297944500770.4888425591107; Mon, 24 Aug 2020 12:39:04 -0700 (PDT) Received: from localhost ([::1]:49314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAIJ5-0005AT-8o for importer@patchew.org; Mon, 24 Aug 2020 15:39:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAIII-0004Li-Da for qemu-devel@nongnu.org; Mon, 24 Aug 2020 15:38:14 -0400 Received: from mail-eopbgr10113.outbound.protection.outlook.com ([40.107.1.113]:60643 helo=EUR02-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAIIG-0000YT-6i for qemu-devel@nongnu.org; Mon, 24 Aug 2020 15:38:14 -0400 Received: from VE1PR03MB5246.eurprd03.prod.outlook.com (2603:10a6:802:a1::22) by VE1PR03MB6047.eurprd03.prod.outlook.com (2603:10a6:803:114::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.26; Mon, 24 Aug 2020 19:38:06 +0000 Received: from VE1PR03MB5246.eurprd03.prod.outlook.com ([fe80::3568:5b4f:ab6b:e362]) by VE1PR03MB5246.eurprd03.prod.outlook.com ([fe80::3568:5b4f:ab6b:e362%6]) with mapi id 15.20.3261.026; Mon, 24 Aug 2020 19:38:06 +0000 Received: from localhost.localdomain (147.91.217.242) by LO2P265CA0251.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.25 via Frontend Transport; Mon, 24 Aug 2020 19:38:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ThSjU5WgaG3vhH0OWGuj2uF7H251SsHQ6k5UhnS4TQfiu8hFyKeTFLancAsCwFEYM23GN/b1wgCYmaEWBqHyGr0Yc/WDVcwXLCbhSOCA/M6i5T/JR+cLDPyq+wD/9ioBZcUC+ibxMXTQITKvnq0/9lczv5OZXEhaPjkMm3YnKGIYBNTBrsEfmIzX51DVC6eVYxFSZMFLM49gMVDarcubQQ1DD9lYKWj3z0DLo0dkWj8kppaZfaIOYJz0yXHWoq+wmM6B0TBYBg7u6k+64oaPaq6/A/wIT9exdpqvPzGdYqXQe6NryxKSXDFM/how6woRm8ExCZzUFXkuUZy2m14VzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L73sbuiC7bnu+oJjs8tKLD0o+bknCPalISJpmNd5ujw=; b=af+ppQ9ufixWyoo4DP0jpzNHWeRPGG67u3V/GxYnE35lwJiCeP90ABo0IT/MMSFa0TWmbRCoogYBtlPhoSYdSjLw7VSCLSL+BhZpSu6LFGAvVjVAuqber9y3SFxN8zY6Lxtww0MzNoqgkQhcK39srqBhIfU4HRFVTCWJH5Aez3YMKojyiNZnJr7rybXNZe+aiOBoUxIbIRVLMgAOgUj9CBmN3rK0e2kmI+PM4NjibMSxPV/lFQV0EJsA4h2x6tn1RFqzTrhg8wDVV/wEZCgGLck0yD0NHWj0onJL0x8/8mUWg9lFtj24Sd9Whked1y4tlOg30W/QsQJ1haB+XUDf3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L73sbuiC7bnu+oJjs8tKLD0o+bknCPalISJpmNd5ujw=; b=t+SduMhpiCG9UsotgKHECE1XpOz1n2xGv5gEmcck+CYCOpw++sLr0fR7bZ89bQyR4c4ZN5/5jHXcKipP1h4KUSgA+eep3tRnNBJJU72VamcSZFGYFlrper+SWDXXCzrnuFQxOiMlOoEIFcHIda12Bia17pYIewCkuq6ebuoen9Y= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v3 1/2] linux-user: Fix 'mq_timedsend()' and 'mq_timedreceive()' Date: Mon, 24 Aug 2020 21:37:51 +0200 Message-Id: <20200824193752.67950-2-Filip.Bozuta@syrmia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200824193752.67950-1-Filip.Bozuta@syrmia.com> References: <20200824193752.67950-1-Filip.Bozuta@syrmia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO2P265CA0251.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8a::23) To VE1PR03MB5246.eurprd03.prod.outlook.com (2603:10a6:802:a1::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [147.91.217.242] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cbe02542-c594-4eeb-4304-08d84865395f X-MS-TrafficTypeDiagnostic: VE1PR03MB6047: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JOwhk+2U+D8BI5sWbzC4JjpVRRq/H69VLi+jNzBGTpzzIQZ5HWe0jq3Fb8YfhYdmz4S2RVwbnXZFej3wEwrYTthgQAK2LKz0br+ywoiqnfeoy+Rsdly7eHQh0zKJ3B1dMt5OwV9B6ZLccbkpDc/5H4vmbaOJanIUWMH82VXmoIzC0y4jSdY8OQ/fQCMgajVIaMrd4YnPfquae8cbLHjwIl79XNKsMf7npXtVIL4bwO8wBy3fsasPcGuPQvqhmA0Zss7AEkklvwW5Lvzmfo/5uy4f5+Z+wTONJcHkselWIzWj1Yt/J9SngieoxwFaxlEj6eKqAEcFVNzX5Jwn1b0ZPTSjdkS4/DDEvL+Vov+tJDN0NDY68OeqJV5yqxTHkPNecV1bv1YeOzbZGEw+dhB4uJtBYxRk4fHCwoHhFYA3fDQP4MnW/18mIvx1lL9FtL46e9NGBmsg+vuB9LwCsQ9OwA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR03MB5246.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(136003)(366004)(39830400003)(376002)(396003)(16526019)(8936002)(66556008)(83380400001)(26005)(107886003)(2616005)(956004)(6916009)(86362001)(66476007)(5660300002)(1076003)(6512007)(186003)(6666004)(316002)(966005)(6506007)(66946007)(6486002)(8676002)(36756003)(69590400007)(4326008)(52116002)(2906002)(478600001)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 4a+tmOJlh8BiviDpZvET0u/q3cAwwkD9iNqhJrLJhoD7IJesxaoIIH+YUGtawqE0Yjlxj9YufAZXMvxU7X++bwS1Fm0jTE5X34SwCDRhnYscLKnJdgha/dEB4V1iyKCJQNSZ0LITA5GdkeXqTuYqAioRJJYZypZmLUcfCo7nBNMePOmdyBpMG+YiflEQ/1Qf/BM6ZpasQoGsWBdB+tsfEallqi7DwzjrpyctZZOkHDWljKHDawKPXKQQBLhG3CmYlCcD7CPjG6YId/1Km/jKmIV8WewXQGaN80nHB7SO2VjlE0Ya3MKNitUMmE4UnzpfjM7A5412c4aosLMOa5r9L67BKZ1HgAl2JOe9NIoDXo5Z+2oTNKYC6ronV3oZFJQuTNQqoiz7+4d/aCl5gGss42j+niNZ/dgLh3nighomFWvJFHi4kxyE5doubLvdtPIDQi1x0WmZV3n9gPC7AiTaaEJ9dGHOFlK2ijHAEqZfCogEZReMuilEAcprJiH/ufTpCHY8Xpp8gEbyZjaBFYiJl3RVNz2V9cccrMsB/Xye8juuRFN9gGfn4JQPPM5CZlnpxOpTKALd/rScb1TAAUykNCsyTnowVuhnB3KIgT8I6Rw8REphXjBbiYyqsCzJOG8/DU2nLozPd7x5J0L0tMP64A== X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbe02542-c594-4eeb-4304-08d84865395f X-MS-Exchange-CrossTenant-AuthSource: VE1PR03MB5246.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2020 19:38:06.5885 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8MNljHT2C6s6BHXOryG+33g6e59c4X8ibiAbr5FqGA01P54JUd6L6lD0KEMsdBeQa4xkg0Ac0Dqr1hR9esdRQg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB6047 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.1.113; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR02-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/24 15:38:08 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @syrmia.com) Content-Type: text/plain; charset="utf-8" Implementations of syscalls 'mq_timedsend()' and 'mq_timedreceive()' in 'syscall.c' use functions 'target_to_host_timespec()' and 'host_to_target_timespec()' to transfer the value of 'struct timespec' between target and host. However, the implementations don't check whether this conversion succeeds and thus can cause an unaproppriate error instead of the 'EFAULT (Bad address)' which is supposed to be set if the conversion from target to host fails. This was confirmed with the modified LTP test suite where test cases with a bad adress for 'timespec' were added. This modified test suite can be found at: https://github.com/bozutaf/ltp Without the changes from this patch the bad adress testcase for 'mq_timedse= nd()' succeds unexpectedly, while the test returns errno 'ETIMEOUT' for 'mq_timedreceive()': mq_timedsend01.c:190: FAIL: mq_timedsend() returned 0, expected -1: SUCCESS= (0) mq_timedreceive01.c:178: FAIL: mq_timedreceive() failed unexpectedly, expected EFAULT: ETIMEDOUT (110) After the changes from this patch, testcases for both syscalls fail with EF= AULT as expected, which is the same test result that is received with native exe= cution: mq_timedsend01.c:187: PASS: mq_timedsend() failed expectedly: EFAULT (14) mq_timedreceive01.c:180: PASS: mq_timedreceive() failed expectedly: EFAULT = (14) (Patch with this new test case will be sent to LTP mailing list soon) Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 05f03919ff..4ee1de6e65 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11817,9 +11817,13 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, =20 p =3D lock_user (VERIFY_READ, arg2, arg3, 1); if (arg5 !=3D 0) { - target_to_host_timespec(&ts, arg5); + if (target_to_host_timespec(&ts, arg5)) { + return -TARGET_EFAULT; + } ret =3D get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, &= ts)); - host_to_target_timespec(arg5, &ts); + if (!is_error(ret) && host_to_target_timespec(arg5, &ts)) { + return -TARGET_EFAULT; + } } else { ret =3D get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, N= ULL)); } @@ -11836,10 +11840,14 @@ static abi_long do_syscall1(void *cpu_env, int nu= m, abi_long arg1, =20 p =3D lock_user (VERIFY_READ, arg2, arg3, 1); if (arg5 !=3D 0) { - target_to_host_timespec(&ts, arg5); + if (target_to_host_timespec(&ts, arg5)) { + return -TARGET_EFAULT; + } ret =3D get_errno(safe_mq_timedreceive(arg1, p, arg3, &prio, &ts)); - host_to_target_timespec(arg5, &ts); + if (!is_error(ret) && host_to_target_timespec(arg5, &ts)) { + return -TARGET_EFAULT; + } } else { ret =3D get_errno(safe_mq_timedreceive(arg1, p, arg3, &prio, NULL)); --=20 2.25.1 From nobody Sat May 18 23:44:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) ARC-Seal: i=2; a=rsa-sha256; t=1598298035; cv=pass; d=zohomail.com; s=zohoarc; b=hS6PHdoaSzGUVtZtdV4D3/OCUI6ydMJUbSTx1soa7kyPFFc9Q4sjkQ/S4zkBguFJrH2P8U5rFLllVvCUJ+Cj75wOr/WvzHS2rw7ST9k4OcdmYjMwYg8CmmbHAq67O06WVDeOUvlmpEEliCwzHA/+w0sLrpKYzUzPJfZ7FhjwX68= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598298035; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=D58k38h9xk9Nq28XHZi+jEvQTLchwClfkZEJ2V5IM1Q=; b=ZhUhp1hwls91jG19r++tPGUIooJC4XUwi4igHiKGfM/jP90AyzhmajfAAeiFWU+I76JKh3PgQmeDz61fU+P7Wzbf4yXPnbHC3hc4PxKyuEYIOmeoNC/fr57v/JRcfSCOT80B+ZU/2HmDqvFdSMYNne5amiq+SoXuU6iGZ8eaVqM= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=syrmia.com) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598298035229826.9260325033903; Mon, 24 Aug 2020 12:40:35 -0700 (PDT) Received: from localhost ([::1]:52568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAIKX-0006bf-P0 for importer@patchew.org; Mon, 24 Aug 2020 15:40:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAIIP-0004Sm-BY for qemu-devel@nongnu.org; Mon, 24 Aug 2020 15:38:21 -0400 Received: from mail-eopbgr10113.outbound.protection.outlook.com ([40.107.1.113]:60643 helo=EUR02-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAIIN-0000YT-6b for qemu-devel@nongnu.org; Mon, 24 Aug 2020 15:38:21 -0400 Received: from VE1PR03MB5246.eurprd03.prod.outlook.com (2603:10a6:802:a1::22) by VE1PR03MB6047.eurprd03.prod.outlook.com (2603:10a6:803:114::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.26; Mon, 24 Aug 2020 19:38:07 +0000 Received: from VE1PR03MB5246.eurprd03.prod.outlook.com ([fe80::3568:5b4f:ab6b:e362]) by VE1PR03MB5246.eurprd03.prod.outlook.com ([fe80::3568:5b4f:ab6b:e362%6]) with mapi id 15.20.3261.026; Mon, 24 Aug 2020 19:38:07 +0000 Received: from localhost.localdomain (147.91.217.242) by LO2P265CA0251.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.25 via Frontend Transport; Mon, 24 Aug 2020 19:38:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g/uPEYftRaO46Zi/pyxkTXeyqxLYj9y0l8KfD2ap2yOkFp7QJN4xSz9TH4dI9TyxbchZRgQ1D7MckUYt8bvu3BMZ4xQrHd9SOtyf7Yj7P+SU02gtYzeJMHEUDCFnW/l7qwxTM5PZxT5aJB7yg1O5C1BPrzFrOQweAZTQ8cy4NVAheNo8jSILp8K5D9DgD8DzXW8nSFjsysE+RTJPt7F+LlWNQDqoY9GzCV56gJ8wxF3Bry0vfxeqNBQH21fNFtfw15IuR6GP16HHciFEQYGf6pBzne86wr0vl50wxXLEn1dfBa5M+p9mAJpF7KBDjuhpZHi/+26MB6DSQyZvMKnMmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D58k38h9xk9Nq28XHZi+jEvQTLchwClfkZEJ2V5IM1Q=; b=QAcqPpXIEXCEbb4R6K8HM+VWO8wx1FbxKX7cL8L8Gd4zHMUn3AkLYmc67ynhnJr3+n1vf3sPj4pPfVOboBwKhJz3l4/ueimvGa43AmiS3aZGRh39XmyQMFiq7+mBWnHoYYIeCFle2VoB0m1Nd8tIeGIhmaUxA+7YFhAXB/JS8PVAbQG0KAyM+SaG8ZAxKzy5kxs/DMYIrSWhZC1FrbO2unjKsSgme4gCdo4RIgmkLYSeQlYVR8alikvMmB1gINrdyD4IQzF6xzgksQsBNiuQa0Mc5tO7nGJsqu9bp6GbgY8wMOn0QAqKAnDsKUKfaI0eu6NB2VwJFevnW+O9cL7ezw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D58k38h9xk9Nq28XHZi+jEvQTLchwClfkZEJ2V5IM1Q=; b=uba0B8yt8uSTanl5NHnwH7DtcgxARTBiqkMZesgd6geOr1NBRIIAkAn+eVmtKZxwZUhMPWUEXCj4nHGNeVWCACT5cQslpk81ToKfqXAmm8PyE1wx6UkTkA3i/foBD2vFddQ+vgEdFZPtmWJHxTUlB5vNjUKCZz7THX/SY4KCDVs= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=syrmia.com; From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v3 2/2] linux-user: Add support for 'mq_timedsend_time64()' and 'mq_timedreceive_time64()' Date: Mon, 24 Aug 2020 21:37:52 +0200 Message-Id: <20200824193752.67950-3-Filip.Bozuta@syrmia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200824193752.67950-1-Filip.Bozuta@syrmia.com> References: <20200824193752.67950-1-Filip.Bozuta@syrmia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO2P265CA0251.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8a::23) To VE1PR03MB5246.eurprd03.prod.outlook.com (2603:10a6:802:a1::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [147.91.217.242] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cab737b7-fc58-4d53-418a-08d8486539eb X-MS-TrafficTypeDiagnostic: VE1PR03MB6047: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OUfroD0gBccWm2hQCWDTjeELfbtXk+FoTH+6Z97zGrUH8kAhYDOs50pkDJfURTigokvYOCHQ12xRr8I0crGeo+yBrVCDmPZGMKBmg18vYa4K8/QS2Ijp63OSZpZR+wFVz/g3nlmNuxUsaQ9roDOgtr3YkncsoEavEzoVsL0NR4/aZns+n9ntaivBUwhqe2aQ0mOb5XW2UGMaVCvQpSHa6H9cw0tiqEYf4XfMmXkD1o660UIjXRbxWPR45vewxF466q/Uq6Hqhvs3H2/J7dIQIhVD9nDlnawBqORYZVyEq/V+RwSMLc29kLGEs6MQyVTErLILLdoHxIx07l0qgBZbJdRYCYlVbL1eOc9LVfu4h/vIcWEvpQpRXd6BLpX4yx0VuSgrAE0055Cl471HxtM7yw+Ssp8OxCrlu19RQDBJ6RkaOh7lpsToknKDFlvjQCmAL0bLwY1jk3ji7/QXAX5S/A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR03MB5246.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(136003)(366004)(39830400003)(376002)(396003)(16526019)(8936002)(66556008)(83380400001)(26005)(107886003)(2616005)(956004)(6916009)(86362001)(66476007)(5660300002)(1076003)(6512007)(186003)(6666004)(316002)(966005)(6506007)(66946007)(6486002)(8676002)(36756003)(69590400007)(4326008)(52116002)(2906002)(478600001)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: A6BYmVdxr0qdnpIMAneX4lQZOJHNNbpHgn+QkcRyyDQid8psZrc7G9LWG+fGjrJzeBTM3vKa2NV0mUFOUa2upO6Lo9mE5Al15ZyrjClwjI/3eLaMfDns5IYh/BUilyR+FT4pr3rWWCHq9TwyG9XooQ8aCr1/j5ySe6gEueQjh7+26d6nzTEcdJ9aalwxqYov9+C/7FzKoS0K6VEEEJd/TOerj6j3F/iSfAjz5i9Oo8ox8d00MO2sJtHUY9MWfSkQoESwL6nt4ZAlTZPD/+cqDbAWAnlcZTb6SDG5kTBNT5rETbcsevLhqSbbkFztwmE48J/4oWAWw0J2giJAnqvB+MUPT6zAhSLEMQUv3MYJOt2FazkTFk7FE8+nu+vjpv67xAcmjWWUDMOWUGqWBoylM/b/hU9AzH+Ieirn0VQlcjUppw/cbFwpjDJYMreO5FQN02M9VTCJHueUsZZlz+FgQ+ugmRYNeDSEBBeMAkL2P66gCvM+KTREnT+2RGXkWW0YqrkvTLMq+IgaJUgjhuXfdWzLbL2lrYsUvXHPLY9dra+jzaq8/Fp9HP5464Ps63O3RY4irS4b1N/LDxRXyC6N2OS0MGgJWAcRo+rLWJmZXW4ppRHyJWfebnvfON6U1x8BSCVKWNsYN+utM/IkpIXg3g== X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: cab737b7-fc58-4d53-418a-08d8486539eb X-MS-Exchange-CrossTenant-AuthSource: VE1PR03MB5246.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2020 19:38:07.4990 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ozgM4d3R7v//wB5iX3XHtAB0XtwJx7zljzygsqH1rwWuDa9cWoHh3bbYj5FoKiZEPTshwqrWb39GRo5aeZgLkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB6047 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.1.113; envelope-from=Filip.Bozuta@syrmia.com; helo=EUR02-HE1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/24 15:38:08 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @syrmia.com) Content-Type: text/plain; charset="utf-8" This patch implements functionality for following time64 syscalls: *mq_timedsend_time64() This is a year 2038 safe vairant of syscall: int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout) --send a message to a message queue-- man page: https://www.man7.org/linux/man-pages/man2/mq_timedsend.2.html *mq_timedreceive_time64() This is a year 2038 safe variant of syscall: ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio, const struct timespec *abs_timeout) --receive a message from a message queue-- man page: https://man7.org/linux/man-pages/man3/mq_receive.3.html Implementation notes: These syscalls were implemented in similar ways like 'mq_timedsend()' and 'mq_timedreceive' except that functions 'target_to_host_timespec64()' and 'host_to_target_timespec64()' were used to convert values of 'struct timespec' between host and target. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 58 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4ee1de6e65..3331ec9fea 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -829,11 +829,13 @@ safe_syscall5(int, msgrcv, int, msgid, void *, msgp, = size_t, sz, safe_syscall4(int, semtimedop, int, semid, struct sembuf *, tsops, unsigned, nsops, const struct timespec *, timeout) #endif -#ifdef TARGET_NR_mq_timedsend +#if defined(TARGET_NR_mq_timedsend) || \ + defined(TARGET_NR_mq_timedsend_time64) safe_syscall5(int, mq_timedsend, int, mqdes, const char *, msg_ptr, size_t, len, unsigned, prio, const struct timespec *, timeou= t) #endif -#ifdef TARGET_NR_mq_timedreceive +#if defined(TARGET_NR_mq_timedreceive) || \ + defined(TARGET_NR_mq_timedreceive_time64) safe_syscall5(int, mq_timedreceive, int, mqdes, char *, msg_ptr, size_t, len, unsigned *, prio, const struct timespec *, time= out) #endif @@ -1243,7 +1245,9 @@ static inline abi_long target_to_host_timespec(struct= timespec *host_ts, } #endif =20 -#if defined(TARGET_NR_clock_settime64) || defined(TARGET_NR_futex_time64) +#if defined(TARGET_NR_clock_settime64) || defined(TARGET_NR_futex_time64) = || \ + defined(TARGET_NR_mq_timedsend_time64) || \ + defined(TARGET_NR_mq_timedreceive_time64) static inline abi_long target_to_host_timespec64(struct timespec *host_ts, abi_ulong target_addr) { @@ -11831,6 +11835,27 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, } return ret; #endif +#ifdef TARGET_NR_mq_timedsend_time64 + case TARGET_NR_mq_timedsend_time64: + { + struct timespec ts; + + p =3D lock_user(VERIFY_READ, arg2, arg3, 1); + if (arg5 !=3D 0) { + if (target_to_host_timespec64(&ts, arg5)) { + return -TARGET_EFAULT; + } + ret =3D get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, &= ts)); + if (!is_error(ret) && host_to_target_timespec64(arg5, &ts)= ) { + return -TARGET_EFAULT; + } + } else { + ret =3D get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, N= ULL)); + } + unlock_user(p, arg2, arg3); + } + return ret; +#endif =20 #ifdef TARGET_NR_mq_timedreceive case TARGET_NR_mq_timedreceive: @@ -11858,6 +11883,33 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, } return ret; #endif +#ifdef TARGET_NR_mq_timedreceive_time64 + case TARGET_NR_mq_timedreceive_time64: + { + struct timespec ts; + unsigned int prio; + + p =3D lock_user(VERIFY_READ, arg2, arg3, 1); + if (arg5 !=3D 0) { + if (target_to_host_timespec64(&ts, arg5)) { + return -TARGET_EFAULT; + } + ret =3D get_errno(safe_mq_timedreceive(arg1, p, arg3, + &prio, &ts)); + if (!is_error(ret) && host_to_target_timespec64(arg5, &ts)= ) { + return -TARGET_EFAULT; + } + } else { + ret =3D get_errno(safe_mq_timedreceive(arg1, p, arg3, + &prio, NULL)); + } + unlock_user(p, arg2, arg3); + if (arg4 !=3D 0) { + put_user_u32(prio, arg4); + } + } + return ret; +#endif =20 /* Not implemented for now... */ /* case TARGET_NR_mq_notify: */ --=20 2.25.1