linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] smb3: pass mode bits into create calls
@ 2019-10-01  8:21 Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2019-10-01  8:21 UTC (permalink / raw)
  To: stfrench; +Cc: linux-cifs

Hello Steve French,

The patch c3ca78e21744: "smb3: pass mode bits into create calls" from
Sep 25, 2019, leads to the following static checker warning:

	fs/cifs/smb2pdu.c:754 add_posix_context()
	warn: impossible condition '(mode == -1) => (0-u16max == (-1))'

fs/cifs/smb2pdu.c
   747  static int
   748  add_posix_context(struct kvec *iov, unsigned int *num_iovec, umode_t mode)
                                                                     ^^^^^^^
This is unsigned short.

   749  {
   750          struct smb2_create_req *req = iov[0].iov_base;
   751          unsigned int num = *num_iovec;
   752  
   753          iov[num].iov_base = create_posix_buf(mode);
   754          if (mode == -1)
                    ^^^^^^^^^^
So this debug code will never trigger.

   755                  cifs_dbg(VFS, "illegal mode\n"); /* BB REMOVEME */
   756          if (iov[num].iov_base == NULL)
   757                  return -ENOMEM;
   758          iov[num].iov_len = sizeof(struct create_posix);
   759          if (!req->CreateContextsOffset)
   760                  req->CreateContextsOffset = cpu_to_le32(
   761                                  sizeof(struct smb2_create_req) +
   762                                  iov[num - 1].iov_len);
   763          le32_add_cpu(&req->CreateContextsLength, sizeof(struct create_posix));
   764          *num_iovec = num + 1;
   765          return 0;
   766  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread
* [bug report] smb3: pass mode bits into create calls
@ 2019-10-01  8:35 Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2019-10-01  8:35 UTC (permalink / raw)
  To: stfrench; +Cc: linux-cifs

Hello Steve French,

The patch c3ca78e21744: "smb3: pass mode bits into create calls" from
Sep 25, 2019, leads to the following static checker warning:

	fs/cifs/smb2pdu.c:2528 SMB2_open_init()
	warn: always true condition '(oparms->mode != -1) => (0-u16max != (-1))'

fs/cifs/smb2pdu.c
  2510          if (tcon->snapshot_time) {
  2511                  cifs_dbg(FYI, "adding snapshot context\n");
  2512                  if (n_iov > 2) {
  2513                          struct create_context *ccontext =
  2514                              (struct create_context *)iov[n_iov-1].iov_base;
  2515                          ccontext->Next =
  2516                                  cpu_to_le32(iov[n_iov-1].iov_len);
  2517                  }
  2518  
  2519                  rc = add_twarp_context(iov, &n_iov, tcon->snapshot_time);
  2520                  if (rc)
  2521                          return rc;
  2522          }
  2523  
  2524          /* TODO: add handling for the mode on create */
  2525          if (oparms->disposition == FILE_CREATE)
  2526                  cifs_dbg(VFS, "mode is 0x%x\n", oparms->mode); /* BB REMOVEME */
  2527  
  2528          if ((oparms->disposition == FILE_CREATE) && (oparms->mode != -1)) {
                                                             ^^^^^^^^^^^^^^^^^^
unsigned short can't equal -1.

  2529                  if (n_iov > 2) {
  2530                          struct create_context *ccontext =
  2531                              (struct create_context *)iov[n_iov-1].iov_base;
  2532                          ccontext->Next =
  2533                                  cpu_to_le32(iov[n_iov-1].iov_len);
  2534                  }
  2535  
  2536                  /* rc = add_sd_context(iov, &n_iov, oparms->mode); */
  2537                  if (rc)
  2538                          return rc;
  2539          }
  2540  
  2541          if (n_iov > 2) {
  2542                  struct create_context *ccontext =
  2543                          (struct create_context *)iov[n_iov-1].iov_base;
  2544                  ccontext->Next = cpu_to_le32(iov[n_iov-1].iov_len);
  2545          }

regards,
dan carpenter

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

end of thread, other threads:[~2019-10-01  8:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-01  8:21 [bug report] smb3: pass mode bits into create calls Dan Carpenter
2019-10-01  8:35 Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).