EcryptFS development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: ecryptfs@vger.kernel.org
Cc: viro@zeniv.linux.org.uk
Subject: re: file->f_op is never NULL...
Date: Tue, 12 Nov 2013 13:30:13 +0300	[thread overview]
Message-ID: <20131112103013.GB10651@elgon.mountain> (raw)

Hello Ecrypt FS People,

Al Viro has a patch in linux-next and it upsets Smatch:

The patch 72c2d5319200: "file->f_op is never NULL..." from Sep 22, 
2013, leads to the following
static checker warning: "fs/ecryptfs/file.c:320 ecryptfs_unlocked_ioctl()
	 error: potential NULL dereference 'lower_file'."

fs/ecryptfs/file.c
   312  static long
   313  ecryptfs_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
   314  {
   315          struct file *lower_file = NULL;
   316          long rc = -ENOTTY;
   317  
   318          if (ecryptfs_file_to_private(file))
   319                  lower_file = ecryptfs_file_to_lower(file);
   320          if (lower_file->f_op && lower_file->f_op->unlocked_ioctl)
   321                  rc = lower_file->f_op->unlocked_ioctl(lower_file, cmd, arg);

If there is no file->private_data then "lower_file" is NULL.  However,
I think file->private_data is always set to a valid pointer in
ecryptfs_open() so really we should just remove the
"if (ecryptfs_file_to_private(file))" check.  Is that right, or am I
missing something.

   322          return rc;
   323  }
   324  
   325  #ifdef CONFIG_COMPAT
   326  static long
   327  ecryptfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
   328  {
   329          struct file *lower_file = NULL;
   330          long rc = -ENOIOCTLCMD;
   331  
   332          if (ecryptfs_file_to_private(file))
   333                  lower_file = ecryptfs_file_to_lower(file);
   334          if (lower_file->f_op && lower_file->f_op->compat_ioctl)
   335                  rc = lower_file->f_op->compat_ioctl(lower_file, cmd, arg);

Same things.

   336          return rc;
   337  }
   338  #endif

regards,
dan carpenter

             reply	other threads:[~2013-11-12 10:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-12 10:30 Dan Carpenter [this message]
2013-11-13 18:54 ` [PATCH] eCryptfs: file->private_data is always valid Tyler Hicks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131112103013.GB10651@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=ecryptfs@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox