Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7813809rwb; Mon, 12 Dec 2022 21:02:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Zr5rYogFj8jJOWjsbHZywoqWlfazyvn6fRPwyotQz0pV6fx6NSM3lvOKmZQDGsXAmn20t X-Received: by 2002:a17:906:5208:b0:7a5:e8d9:a305 with SMTP id g8-20020a170906520800b007a5e8d9a305mr15965250ejm.70.1670907746650; Mon, 12 Dec 2022 21:02:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670907746; cv=none; d=google.com; s=arc-20160816; b=I+RUjTiUKNEETq2C7DCH1f5//jOe+aOgIRIAaBvwbiqmHe76q5pERQtX7+urcYm9gX 4BMSCpQx65wR+tSg1um2eZfEeuq+LKMpzs1N+kRIkp7rw29hiP9uTeS/WU6bW2KlU99d M+P4Q3BDQZdHUXWsyKxc1D4fpc/wH8ofPa/zota5ub0QkzJ2ahRq0/mAPShCEUeQCOaM YvCg4fkieUeM8LdFOAshLc9hl94FO6r6T3YbsQAbEAJ6uFhpxYXZyAAAGeNzFvnWefYN 11UuGAHT4vnoGqiN/YsGOXx6/DqQqEC+TcJas8P4Q6UmMFwBn6ka8VFwcxCDypxylGiN 0DsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=idiNl1j/MK9FVPg4fRiGJYQoEIte4QmSOGFnBA0X0+I=; b=pURypMYLLR4oRgcBq7FitR1lU7MR3h4Lt9ATH3mFrw3q5pg/cc93XbD3fW5un0o2uB QpzdNxbSaDUIbg6kkIQgOFONbY6f1sUwWUn4ItvHlFNtRmgfehYv538j32P6v5ovKvSU 0GDA1jxxUBRkvI+Rf+5t5mpdIj7rssJmseH459ltWqH8vqln1qBGXH3l+ARfSE2L7r/k T0o3NQLcgAo97ndJHmwxO3vpZAn1as7cMOsEE9IXb9Y9Jrj5q9rRvdnCfVIxffIFohVL tndGdgneXk7IelZHsWluNipPPgrlgILmW6112XidhYfG//fJGa0DWUfCH9Ur0kLuoLmh QjHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=UJfike5h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xd2-20020a170907078200b0073d9c412570si7499456ejb.785.2022.12.12.21.02.03; Mon, 12 Dec 2022 21:02:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=UJfike5h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233936AbiLME0o (ORCPT + 74 others); Mon, 12 Dec 2022 23:26:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230052AbiLME0n (ORCPT ); Mon, 12 Dec 2022 23:26:43 -0500 Received: from forward502o.mail.yandex.net (forward502o.mail.yandex.net [37.140.190.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 911BD1AD83 for ; Mon, 12 Dec 2022 20:26:41 -0800 (PST) Received: from vla1-62318bfe5573.qloud-c.yandex.net (vla1-62318bfe5573.qloud-c.yandex.net [IPv6:2a02:6b8:c0d:3819:0:640:6231:8bfe]) by forward502o.mail.yandex.net (Yandex) with ESMTP id 04B3125D449C; Tue, 13 Dec 2022 07:18:29 +0300 (MSK) Received: by vla1-62318bfe5573.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id QIV8sJaY6uQ1-fxO2YiFE; Tue, 13 Dec 2022 07:18:29 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1670905109; bh=idiNl1j/MK9FVPg4fRiGJYQoEIte4QmSOGFnBA0X0+I=; h=In-Reply-To:Cc:Date:References:To:Subject:Message-ID:From; b=UJfike5hU+OUASPhqXOXg2XO+coxYD+S30dgzcIw8DiDDmUZIKacEoPus5hCxqS8V zDe1+ZlqOjcAkC27qWRohXg/yCdSDCUjnEkJKXN9oj++xGYQn0eSxMWuJM3tVWe1CA LKe0WCOYeBq1jr4bBcXTyxHqAFSDJrE0pbiT+BU8= Authentication-Results: vla1-62318bfe5573.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Content-Type: multipart/mixed; boundary="------------pvK00QZuIngFMzJlcaJw6ZqH" Message-ID: <6ecb3a57-f552-500f-c853-023f95304bc2@yandex.ru> Date: Tue, 13 Dec 2022 09:18:25 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: strange behavior with sigreturn() to 32bit Content-Language: en-US To: Thomas Gleixner , linux-kernel@vger.kernel.org Cc: x86@kernel.org, luto@kernel.org, "Eric W. Biederman" , Andrew Cooper References: <85ca9ae1-d319-ee77-4a71-bc9c7874f2cb@yandex.ru> <87zgbsno9y.ffs@tglx> From: stsp In-Reply-To: <87zgbsno9y.ffs@tglx> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a multi-part message in MIME format. --------------pvK00QZuIngFMzJlcaJw6ZqH Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, 13.12.2022 05:24, Thomas Gleixner пишет: > Your observation that running this under GDB changes the behaviour of > the error is completely correct because BX/SI are subject to context. So > depending where the combo points to it results in random behaviour. > > So nothing strange to see here, really. You got what you asked for: Thanks for checking, so some problems were not valid ones, but lets remove the mov to eax from the test. Without gdb: err=0 trapno=d ax=0 ip=100000003 With gdb: err=18a trapno=d ax=0 ip=403003 Without high RIP poison: err=18a trapno=d ax=0 ip=3 This case is perfectly valid now, thanks. Without high RIP poison and with gdb: err=18a trapno=d ax=0 ip=403003 So under gdb we still see the wrong RIP value and high RIP part breaks things only without gdb (gdb "fixes" it). Attaching the new diff that doesn't do the mov to eax, so should be correct now. --------------pvK00QZuIngFMzJlcaJw6ZqH Content-Type: text/x-patch; charset=UTF-8; name="a.diff" Content-Disposition: attachment; filename="a.diff" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL3Rvb2xzL3Rlc3Rpbmcvc2VsZnRlc3RzL3g4Ni9zaWdyZXR1cm4uYyBi L3Rvb2xzL3Rlc3Rpbmcvc2VsZnRlc3RzL3g4Ni9zaWdyZXR1cm4uYwppbmRleCA1ZDc5NjFh NWY3ZjYuLjYwNTMyZmQ4MjRlNCAxMDA2NDQKLS0tIGEvdG9vbHMvdGVzdGluZy9zZWxmdGVz dHMveDg2L3NpZ3JldHVybi5jCisrKyBiL3Rvb2xzL3Rlc3Rpbmcvc2VsZnRlc3RzL3g4Ni9z aWdyZXR1cm4uYwpAQCAtMTAxLDkgKzEwMSwxMyBAQCBhc20gKCIucH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