Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3280130lfo; Mon, 23 May 2022 00:34:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpSkYue737MvUhy22xLwHj9Ii+JPYV26/s5COnapzK07qex+BkQ3zj9+eEedDJr4johvxQ X-Received: by 2002:a05:6a00:15c5:b0:518:a654:1bf8 with SMTP id o5-20020a056a0015c500b00518a6541bf8mr2879899pfu.23.1653291285230; Mon, 23 May 2022 00:34:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653291285; cv=none; d=google.com; s=arc-20160816; b=lMW96HCWAP/6Ajp+hIktaXu8jQKotvTw3bN9Met2VsjnwMt91NTQKsimM6xOYSnZGV CymHiERIScoWaCzGOxWlrMWO+wBhhKJlQlgoCsfy+SJNDqk/vmCxMVY1dWNvBNGr56Yq lEZLgsEFYry6ewjWkW/+1EclHjo34gjyIp5TV7SQLc+8Cgeay3+cveWEHbHT5n5f+Fud 6zW7WPzqPf3pVmYUVufcotNE5W3bx+6LSSiMHHDt9FLRD/i7uiyZh3JbhZthnRutrnfw Z049sXfAy8ExhAw6zwZWfNOH9r9JHGMJFip/cImLmwsYxqhE7aMBq2aq824NmO9PEROa Epsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8NenhAfYIMRmvTFmjGJtXIi8zEG3PIr7S+ROeDiY8Zw=; b=ryAANp1jgkQMpxQ6l60+LIS0SRFZ0o0WPibQyJ11meNJhOHwRP8pi4eRenr9MQYqtM mZCN+gI8K2KBQfG6LNpEI7UVcM7JJl6mUsK+bAhXR3IkN2k+tEju/hr4JnodTQTTUKYC h1bzG3IMIfll2U8AC5Hccr2JQ0Ktp9pbkVeoelsTOwnyNujAg6I0baJ52eGO+imgnsOA gXllL6zo6l7VnNsKWnmTtVZy9th61jq28f0SL35jyNEm0MJIAmS3oUzgNuuM41YLivgz /xUe/zJEoTh++ykFDroDJYoYLX4Zjn7iX7QHmSwxK8YQwCp5l5SkDF51s5dU8lzJxqB3 BNag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EHRCIlG9; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b69-20020a633448000000b003f5e1556e49si9016319pga.601.2022.05.23.00.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:34:45 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EHRCIlG9; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 790CE1A359B; Sun, 22 May 2022 23:44:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240704AbiEVXEv (ORCPT + 99 others); Sun, 22 May 2022 19:04:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231491AbiEVXEt (ORCPT ); Sun, 22 May 2022 19:04:49 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F02724588; Sun, 22 May 2022 16:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=8NenhAfYIMRmvTFmjGJtXIi8zEG3PIr7S+ROeDiY8Zw=; b=EHRCIlG9uIsnmzJjCasjyT1TGQ 366OoMh/4UUIiKf0OCJq65pZmJNHH7Uyv8cj+fwNOfmJWBPHkoLfcM27Yw4RYIxcm1mIAqncfa1hl +iLB0/F+9Y4KsZMZ/Oc+CJa7znjapRnJnrZgeyywx26vK6kZBF4zDUpYEWWc9Gq9z9dE2av/a07/2 7eDdu5wUOAstdtTKPKIU3n+jt37mBPc4eq+h/EAytcRp7X/1Xkko8p+3pNBFVXZ95x0d6HOO8vP68 K00E3haO6DD/82A0PpoBs9j4iHHEd52FcNsbYx/tZPOQR1d90k9YgPtVdtnr5ixykWq9p/UJ2XVJL WOrwVp9g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nsuct-00FfAN-3p; Sun, 22 May 2022 23:04:43 +0000 Date: Mon, 23 May 2022 00:04:43 +0100 From: Matthew Wilcox To: Vasily Averin Cc: Christoph Hellwig , kernel@openvz.org, linux-kernel@vger.kernel.org, Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v3] fs/proc/base.c: fix incorrect fmode_t casts Message-ID: References: <31a6874c-1cb8-e081-f1ca-ef1a81f9dda0@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <31a6874c-1cb8-e081-f1ca-ef1a81f9dda0@openvz.org> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Sun, May 22, 2022 at 03:08:42PM +0300, Vasily Averin wrote: > diff --git a/fs/proc/base.c b/fs/proc/base.c > index c1031843cc6a..4e4edf9db5f0 100644 > --- a/fs/proc/base.c > +++ b/fs/proc/base.c > @@ -2237,13 +2237,13 @@ static struct dentry * > proc_map_files_instantiate(struct dentry *dentry, > struct task_struct *task, const void *ptr) > { > - fmode_t mode = (fmode_t)(unsigned long)ptr; > + const fmode_t *mode = ptr; Why not ... fmode_t mode = *(fmode_t *)ptr; and then you don't need > - ((mode & FMODE_READ ) ? S_IRUSR : 0) | > - ((mode & FMODE_WRITE) ? S_IWUSR : 0)); > + ((*mode & FMODE_READ ) ? S_IRUSR : 0) | > + ((*mode & FMODE_WRITE) ? S_IWUSR : 0));