From patchwork Thu Feb 27 21:32:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 13995237 X-Patchwork-Delegate: plautrba@redhat.com Received: from tarta.nabijaczleweli.xyz (tarta.nabijaczleweli.xyz [139.28.40.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A2FC26F460 for ; Thu, 27 Feb 2025 21:34:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=139.28.40.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740692078; cv=none; b=unCTzVD3zNonU+OgjHeI2M1QlHLTZi1C+meIQG+q07Odie+cqOR0eyGmGLVueWMrGThcz4I6ZNl0XSTbo+DRTSoc23HH+jj2aT6Q2mn7qc1Ajs8YG9lmzOWzXWy2Pwvhbxc7ZLZmgBdAgmmbzX04hr269bZBs680GaUi1Sbk+rU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740692078; c=relaxed/simple; bh=ya1qk9lYYTZfO9ff2Xk9gnLhfnlryoX7HPX0orHoh6c=; h=Date:From:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=bOrtf94WwXetCgnFQut5gbx1Ml/rXIB3tQECuYCSqjNxwLuolg/F4+682sR0tQO5lY7DjX43/sQ58WtWztTsLSB+h2hGlcez00MyKvlQSJfmCMghvazOws628t10F8f2XnF6/8prInL0FCcj5iYd5+ShuSSOYN7TdDxNZhDjHnM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nabijaczleweli.xyz; spf=pass smtp.mailfrom=nabijaczleweli.xyz; dkim=pass (2048-bit key) header.d=nabijaczleweli.xyz header.i=@nabijaczleweli.xyz header.b=NXlxUqXZ; arc=none smtp.client-ip=139.28.40.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nabijaczleweli.xyz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nabijaczleweli.xyz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nabijaczleweli.xyz header.i=@nabijaczleweli.xyz header.b="NXlxUqXZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202405; t=1740691931; bh=ya1qk9lYYTZfO9ff2Xk9gnLhfnlryoX7HPX0orHoh6c=; h=Date:From:Cc:Subject:From; b=NXlxUqXZk5UnvDD+GTJMI/85znNYFwnKKk4O4lH+qN8MNLWJHYmD/iEE1cR8WY9XQ xW5/xWn4wMHSZrUDExoxgtsLH+sv7fOxSU+rFrZFjG9+eKwsit1kSj4UQOr6iBlQLy xghr5j9d2EThNpcNBT7RVkrqzkCxvzH4Z8U2UqZ+6ONUM5FWnayCmdLeW6QVcLkKCZ VPtZ6l5E607RbNe+v17tk0pZwiBdt/3AiCiluyePh+VPLeY2V+ATqhPAXk7v59Boap 4aCHzHry/VgQroB/R3Eae9jN4A1qwXQeMwDRHKq28C7UlNWHLPmzqw0nqm311XjWNv +P+aC1R4y6+Sg== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id CCBC2A35E for ; Thu, 27 Feb 2025 22:32:11 +0100 (CET) Date: Thu, 27 Feb 2025 22:32:11 +0100 From: =?utf-8?b?0L3QsNCx?= Cc: selinux@vger.kernel.org Subject: [PATCH] Don't inject matchpathcon_filespec_add64() ifdef __x86_64__ Message-ID: Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20231221-2-4202cf-dirty As the code notes, it wants to add an /* ABI backwards-compatible shim for non-LFS 32-bit systems */ it tries to detect these with #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64 which is correct with the added precondition that the ino_t /without/ -D_FILE_OFFSET_BITS=64 /was actually/ u32 (i.e. it conflates /all/ ILP32 systems into being non-LFS). This is not the case on x32, for example, which is LFS; thus, the static_assert(sizeof(unsigned long) == sizeof(__ino_t), "inode size mismatch"); assertion fails (__ino_t is the "kernel ino_t" type, which generally corresponds to the kernel's ulong, which is u64 on x32). The correct spelling of the test for this is #if (...) && sizeof(__ino_t) == 4 but this is not statically solvable with the preprocessor. Thus, we need to explcitly special-case this. __x86_64__ indicates one of two ABIs (LP64 (amd64) or ILP32 (x32)), both of which have ino_t=u64, and is the macro used for defining __INO_T_TYPE in the system headers, so it's the best fit here. Fixes: commit 9395cc0322 ("Always build for LFS mode on 32-bit archs.") Closes: #463 Closes: Debian#1098481 Signed-off-by: наб --- libselinux/include/selinux/selinux.h | 2 +- libselinux/src/matchpathcon.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libselinux/include/selinux/selinux.h b/libselinux/include/selinux/selinux.h index f3cf5a20..318e273f 100644 --- a/libselinux/include/selinux/selinux.h +++ b/libselinux/include/selinux/selinux.h @@ -537,7 +537,7 @@ extern int matchpathcon_index(const char *path, with the same inode (e.g. due to multiple hard links). If so, then use the latter of the two specifications based on their order in the file contexts configuration. Return the used specification index. */ -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64 +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64 && !defined(__x86_64__) #define matchpathcon_filespec_add matchpathcon_filespec_add64 #endif extern int matchpathcon_filespec_add(ino_t ino, int specind, const char *file); diff --git a/libselinux/src/matchpathcon.c b/libselinux/src/matchpathcon.c index 51f0e4ff..61f27274 100644 --- a/libselinux/src/matchpathcon.c +++ b/libselinux/src/matchpathcon.c @@ -261,7 +261,7 @@ int matchpathcon_filespec_add(ino_t ino, int specind, const char *file) return -1; } -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64 +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64 && !defined(__x86_64__) /* alias defined in the public header but we undefine it here */ #undef matchpathcon_filespec_add @@ -282,7 +282,7 @@ int matchpathcon_filespec_add(unsigned long ino, int specind, } #else -static_assert(sizeof(unsigned long) == sizeof(ino_t), "inode size mismatch"); +static_assert(sizeof(uint64_t) == sizeof(ino_t), "inode size mismatch"); #endif