From patchwork Tue May 18 05:31:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 441160 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp1806718jac; Mon, 17 May 2021 23:26:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxXpFD3oSOVm2fTqahtu07PH8iRvLGHWMrva7jc73hidLsSdLbk09hCqrCglVnWe3v/1up X-Received: by 2002:a05:620a:208a:: with SMTP id e10mr3914721qka.112.1621319199407; Mon, 17 May 2021 23:26:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621319199; cv=none; d=google.com; s=arc-20160816; b=Ma8ab44ZtwPmUbSJRJYDFGlRJjPryjfdeRrB2MFRQRynhJ7VYXKZ3qqj5gzOCDJiXc H6mQf3+NEnB3tBpFOla7qLTux++Vstd6iQ95KSf5WLftYIQurW+QgJbTttgRJjJTWRvs 197aSCccoHqe6KWMWUZE7Wuf9ZlhZMutnLku+hM4ao6igpVSiakMOyS2J356XeSBQtbG JPhJBeduJjdMyKTMHSsihzTNhVhj58wqz5QuJ/qZAoHH5AEszV2/BGs5EPPm8tQq3AGD oNHeQsN1n2sFOlNUJHcClpyoxZsvQ8ZqRxiTJoWS2IVQYpnzGtPU4ZDSA8u4Bmi2tMRP /a/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from; bh=+buWlw1rGnP1RkVvsXNxp6KkzCSwGW3LfoTCKFY28iE=; b=Dh34xruoDDZVgMLey3gXPOGct0f2j9FHZuSNZACWG9a32xznPZehZ8JrPXND3Z8DD3 6E6BNmJ/cS16UngtnDxfhWUwTG3u0e9kpgqjdPzqVyDAZhxWPS6uifaIUKp/kTmjdB8p ablUS1YWeM2uLewB2q/ufMuRmhEWpbjw1/Wkxi/hfwBuGUtHdnHlCRKMxc/jKwAZQi7q 4NBIgci20mlcInhVnkWbfGzaaTdNyKit+74iCVtYzfNmvqgrksWTr4z4LXBHVVwE2BUS AKOWzRBNEC0lmZud3SktBBokG23LFDo8Nx23ZvQZMu+zG+oXG0e+ubqag7Ie1Ftel6Eu yKpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o16si7681065qtv.66.2021.05.17.23.26.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 May 2021 23:26:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:56680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1litBe-0003VK-Ni for patch@linaro.org; Tue, 18 May 2021 02:26:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lisKw-00085N-9X for qemu-devel@nongnu.org; Tue, 18 May 2021 01:32:10 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:40853) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lisKo-0007B7-Ew for qemu-devel@nongnu.org; Tue, 18 May 2021 01:32:09 -0400 Received: from quad ([82.142.31.78]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M9Ib1-1lnXQl1NFX-006M81; Tue, 18 May 2021 07:32:00 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 53/59] linux-user: Pass ka_restorer to do_sigaction Date: Tue, 18 May 2021 07:31:25 +0200 Message-Id: <20210518053131.87212-54-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210518053131.87212-1-laurent@vivier.eu> References: <20210518053131.87212-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:u0DZmha5GcjAO88SvCoHsHfehkDLTONIUtdiqV69nf58rJi/J5n JLXBDenbZtCaKAQ4in73uYzSOuZdgaywFOGr/E9RLBp1R68h3WGby6mtqHccIqKisGSBJs2 1B4mtrqPSMP9EndJYk+K6oVzj5LGzTtK1w4k/rdh+HKQeHuXjK/lze6PB1i5pDN+rFY5Inn IThiJ/qJA85gvKdfAVBaw== X-UI-Out-Filterresults: notjunk:1; V03:K0:zg2Kb7W5opU=:YhUDY3QU5cBVWYuRfmIutZ Fe7AXK2240mXXNp1qnnp4NrVbAxj51bs/s0qYOjHdD8k5n2IZvEcOZU1hFAam+DFU7rYm5C7y 7PSqgDTAvP0QXcYuK2d1ibUh1v82pldLKq/zfurWgBVtQr89BgHaYDrRtFNHzwUGdFEJJmSuM c3MzRLFP97VPutrE7GXinj0zyK7ulvJxurORt5S8x5ME+9WbGePmFVvwWO42E+mWgpLhwCHiO Qav3mfraymHlTpYkyrCpqe8fdcSe8BmV3NG3tIUC6LMSuPRj/E4/SOfFOQGh1JqspgP7eSRHZ Wlp9l9Okm1esXQ+JwIar49Hep6lvenY0H7hB7PL/hji2ytQuKV6tuVwqMkBReFddhM/JtNEZp mRRkX+sn7iXIwDRtjoLrblF+fhk+Jr4chWGm/ctgZ93qfA603jUcXCpEaUXAVo0vW/gvvdCoZ dZct71DUViTdF+lO4lVsNFhqEjf9gsKuIUtAO4jUoOJW+yQ3Qxt6Dm4fnzfWD+2dSeZe4jGA9 OD2t4/tZoGS+TEcHynv0Mc= Received-SPF: none client-ip=212.227.126.130; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The value of ka_restorer needs to be saved in sigact_table. At the moment, the attempt to save it in do_syscall is improperly clobbering user memory. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée Message-Id: <20210422230227.314751-4-richard.henderson@linaro.org> [lv: remove tab] Signed-off-by: Laurent Vivier --- linux-user/signal.c | 5 ++++- linux-user/syscall.c | 19 ++++++------------- linux-user/syscall_defs.h | 2 +- 3 files changed, 11 insertions(+), 15 deletions(-) -- 2.31.1 diff --git a/linux-user/signal.c b/linux-user/signal.c index cbd80b28cf5a..9016896dcda0 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -842,7 +842,7 @@ abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, /* do_sigaction() return target values and host errnos */ int do_sigaction(int sig, const struct target_sigaction *act, - struct target_sigaction *oact) + struct target_sigaction *oact, abi_ulong ka_restorer) { struct target_sigaction *k; struct sigaction act1; @@ -875,6 +875,9 @@ int do_sigaction(int sig, const struct target_sigaction *act, __get_user(k->sa_flags, &act->sa_flags); #ifdef TARGET_ARCH_HAS_SA_RESTORER __get_user(k->sa_restorer, &act->sa_restorer); +#endif +#ifdef TARGET_ARCH_HAS_KA_RESTORER + k->ka_restorer = ka_restorer; #endif /* To be swapped in target_to_host_sigset. */ k->sa_mask = act->sa_mask; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 82736540ebcc..15b3af257bef 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8989,11 +8989,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, act._sa_handler = old_act->_sa_handler; target_siginitset(&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags; - act.ka_restorer = 0; unlock_user_struct(old_act, arg2, 0); pact = &act; } - ret = get_errno(do_sigaction(arg1, pact, &oact)); + ret = get_errno(do_sigaction(arg1, pact, &oact, 0)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) return -TARGET_EFAULT; @@ -9017,7 +9016,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, pact = NULL; } - ret = get_errno(do_sigaction(arg1, pact, &oact)); + ret = get_errno(do_sigaction(arg1, pact, &oact, 0)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) @@ -9040,15 +9039,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_siginitset(&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags; act.sa_restorer = old_act->sa_restorer; -#ifdef TARGET_ARCH_HAS_KA_RESTORER - act.ka_restorer = 0; -#endif unlock_user_struct(old_act, arg2, 0); pact = &act; } else { pact = NULL; } - ret = get_errno(do_sigaction(arg1, pact, &oact)); + ret = get_errno(do_sigaction(arg1, pact, &oact, 0)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) return -TARGET_EFAULT; @@ -9085,11 +9081,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, act._sa_handler = rt_act->_sa_handler; act.sa_mask = rt_act->sa_mask; act.sa_flags = rt_act->sa_flags; - act.ka_restorer = arg5; unlock_user_struct(rt_act, arg2, 0); pact = &act; } - ret = get_errno(do_sigaction(arg1, pact, &oact)); + ret = get_errno(do_sigaction(arg1, pact, &oact, arg5)); if (!is_error(ret) && arg3) { if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0)) return -TARGET_EFAULT; @@ -9104,6 +9099,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_ulong sigsetsize = arg5; #else target_ulong sigsetsize = arg4; + target_ulong restorer = 0; #endif struct target_sigaction *act; struct target_sigaction *oact; @@ -9115,9 +9111,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) { return -TARGET_EFAULT; } -#ifdef TARGET_ARCH_HAS_KA_RESTORER - act->ka_restorer = restorer; -#endif } else { act = NULL; } @@ -9128,7 +9121,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } else oact = NULL; - ret = get_errno(do_sigaction(arg1, act, oact)); + ret = get_errno(do_sigaction(arg1, act, oact, restorer)); rt_sigaction_fail: if (act) unlock_user_struct(act, arg2, 0); diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 693d4f3788d4..e4aaf8412f56 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -492,7 +492,7 @@ void target_to_host_old_sigset(sigset_t *sigset, const abi_ulong *old_sigset); struct target_sigaction; int do_sigaction(int sig, const struct target_sigaction *act, - struct target_sigaction *oact); + struct target_sigaction *oact, abi_ulong ka_restorer); #include "target_signal.h"