Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninitialized resid variable in vdev_file_io_start()/vn_rdwr() #51

Closed
wizeman opened this issue Aug 12, 2010 · 1 comment
Closed

Uninitialized resid variable in vdev_file_io_start()/vn_rdwr() #51

wizeman opened this issue Aug 12, 2010 · 1 comment

Comments

@wizeman
Copy link

wizeman commented Aug 12, 2010

In the userspace implementation of vdev_file_io_start():

142 vdev_file_io_start(zio_t *zio)
143 {
(...)
146         ssize_t resid;
(...)
167         zio->io_error = vn_rdwr(zio->io_type == ZIO_TYPE_READ ?
168             UIO_READ : UIO_WRITE, vf->vf_vnode, zio->io_data,
169             zio->io_size, zio->io_offset, UIO_SYSSPACE,
170             0, RLIM64_INFINITY, kcred, &resid);
171 
172         if (resid != 0 && zio->io_error == 0)
173                 zio->io_error = ENOSPC;

However, in vn_rdwr():

644 vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len, offset_t offset,
645         int x1, int x2, rlim64_t x3, void *x4, ssize_t *residp)
646 {                     
(...)
675         if (rc == -1)
676                 return (errno);
677 
678         done += rc;
679 
680         if (residp)
681                 *residp = len - done;

As you can see, the "resid" variable in the first function may never get set before it is checked in the "if" statement.

@behlendorf
Copy link
Contributor

Initialize resid variable

Properly initialize the variable resid for the error case where
vn_rdwr() returns an error with setting *resid. In practice
this is harmless because the contents of resid don't matter
when vn_rdwr() returns an error. But the code does check the
result which means we may or may not end up having the check
zio->io_error. This makes gcc unhappy and having a completely
deterministic code path here is a good thing.

Closed by 2b89d86

@elan elan mentioned this issue Nov 3, 2012
akatrevorjay added a commit to akatrevorjay/zfs that referenced this issue Dec 16, 2017
# This is the 1st commit message:
Merge branch 'master' of https://github.com/zfsonlinux/zfs

* 'master' of https://github.com/zfsonlinux/zfs:
  Enable QAT support in zfs-dkms RPM

# This is the commit message openzfs#2:

Import 0.6.5.7-0ubuntu3

# This is the commit message openzfs#3:

gbp changes

# This is the commit message openzfs#4:

Bump ver

# This is the commit message openzfs#5:

-j9 baby

# This is the commit message openzfs#6:

Up

# This is the commit message openzfs#7:

Yup

# This is the commit message openzfs#8:

Add new module

# This is the commit message openzfs#9:

Up

# This is the commit message openzfs#10:

Up

# This is the commit message openzfs#11:

Bump

# This is the commit message openzfs#12:

Grr

# This is the commit message openzfs#13:

Yay

# This is the commit message openzfs#14:

Yay

# This is the commit message openzfs#15:

Yay

# This is the commit message openzfs#16:

Yay

# This is the commit message openzfs#17:

Yay

# This is the commit message openzfs#18:

Yay

# This is the commit message openzfs#19:

yay

# This is the commit message openzfs#20:

yay

# This is the commit message openzfs#21:

yay

# This is the commit message openzfs#22:

Update ppa script

# This is the commit message openzfs#23:

Update gbp conf with br changes

# This is the commit message openzfs#24:

Update gbp conf with br changes

# This is the commit message openzfs#25:

Bump

# This is the commit message openzfs#26:

No pristine

# This is the commit message openzfs#27:

Bump

# This is the commit message openzfs#28:

Lol whoops

# This is the commit message openzfs#29:

Fix name

# This is the commit message openzfs#30:

Fix name

# This is the commit message openzfs#31:

rebase

# This is the commit message openzfs#32:

Bump

# This is the commit message openzfs#33:

Bump

# This is the commit message openzfs#34:

Bump

# This is the commit message openzfs#35:

Bump

# This is the commit message openzfs#36:

ntrim

# This is the commit message openzfs#37:

Bump

# This is the commit message openzfs#38:

9

# This is the commit message openzfs#39:

Bump

# This is the commit message openzfs#40:

Bump

# This is the commit message openzfs#41:

Bump

# This is the commit message openzfs#42:

Revert "9"

This reverts commit de488f1.

# This is the commit message openzfs#43:

Bump

# This is the commit message openzfs#44:

Account for zconfig.sh being removed

# This is the commit message openzfs#45:

Bump

# This is the commit message openzfs#46:

Add artful

# This is the commit message openzfs#47:

Add in zed.d and zpool.d scripts

# This is the commit message openzfs#48:

Bump

# This is the commit message openzfs#49:

Bump

# This is the commit message openzfs#50:

Bump

# This is the commit message openzfs#51:

Bump

# This is the commit message openzfs#52:

ugh

# This is the commit message openzfs#53:

fix zed upgrade

# This is the commit message openzfs#54:

Bump

# This is the commit message openzfs#55:

conf file zed.d

# This is the commit message #56:

Bump
richardelling pushed a commit to richardelling/zfs that referenced this issue Oct 15, 2018
Signed-off-by: satbir <satbir.chhikara@gmail.com>
@PE1NUT PE1NUT mentioned this issue Sep 24, 2019
ahrens added a commit to ahrens/zfs that referenced this issue Oct 3, 2019
sysinit.target depends on systemd-random-seed.service, so we need to
remove the systemd-random-seed.service dependency from
zfs-mount.service, otherwise it would undo our change related to
local-fs.target done in openzfs#51 (note that all services that do not have
DefaultDependencies=no depend on sysinit.target).

Therefore we discard the upstream change.
tonynguien pushed a commit to tonynguien/zfs that referenced this issue Dec 21, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants