Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1652700ioo; Sun, 22 May 2022 23:06:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEE3lkd0DqCMF0ScrgTWvjaZQFJCFgd60zP/1qbioUk9E1+5sn7XVPg0y8eAbvZXh6dkAa X-Received: by 2002:a63:8041:0:b0:3f9:f00f:27af with SMTP id j62-20020a638041000000b003f9f00f27afmr8739152pgd.498.1653285972105; Sun, 22 May 2022 23:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653285972; cv=none; d=google.com; s=arc-20160816; b=X7RvgvV849+Ikp59ur+0x/hYQxWCIIDnZpAz8huvYVbfliv1X/5RaiMDRkB9jUrcH3 ur8Jo6q81F+M3Kpo0GSFH9613eEuORj2R5eOZFFfPwH8EPJkgheAH9ldY7y5J29uBUVR /+UEAWRuU+EnHVBXK0qANXzwl9D4ZCwvfxjgr+CxVKjnzQHNxWRNSsF0HhJBiKJj0ony TLhSgeUsRECma6P72BNzvjMxHMzKdTchIb5vvzO7gZkDS8xMqn1TyX2kEwMfeTaCsCNs vBw1i2INgBKesQjCkZw4doPYOgYCNMA0W2dVL9CXpqlZ/Z0o9gVCvANiUgI8nqPRAJ5I xspg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:to:content-language:cc :subject:from:user-agent:mime-version:date:message-id:dkim-signature; bh=uk1OTCr2W3WWHv7qfitt9BCJebEVB6x82RShNeGdjGw=; b=Cr6g3b8NTxcAVkQ2rSqL6nQQvCYnjUNETXplzDTCC3s0vjD5/eQmAW+ciPMDw5ufzi 4vDiN0g7K4GPZpUs6xQkE6tWO8xmuEYBQkSkHvhNSRwkwRtEM3WO2UXbYT1x8WkAcw+b Vg6/X8ZfEECdE3Mj6uHy0muYOVuHQXNhp7OyLbsK3gsdxX4F/E+qvTCzma9/d76hIwHa 75naBrfE4yGZIVZu2nygsjojEm5/JEQVLM9j6n3fB/B8dtKghoAeMrNTsEnaKwNlfKkk dOM9gEVFrmE4Qnh58TQlFA35hze1UbbS8eh+lJUQ+zs8XpkAdED9B9vWevtlw+DJAXhd eeMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=mEF9IYA2; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e127-20020a636985000000b003db4cb6a71dsi9620931pgc.0.2022.05.22.23.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 23:06:12 -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=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=mEF9IYA2; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 907AC2C13A; Sun, 22 May 2022 22:57:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343749AbiEVMIs (ORCPT + 99 others); Sun, 22 May 2022 08:08:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344428AbiEVMIp (ORCPT ); Sun, 22 May 2022 08:08:45 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B387F3A5D8 for ; Sun, 22 May 2022 05:08:44 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id c19so8181098lfv.5 for ; Sun, 22 May 2022 05:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:cc :content-language:to:content-transfer-encoding; bh=uk1OTCr2W3WWHv7qfitt9BCJebEVB6x82RShNeGdjGw=; b=mEF9IYA2ZRrG+Bhx9uSNUkHKRVD23MKTrWJX9EOlAiZbU9wRpuRejbqb2yLlDp8X9T OVkYvX99lVBCZH9yTyNW6wz5dmwwcIBqDmkd/kfmDjs3QU1HfzQdsxjESnW8mUYaRriV 6Z4j9R5Mh+vtTVlzeoT2gT0K6gCelvK0vbTZruG93Te7htRZiAVz7U6cNyRlgAQwtYel +khOQlfIVKnMgrxe6lzMhkz7YFkBNTHNvwIKm+FE/qVA8uF0/bN7dRsE07cNtwCKgfFg Pcfya8g6j5nTQas5lCGnlj8hXDt/amkiz1SujbiF71e4J7xwvJ/qqttoZJJgITEQWL4x aLRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:cc:content-language:to:content-transfer-encoding; bh=uk1OTCr2W3WWHv7qfitt9BCJebEVB6x82RShNeGdjGw=; b=Z6Oi81s3ZZ26Q5biD17twbTxUBuI21DpdPskn8xvbzqhkXH0jeYdX05Qwy8YXylzlF SFiQMyCur8JCEaF3W5TzgjEMrs5Nn6gC7wQEQBfA0uqEcYeX/rYry8/CDtfZMtQ+H5sq eJRwKdQHHkUjd7L7qVrY15lo6WwuRsgq8nlbOV0jyU9FjmeUkjTzWP7RZbwq+CmArUWh ZT0B6NLF4xiYuJau3cS48mHbh/4UqC6CIhH2pVKKK8UdnO/+UNN+Ps00CbP1rCviQC0Y tOmOM53RBwfDejOr6Po1lznlTX4+BepG6esRbV28kRFaPkCXuTnEkxtGa/sksYn4IMtr clzA== X-Gm-Message-State: AOAM532if5sT9C/mZIsRm1a4ewQADUDmPAN2SFPrYRxy9m1DY/Z6yyIh zwYGrFstXQZXWcNUb5OAFPb4QA== X-Received: by 2002:a05:6512:3f94:b0:474:68e:46c3 with SMTP id x20-20020a0565123f9400b00474068e46c3mr13678027lfa.431.1653221323129; Sun, 22 May 2022 05:08:43 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.185]) by smtp.gmail.com with ESMTPSA id t25-20020ac24c19000000b0047255d21181sm1426580lfq.176.2022.05.22.05.08.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 May 2022 05:08:42 -0700 (PDT) Message-ID: <31a6874c-1cb8-e081-f1ca-ef1a81f9dda0@openvz.org> Date: Sun, 22 May 2022 15:08:42 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 From: Vasily Averin Subject: [PATCH v3] fs/proc/base.c: fix incorrect fmode_t casts Cc: kernel@openvz.org, linux-kernel@vger.kernel.org, Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org Content-Language: en-US To: Christoph Hellwig Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 Fixes sparce warnings: fs/proc/base.c:2240:25: sparse: warning: cast to restricted fmode_t fs/proc/base.c:2297:42: sparse: warning: cast from restricted fmode_t fs/proc/base.c:2394:48: sparse: warning: cast from restricted fmode_t fmode_t is birwie type and requires __force attribute for any cast Signed-off-by: Vasily Averin --- v3: split, reworked according to Christoph Hellwig recommendation --- fs/proc/base.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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; struct proc_inode *ei; struct inode *inode; inode = proc_pid_make_inode(dentry->d_sb, task, S_IFLNK | - ((mode & FMODE_READ ) ? S_IRUSR : 0) | - ((mode & FMODE_WRITE) ? S_IWUSR : 0)); + ((*mode & FMODE_READ ) ? S_IRUSR : 0) | + ((*mode & FMODE_WRITE) ? S_IWUSR : 0)); if (!inode) return ERR_PTR(-ENOENT); @@ -2294,7 +2294,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir, if (vma->vm_file) result = proc_map_files_instantiate(dentry, task, - (void *)(unsigned long)vma->vm_file->f_mode); + &vma->vm_file->f_mode); out_no_vma: mmap_read_unlock(mm); @@ -2391,7 +2391,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx) buf, len, proc_map_files_instantiate, task, - (void *)(unsigned long)p->mode)) + &p->mode)) break; ctx->pos++; } -- 2.36.1