From patchwork Sat Oct 29 07:17:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaosheng Cui X-Patchwork-Id: 12656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1227157wru; Sat, 29 Oct 2022 00:20:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ASYrxYvqA6pryn8hcdS4zb8Pup1/HrQJVsjqDi4sO18egK5R7jcuk30LocRpTZ8NESUXM X-Received: by 2002:a17:906:4786:b0:78d:c3c0:1508 with SMTP id cw6-20020a170906478600b0078dc3c01508mr2671047ejc.211.1667028019507; Sat, 29 Oct 2022 00:20:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667028019; cv=none; d=google.com; s=arc-20160816; b=FL2ZC25NPSPMU9+WaHRx3RRx4ZBxzo4MBXKXkZ1fD0DBgtO4DnvtdRxyEyZLEIyay+ ckTqj8y+WV3uq0cTslUjnKcRxcNnjFg1jZFGQR/RGo8wHsgeA5LvW3uuUHhOPwrI7J5e KFc0dv+V4TdGbDQUM2U3LF7/UZNuDxU/beFRVFv7ttgWV4Wp/QEyUMKd8faDi61bq17G ShV5N0GsQxROkJS1aqVrZW6BQ/Z35Pu9ynqznPWn9w/nGgzMY+hqjBrFwIZly0dMIEvq qi2kCp7RDF6VWy0/49YUJe08kCCxInwxBdAhzXXU4lHj87y6NitlWUKdHa0y6ptHvgrT hrMA== 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=aWOGIUdzZeOvec8D9497skAFkdd7YcACskrN40Ihl0w=; b=e8PCdZ2ESAgGfAZfw3vg2H/gsYLZMjMlVtlYKkUdcb4SdQeTFwwG/ReK6WtWRsTxWY BynFpVV0pAke1Lz/i2u3xBqIBK0rFfIDPHfw17m6nWCSxuGmNTsUe9/wOFVtBIpD1lc9 fD6Y/6qfxxAeN84HhONnMoDZHZgiUTgRy21pd6jeho5UBSjqJsVn1R7uEb7u3IBRDAXk UcTElq0TY9q2jNQ1X/cVtk8kX8L9OLJNenGI+Splea+7XmgZnNqqvi5Hg9OzRI25K84a MZdQsZWCSKTLs/IVB3nLThagLZVzi4OyhZPlG7hDJiqR1vjWdpwM8UllgZZDBN/WFIyi xj8g== 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 a6-20020a509b46000000b0045c3f5b458fsi1023014edj.397.2022.10.29.00.19.55; Sat, 29 Oct 2022 00:20:19 -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 S229674AbiJ2HRu (ORCPT + 99 others); Sat, 29 Oct 2022 03:17:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbiJ2HRs (ORCPT ); Sat, 29 Oct 2022 03:17:48 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 208F3180AF2; Sat, 29 Oct 2022 00:17:48 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MzrGT3w59z15MFW; Sat, 29 Oct 2022 15:12:49 +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; Sat, 29 Oct 2022 15:17:45 +0800 From: Gaosheng Cui To: , , CC: , Subject: [PATCH] fs: fix undefined behavior in bit shift for SB_NOUSER Date: Sat, 29 Oct 2022 15:17:45 +0800 Message-ID: <20221029071745.2836665-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: dggems702-chm.china.huawei.com (10.3.19.179) 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?1748005572293873824?= X-GMAIL-MSGID: =?utf-8?q?1748005572293873824?= Shifting signed 32-bit value by 31 bits is undefined, so changing most significant bit to unsigned. The UBSAN warning calltrace like below: UBSAN: shift-out-of-bounds in fs/namespace.c:2330:33 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 graft_tree+0x36/0xf0 do_add_mount+0x98/0x100 path_mount+0xbd6/0xd50 init_mount+0x6a/0xa3 devtmpfs_setup+0x47/0x7e devtmpfsd+0x1a/0x50 kthread+0x126/0x160 ret_from_fork+0x1f/0x30 Fixes: e462ec50cb5f ("VFS: Differentiate mount flags (MS_*) from internal superblock flags") Signed-off-by: Gaosheng Cui --- include/linux/fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 85015e21b755..a68d5310be7b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1396,7 +1396,7 @@ extern int send_sigurg(struct fown_struct *fown); #define SB_NOSEC (1<<28) #define SB_BORN (1<<29) #define SB_ACTIVE (1<<30) -#define SB_NOUSER (1<<31) +#define SB_NOUSER (1U<<31) /* These flags relate to encoding and casefolding */ #define SB_ENC_STRICT_MODE_FL (1 << 0)