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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 955BEFA3740 for ; Tue, 1 Nov 2022 01:47:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229881AbiKABrJ (ORCPT ); Mon, 31 Oct 2022 21:47:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbiKABrJ (ORCPT ); Mon, 31 Oct 2022 21:47:09 -0400 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0929417059; Mon, 31 Oct 2022 18:47:07 -0700 (PDT) Received: from letrec.thunk.org (guestnat-104-133-8-97.corp.google.com [104.133.8.97] (may be forged)) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 2A11ks0o027540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Oct 2022 21:46:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1667267217; bh=K7F7eAuVL6eJwWHS+KAn77FNAn3sfayK8RIGACJmqzs=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=HhE/pQEUvwvAlquMRH039fGiNRskX+pEammhnhkH56kYXDEX4Zhwg1QPnpA5ZpQrN G2f4nrsBFPD+gXITYMO4YRhrrPTzV1mTzpTgIl/EC+bGmEL6haAeS/Htc1fLjy2sF3 zgJ4mdld+opJURk+t0hri19lf/ZwFUw8p2k8Av7cJ+DDwgRepY8j0FSgosRi/ePh23 E4762KLk9Uj+2DaN6C5CnTMYaTrPYm+ksJwn3dJaXTzntC2hG9PQHa5OMKhGTG0RIb rpr7bENmcrC5AsLs91y60MlV4s6IAjs7imXZwAU1w7YqQ3VXnqwkmJq5BhIFGuZA0+ 3LsUrlLQWSi1A== Received: by letrec.thunk.org (Postfix, from userid 15806) id 064888C2A08; Mon, 31 Oct 2022 21:46:54 -0400 (EDT) Date: Mon, 31 Oct 2022 21:46:53 -0400 From: "Theodore Ts'o" To: Szabolcs Nagy Cc: linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: linux interprets an fcntl int arg as long Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On Mon, Oct 31, 2022 at 12:44:59PM +0000, Szabolcs Nagy wrote: > and such fcntl call can happen with c code that just passes > F_SEAL_WRITE since it is an int and e.g. with aarch64 pcs rules > it is passed in a register where top bits can be non-zero > (unlikely in practice but valid). In Linux's aarch64 ABI, an int is a 4-byte value. It is *not* an 8-byte value. So passing in "F_SEAL_WRITE | 0xF00000000" as an int (as in your example) is simply not valid thing for the userspace program to do. Now, if there is a C program which has "int c = F_SEAL_WRITE", if the PCS allows the compiler to pass a function paramter c --- for example f(a, b, c) --- where the 4-byte paramter 'c' is placed in a 64-bit register where the high bits of the 64-bit register contains non-zero garbage values, I would argue that this is a bug in the PCS and/or the compiler. - Ted 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F0B93FA3741 for ; Tue, 1 Nov 2022 01:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lry7B2oXrdSpeiM2NSqv+/QTCBNnxKnfDB/D61etnls=; b=WhjX6EFsMiixhp 1b1+moZxwpkwEJ7TkVFM7ceaFG3EXM3NaozB0i1M52MTjQ8HoZsOI7Sbz5ydkS6d6IJugo8TRkF8I cpkMOKkF071xrWWAbG3hMMphfVdwIekpO7CR5cVGs6TgYoXEr9UODXvHytrzAdfbRD26fFcv6f5B4 CcpbSuiSiLeMwSddrl/Yq2bS0s/0g8+1BgVu5k+7zDya5vKinJy21FDOxZeIr/IVGu0w03WfKKN2h CeJUgYBwVnthV9UxcNmZaeM8iqhBsM+Kl4UOlJ1b02M/uOG40zDwp5mOoXxnMZHknuUjBAFhFaYbi kRQHEF4oSPXpoXwZIiAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1opgMt-000CYi-1r; Tue, 01 Nov 2022 01:47:07 +0000 Received: from outgoing-auth-1.mit.edu ([18.9.28.11] helo=outgoing.mit.edu) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1opgMp-000CNK-J7 for linux-arm-kernel@lists.infradead.org; Tue, 01 Nov 2022 01:47:05 +0000 Received: from letrec.thunk.org (guestnat-104-133-8-97.corp.google.com [104.133.8.97] (may be forged)) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 2A11ks0o027540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Oct 2022 21:46:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1667267217; bh=K7F7eAuVL6eJwWHS+KAn77FNAn3sfayK8RIGACJmqzs=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=HhE/pQEUvwvAlquMRH039fGiNRskX+pEammhnhkH56kYXDEX4Zhwg1QPnpA5ZpQrN G2f4nrsBFPD+gXITYMO4YRhrrPTzV1mTzpTgIl/EC+bGmEL6haAeS/Htc1fLjy2sF3 zgJ4mdld+opJURk+t0hri19lf/ZwFUw8p2k8Av7cJ+DDwgRepY8j0FSgosRi/ePh23 E4762KLk9Uj+2DaN6C5CnTMYaTrPYm+ksJwn3dJaXTzntC2hG9PQHa5OMKhGTG0RIb rpr7bENmcrC5AsLs91y60MlV4s6IAjs7imXZwAU1w7YqQ3VXnqwkmJq5BhIFGuZA0+ 3LsUrlLQWSi1A== Received: by letrec.thunk.org (Postfix, from userid 15806) id 064888C2A08; Mon, 31 Oct 2022 21:46:54 -0400 (EDT) Date: Mon, 31 Oct 2022 21:46:53 -0400 From: "Theodore Ts'o" To: Szabolcs Nagy Cc: linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: linux interprets an fcntl int arg as long Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221031_184704_059087_2D6DD09C X-CRM114-Status: GOOD ( 13.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Oct 31, 2022 at 12:44:59PM +0000, Szabolcs Nagy wrote: > and such fcntl call can happen with c code that just passes > F_SEAL_WRITE since it is an int and e.g. with aarch64 pcs rules > it is passed in a register where top bits can be non-zero > (unlikely in practice but valid). In Linux's aarch64 ABI, an int is a 4-byte value. It is *not* an 8-byte value. So passing in "F_SEAL_WRITE | 0xF00000000" as an int (as in your example) is simply not valid thing for the userspace program to do. Now, if there is a C program which has "int c = F_SEAL_WRITE", if the PCS allows the compiler to pass a function paramter c --- for example f(a, b, c) --- where the 4-byte paramter 'c' is placed in a 64-bit register where the high bits of the 64-bit register contains non-zero garbage values, I would argue that this is a bug in the PCS and/or the compiler. - Ted _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel