All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] NFSv4.2: Don't send mode again in post-EXCLUSIVE4_1 SETATTR with umask
@ 2017-06-02 13:55 Benjamin Coddington
  2017-06-02 15:21 ` [PATCH v2] " Benjamin Coddington
  2017-06-02 22:00 ` [PATCH] " kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Benjamin Coddington @ 2017-06-02 13:55 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker; +Cc: linux-nfs

From: Benjamin Coddington <bcodding@godel.bcodding.lab>

Now that we have umask support, we shouldn't re-send the mode in a SETATTR
following an exclusive CREATE, or we risk having the same problem fixed in
commit 5334c5bdac92 ("NFS: Send attributes in OPEN request for
NFS4_CREATE_EXCLUSIVE4_1"), which is that files with S_ISGID will have that
bit stripped away.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/nfs4proc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index c08c46a3b8cd..403787319446 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2589,7 +2589,8 @@ static inline void nfs4_exclusive_attrset(struct nfs4_opendata *opendata,
 
 	/* Except MODE, it seems harmless of setting twice. */
 	if (opendata->o_arg.createmode != NFS4_CREATE_EXCLUSIVE &&
-		attrset[1] & FATTR4_WORD1_MODE)
+		(attrset[1] & FATTR4_WORD1_MODE) ||
+		(attrset[2] & FATTR4_WORD2_MODE_UMASK))
 		sattr->ia_valid &= ~ATTR_MODE;
 
 	if (attrset[2] & FATTR4_WORD2_SECURITY_LABEL)
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2] NFSv4.2: Don't send mode again in post-EXCLUSIVE4_1 SETATTR with umask
  2017-06-02 13:55 [PATCH] NFSv4.2: Don't send mode again in post-EXCLUSIVE4_1 SETATTR with umask Benjamin Coddington
@ 2017-06-02 15:21 ` Benjamin Coddington
  2017-06-02 22:00 ` [PATCH] " kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: Benjamin Coddington @ 2017-06-02 15:21 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker; +Cc: linux-nfs

From: Benjamin Coddington <bcodding@godel.bcodding.lab>

On 2 Jun 2017, at 9:55, Benjamin Coddington wrote:

> From: Benjamin Coddington <bcodding@godel.bcodding.lab>
>
> Now that we have umask support, we shouldn't re-send the mode in a SETATTR
> following an exclusive CREATE, or we risk having the same problem fixed in
> commit 5334c5bdac92 ("NFS: Send attributes in OPEN request for
> NFS4_CREATE_EXCLUSIVE4_1"), which is that files with S_ISGID will have that
> bit stripped away.
>
> Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
> ---
>  fs/nfs/nfs4proc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index c08c46a3b8cd..403787319446 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -2589,7 +2589,8 @@ static inline void nfs4_exclusive_attrset(struct nfs4_opendata *opendata,
>
>   /* Except MODE, it seems harmless of setting twice. */
>   if (opendata->o_arg.createmode != NFS4_CREATE_EXCLUSIVE &&
> -     attrset[1] & FATTR4_WORD1_MODE)
> +     (attrset[1] & FATTR4_WORD1_MODE) ||
> +     (attrset[2] & FATTR4_WORD2_MODE_UMASK))

^^ I've definitely gotten the parens wrong here.. Here's the correction:
8<-----------------------------------------------------------------------

Now that we have umask support, we shouldn't re-send the mode in a SETATTR
following an exclusive CREATE, or we risk having the same problem fixed in
commit 5334c5bdac92 ("NFS: Send attributes in OPEN request for
NFS4_CREATE_EXCLUSIVE4_1"), which is that files with S_ISGID will have that
bit stripped away.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/nfs4proc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index c08c46a3b8cd..4e43fd1270c4 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2589,7 +2589,8 @@ static inline void nfs4_exclusive_attrset(struct nfs4_opendata *opendata,
 
 	/* Except MODE, it seems harmless of setting twice. */
 	if (opendata->o_arg.createmode != NFS4_CREATE_EXCLUSIVE &&
-		attrset[1] & FATTR4_WORD1_MODE)
+		(attrset[1] & FATTR4_WORD1_MODE ||
+		 attrset[2] & FATTR4_WORD2_MODE_UMASK))
 		sattr->ia_valid &= ~ATTR_MODE;
 
 	if (attrset[2] & FATTR4_WORD2_SECURITY_LABEL)
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] NFSv4.2: Don't send mode again in post-EXCLUSIVE4_1 SETATTR with umask
  2017-06-02 13:55 [PATCH] NFSv4.2: Don't send mode again in post-EXCLUSIVE4_1 SETATTR with umask Benjamin Coddington
  2017-06-02 15:21 ` [PATCH v2] " Benjamin Coddington
@ 2017-06-02 22:00 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2017-06-02 22:00 UTC (permalink / raw)
  To: Benjamin Coddington
  Cc: kbuild-all, Trond Myklebust, Anna Schumaker, linux-nfs

[-- Attachment #1: Type: text/plain, Size: 11984 bytes --]

Hi Benjamin,

[auto build test WARNING on nfs/linux-next]
[also build test WARNING on v4.12-rc3 next-20170602]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Benjamin-Coddington/NFSv4-2-Don-t-send-mode-again-in-post-EXCLUSIVE4_1-SETATTR-with-umask/20170603-051515
base:   git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
config: x86_64-randconfig-x014-201722 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from include/asm-generic/bug.h:4:0,
                    from arch/x86/include/asm/bug.h:81,
                    from include/linux/bug.h:4,
                    from include/linux/mmdebug.h:4,
                    from include/linux/mm.h:8,
                    from fs//nfs/nfs4proc.c:38:
   fs//nfs/nfs4proc.c: In function 'nfs4_exclusive_attrset':
>> fs//nfs/nfs4proc.c:2591:58: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     if (opendata->o_arg.createmode != NFS4_CREATE_EXCLUSIVE &&
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
      (attrset[1] & FATTR4_WORD1_MODE) ||
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                        
   include/linux/compiler.h:160:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> fs//nfs/nfs4proc.c:2591:2: note: in expansion of macro 'if'
     if (opendata->o_arg.createmode != NFS4_CREATE_EXCLUSIVE &&
     ^~
>> fs//nfs/nfs4proc.c:2591:58: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     if (opendata->o_arg.createmode != NFS4_CREATE_EXCLUSIVE &&
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
      (attrset[1] & FATTR4_WORD1_MODE) ||
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                        
   include/linux/compiler.h:160:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
>> fs//nfs/nfs4proc.c:2591:2: note: in expansion of macro 'if'
     if (opendata->o_arg.createmode != NFS4_CREATE_EXCLUSIVE &&
     ^~
>> fs//nfs/nfs4proc.c:2591:58: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     if (opendata->o_arg.createmode != NFS4_CREATE_EXCLUSIVE &&
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
      (attrset[1] & FATTR4_WORD1_MODE) ||
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                        
   include/linux/compiler.h:171:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
>> fs//nfs/nfs4proc.c:2591:2: note: in expansion of macro 'if'
     if (opendata->o_arg.createmode != NFS4_CREATE_EXCLUSIVE &&
     ^~
   Cyclomatic Complexity 5 include/linux/compiler.h:__read_once_size
   Cyclomatic Complexity 5 include/linux/compiler.h:__write_once_size
   Cyclomatic Complexity 3 arch/x86/include/asm/bitops.h:set_bit
   Cyclomatic Complexity 3 arch/x86/include/asm/bitops.h:clear_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:test_and_set_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:test_and_clear_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:constant_test_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:variable_test_bit
   Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls64
   Cyclomatic Complexity 1 include/linux/log2.h:__ilog2_u64
   Cyclomatic Complexity 1 arch/x86/include/asm/current.h:get_current
   Cyclomatic Complexity 1 include/asm-generic/getorder.h:__get_order
   Cyclomatic Complexity 2 arch/x86/include/asm/jump_label.h:arch_static_branch
   Cyclomatic Complexity 1 include/linux/jump_label.h:static_key_false
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_read
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_set
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_inc
   Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:atomic_dec_and_test
   Cyclomatic Complexity 2 arch/x86/include/asm/atomic.h:atomic_try_cmpxchg
   Cyclomatic Complexity 3 arch/x86/include/asm/atomic.h:__atomic_add_unless
   Cyclomatic Complexity 1 include/linux/atomic.h:atomic_add_unless
   Cyclomatic Complexity 1 include/linux/err.h:ERR_PTR
   Cyclomatic Complexity 1 include/linux/err.h:PTR_ERR
   Cyclomatic Complexity 1 include/linux/err.h:ERR_CAST
   Cyclomatic Complexity 7 arch/x86/include/asm/preempt.h:__preempt_count_add
   Cyclomatic Complexity 1 arch/x86/include/asm/preempt.h:__preempt_count_dec_and_test
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_lock
   Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock
   Cyclomatic Complexity 1 include/linux/seqlock.h:raw_seqcount_begin
   Cyclomatic Complexity 1 include/linux/seqlock.h:raw_write_seqcount_begin
   Cyclomatic Complexity 1 include/linux/seqlock.h:raw_write_seqcount_end
   Cyclomatic Complexity 1 include/linux/rcupdate.h:rcu_read_lock_sched_notrace
   Cyclomatic Complexity 1 include/linux/mmzone.h:__section_mem_map_addr
   Cyclomatic Complexity 1 arch/x86/include/asm/topology.h:numa_node_id
   Cyclomatic Complexity 1 include/linux/topology.h:numa_mem_id
   Cyclomatic Complexity 1 include/linux/gfp.h:gfp_zonelist
   Cyclomatic Complexity 1 include/linux/gfp.h:node_zonelist
   Cyclomatic Complexity 1 include/linux/page_ref.h:page_ref_dec_and_test
   Cyclomatic Complexity 1 include/linux/mm.h:put_page_testzero
   Cyclomatic Complexity 1 include/linux/mm.h:page_to_section
   Cyclomatic Complexity 1 include/linux/mm.h:lowmem_page_address
   Cyclomatic Complexity 1 include/linux/sched.h:task_thread_info
   Cyclomatic Complexity 68 include/linux/slab.h:kmalloc_large
   Cyclomatic Complexity 5 include/linux/slab.h:kmalloc
   Cyclomatic Complexity 1 include/linux/slab.h:kzalloc
   Cyclomatic Complexity 1 include/linux/refcount.h:refcount_set
   Cyclomatic Complexity 1 include/linux/kref.h:kref_init
   Cyclomatic Complexity 1 include/linux/dcache.h:d_really_is_negative
   Cyclomatic Complexity 1 include/linux/dcache.h:d_really_is_positive
   Cyclomatic Complexity 1 include/linux/dcache.h:d_inode
   Cyclomatic Complexity 1 include/linux/fs.h:i_size_read
   Cyclomatic Complexity 1 include/linux/uaccess.h:pagefault_disabled_inc
   Cyclomatic Complexity 1 include/linux/uaccess.h:pagefault_disabled_dec
   Cyclomatic Complexity 1 include/linux/uaccess.h:pagefault_disable
   Cyclomatic Complexity 1 include/linux/uaccess.h:pagefault_enable
   Cyclomatic Complexity 1 include/linux/signal.h:sigismember
   Cyclomatic Complexity 1 include/linux/unaligned/access_ok.h:put_unaligned_be64
   Cyclomatic Complexity 1 include/linux/sunrpc/xdr.h:xdr_encode_hyper
   Cyclomatic Complexity 2 include/linux/nfs4.h:seqid_mutating_err
   Cyclomatic Complexity 1 include/linux/highmem.h:kmap_atomic
   Cyclomatic Complexity 3 include/linux/nfs_xdr.h:nfs_fsid_equal
   Cyclomatic Complexity 1 include/linux/nfs_fs.h:NFS_I
   Cyclomatic Complexity 1 include/linux/nfs_fs.h:NFS_SB
   Cyclomatic Complexity 1 include/linux/nfs_fs.h:NFS_FH
   Cyclomatic Complexity 1 include/linux/nfs_fs.h:NFS_SERVER
   Cyclomatic Complexity 1 include/linux/nfs_fs.h:NFS_CLIENT
   Cyclomatic Complexity 1 include/linux/nfs_fs.h:NFS_FILEID
   Cyclomatic Complexity 1 include/linux/nfs_fs.h:nfs_set_verifier
   Cyclomatic Complexity 1 include/linux/nfs_fs.h:nfs_save_change_attribute
   Cyclomatic Complexity 1 include/linux/nfs_fs.h:nfs_display_fhandle
   Cyclomatic Complexity 1 include/linux/nfs_fs.h:nfs_file_open_context
   Cyclomatic Complexity 1 include/linux/freezer.h:freezer_do_not_count
   Cyclomatic Complexity 2 fs//nfs/nfs4_fs.h:nfs_confirm_seqid
   Cyclomatic Complexity 1 fs//nfs/nfs4_fs.h:nfs4_state_protect
   Cyclomatic Complexity 1 fs//nfs/nfs4_fs.h:nfs4_schedule_session_recovery
   Cyclomatic Complexity 1 fs//nfs/nfs4_fs.h:nfs4_stateid_copy
   Cyclomatic Complexity 1 fs//nfs/nfs4_fs.h:nfs4_valid_open_stateid
   Cyclomatic Complexity 1 fs//nfs/internal.h:nfs4_label_alloc
   Cyclomatic Complexity 1 fs//nfs/internal.h:nfs4_label_free
   Cyclomatic Complexity 1 fs//nfs/internal.h:nfs4_label_copy
   Cyclomatic Complexity 1 fs//nfs/iostat.h:nfs_inc_server_stats
   Cyclomatic Complexity 1 fs//nfs/pnfs.h:nfs_have_layout
   Cyclomatic Complexity 1 fs//nfs/pnfs.h:pnfs_commit_and_return_layout
   Cyclomatic Complexity 1 fs//nfs/pnfs.h:pnfs_ld_layoutret_on_setattr
   Cyclomatic Complexity 1 fs//nfs/pnfs.h:pnfs_roc
   Cyclomatic Complexity 1 fs//nfs/pnfs.h:pnfs_roc_release
   Cyclomatic Complexity 1 fs//nfs/pnfs.h:pnfs_wait_on_layoutreturn
   Cyclomatic Complexity 1 fs//nfs/pnfs.h:set_pnfs_layoutdriver
   Cyclomatic Complexity 1 fs//nfs/pnfs.h:pnfs_use_threshold
   Cyclomatic Complexity 1 fs//nfs/pnfs.h:pnfs_mdsthreshold_alloc
   Cyclomatic Complexity 1 fs//nfs/nfs4session.h:nfs4_slot_tbl_draining
   Cyclomatic Complexity 1 fs//nfs/nfs4session.h:nfs4_get_session
   Cyclomatic Complexity 1 fs//nfs/nfs4session.h:nfs4_has_session
   Cyclomatic Complexity 1 fs//nfs/nfs4session.h:nfs4_has_persistent_session
   Cyclomatic Complexity 1 fs//nfs/fscache.h:nfs_fscache_invalidate
   Cyclomatic Complexity 1 fs//nfs/nfs4proc.c:nfs4_label_init_security
   Cyclomatic Complexity 1 fs//nfs/nfs4proc.c:nfs4_label_release_security
   Cyclomatic Complexity 1 fs//nfs/nfs4proc.c:nfs4_bitmask

vim +2591 fs//nfs/nfs4proc.c

aa53ed541 Jeff Layton         2007-06-05  2575   * Make sure we clobber those fields in the later setattr call
aa53ed541 Jeff Layton         2007-06-05  2576   */
5334c5bda Kinglong Mee        2015-08-26  2577  static inline void nfs4_exclusive_attrset(struct nfs4_opendata *opendata,
5334c5bda Kinglong Mee        2015-08-26  2578  				struct iattr *sattr, struct nfs4_label **label)
aa53ed541 Jeff Layton         2007-06-05  2579  {
5334c5bda Kinglong Mee        2015-08-26  2580  	const u32 *attrset = opendata->o_res.attrset;
5334c5bda Kinglong Mee        2015-08-26  2581  
5334c5bda Kinglong Mee        2015-08-26  2582  	if ((attrset[1] & FATTR4_WORD1_TIME_ACCESS) &&
aa53ed541 Jeff Layton         2007-06-05  2583  	    !(sattr->ia_valid & ATTR_ATIME_SET))
aa53ed541 Jeff Layton         2007-06-05  2584  		sattr->ia_valid |= ATTR_ATIME;
aa53ed541 Jeff Layton         2007-06-05  2585  
5334c5bda Kinglong Mee        2015-08-26  2586  	if ((attrset[1] & FATTR4_WORD1_TIME_MODIFY) &&
aa53ed541 Jeff Layton         2007-06-05  2587  	    !(sattr->ia_valid & ATTR_MTIME_SET))
aa53ed541 Jeff Layton         2007-06-05  2588  		sattr->ia_valid |= ATTR_MTIME;
5334c5bda Kinglong Mee        2015-08-26  2589  
5334c5bda Kinglong Mee        2015-08-26  2590  	/* Except MODE, it seems harmless of setting twice. */
a430607b2 Benjamin Coddington 2017-01-24 @2591  	if (opendata->o_arg.createmode != NFS4_CREATE_EXCLUSIVE &&
ff573e29e Benjamin Coddington 2017-06-02  2592  		(attrset[1] & FATTR4_WORD1_MODE) ||
ff573e29e Benjamin Coddington 2017-06-02  2593  		(attrset[2] & FATTR4_WORD2_MODE_UMASK))
5334c5bda Kinglong Mee        2015-08-26  2594  		sattr->ia_valid &= ~ATTR_MODE;
5334c5bda Kinglong Mee        2015-08-26  2595  
5334c5bda Kinglong Mee        2015-08-26  2596  	if (attrset[2] & FATTR4_WORD2_SECURITY_LABEL)
5334c5bda Kinglong Mee        2015-08-26  2597  		*label = NULL;
aa53ed541 Jeff Layton         2007-06-05  2598  }
aa53ed541 Jeff Layton         2007-06-05  2599  

:::::: The code at line 2591 was first introduced by commit
:::::: a430607b2ef7c3be090f88c71cfcb1b3988aa7c0 NFSv4.0: always send mode in SETATTR after EXCLUSIVE4

:::::: TO: Benjamin Coddington <bcodding@redhat.com>
:::::: CC: Trond Myklebust <trond.myklebust@primarydata.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28689 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-02 22:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-02 13:55 [PATCH] NFSv4.2: Don't send mode again in post-EXCLUSIVE4_1 SETATTR with umask Benjamin Coddington
2017-06-02 15:21 ` [PATCH v2] " Benjamin Coddington
2017-06-02 22:00 ` [PATCH] " kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.