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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8A69C7EE23 for ; Tue, 23 May 2023 14:14:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58EE4900003; Tue, 23 May 2023 10:14:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5168B900002; Tue, 23 May 2023 10:14:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B870900003; Tue, 23 May 2023 10:14:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2D4B2900002 for ; Tue, 23 May 2023 10:14:02 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B9C611C72AD for ; Tue, 23 May 2023 14:14:01 +0000 (UTC) X-FDA: 80821713882.06.97E2CD5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id 2D8F01003E7 for ; Tue, 23 May 2023 14:10:05 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf05.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684851006; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y2XsXytaVuBtbo5LhzRBIk7KI83cSNJGyp/QLDIwQ7E=; b=pC3FxJPR+laDU9MjHZ3Q+nj/AUCA2olyhldoJB72C4G8fgLD5VZ0OKgMXpfN8nztZF2FcB gQlnc/i1SzRIzHXoKkuiTkDf66PSmatlt1HmfsUvbSTUFXne2HATZzubIEOe84Y/5aBPHc ou8DZ+fyqY3ISEa1z9pXA5m5K5zXU4M= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf05.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684851006; a=rsa-sha256; cv=none; b=x6Xn9rW1Le0nE70NAaRE1mBtVacnLjHZ2+T3DrDstnymfLHm6ALYPlJLKBQgF9NwWVgEM9 amNrLXwZlrVITa2lIIs96ebH6ClM6r2hDofghiLq0FaPn0S1w4IQCV9P6X5c0Hu0KGqslD iI0YTVkTRUobTtjl7pMb8xiCWWMEQmQ= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F11F661949; Tue, 23 May 2023 14:10:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F2AFC433D2; Tue, 23 May 2023 14:10:01 +0000 (UTC) Date: Tue, 23 May 2023 15:09:58 +0100 From: Catalin Marinas To: Alexey Izbyshev Cc: David Hildenbrand , Florent Revest , linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, anshuman.khandual@arm.com, joey.gouly@arm.com, mhocko@suse.com, keescook@chromium.org, peterx@redhat.com, broonie@kernel.org, szabolcs.nagy@arm.com, kpsingh@kernel.org, gthelen@google.com, toiwoton@gmail.com Subject: Re: [PATCH v2 3/5] mm: Make PR_MDWE_REFUSE_EXEC_GAIN an unsigned long Message-ID: References: <20230517150321.2890206-1-revest@chromium.org> <20230517150321.2890206-4-revest@chromium.org> <884d131bbc28ebfa0b729176e6415269@ispras.ru> <3c2e210b75bd56909322e8a3e5086d91@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 2D8F01003E7 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ssztn4k5y8w4rxxaeio5ap5wdh17o6my X-HE-Tag: 1684851005-344380 X-HE-Meta: U2FsdGVkX1/LxK1gAsG2xvEYS6iVNao6SPOOTaQ69ZDU6foTdgjI1ajMAQGDlCqZFbELmcFoZctUIARDhmQIS36DxP/buCwl93aRvjiPY1RMTAJJMmPN9a0vIlYZ5HMioSbMJNZiYTVxYtiAwcM5nxmA940IsFhV9yFwEwoCdBL7yBwoggHauR03HovZQI9M9m7eMPy/1GqThES9b30EFNNWJDUnlwUd+CNOf+CkLv327h1rB9/m75+SBCaNoYDvkgKpnO/uYCtaQm/93PikGVAc+3eirl9SdAupxMN/YyLnmILhnmbdb3irkToJJW4ubh6m3HpbzO/37ppJzB21y2ldjTCDTeQgRT+Mflthq9y4tqdrshqO2MO3YgSnJPnVTZzavzzHUYhu4c61tsxZGKdq4Jd2fHynlPcNR+1LWEi8nySScJLzZIAl878H2v5GCVc/QtGSA8epxotkokm93xGK2ZyaNs5nSg3UiyOO6FYdc1vx3RyxoEmKKhyK4FeqzI59AkRw4vkhactL0nTaHIxAwcjgKPGpchKgqiJIiAJBJX2wKneUbmeD92oDPH4mRTNc4NoQR3VMeRvGTWpE4QTztRSqLfY8HiUwrvYygYD+LsWF2nTLPaPZEczzjXVceOk2EzTf2/r8ZnEga5z2prFKct+MMkwOUUZowRq4MGdmNhc3vcZI1YRUNK3b1Zc6QzobbdjSAdP/RsFiaZKLdpRzIwOJMvPz52olM+2tfYvVzDDrm9F0kmQYL4ErSI0UfqNScNvO8gxXaJ1DrmP7s9227gSuilY/7PLAnhDLNCL8xXbFd/e9woVTjb1wJIQ7oatvuH6jQgn+c102zwu9ctS8SOhMXbTIfJWhFAwPzNiQYKaQCf69CNiV3utY+nWdn+4PDZkINrUED0TgbcEDsLLaxjZAX2HqhBeYueUkoSKEPfhH3eUh6LzN2CUgGV2J8STTXj2z79s9KtCIp7q 62djkel/ fIYs9m+StS9PSLXR3WwZzSpoz2T6HSplRQSj3caZhM3/yIAQjMcRINoLpwcKP99quw6yM0BtFF6hCqc80LTUrjGYFTKbfxhpMBDIN1+kTBF5uPj7R0+flyLutXyVVXEbtj0Iv8WbH+Rv/nfhjYmPlFm9rS326RPflXfWqpkfjIX0j8xBC1pbe2UjNZfo14/zJ1cyjgiUr+wFeEnaTUyrZFw1oOxR+ip/gCxMNGuLQ/dLhiVESVNXBNT+ubM6C3GE+KzxpwN8rbeIAyZaH/Sr8pCViSDDOhgSwBevOg1Kq4h0JeyprA2rDeCDofzyhSi9vfYD4BGAbMrITIjfsN5pQW4/9CDkOBrdLcAp1ni2MJi3CtZd1kIFJOsonbXvvf/nZTeWl0k7KIcTh5Mbwka2j63g332oIi/Ww7uKTFMIfOW1pDEQO+RQKI3dBrISyVDzdU8a4EN5wQAycPo16gpzh55SfusOk8tIJn81Cn+WO5TDkFTIjD3oWnrtmrdT8QKmdEwthVoHxPyn0yKODSYtq8+qhABHkaCuxPYs7Y1BR071I0GPamailOKT1n8Do+TllWQbXvmElo0EDpSuzL7Kstia3hfbo9RdQ4bscStH9H8y3rPd8PoCAG1ek3VA8svLWQUWDv7hE5QCw5LI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, May 23, 2023 at 04:25:45PM +0300, Alexey Izbyshev wrote: > On 2023-05-23 16:07, Catalin Marinas wrote: > > On Tue, May 23, 2023 at 11:12:37AM +0200, David Hildenbrand wrote: > > > Also, how is passing "0"s to e.g., PR_GET_THP_DISABLE reliable? We > > > need arg2 > > > -> arg5 to be 0. But wouldn't the following also just pass a 0 "int" ? > > > > > > prctl(PR_GET_THP_DISABLE, 0, 0, 0, 0) > > > > > > I'm easily confused by such (va_args) things, so sorry for the dummy > > > questions. > > > > Isn't the prctl() prototype in the user headers defined with the first > > argument as int while the rest as unsigned long? At least from the man > > page: > > > > int prctl(int option, unsigned long arg2, unsigned long arg3, > > unsigned long arg4, unsigned long arg5); > > > > So there are no va_args tricks (which confuse me as well). > > > I have explicitly mentioned the problem with man pages in my response to > David[1]. Quoting myself: > > > This stuff *is* confusing, and note that Linux man pages don't even tell > that prctl() is actually declared as a variadic function (and for > ptrace() this is mentioned only in the notes, but not in its signature). Ah, thanks for the clarification (I somehow missed your reply). > The reality: > > * glibc: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sys/prctl.h;h=821aeefc1339b35210e8918ecfe9833ed2792626;hb=glibc-2.37#l42 > > * musl: > https://git.musl-libc.org/cgit/musl/tree/include/sys/prctl.h?h=v1.2.4#n180 > > Though there is a test in the kernel that does define its own prototype, > avoiding the issue: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/sched/cs_prctl_test.c?h=v6.3#n77 At least for glibc, it seems that there is a conversion to unsigned long: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/prctl.c#l28 unsigned long int arg2 = va_arg (arg, unsigned long int); (does va_arg expand to an actual cast?) If the libc passes a 32-bit to a kernel ABI that expects 64-bit, I think it's a user-space bug and not a kernel ABI issue. -- Catalin