Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1538426rwb; Fri, 18 Nov 2022 21:51:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf7gHntmGiQtndiyZHY8ImOtSXYMWIdIKOLDdfbcqGIeoBejmd5XI5I0Sb4hT8piqolPBlLb X-Received: by 2002:a17:906:6782:b0:7ad:7d50:dec2 with SMTP id q2-20020a170906678200b007ad7d50dec2mr8925284ejp.37.1668837066117; Fri, 18 Nov 2022 21:51:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668837066; cv=none; d=google.com; s=arc-20160816; b=qvykwoY1bUfzqOhyV9ia9ctWL26YS0axI284pZ/epF1rLoeXPHlZURmtI++24Rwhzy n7inoVOkySEqPkPvtWZsA+iCl8wr2aj5xipQbd+gNaYXGAh2k4sOxkLYHS7pE0PtxTz0 QIe4w8uZ1174I3+4wireVRoPWnX4iGKl/VOqbrCa4Qirpse3vIgMlmjPL6+UwltAGT6a tqx+DkDRqza79m1jkzdlAabJ+cAWMpe8N2nnq3pmOxxhWL3EkZvQOh9kJBrWwUrpqEdy X/x8rQ1/9Qj5W+qZRZXzrqbXHNAkDX3nNVooxqpscIJbQFSE5YLQlzNZHkuXzWgpoohL 2fEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=yRfhb+NrhMCpwQojHAdu4kSKTfkVB70x/cknHkdRPP8=; b=UAZzdtEDlneG8ZO2wt4XVkXO4tegjvCESXc7YHJhqssSLdEh6J+GPXFpyitK4ecT4b lNf+dMRPZkaADduelWt6N6yKw1nTw8TmW1HE17eSzh/dki4ToxbmijSmESRL/Gl4koMB 7VCk9RQ2q/VsYGu9iccSAU9qckSjXDvo1RkzdZm/uh+1KZPRubmS7VH6NAFngVF87Q0J dIL94mJYlKvkog0ibYQoEOY27c8XVXcK4YQon6ebSfyiX/Pf7vMCKSgQM+JHreM1FWC8 k/2drquuFvspVI5NZqpfj/aAk9Gkjv/H3fBsYgA9wcXbD39fyONmZE64PrE2qLprUSv/ isqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=pf87u4oT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z3-20020a056402274300b00463c29b5443si4824681edd.27.2022.11.18.21.50.44; Fri, 18 Nov 2022 21:51:06 -0800 (PST) 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; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=pf87u4oT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231425AbiKSF3o (ORCPT + 90 others); Sat, 19 Nov 2022 00:29:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbiKSF3l (ORCPT ); Sat, 19 Nov 2022 00:29:41 -0500 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41C204AF31; Fri, 18 Nov 2022 21:29:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=yRfhb+NrhMCpwQojHAdu4kSKTfkVB70x/cknHkdRPP8=; b=pf87u4oTQjYpt5Kue2sttXTfdD gYe+9YPbM438h4uJ8GHSprDo8rJFusGWG1D7MOnAbza7Zh+mfoIB3Y8Lsi4i12zopiOa+YVy75gCN JuxtOh8IXowqco7em0GWWWFLdl5ge/wecZugF/4GVcGK2scKI2VgO8lD7FAj9yJmO94kuWjMkLmMA ggmMH0Y0X83DwdjRPQ2wTRSuJDrakuAlkwsZkF/yEEuKT4adIYC+FFYGletRX4kqjswewR9CmmCBi hE9eZDaH2thJa+B6RhrG3ry2LdG4TNmDu+6gRr66CxjImNAV/CvWK44oPBy8hV+OzbMPjtmNjbNBS 4BmzBRSA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1owGPq-004zW4-20; Sat, 19 Nov 2022 05:29:22 +0000 Date: Sat, 19 Nov 2022 05:29:22 +0000 From: Al Viro To: Liu Shixin Cc: Eric Biederman , Kees Cook , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] binfmt_misc: fix shift-out-of-bounds in check_special_flags Message-ID: References: <20221102025123.1117184-1-liushixin2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221102025123.1117184-1-liushixin2@huawei.com> Sender: Al Viro X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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 On Wed, Nov 02, 2022 at 10:51:23AM +0800, Liu Shixin wrote: > UBSAN reported a shift-out-of-bounds warning: > > left shift of 1 by 31 places cannot be represented in type 'int' > Call Trace: > > __dump_stack lib/dump_stack.c:88 [inline] > dump_stack_lvl+0x8d/0xcf lib/dump_stack.c:106 > ubsan_epilogue+0xa/0x44 lib/ubsan.c:151 > __ubsan_handle_shift_out_of_bounds+0x1e7/0x208 lib/ubsan.c:322 > check_special_flags fs/binfmt_misc.c:241 [inline] > create_entry fs/binfmt_misc.c:456 [inline] > bm_register_write+0x9d3/0xa20 fs/binfmt_misc.c:654 > vfs_write+0x11e/0x580 fs/read_write.c:582 > ksys_write+0xcf/0x120 fs/read_write.c:637 > do_syscall_x64 arch/x86/entry/common.c:50 [inline] > do_syscall_64+0x34/0x80 arch/x86/entry/common.c:80 > entry_SYSCALL_64_after_hwframe+0x63/0xcd > RIP: 0033:0x4194e1 > > Since the type of Node's flags is unsigned long, we should define these > macros with same type too. We are limited to 32 bits anyway. More interesting question here is what's the point of having those bits that high anyway?