From patchwork Mon Oct 31 11:39:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaosheng Cui X-Patchwork-Id: 13219 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2261204wru; Mon, 31 Oct 2022 04:44:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM437DEgJemKOs4pMUC/4IYhf/0tAguMiNvuOcV0AJl9GvzDwvLLRUIZjRFz8CyNCGpDM/rx X-Received: by 2002:a17:906:9746:b0:798:baec:3a80 with SMTP id o6-20020a170906974600b00798baec3a80mr12319233ejy.610.1667216653013; Mon, 31 Oct 2022 04:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667216653; cv=none; d=google.com; s=arc-20160816; b=Cl0ocj0Dep1ZnbkENDuD+DTNaoPfTnDaA265QLmlhGTpANR+ul1CSUuVy4YBvt5hlb aOPloUoriDvrvHIm3lYNWcYxe7W25R5rqDHg1I6ViB7qWZkqDjpzZ2b5l9TfSBtsoGG+ 2prAS1418rxY1TcfDKs2iCRmsrsjaat/GhA7qtelK3gaZdmPu9occLHay/xFsHdaKsEh xzvwC4FPrNQ0YcXhaFpwqJnmU3rpkzHOYRRmvoGsHA/rOn/tD9uVod7KAH08G3QvL1Qt RFyBc59f36i1+hNwvX2qy6hxNqX9dXfpFZC/ewu555i9TMyp220SJoo0EysD5N8gy0zh mkOw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg26-20020a170907971a00b0078266dc4b8csi8265211ejc.719.2022.10.31.04.43.48; Mon, 31 Oct 2022 04:44:13 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748203369378768477?= X-GMAIL-MSGID: =?utf-8?q?1748203369378768477?= 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