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 5350DC433FE for ; Sat, 19 Nov 2022 02:28:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234918AbiKSC2W (ORCPT ); Fri, 18 Nov 2022 21:28:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236007AbiKSC0l (ORCPT ); Fri, 18 Nov 2022 21:26:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C085629C95; Fri, 18 Nov 2022 18:16:16 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 6958DB82672; Sat, 19 Nov 2022 02:16:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E2ABC4347C; Sat, 19 Nov 2022 02:16:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668824174; bh=mba1F/j+7n5C0gfxfn5N40P/edJxLx43upNjOueW8XM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s7T1F5BFR4X2Yse013gdLEnSmKBC0qNkbzfflAhRdT9bb9tZ5z3LQqf98E5a0bhbE dtAyuxrqQ+5yIzNpn0NZGLnTsZGbaCnK6zBb50xFjt/9PtP75itgKA6VW8WA3Fjoeg 22ljVRqWOi16PmkgSuq5aG5FmD3CXv3LNhXxmGL5TGdwerlSLwIa9yZ5ZtTQPK9I8j ZnBNw21a9zIivmM+PTTORp5PAqb6EMse+uRD2VRNkv7JhIwqPYySDlA1JOA3EqMH1Z PZ3fy1kxz6/QqT9JearL15u3aeyh+6JY6q+RwQhxK/zORslSY5/ymNtmlFAhcE5+zh li8PcxwFiLuQg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Gaosheng Cui , Paul Moore , Sasha Levin , eparis@redhat.com, linux-audit@redhat.com Subject: [PATCH AUTOSEL 4.19 2/8] audit: fix undefined behavior in bit shift for AUDIT_BIT Date: Fri, 18 Nov 2022 21:16:03 -0500 Message-Id: <20221119021610.1775469-2-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221119021610.1775469-1-sashal@kernel.org> References: <20221119021610.1775469-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gaosheng Cui [ Upstream commit 986d93f55bdeab1cac858d1e47b41fac10b2d7f6 ] Shifting signed 32-bit value by 31 bits is undefined, so changing significant bit to unsigned. The UBSAN warning calltrace like below: UBSAN: shift-out-of-bounds in kernel/auditfilter.c:179:23 left shift of 1 by 31 places cannot be represented in type 'int' Call Trace: dump_stack_lvl+0x7d/0xa5 dump_stack+0x15/0x1b ubsan_epilogue+0xe/0x4e __ubsan_handle_shift_out_of_bounds+0x1e7/0x20c audit_register_class+0x9d/0x137 audit_classes_init+0x4d/0xb8 do_one_initcall+0x76/0x430 kernel_init_freeable+0x3b3/0x422 kernel_init+0x24/0x1e0 ret_from_fork+0x1f/0x30 Signed-off-by: Gaosheng Cui [PM: remove bad 'Fixes' tag as issue predates git, added in v2.6.6-rc1] Signed-off-by: Paul Moore Signed-off-by: Sasha Levin --- include/uapi/linux/audit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h index 818ae690ab79..b163911b1d39 100644 --- a/include/uapi/linux/audit.h +++ b/include/uapi/linux/audit.h @@ -177,7 +177,7 @@ #define AUDIT_MAX_KEY_LEN 256 #define AUDIT_BITMASK_SIZE 64 #define AUDIT_WORD(nr) ((__u32)((nr)/32)) -#define AUDIT_BIT(nr) (1 << ((nr) - AUDIT_WORD(nr)*32)) +#define AUDIT_BIT(nr) (1U << ((nr) - AUDIT_WORD(nr)*32)) #define AUDIT_SYSCALL_CLASSES 16 #define AUDIT_CLASS_DIR_WRITE 0 -- 2.35.1