From patchwork Tue Mar 18 22:41:17 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: 14021688 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 71B4F85626 for ; Tue, 18 Mar 2025 22:47:57 +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=1742338082; cv=none; b=kTNJqux6DEXEaWFtoh0gg1CN5yKvR57OnYx5eimPSyJK0EJqE5OxqVW0bQhKWObTrph+hIo4YwWKw5ZU18iYH/I8MYwZt6Cg62UzWnSLz+e21xsn/BqdS9eoSCZuvRxBSDEQH2th/9VlitttVqHa1m3LiFp6lAgPOCgfs2knMSk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742338082; c=relaxed/simple; bh=WQjPRH2t/ii27JdUEkhcOylXY9eARvj78N1HEfZHlpI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hvi/VVF5dqTqY53orBc2IK8xTwJlqUSbwZ2aswkD+1aJz1vh7cTa4UrUaBqG+Ag3HEd79xzPNpn9t8+80sqdIYRWVwMW6O4lpvTto+O29wz14N33OVMCCCEMnRdVGe6X9ScLQHbgU8AuALrPv7NWbsvIwRdf4mZki3DdxFFaFFY= 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=CpZm3FUg; 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="CpZm3FUg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202405; t=1742337677; bh=WQjPRH2t/ii27JdUEkhcOylXY9eARvj78N1HEfZHlpI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CpZm3FUgKUKcPmahxvVGkTAUHFGMnX8zLMc6PDgn5QqbzibHBPeed5NOtc4l2ggsh e44RHMQusQqyi5wYpflQ4l2gUrRwAXhe0VYW0qxOTgXHDfLacKZABUX5GHL0p+f0Kk T2lCoZiQPrqXHAAbzLhXf3jB9i5Cbx7G6rdOX/soxZOezkgDOyDPq6tHFMDZ1FyRzv 0/4s15zAns7q8LKQW4dsV9OF0hdFWqYer63r8i+s6gH02EOfw00aEPJokMgPLYGOXw JFfHp7ZQQgOo08R4N1Z0+5MVMe0GwIty1BvvtU9eP/wPmg2TdaNFErDEAK8ZaFV8ZS KWTi0fet4YjoQ== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 6D6EEBEBA; Tue, 18 Mar 2025 23:41:17 +0100 (CET) Date: Tue, 18 Mar 2025 23:41:17 +0100 From: =?utf-8?b?0L3QsNCx?= To: selinux@vger.kernel.org Cc: Alba Mendez Subject: [PATCH v2] Inject matchpathcon_filespec_add64() if !defined(__INO_T_MATCHES_INO64_T) instead of using __BITS_PER_LONG < 64 as proxy Message-ID: References: Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20231221-2-4202cf-dirty The __INO_T_MATCHES_INO64_T is defined if ino_t would be the same size as ino64_t if -D_FILE_OFFSET_BITS=64 were not defined. This is /exactly/ what /* ABI backwards-compatible shim for non-LFS 32-bit systems */ #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64 is trying to get at, but currently fails because x32/RV32 are "LFS" with 32-bit longs and 64-bit time_ts natively. 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). glibc headers allow us to check the condition we care about directly. Fixes: commit 9395cc0322 ("Always build for LFS mode on 32-bit archs.") Closes: #463 Closes: Debian#1098481 Signed-off-by: наб Cc: Alba Mendez --- 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..f64896b7 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 && !defined(__INO_T_MATCHES_INO64_T) #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..ab7c3090 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 && !defined(__INO_T_MATCHES_INO64_T) /* 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