From nobody Mon May 6 12:34:04 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; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1641506871; cv=none; d=zohomail.com; s=zohoarc; b=LVxflp8AufU8BC3CsAxdt9rxDV4zX/zH/BsfcpXS4IX3pZwAeTG9xtJYAdWtU3BYGXSXIY3vF8Uq5xMYv9jr1Tczf4NOegWfLwc8tOvOtDkTCNmuqAbc25pzZu8Ld0wxMOTtFQ8SM4Gt/ZIOHiS6n1Q3FQRg1FA8Rb9wbioj6B4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641506871; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=5IlEkjJ+ofJj0s6IViJPQp6sFty9w8jzIZpJGSxhSHM=; b=O/Q0Veg7p5/H69erCTqBoF9JV/mZcNI+a8Va4s2U89X3e3+9X6YZUDhCGGeXJwmtrcVc4Qbmq+qboHrybBN3rm+rJ9HFiscPycWnhv+xwKkaMy5rNst7veAtrvvyJAol57lgnvlqa8avAjnube7oUQ/VccSx0puj7BGR7xv9qu8= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641506871114449.3226593963849; Thu, 6 Jan 2022 14:07:51 -0800 (PST) Received: from localhost ([::1]:60964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5avF-0002JK-HU for importer@patchew.org; Thu, 06 Jan 2022 17:07:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3imbXYQcKCskAt2896tv33v0t.r315t19-stAt0232v29.36v@flex--venture.bounces.google.com>) id 1n5auQ-0001cy-6P for qemu-devel@nongnu.org; Thu, 06 Jan 2022 17:06:58 -0500 Received: from [2607:f8b0:4864:20::b4a] (port=52895 helo=mail-yb1-xb4a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3imbXYQcKCskAt2896tv33v0t.r315t19-stAt0232v29.36v@flex--venture.bounces.google.com>) id 1n5auO-0004IU-J8 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 17:06:57 -0500 Received: by mail-yb1-xb4a.google.com with SMTP id u130-20020a254788000000b0060a9645f781so7612976yba.19 for ; Thu, 06 Jan 2022 14:06:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=5IlEkjJ+ofJj0s6IViJPQp6sFty9w8jzIZpJGSxhSHM=; b=P/8tnCznF5ncUi1FaT6Hl5/UTWqvO7VUfhc/bkpuNH5aZjTYBt9aJZ90LsIVS0TNRh sSwWUdAQe7UwDneyEX2SftJq3w/uV1yY8Dna8zhzApbHYokdY/N0QZrhGc0Jt6fNbJHK 6UKKkhWISex+cbbzYJYyUzOj+a0c028mgx9IfT3PaxkrYLT9yD3RUalt219TCoZWcscE 2n0kWDKvnCzufkGLuhjHzXuljNZcG7UqxuR8A5eF/NU/XfUpvkttDBblozDf/URCfyWj 9zegMiu6UWXqRwiTvOGunZ+xxT37InTs10ojXjHT7DdbZsOmQsX4BV3WsuOL7SaLBjdb dyOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=5IlEkjJ+ofJj0s6IViJPQp6sFty9w8jzIZpJGSxhSHM=; b=CwNv4m5f6LeNZ8Hqf+PQVkG1JwG43Y+kZg2OERwAmwlwUfUXeWI8fG1ucvQQ4M8WPI LLgeh4kLiG4KCHdSZA/syag5bhx/lOD/L7JPvJldwF0iO/cWsZR2kcZPq6crzUhJ5b5l MkVl4eEUpSQYh1Y11ZXaJ6FUu42UVssBLa6ao14eJQMB0ffSST8QJwshD4djdhQOaJKh ff1v8+PfNx5N7QL0B49UurSi9u+NWzrsjOpMn2K20cs4V2bNBm3N60WqZc+VS+OvMNRo J5eirModlQEWF4baagTecoGFfFhYln0EdRHYcRxO7nvGrUF4n8RrSdW0nyz/iC+1WkjZ NzYQ== X-Gm-Message-State: AOAM532kdvyzty+J3EYhYlYxpNuqFF+E1qE11vcFn4G+JEDKnMHiWQGc SYZyjWCxJhmVmXNf3aCFTdJPeuB2zsdW X-Google-Smtp-Source: ABdhPJzTYsWBUGdK72VvINl7XaD0PKLJ71mjf+qeZuZNJdzndAMby8QNmSvqOW5KMKvoINhM7keokK5HEni1 X-Received: from venture.svl.corp.google.com ([2620:15c:2a3:200:9986:338a:477f:1df7]) (user=venture job=sendgmr) by 2002:a05:6902:154d:: with SMTP id r13mr43465529ybu.314.1641506442894; Thu, 06 Jan 2022 14:00:42 -0800 (PST) Date: Thu, 6 Jan 2022 14:00:38 -0800 Message-Id: <20220106220038.3658586-1-venture@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.34.1.448.ga2b2bfdf31-goog Subject: [PATCH] linux-user: rt_sigprocmask, check read perms first From: Patrick Venture To: laurent@vivier.eu Cc: qemu-devel@nongnu.org, Shu-Chun Weng , Patrick Venture X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::b4a (failed) 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=2607:f8b0:4864:20::b4a; envelope-from=3imbXYQcKCskAt2896tv33v0t.r315t19-stAt0232v29.36v@flex--venture.bounces.google.com; helo=mail-yb1-xb4a.google.com X-Spam_score_int: -87 X-Spam_score: -8.8 X-Spam_bar: -------- X-Spam_report: (-8.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1641506872343100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Shu-Chun Weng Linux kernel does it this way (checks read permission before validating `ho= w`) and the latest version of ABSL's `AddressIsReadable()` depends on this behavior. c.f. https://github.com/torvalds/linux/blob/9539ba4308ad5bdca6cb41c7b73cbb= 9f796dcdd7/kernel/signal.c#L3147 Reviewed-by: Patrick Venture Signed-off-by: Shu-Chun Weng --- linux-user/syscall.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ce9d64896c..3070d31f34 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9491,6 +9491,11 @@ static abi_long do_syscall1(void *cpu_env, int num, = abi_long arg1, } =20 if (arg2) { + if (!(p =3D lock_user(VERIFY_READ, arg2, sizeof(target_sig= set_t), 1))) + return -TARGET_EFAULT; + target_to_host_sigset(&set, p); + unlock_user(p, arg2, 0); + set_ptr =3D &set; switch(how) { case TARGET_SIG_BLOCK: how =3D SIG_BLOCK; @@ -9504,11 +9509,6 @@ static abi_long do_syscall1(void *cpu_env, int num, = abi_long arg1, default: return -TARGET_EINVAL; } - if (!(p =3D lock_user(VERIFY_READ, arg2, sizeof(target_sig= set_t), 1))) - return -TARGET_EFAULT; - target_to_host_sigset(&set, p); - unlock_user(p, arg2, 0); - set_ptr =3D &set; } else { how =3D 0; set_ptr =3D NULL; --=20 2.34.1.448.ga2b2bfdf31-goog