From patchwork Thu Mar 20 15:55: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: 14024105 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 3D16321D5B0 for ; Thu, 20 Mar 2025 15:55:25 +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=1742486131; cv=none; b=qLB+g562muW2IvCc7lfq/w7OzriT/W0DYIfxHkMEVZNdZHjtLcXQpMjuyzdoq2DAMc54Q1ZTnzvAvjwtDC7VYgBWw6odKNMOexP5wVaadciWWnW4NpLOPSEzbBPsKwdDChPy3JuyN7L4HbG/hgjO5Vj7gHhoSYm3sMSzScn7Gro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742486131; c=relaxed/simple; bh=SWOBdaWZPRRdaS3EGAaFi7qbv5f9tuMsMBfKjJCL2HA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kpv16PktTx1SAnKxpj7vsdJfnYWRADu9I9sxyD5Bvji6lB5hhMmQpc/yTNDRw9hP9TY8RuZZd2c6/w3qGZoS1ijUKI+utAkU1BNS8Jcub/ZLrR26Sxb6LIvDikr9eHvGieis5xYpeHi1GKZZTgby92Xv5KeOMTnbh8Dm+I+KOKs= 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=Gx50sX28; 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="Gx50sX28" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202405; t=1742486117; bh=SWOBdaWZPRRdaS3EGAaFi7qbv5f9tuMsMBfKjJCL2HA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Gx50sX283Ur5JUpBqYs1n+FUHNhmB5xN6Iqxv6vT0PZ3YdBrkTpklRG6JygL3w3qD +hGpBeLtwaugzib8M1//AFVtj1pcYmpzKJuoNr37SsijG6niIXwW8P435BtGjohxyl 84cIeQpiTUcT41XIFLzqDJr4KKYogCa9agKUce453jcA8HxBWojPXEhGkKi0esRcZj sNh4DCRcRYPCUvAP156XYTT77Cx9z5rpEOi1MbOcbe80RP8LMX0KDFlV8c7BkhVu90 BAlSbqNJdUNzDFVe2mCpCSKk8GHFdMLQMK6fcZ5A6JsW3q95MMTVFV3+odB5T1RDvz D68KxE2cp9Haw== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id A6627C392; Thu, 20 Mar 2025 16:55:17 +0100 (CET) Date: Thu, 20 Mar 2025 16:55:17 +0100 From: =?utf-8?b?0L3QsNCx?= To: selinux@vger.kernel.org Cc: Alba Mendez Subject: [PATCH v3] 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 --- Changes from v2: fix build with USE_LFS=n on non-LFS ILP32 systems (i386) libselinux/include/selinux/selinux.h | 2 +- libselinux/src/matchpathcon.c | 8 ++++++-- 2 files changed, 7 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..a4f65045 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 @@ -280,9 +280,13 @@ int matchpathcon_filespec_add(unsigned long ino, int specind, { return matchpathcon_filespec_add64(ino, specind, file); } +#elif (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) || defined(__INO_T_MATCHES_INO64_T) + +static_assert(sizeof(uint64_t) == sizeof(ino_t), "inode size mismatch"); + #else -static_assert(sizeof(unsigned long) == sizeof(ino_t), "inode size mismatch"); +static_assert(sizeof(uint32_t) == sizeof(ino_t), "inode size mismatch"); #endif