Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

autofs: work around unhappy compat problem on x86-64

When the autofs protocol version 5 packet type was added in commit
5c0a32f ("autofs4: add new packet type for v5 communications"), it
obvously tried quite hard to be word-size agnostic, and uses explicitly
sized fields that are all correctly aligned.

However, with the final "char name[NAME_MAX+1]" array at the end, the
actual size of the structure ends up being not very well defined:
because the struct isn't marked 'packed', doing a "sizeof()" on it will
align the size of the struct up to the biggest alignment of the members
it has.

And despite all the members being the same, the alignment of them is
different: a "__u64" has 4-byte alignment on x86-32, but native 8-byte
alignment on x86-64.  And while 'NAME_MAX+1' ends up being a nice round
number (256), the name[] array starts out a 4-byte aligned.

End result: the "packed" size of the structure is 300 bytes: 4-byte, but
not 8-byte aligned.

As a result, despite all the fields being in the same place on all
architectures, sizeof() will round up that size to 304 bytes on
architectures that have 8-byte alignment for u64.

Note that this is *not* a problem for 32-bit compat mode on POWER, since
there __u64 is 8-byte aligned even in 32-bit mode.  But on x86, 32-bit
and 64-bit alignment is different for 64-bit entities, and as a result
the structure that has exactly the same layout has different sizes.

So on x86-64, but no other architecture, we will just subtract 4 from
the size of the structure when running in a compat task.  That way we
will write the properly sized packet that user mode expects.

Not pretty.  Sadly, this very subtle, and unnecessary, size difference
has been encoded in user space that wants to read packets of *exactly*
the right size, and will refuse to touch anything else.

Reported-and-tested-by: Thomas Meyer <thomas@m3y3r.de>
Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
latest commit a32744d4ab
@raven-au raven-au authored torvalds committed
..
Failed to load latest commit information.
9p Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
adfs vfs: switch ->show_options() to struct dentry *
affs affs: propagate umode_t
afs switch ->create() to umode_t
autofs4 autofs: work around unhappy compat problem on x86-64
befs vfs: fix the stupidity with i_dentry in inode destructors
bfs switch ->create() to umode_t
btrfs Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
cachefiles fs: move code out of buffer.c
ceph Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
cifs cifs: don't return error from standard_receive3 after marking respons…
coda coda: switch coda_cnode_make() to sane API as well, clean coda_lookup()
configfs configfs: convert to umode_t
cramfs Merge branches 'vfsmount-guts', 'umode_t' and 'partitions' into Z
debugfs kernel-doc: fix new warnings in debugfs
devpts devpts: fix double-free on mount failure
dlm Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
ecryptfs ecryptfs: remove the second argument of k[un]map_atomic()
efs vfs: fix the stupidity with i_dentry in inode destructors
exofs Merge branch 'for-linus' of git://git.open-osd.org/linux-open-osd
exportfs vfs: Add open by file handle support
ext2 ext2: protect inode changes in the SETVERSION and SETFLAGS ioctls
ext3 Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel…
ext4 Merge branch 'for_linus' into for_linus_merged
fat Merge branch 'usb-next' of git://git.kernel.org/pub/scm/linux/kernel/…
freevxfs fs: propagate umode_t, misc bits
fscache FS-Cache: Fix __fscache_uncache_all_inode_pages()'s outer loop
fuse Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
gfs2 GFS2: Fix nlink setting on inode creation
hfs vfs: switch ->show_options() to struct dentry *
hfsplus hfsplus: creation of hidden dir on mount can fail
hostfs vfs: switch ->show_options() to struct dentry *
hpfs switch ->mknod() to umode_t
hppfs vfs: for usbfs, etc. internal vfsmounts ->mnt_sb->s_root == ->mnt_root
hugetlbfs mm: compaction: introduce sync-light migration for use by compaction
isofs isofs: inode leak on mount failure
jbd jbd: Issue cache flush after checkpointing
jbd2 Merge branch 'for_linus' into for_linus_merged
jffs2 jffs2: do not initialize variable unnecessarily
jfs Merge branch 'pm-for-linus' of git://git.kernel.org/pub/scm/linux/ker…
lockd module_param: make bool parameters really bool (drivers & misc)
logfs mtd: fix merge conflict resolution breakage
minix Merge branch 'for-linus2' of git://git.kernel.org/pub/scm/linux/kerne…
ncpfs vfs: switch ->show_options() to struct dentry *
nfs NFSv4: fix server_scope memory leak
nfs_common Fix common misspellings
nfsd Merge branch 'for-3.3' of git://linux-nfs.org/~bfields/linux
nilfs2 nilfs2: avoid overflowing segment numbers in nilfs_ioctl_clean_segmen…
nls NLS: raname "maxlen" to "maxout" in UTF conversion routines
notify fsnotify: don't BUG in fsnotify_destroy_mark()
ntfs module_param: avoid bool abuse, add bint for special cases.
ocfs2 ocfs2: deal with wraparounds of i_nlink in ocfs2_rename()
omfs omfs: propagate umode_t
openpromfs vfs: fix the stupidity with i_dentry in inode destructors
proc Fix race in process_vm_rw_core
pstore pstore: gracefully handle NULL pstore_info functions
qnx4 qnx4: don't leak ->BitMap on late failure exits
quota quota: Fix deadlock with suspend and quotas
ramfs pohmelfs: propagate umode_t
reiserfs reiserfs: don't lock root inode searching
romfs Merge tag 'for-linus-3.3' of git://git.infradead.org/mtd-2.6
squashfs Merge git://git.kernel.org/pub/scm/linux/kernel/git/pkl/squashfs-next
sysfs sysfs: Complain bitterly about attempts to remove files from nonexist…
sysv vfs: prefer ->dentry->d_sb to ->mnt->mnt_sb
ubifs UBIFS: fix non-debug configuration build
udf Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel…
ufs vfs: switch ->show_options() to struct dentry *
xfs
Kconfig Merge branch 'for-linus' of git://git.open-osd.org/linux-open-osd
Kconfig.binfmt fs: binfmt_elf: create Kconfig variable for PIE randomization
Makefile Merge branches 'vfsmount-guts', 'umode_t' and 'partitions' into Z
aio.c Unused iocbs in a batch should not be accounted as active.
anon_inodes.c vfs: dont chain pipe/anon/socket on superblock s_inodes list
attr.c switch is_sxid() to umode_t
bad_inode.c switch ->mknod() to umode_t
binfmt_aout.c Don't dump task struct in a.out core-dumps
binfmt_elf.c fs: binfmt_elf: create Kconfig variable for PIE randomization
binfmt_elf_fdpic.c consolidate BINPRM_FLAGS_ENFORCE_NONDUMP handling
binfmt_em86.c include cleanup: Update gfp.h and slab.h includes to prepare for brea…
binfmt_flat.c CRED: Fix load_flat_shared_library() to initialise bprm correctly
binfmt_misc.c vfs: prefer ->dentry->d_sb to ->mnt->mnt_sb
binfmt_script.c Make do_execve() take a const filename pointer
binfmt_som.c Split 'flush_old_exec' into two functions
bio-integrity.c fs: add export.h to files using EXPORT_SYMBOL/THIS_MODULE macros
bio.c bio: don't overflow in bio_get_nr_vecs()
block_dev.c vfs: cache request_queue in struct block_device
buffer.c fs: move code out of buffer.c
char_dev.c char_dev.c: fix up some whitespace errors
compat.c vfs: fix compat_sys_stat() handling of overflows in st_nlink
compat_binfmt_elf.c elf coredump: replace ELF_CORE_EXTRA_* macros by functions
compat_ioctl.c Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/ke…
dcache.c vfs: fix panic in __d_lookup() with high dentry hashtable counts
dcookies.c oprofile, dcookies: Fix possible circular locking dependency
direct-io.c Restore direct_io / truncate locking API
drop_caches.c vmscan: change shrinker API by passing shrink_control struct
eventfd.c Docbook: add fs/eventfd.c and fix typos in it
eventpoll.c epoll: ep_unregister_pollwait() can use the freed pwq->whead
exec.c exec: fix use-after-free bug in setup_new_exec()
fcntl.c userns: rename is_owner_or_cap to inode_owner_or_capable
fhandle.c vfs: prefer ->dentry->d_sb to ->mnt->mnt_sb
fifo.c Filesystem: fifo: Fixed coding style issue.
file.c vfs: avoid large kmalloc()s for the fdtable
file_table.c vfs: prevent remount read-only if pending removes
filesystems.c vfs: convert fs_supers to hlist
fs-writeback.c writeback: fix NULL bdi->dev in trace writeback_single_inode
fs_struct.c sanitize vfsmount refcounting changes
generic_acl.c switch posix_acl_equiv_mode() to umode_t *
inode.c vfs: fix panic in __d_lookup() with high dentry hashtable counts
internal.h vfs: protect remounting superblock read-only
ioctl.c vfs: fix up ENOIOCTLCMD error handling
ioprio.c block: strip out locking optimization in put_io_context()
libfs.c fs: move code out of buffer.c
locks.c vfs: fix handling of lock allocation failure in lease-break case
mbcache.c vmscan: change shrinker API by passing shrink_control struct
mount.h vfs: keep list of mounts for each superblock
mpage.c fs: remove unneeded plug in mpage_readpages()
namei.c vfs: fix d_inode_lookup() dentry ref leak
namespace.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
no-block.c llseek: automatically add .llseek fop
open.c switch security_path_chmod() to struct path *
pipe.c pipe: fail cleanly when root tries F_SETPIPE_SZ with big size
pnode.c vfs: switch pnode.h macros to struct mount *
pnode.h vfs: switch pnode.h macros to struct mount *
posix_acl.c vfs: pass all mask flags check_acl and posix_acl_permission
proc_namespace.c vfs: switch ->show_options() to struct dentry *
read_write.c Cross Memory Attach
read_write.h [PATCH] Remove readv/writev methods and use aio_read/aio_write instead
readdir.c vfs: fix warning: 'dirent' is used uninitialized in this function
select.c sys_poll: fix incorrect type for 'timeout' parameter
seq_file.c constify seq_file stuff
signalfd.c epoll: ep_unregister_pollwait() can use the freed pwq->whead
splice.c fs: move code out of buffer.c
stack.c filesystems: add set_nlink()
stat.c readlinkat: ensure we return ENOENT for the empty pathname for normal…
statfs.c vfs: new helper - vfs_ustat()
super.c vfs: Provide function to get superblock and wait for it to thaw
sync.c fs: move code out of buffer.c
timerfd.c timerfd: Fix wakeup of processes when timer is cancelled on clock change
utimes.c userns: rename is_owner_or_cap to inode_owner_or_capable
xattr.c
xattr_acl.c include cleanup: Update gfp.h and slab.h includes to prepare for brea…
Something went wrong with that request. Please try again.