Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp542800rwi; Mon, 31 Oct 2022 04:56:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6YP6sG10fuXDXqrlns18ScQQBq35AyymKV686H2oZ7rJeXXQbcthIRyXERuemSJ7pxXK3d X-Received: by 2002:a05:6a00:1947:b0:56c:8c22:799f with SMTP id s7-20020a056a00194700b0056c8c22799fmr13699354pfk.47.1667217410366; Mon, 31 Oct 2022 04:56:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667217410; cv=none; d=google.com; s=arc-20160816; b=cXAC9h2byuY2USmOrTUfSIldZZYvpK9D+Be2VWJJdZFjojfnISu5kk8OAR7U2PcniL GnU2qq0pj/VA2V4NBuJdUE9PkPADe/E6qVPdJwJp6it2jrEsQI9ZNHUupNRDlXAlCeQu TMP4McL2poNVSLEq28yScALkyqAZ96qHG/SoLc2BM7s5ivy0mXsSJxr0jKqQ3PspX+Wt wJ+8PBA0lmGatzIGNazYs8Sc8ANHChwIT8cwuYkpK7bJFSgfxosRsvvZvBUFTLbAJxNc zl1cfunatV9vFGbHewTbMkX5MYB6auSSIfYnwGR9RjOMWOqhm+f305B2oBCG6JcEfKf1 o4lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=sXYLB7/JZU76t+eZ2EnIV6M94wEM87mICf/RdZJrIlE=; b=Fvj0UmzKBVsVDE3WdhkvUKKmBwL1G+LWCCL3gOBtJwOxGry1EpKxbZ7yDfkim9avVQ rn5979LDTjjytrJonSrEvJs4dbzTPNiElVk2T0WS3KTNJC9lL1myOyJ6bmspQpQY1zNZ nQcLVGWgHMn+LZxGu0IZa6IrERvKgXJ0JYb7YK6BuZAeEk+sc5lk1Zm2su0ptPyglnFT GkK4RUDHCP5NMXL5JPP8cOfBH2kS/ILZDO28mXTEudmYXr7hjNpochDhTVTHNxWk/X9g Q+ibgULheJi2BejRd9JW810MkmmHQl2QuQlL98XTcE7FBY6OKLWUm/L+pVPttIvk8y7M wmZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020a170902f38200b00186a16f8d94si7382964ple.77.2022.10.31.04.56.36; Mon, 31 Oct 2022 04:56:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229992AbiJaLjx (ORCPT + 98 others); Mon, 31 Oct 2022 07:39:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230443AbiJaLjt (ORCPT ); Mon, 31 Oct 2022 07:39:49 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3F97E0E8 for ; Mon, 31 Oct 2022 04:39:44 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N19zr1SkPzVj05; Mon, 31 Oct 2022 19:34:48 +0800 (CST) Received: from cgs.huawei.com (10.244.148.83) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 31 Oct 2022 19:39:42 +0800 From: Gaosheng Cui To: , , CC: Subject: [PATCH] mount: fix undefined behavior in bit shift for MS_NOUSER Date: Mon, 31 Oct 2022 19:39:42 +0800 Message-ID: <20221031113942.4183728-1-cuigaosheng1@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.244.148.83] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 fs/namespace.c:3309:14 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 path_mount+0x93/0xd50 init_mount+0x6a/0xa3 devtmpfs_setup+0x47/0x7e devtmpfsd+0x1a/0x50 kthread+0x126/0x160 ret_from_fork+0x1f/0x30 Fixes: e262e32d6bde ("vfs: Suppress MS_* flag defs within the kernel unless explicitly enabled") Signed-off-by: Gaosheng Cui --- include/uapi/linux/mount.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/mount.h b/include/uapi/linux/mount.h index 4d93967f8aea..035de4bd968f 100644 --- a/include/uapi/linux/mount.h +++ b/include/uapi/linux/mount.h @@ -44,7 +44,7 @@ #define MS_NOSEC (1<<28) #define MS_BORN (1<<29) #define MS_ACTIVE (1<<30) -#define MS_NOUSER (1<<31) +#define MS_NOUSER (1U<<31) /* * Superblock flags that can be altered by MS_REMOUNT -- 2.25.1