/* * common.h - Common definitions for both Kernel and user-mode utilities * * Copyright (C) 2005, 2006 * Avishay Traeger (avishay@gmail.com) * Copyright (C) 2008, 2009 * Boaz Harrosh * * Copyrights for code taken from ext2: * Copyright (C) 1992, 1993, 1994, 1995 * Remy Card (card@masi.ibp.fr) * Laboratoire MASI - Institut Blaise Pascal * Universite Pierre et Marie Curie (Paris VI) * from * linux/fs/minix/inode.c * Copyright (C) 1991, 1992 Linus Torvalds * * This file is part of exofs. * * exofs is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation. Since it is based on ext2, and the only * valid version of GPL for the Linux kernel is version 2, the only valid * version of GPL for exofs is version 2. * * exofs is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with exofs; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __EXOFS_COM_H__ #define __EXOFS_COM_H__ #include #include #include #include /**************************************************************************** * Object ID related defines * NOTE: inode# = object ID - EXOFS_OBJ_OFF ****************************************************************************/ #define EXOFS_MIN_PID 0x10000 /* Smallest partition ID */ #define EXOFS_OBJ_OFF 0x10000 /* offset for objects */ #define EXOFS_SUPER_ID 0x10000 /* object ID for on-disk superblock */ #define EXOFS_DEVTABLE_ID 0x10001 /* object ID for on-disk device table */ #define EXOFS_ROOT_ID 0x10002 /* object ID for root directory */ /* exofs Application specific page/attribute */ /* Inode attrs */ # define EXOFS_APAGE_FS_DATA (OSD_APAGE_APP_DEFINED_FIRST + 3) # define EXOFS_ATTR_INODE_DATA 1 # define EXOFS_ATTR_INODE_FILE_LAYOUT 2 # define EXOFS_ATTR_INODE_DIR_LAYOUT 3 /* Partition attrs */ # define EXOFS_APAGE_SB_DATA (0xF0000000U + 3) # define EXOFS_ATTR_SB_STATS 1 /* * The maximum number of files we can have is limited by the size of the * inode number. This is the largest object ID that the file system supports. * Object IDs 0, 1, and 2 are always in use (see above defines). */ enum { EXOFS_MAX_INO_ID = (sizeof(ino_t) * 8 == 64) ? ULLONG_MAX : (1ULL << (sizeof(ino_t) * 8ULL - 1ULL)), EXOFS_MAX_ID = (EXOFS_MAX_INO_ID - 1 - EXOFS_OBJ_OFF), }; /**************************************************************************** * Misc. ****************************************************************************/ #define EXOFS_BLKSHIFT 12 #define EXOFS_BLKSIZE (1UL << EXOFS_BLKSHIFT) /**************************************************************************** * superblock-related things ****************************************************************************/ #define EXOFS_SUPER_MAGIC 0x5DF5 /* * The file system control block - stored in object EXOFS_SUPER_ID's data. * This is where the in-memory superblock is stored on disk. */ enum {EXOFS_FSCB_VER = 1, EXOFS_DT_VER = 1}; struct exofs_fscb { __le64 s_nextid; /* Only used after mkfs */ __le64 s_numfiles; /* Only used after mkfs */ __le32 s_version; /* == EXOFS_FSCB_VER */ __le16 s_magic; /* Magic signature */ __le16 s_newfs; /* Non-zero if this is a new fs */ /* From here on it's a static part, only written by mkexofs */ __le64 s_dev_table_oid; /* Resurved, not used */ __le64 s_dev_table_count; /* == 0 means no dev_table */ } __packed; /* * This struct is set on the FS partition's attributes. * [EXOFS_APAGE_SB_DATA, EXOFS_ATTR_SB_STATS] and is written together * with the create command, to atomically persist the sb writeable information. */ struct exofs_sb_stats { __le64 s_nextid; /* Highest object ID used */ __le64 s_numfiles; /* Number of files on fs */ } __packed; /* * Describes the raid used in the FS. It is part of the device table. * This here is taken from the pNFS-objects definition. In exofs we * use one raid policy through-out the filesystem. (NOTE: the funny * alignment at beginning. We take care of it at exofs_device_table. */ struct exofs_dt_data_map { __le32 cb_num_comps; __le64 cb_stripe_unit; __le32 cb_group_width; __le32 cb_group_depth; __le32 cb_mirror_cnt; __le32 cb_raid_algorithm; } __packed; /* * This is an osd device information descriptor. It is a single entry in * the exofs device table. It describes an osd target lun which * contains data belonging to this FS. (Same partition_id on all devices) */ struct exofs_dt_device_info { __le32 systemid_len; u8 systemid[OSD_SYSTEMID_LEN]; __le64 long_name_offset; /* If !0 then offset-in-file */ __le32 osdname_len; /* */ u8 osdname[44]; /* Embbeded, Usually an asci uuid */ } __packed; /* * The EXOFS device table - stored in object EXOFS_DEVTABLE_ID's data. * It contains the raid used for this multy-device FS and an array of * participating devices. */ struct exofs_device_table { __le32 dt_version; /* == EXOFS_DT_VER */ struct exofs_dt_data_map dt_data_map; /* Raid policy to use */ /* Resurved space For future use. Total includeing this: * (8 * sizeof(le64)) */ __le64 __Resurved[4]; __le64 dt_num_devices; /* Array size */ struct exofs_dt_device_info dt_dev_table[]; /* Array of devices */ } __packed; /**************************************************************************** * inode-related things ****************************************************************************/ #define EXOFS_IDATA 5 /* * The file control block - stored in an object's attributes. This is where * the in-memory inode is stored on disk. */ struct exofs_fcb { __le64 i_size; /* Size of the file */ __le16 i_mode; /* File mode */ __le16 i_links_count; /* Links count */ __le32 i_uid; /* Owner Uid */ __le32 i_gid; /* Group Id */ __le32 i_atime; /* Access time */ __le32 i_ctime; /* Creation time */ __le32 i_mtime; /* Modification time */ __le32 i_flags; /* File flags (unused for now)*/ __le32 i_generation; /* File version (for NFS) */ __le32 i_data[EXOFS_IDATA]; /* Short symlink names and device #s */ }; #define EXOFS_INO_ATTR_SIZE sizeof(struct exofs_fcb) /* This is the Attribute the fcb is stored in */ static const struct __weak osd_attr g_attr_inode_data = ATTR_DEF( EXOFS_APAGE_FS_DATA, EXOFS_ATTR_INODE_DATA, EXOFS_INO_ATTR_SIZE); /**************************************************************************** * dentry-related things ****************************************************************************/ #define EXOFS_NAME_LEN 255 /* * The on-disk directory entry */ struct exofs_dir_entry { __le64 inode_no; /* inode number */ __le16 rec_len; /* directory entry length */ u8 name_len; /* name length */ u8 file_type; /* umm...file type */ char name[EXOFS_NAME_LEN]; /* file name */ }; enum { EXOFS_FT_UNKNOWN, EXOFS_FT_REG_FILE, EXOFS_FT_DIR, EXOFS_FT_CHRDEV, EXOFS_FT_BLKDEV, EXOFS_FT_FIFO, EXOFS_FT_SOCK, EXOFS_FT_SYMLINK, EXOFS_FT_MAX }; #define EXOFS_DIR_PAD 4 #define EXOFS_DIR_ROUND (EXOFS_DIR_PAD - 1) #define EXOFS_DIR_REC_LEN(name_len) \ (((name_len) + offsetof(struct exofs_dir_entry, name) + \ EXOFS_DIR_ROUND) & ~EXOFS_DIR_ROUND) /* * The on-disk (optional) layout structure. * sits in an EXOFS_ATTR_INODE_FILE_LAYOUT or EXOFS_ATTR_INODE_DIR_LAYOUT * attribute, attached to any inode, usually to a directory. */ enum exofs_inode_layout_gen_functions { LAYOUT_MOVING_WINDOW = 0, LAYOUT_IMPLICT = 1, }; struct exofs_on_disk_inode_layout { __le16 gen_func; /* One of enum exofs_inode_layout_gen_functions */ __le16 pad; union { /* gen_func == LAYOUT_MOVING_WINDOW (default) */ struct exofs_layout_sliding_window { __le32 num_devices; /* first n devices in global-table*/ } sliding_window __packed; /* gen_func == LAYOUT_IMPLICT */ struct exofs_layout_implict_list { struct exofs_dt_data_map data_map; /* Variable array of size data_map.cb_num_comps. These * are device indexes of the devices in the global table */ __le32 dev_indexes[]; } implict __packed; }; } __packed; static inline size_t exofs_on_disk_inode_layout_size(unsigned max_devs) { return sizeof(struct exofs_on_disk_inode_layout) + max_devs * sizeof(__le32); } #endif /*ifndef __EXOFS_COM_H__*/ fallback mechanism and preventing access from it once we abort as its inside the buf (buf->fw_st). The firmware_class.c code is setting the buf to NULL to annotate an abort has occurred. Replace this mechanism by simply using the state check instead. All the other code in place already uses similar checks for aborting as well so no further changes are needed. An oops can be reproduced with the new fw_fallback.sh fallback mechanism cancellation test. Either cancelling the fallback mechanism or the custom fallback mechanism triggers a crash. mcgrof@piggy ~/linux-next/tools/testing/selftests/firmware (git::20170111-fw-fixes)$ sudo ./fw_fallback.sh ./fw_fallback.sh: timeout works ./fw_fallback.sh: firmware comparison works ./fw_fallback.sh: fallback mechanism works [ this then sits here when it is trying the cancellation test ] Kernel log: test_firmware: loading 'nope-test-firmware.bin' misc test_firmware: Direct firmware load for nope-test-firmware.bin failed with error -2 misc test_firmware: Falling back to user helper BUG: unable to handle kernel NULL pointer dereference at 0000000000000038 IP: _request_firmware+0xa27/0xad0 PGD 0 Oops: 0000 [#1] SMP Modules linked in: test_firmware(E) ... etc ... CPU: 1 PID: 1396 Comm: fw_fallback.sh Tainted: G W E 4.10.0-rc3-next-20170111+ #30 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.10.1-0-g8891697-prebuilt.qemu-project.org 04/01/2014 task: ffff9740b27f4340 task.stack: ffffbb15c0bc8000 RIP: 0010:_request_firmware+0xa27/0xad0 RSP: 0018:ffffbb15c0bcbd10 EFLAGS: 00010246 RAX: 00000000fffffffe RBX: ffff9740afe5aa80 RCX: 0000000000000000 RDX: ffff9740b27f4340 RSI: 0000000000000283 RDI: 0000000000000000 RBP: ffffbb15c0bcbd90 R08: ffffbb15c0bcbcd8 R09: 0000000000000000 R10: 0000000894a0d4b1 R11: 000000000000008c R12: ffffffffc0312480 R13: 0000000000000005 R14: ffff9740b1c32400 R15: 00000000000003e8 FS: 00007f8604422700(0000) GS:ffff9740bfc80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000038 CR3: 000000012164c000 CR4: 00000000000006e0 Call Trace: request_firmware+0x37/0x50 trigger_request_store+0x79/0xd0 [test_firmware] dev_attr_store+0x18/0x30 sysfs_kf_write+0x37/0x40 kernfs_fop_write+0x110/0x1a0 __vfs_write+0x37/0x160 ? _cond_resched+0x1a/0x50 vfs_write+0xb5/0x1a0 SyS_write+0x55/0xc0 ? trace_do_page_fault+0x37/0xd0 entry_SYSCALL_64_fastpath+0x1e/0xad RIP: 0033:0x7f8603f49620 RSP: 002b:00007fff6287b788 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 000055c307b110a0 RCX: 00007f8603f49620 RDX: 0000000000000016 RSI: 000055c3084d8a90 RDI: 0000000000000001 RBP: 0000000000000016 R08: 000000000000c0ff R09: 000055c3084d6336 R10: 000055c307b108b0 R11: 0000000000000246 R12: 000055c307b13c80 R13: 000055c3084d6320 R14: 0000000000000000 R15: 00007fff6287b950 Code: 9f 64 84 e8 9c 61 fe ff b8 f4 ff ff ff e9 6b f9 ff ff 48 c7 c7 40 6b 8d 84 89 45 a8 e8 43 84 18 00 49 8b be 00 03 00 00 8b 45 a8 <83> 7f 38 02 74 08 e8 6e ec ff ff 8b 45 a8 49 c7 86 00 03 00 00 RIP: _request_firmware+0xa27/0xad0 RSP: ffffbb15c0bcbd10 CR2: 0000000000000038 ---[ end trace 6d94ac339c133e6f ]--- Fixes: 5d47ec02c37e ("firmware: Correct handling of fw_state_wait() return value") Reported-and-Tested-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reported-and-Tested-by: Patrick Bruenn <p.bruenn@beckhoff.com> Reported-by: Chris Wilson <chris@chris-wilson.co.uk> CC: <stable@vger.kernel.org> [3.10+] Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'sound/soc/samsung/Makefile')