106 Commits

Author SHA1 Message Date
qctecmdr Service
6618be6f36 Merge "Merge android-4.14-p.74 (91ff1d1) into msm-4.14" 2018-10-17 21:12:24 -07:00
Blagovest Kolenichev
6a2de27bd7 Merge android-4.14-p.74 (91ff1d1) into msm-4.14
* refs/heads/tmp-91ff1d1:
  ANDROID: sdcardfs: Change current->fs under lock
  ANDROID: sdcardfs: Don't use OVERRIDE_CRED macro
  Linux 4.14.74
  media: v4l: event: Prevent freeing event subscriptions while accessed
  arm64: KVM: Sanitize PSTATE.M when being set from userspace
  x86/pti: Fix section mismatch warning/error
  i2c: i801: Allow ACPI AML access I/O ports not reserved for SMBus
  arm/arm64: smccc-1.1: Handle function result as parameters
  arm/arm64: smccc-1.1: Make return values unsigned long
  ARM: dts: omap4-droid4: Fix emmc errors seen on some devices
  nvme-fcloop: Fix dropped LS's to removed target port
  ata: ftide010: Add a quirk for SQ201
  drm/amdgpu: Update power state at the end of smu hw_init.
  drm/amdgpu: Enable/disable gfx PG feature in rlc safe mode
  Revert "ARM: dts: imx7d: Invert legacy PCI irq mapping"
  hwmon: (adt7475) Make adt7475_read_word() return errors
  hwmon: (ina2xx) fix sysfs shunt resistor read access
  crypto: cavium/nitrox - fix for command corruption in queue full case with backlog submissions.
  e1000: ensure to free old tx/rx rings in set_ringparam()
  e1000: check on netif_running() before calling e1000_up()
  net: hns: fix skb->truesize underestimation
  net: hns: fix length and page_offset overflow when CONFIG_ARM64_64K_PAGES
  bpf: sockmap: write_space events need to be passed to TCP handler
  tls: possible hang when do_tcp_sendpages hits sndbuf is full case
  isofs: reject hardware sector size > 2048 bytes
  thermal: of-thermal: disable passive polling when thermal zone is disabled
  qed: Avoid sending mailbox commands when MFW is not responsive
  qed: Prevent a possible deadlock during driver load and unload
  qed: Wait for MCP halt and resume commands to take place
  qed: Wait for ready indication before rereading the shmem
  arm64: KVM: Tighten guest core register access from userspace
  serial: imx: restore handshaking irq for imx1
  drm/i915: Remove vma from object on destroy, not close
  ovl: hash non-dir by lower inode for fsnotify
  RDMA/uverbs: Atomically flush and mark closed the comp event queue
  IB/hfi1: Fix context recovery when PBC has an UnsupportedVL
  IB/hfi1: Invalid user input can result in crash
  IB/hfi1: Fix SL array bounds check
  IB/srp: Avoid that sg_reset -d ${srp_device} triggers an infinite loop
  Input: elantech - enable middle button of touchpad on ThinkPad P72
  USB: remove LPM management from usb_driver_claim_interface()
  Revert "usb: cdc-wdm: Fix a sleep-in-atomic-context bug in service_outstanding_interrupt()"
  USB: usbdevfs: restore warning for nonsensical flags
  USB: usbdevfs: sanitize flags more
  media: uvcvideo: Support realtek's UVC 1.5 device
  slub: make ->cpu_partial unsigned int
  usb: musb: dsps: do not disable CPPI41 irq in driver teardown
  USB: handle NULL config in usb_find_alt_setting()
  USB: fix error handling in usb_driver_claim_interface()
  regulator: fix crash caused by null driver data
  spi: rspi: Fix interrupted DMA transfers
  spi: rspi: Fix invalid SPI use during system suspend
  spi: sh-msiof: Fix handling of write value for SISTR register
  spi: sh-msiof: Fix invalid SPI use during system suspend
  spi: tegra20-slink: explicitly enable/disable clock
  intel_th: Fix device removal logic
  serial: cpm_uart: return immediately from console poll
  tty: serial: lpuart: avoid leaking struct tty_struct
  x86/mm: Expand static page table for fixmap space
  floppy: Do not copy a kernel pointer to user memory in FDGETPRM ioctl
  ARM: dts: dra7: fix DCAN node addresses
  iio: 104-quad-8: Fix off-by-one error in register selection
  Input: xen-kbdfront - fix multi-touch XenStore node's locations
  fs/lock: skip lock owner pid translation in case we are in init_pid_ns
  EDAC: Fix memleak in module init error path
  nfsd: fix corrupted reply to badly ordered compound
  gpio: Fix wrong rounding in gpio-menz127
  module: exclude SHN_UNDEF symbols from kallsyms api
  ASoC: dapm: Fix potential DAI widget pointer deref when linking DAIs
  EDAC, i7core: Fix memleaks and use-after-free on probe and remove
  scsi: megaraid_sas: Update controller info during resume
  iomap: complete partial direct I/O writes synchronously
  scsi: bnx2i: add error handling for ioremap_nocache
  perf/x86/intel/lbr: Fix incomplete LBR call stack
  MIPS: boot: fix build rule of vmlinux.its.S
  HID: hid-ntrig: add error handling for sysfs_create_group
  arm: dts: mediatek: Add missing cooling device properties for CPUs
  ARM: mvebu: declare asm symbols as character arrays in pmsu.c
  wlcore: Add missing PM call for wlcore_cmd_wait_for_event_or_timeout()
  brcmsmac: fix wrap around in conversion from constant to s16
  rndis_wlan: potential buffer overflow in rndis_wlan_auth_indication()
  ath10k: transmit queued frames after processing rx packets
  drm/sun4i: Fix releasing node when enumerating enpoints
  net: phy: xgmiitorgmii: Check phy_driver ready before accessing
  ath10k: protect ath10k_htt_rx_ring_free with rx_ring.lock
  net: phy: xgmiitorgmii: Check read_status results
  ALSA: hda: Add AZX_DCAPS_PM_RUNTIME for AMD Raven Ridge
  media: tm6000: add error handling for dvb_register_adapter
  drivers/tty: add error handling for pcmcia_loop_config
  staging: android: ashmem: Fix mmap size validation
  media: omap3isp: zero-initialize the isp cam_xclk{a,b} initial data
  media: soc_camera: ov772x: correct setting of banding filter
  media: s3c-camif: ignore -ENOIOCTLCMD from v4l2_subdev_call for s_power
  ALSA: snd-aoa: add of_node_put() in error path
  posix-timers: Sanitize overrun handling
  posix-timers: Make forward callback return s64
  iio: accel: adxl345: convert address field usage in iio_chan_spec
  mtd: rawnand: atmel: add module param to avoid using dma
  s390/extmem: fix gcc 8 stringop-overflow warning
  s390/scm_blk: correct numa_node in scm_blk_dev_setup
  s390/dasd: correct numa_node in dasd_alloc_queue
  alarmtimer: Prevent overflow for relative nanosleep
  s390/sysinfo: add missing #ifdef CONFIG_PROC_FS
  powerpc/powernv/ioda2: Reduce upper limit for DMA window size
  ath10k: sdio: set skb len for all rx packets
  ath10k: sdio: use same endpoint id for all packets in a bundle
  usb: wusbcore: security: cast sizeof to int for comparison
  scsi: target: Avoid that EXTENDED COPY commands trigger lock inversion
  scsi: ibmvscsi: Improve strings handling
  scsi: klist: Make it safe to use klists in atomic context
  scsi: target/iscsi: Make iscsit_ta_authentication() respect the output buffer size
  ARM: dts: ls1021a: Add missing cooling device properties for CPUs
  x86/entry/64: Add two more instruction suffixes
  ARM: hwmod: RTC: Don't assume lock/unlock will be called with irq enabled
  x86/tsc: Add missing header to tsc_msr.c
  media: staging/imx: fill vb2_v4l2_buffer field entry
  media: fsl-viu: fix error handling in viu_of_probe()
  powerpc/kdump: Handle crashkernel memory reservation failure
  IB/mlx4: Test port number before querying type.
  media: exynos4-is: Prevent NULL pointer dereference in __isp_video_try_fmt()
  IB/core: type promotion bug in rdma_rw_init_one_mr()
  RDMA/i40w: Hold read semaphore while looking after VMA
  RDMA/bnxt_re: Fix a couple off by one bugs
  md-cluster: clear another node's suspend_area after the copy is finished
  power: remove possible deadlock when unregistering power_supply
  s390/mm: correct allocate_pgste proc_handler callback
  iommu/msm: Don't call iommu_device_{,un}link from atomic context
  6lowpan: iphc: reset mac_header after decompress to fix panic
  USB: serial: kobil_sct: fix modem-status error handling
  Bluetooth: Add a new Realtek 8723DE ID 0bda:b009
  iommu/amd: make sure TLB to be flushed before IOVA freed
  power: vexpress: fix corruption in notifier registration
  uwb: hwa-rc: fix memory leak at probe
  serial: sh-sci: Stop RX FIFO timer during port shutdown
  misc: sram: enable clock before registering regions
  power: supply: axp288_charger: Fix initial constant_charge_current value
  staging: rts5208: fix missing error check on call to rtsx_write_register
  x86/numa_emulation: Fix emulated-to-physical node mapping
  vmci: type promotion bug in qp_host_get_user_memory()
  tsl2550: fix lux1_input error in low light
  iio: adc: ina2xx: avoid kthread_stop() with stale task_struct
  crypto: skcipher - Fix -Wstringop-truncation warnings

Change-Id: I449d491af38003c7556865c2583b01f8560271dd
Signed-off-by: Blagovest Kolenichev <bkolenichev@codeaurora.org>
2018-10-05 14:59:40 -07:00
Daniel Rosenberg
5e9ff6357f ANDROID: sdcardfs: Change current->fs under lock
Adjusted from previous version to add missing include

bug: 111641492

Change-Id: I321d83f5d599efb3abdfaf2f3a4900ac512beca6
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2018-10-04 08:56:27 -07:00
Daniel Rosenberg
e00c21e88e ANDROID: sdcardfs: Don't use OVERRIDE_CRED macro
The macro hides some control flow, making it easier
to run into bugs.

bug: 111642636

Change-Id: I37ec207c277d97c4e7f1e8381bc9ae743ad78435
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2018-10-04 08:56:19 -07:00
Daniel Rosenberg
fed0824ab9 ANDROID: sdcardfs: Check stacked filesystem depth
bug: 111860541
Change-Id: Ia0a30b2b8956c4ada28981584cd8647713a1e993
Signed-off-by: Daniel Rosenberg <drosen@google.com>
(cherry picked from commit 9664bdeff388afe4749eee2332bc0cc220b6cee2)
Git-commit: 9664bdeff388afe4749eee2332bc0cc220b6cee2
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
2018-09-24 04:36:47 -07:00
Ritesh Harjani
d6fc24244f sdcardfs: Fix the format prints in sdcardfs
Fix the %p format prints with %pK.

Change-Id: I5fbe70350d7b4d986a2b070c9a2602d9d7680dc9
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
2018-07-21 12:25:00 +05:30
Lianjun Huang
c4b98f6473 ANDROID: sdcardfs: fix potential crash when reserved_mb is not zero
sdcardfs_mkdir() calls check_min_free_space(). When reserved_mb is not zero, a negative dentry will be passed to
ext4_statfs() at last and ext4_statfs() will crash. The parent dentry is positive. So we use the parent dentry to
check free space.

Change-Id: I80ab9623fe59ba911f4cc9f0e029a1c6f7ee421b
Signed-off-by: Lianjun Huang <huanglianjun@vivo.com>
2018-06-25 22:13:02 +00:00
Daniel Rosenberg
cc15bd0026 ANDROID: sdcardfs: Don't d_drop in d_revalidate
After d_revalidate returns 0, the vfs will call
d_invalidate, which will call d_drop itself, along
with other cleanup.

Bug: 78262592
Change-Id: Idbb30e008c05d62edf2217679cb6a5517d8d1a2c
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2018-05-18 20:29:26 +00:00
Daniel Rosenberg
4da009f6cd ANDROID: sdcardfs: Set s_root to NULL after putting
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 77923821
Change-Id: I1705bfd146009561d2d1da5f0e6a342ec6932a1c
2018-04-25 20:41:03 +00:00
Daniel Rosenberg
b556f4e38f ANDROID: sdcardfs: d_make_root calls iput
d_make_root will call iput on failure, so we
shouldn't try to do that ourselves.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 77923821
Change-Id: I1abb4afb0f894ab917b7c6be8c833676f436beb7
2018-04-25 20:40:55 +00:00
Daniel Rosenberg
608391f449 ANDROID: sdcardfs: Check for private data earlier
When an sdcardfs dentry is destroyed, it may not yet
have its fsdata initialized. It must be checked before
we try to access the paths in its private data.

Additionally, when cleaning up the superblock after
a failure, we don't have our sb private data, so
check for that case.

Bug: 77923821
Change-Id: I89caf6e121ed86480b42024664453fe0031bbcf3
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2018-04-25 20:40:46 +00:00
Ritesh Harjani
802d80cd74 ANDROID: sdcardfs: Fix sdcardfs to stop creating cases-sensitive duplicate entries.
sdcardfs_name_match gets a 'name' argument from the underlying FS.
This need not be null terminated string.
So in sdcardfs_name_match -> qstr_case_eq -> we should use
str_n_case_eq.

This happens because few of the entries in lower level FS may not be
NULL terminated and may have some garbage characters passed while
doing sdcardfs_name_match.

For e.g.
 # dmesg |grep Download
 [  103.646386] sdcardfs_name_match: q1->name=.nomedia, q1->len=8,
 q2->name=Download\x17\x80\x03, q2->len=8
 [  104.021340] sdcardfs_name_match: q1->name=.nomedia, q1->len=8,
 q2->name=Download\x17\x80\x03, q2->len=8
 [  105.196864] sdcardfs_name_match: q1->name=.nomedia, q1->len=8,
 q2->name=Download\x17\x80\x03, q2->len=8
 [  109.113521] sdcardfs_name_match: q1->name=logs, q1->len=4,
 q2->name=Download\x17\x80\x03, q2->len=8

Now when we try to create a directory with different case for a such
files. SDCARDFS creates a entry if it could not find the underlying
entry in it's dcache.

To reproduce:-
1. bootup the device wait for some time after sdcardfs mounting to
   complete.
2. cd /storage/emulated/0
3. echo 3 > /proc/sys/vm/drop_caches
4. mkdir download

We now start seeing two entries with name.
Download & download.

Change-Id: I976d92a220a607dd8cdb96c01c2041c5c2bc3326
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
bug: 75987238
2018-04-06 17:05:26 -07:00
Daniel Rosenberg
b01df612f7 ANDROID: sdcardfs: fix lock issue on 32 bit/SMP architectures
Fixes: cc668ff4b6a1 ("ANDROID: sdcardfs: Hold i_mutex for i_size_write")

Change-Id: If7f2ed90f59c552b9ef9262b0f6aaed394f68784
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 73287721
2018-03-15 19:58:13 -07:00
Ritesh Harjani
b479cddd98 ANDROID: sdcardfs: Set num in extension_details during make_item
Without this patch when you delete an extension from configfs
it still exists in the hash table data structures and we are
unable to delete it or change it's group.
This happens because during deletion the key & value is taken from
extension_details, and was not properly set.

Fix it by this patch.

Change-Id: I7c20cb1ab4d99e6aceadcb5ef850f0bb47f18be8
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 73055997
2018-02-26 16:25:20 -08:00
Daniel Rosenberg
cc668ff4b6 ANDROID: sdcardfs: Hold i_mutex for i_size_write
When we call i_size_write, we must be holding i_mutex to avoid
possible lockups on 32 bit/SMP architectures. This is not
necessary on 64 bit architectures.

Change-Id: Ic3b946507c54d81b5c9046f9b57d25d4b0f9feef
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 73287721
2018-02-23 14:51:17 -08:00
Daniel Rosenberg
108bd1bb74 ANDROID: sdcardfs: Protect set_top
If the top is changed while we're attempting to use it, it's
possible that the reference will be put while we are in the
process of grabbing a reference.

Now we grab a spinlock to protect grabbing our reference count.

Additionally, we now set the inode_info's top value to point to
it's own data when initializing, which makes tracking changes
easier.

Change-Id: If15748c786ce4c0480ab8c5051a92523aff284d2
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2018-02-02 20:04:44 -08:00
Daniel Rosenberg
d627a9b86f Revert "ANDROID: sdcardfs: notify lower file of opens"
This reverts commit cb83f9ee4dbca51cef9ee710c2f8fdd96e7c996f.

Instead of calling notify within sdcardfs, which reverse the
order of notifications during an open with truncate, we'll
make fs_notify worry about it.

Change-Id: Ic634401c0f223500066300a4df8b1453a0b35b60
Bug: 70706497
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2018-02-02 20:04:45 -08:00
Daniel Rosenberg
b3dcc78634 ANDROID: sdcardfs: Use lower getattr times/size
We now use the lower filesystem's getattr for time and size related
information.

Change-Id: I3dd05614a0c2837a13eeb033444fbdf070ddce2a
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 72007585
2018-02-02 19:54:14 -08:00
Daniel Rosenberg
d245b19680 ANDROID: sdcardfs: port to 4.14
Change-Id: I03271d8e8229ce6f22f337dc7d1938e0bf060f2a
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 70278506
2018-01-29 19:40:13 -08:00
Daniel Rosenberg
6c72cab166 ANDROID: sdcardfs: Add default_normal option
The default_normal option causes mounts with the gid set to
AID_SDCARD_RW to have user specific gids, as in the normal case.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Change-Id: I9619b8ac55f41415df943484dc8db1ea986cef6f
Bug: 64672411
2018-01-29 19:40:12 -08:00
Daniel Rosenberg
cb83f9ee4d ANDROID: sdcardfs: notify lower file of opens
fsnotify_open is not called within dentry_open,
so we need to call it ourselves.

Change-Id: Ia7f323b3d615e6ca5574e114e8a5d7973fb4c119
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 70706497
2018-01-29 19:40:11 -08:00
Daniel Rosenberg
53a088296f ANDROID: Sdcardfs: Move gid derivation under flag
This moves the code to adjust the gid/uid of lower filesystem
files under the mount flag derive_gid.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Change-Id: I44eaad4ef67c7fcfda3b6ea3502afab94442610c
Bug: 63245673
2018-01-29 19:40:11 -08:00
Jaegeuk Kim
f1c935b3a1 ANDROID: sdcardfs: override credential for ioctl to lower fs
Otherwise, lower_fs->ioctl() fails due to inode_owner_or_capable().

Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Bug: 63260873
Change-Id: I623a6c7c5f8a3cbd7ec73ef89e18ddb093c43805
2018-01-29 19:40:11 -08:00
Daniel Rosenberg
f616fece5f ANDROID: sdcardfs: Remove unnecessary lock
The mmap_sem lock does not appear to be protecting
anything, and has been removed in Samsung's more
recent versions of sdcardfs.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Change-Id: I76ff3e33002716b8384fc8be368028ed63dffe4e
Bug: 63785372
2018-01-29 19:40:11 -08:00
Gao Xiang
f7fb301084 ANDROID: sdcardfs: use mount_nodev and fix a issue in sdcardfs_kill_sb
Use the VFS mount_nodev instead of customized mount_nodev_with_options
and fix generic_shutdown_super to kill_anon_super because of set_anon_super

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Change-Id: Ibe46647aa2ce49d79291aa9d0295e9625cfccd80
2018-01-29 19:40:11 -08:00
Greg Hackmann
494fd56001 ANDROID: sdcardfs: remove dead function open_flags_to_access_mode()
smatch warns about the suspicious formatting in the last line of
open_flags_to_access_mode().  It turns out the only caller was deleted
over a year ago by "ANDROID: sdcardfs: Bring up to date with Android M
permissions:", so we can "fix" the function's formatting by deleting it.

Change-Id: Id85946f3eb01722eef35b1815f405a6fda3aa4ff
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2018-01-29 19:40:11 -08:00
Daniel Rosenberg
d5dadb6c35 ANDROID: sdcardfs: d_splice_alias can return error values
We must check that d_splice_alias was successful before using its
output.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 62390017
Change-Id: Ifda0a052fb3f67e35c635a4e5e907876c5400978
2018-01-29 19:40:10 -08:00
Daniel Rosenberg
4fce2666e5 ANDROID: sdcardfs: Check for NULL in revalidate
If the inode is in the process of being evicted,
the top value may be NULL.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 38502532
Change-Id: I0b9d04aab621e0398d44d1c5dc53293106aa5f89
2018-01-29 19:40:10 -08:00
Daniel Rosenberg
638eed3f5e ANDROID: sdcardfs: Move top to its own struct
Move top, and the associated data, to its own struct.
This way, we can properly track refcounts on top
without interfering with the inode's accounting.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 38045152
Change-Id: I1968e480d966c3f234800b72e43670ca11e1d3fd
2018-01-29 19:40:10 -08:00
Gao Xiang
25a818e73e ANDROID: sdcardfs: fix sdcardfs_destroy_inode for the inode RCU approach
According to the following commits,
fs: icache RCU free inodes
vfs: fix the stupidity with i_dentry in inode destructors

sdcardfs_destroy_inode should be fixed for the fast path safety.

Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Change-Id: I84f43c599209d23737c7e28b499dd121cb43636d
2018-01-29 19:40:10 -08:00
Daniel Roseberg
228f1c7f4e ANDROID: sdcardfs: Don't iput if we didn't igrab
If we fail to get top, top is either NULL, or igrab found
that we're in the process of freeing that inode, and did
not grab it. Either way, we didn't grab it, and have no
business putting it.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 38117720
Change-Id: Ie2f587483b9abb5144263156a443e89bc69b767b
2018-01-29 19:40:10 -08:00
Daniel Rosenberg
906fb11709 ANDROID: sdcardfs: Call lower fs's revalidate
We should be calling the lower filesystem's revalidate
inside of sdcardfs's revalidate, as wrapfs does.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 35766959
Change-Id: I939d1c4192fafc1e21678aeab43fe3d588b8e2f4
2018-01-29 19:40:09 -08:00
Daniel Rosenberg
70472b2be7 ANDROID: sdcardfs: Avoid setting GIDs outside of valid ranges
When setting up the ownership of files on the lower filesystem,
ensure that these values are in reasonable ranges for apps. If
they aren't, default to AID_MEDIA_RW

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 37516160
Change-Id: I0bec76a61ac72aff0b993ab1ad04be8382178a00
2018-01-29 19:40:09 -08:00
Daniel Rosenberg
8e94730d5c ANDROID: sdcardfs: Copy meta-data from lower inode
From wrapfs commit 3ee9b365e38c ("Wrapfs: properly copy meta-data after
AIO operations from lower inode")

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 35766959
Change-Id: I9a789222e27a17b8d85ce61c45397d1839f9a675
2018-01-29 19:40:09 -08:00
Daniel Rosenberg
f31cf6e475 ANDROID: sdcardfs: Use filesystem specific hash
We weren't accounting for FS specific hash functions,
causing us to miss negative dentries for any FS that
had one.

Similar to a patch from esdfs
commit 75bd25a9476d ("esdfs: support lower's own hash")

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Change-Id: I32d1ba304d728e0ca2648cacfb4c2e441ae63608
2018-01-29 19:40:09 -08:00
Daniel Rosenberg
de835348d3 ANDROID: sdcardfs: Don't complain in fixup_lower_ownership
Not all filesystems support changing the owner of a file.
We shouldn't complain if it doesn't happen.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 37488099
Change-Id: I403e44ab7230f176e6df82f6adb4e5c82ce57f33
2018-01-29 19:40:09 -08:00
Daniel Rosenberg
b81400914c ANDROID: sdcardfs: Don't do d_add for lower fs
For file based encryption, ext4 explicitly does not
create negative dentries for encrypted files. If you
force one over it, the decrypted file will be hidden
until the cache is cleared. Instead, just fail out.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 37231161
Change-Id: Id2a9708dfa75e1c22f89915c529789caadd2ca4b
2018-01-29 19:40:09 -08:00
Daniel Rosenberg
ce02550067 ANDROID: sdcardfs: ->iget fixes
Adapted from wrapfs
commit 8c49eaa0sb9c ("Wrapfs: ->iget fixes")

Change where we igrab/iput to ensure we always hold a valid lower_inode.
Return ENOMEM (not EACCES) if iget5_locked returns NULL.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 35766959

Change-Id: Id8d4e0c0cbc685a0a77685ce73c923e9a3ddc094
2018-01-29 19:40:08 -08:00
Daniel Rosenberg
5686635680 ANDROID: sdcardfs: Change cache GID value
Change-Id: Ieb955dd26493da26a458bc20fbbe75bca32b094f
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 37193650
2018-01-29 19:40:08 -08:00
Daniel Rosenberg
51a2665899 ANDROID: sdcardfs: Directly pass lower file for mmap
Instead of relying on a copy hack, pass the lower file
as private data. This lets the kernel find the vma
mapping for pages used by the file, allowing pages
used by mapping to be reclaimed.

This is adapted from following esdfs patches
commit 0647e638d: ("esdfs: store lower file in vm_file for mmap")
commit 064850866: ("esdfs: keep a counter for mmaped file")

Change-Id: I75b74d1e5061db1b8c13be38d184e118c0851a1a
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2018-01-29 19:40:08 -08:00
Daniel Rosenberg
5122bd5892 ANDROID: sdcardfs: update module info
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Change-Id: I958c7c226d4e9265fea8996803e5b004fb33d8ad
2018-01-29 19:40:08 -08:00
Daniel Rosenberg
5d73646370 ANDROID: sdcardfs: use d_splice_alias
adapted from wrapfs
commit 9671770ff8b9 ("Wrapfs: use d_splice_alias")

Refactor interpose code to allow lookup to use d_splice_alias.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 35766959
Change-Id: Icf51db8658202c48456724275b03dc77f73f585b
2018-01-29 19:40:08 -08:00
Daniel Rosenberg
249834d36d ANDROID: sdcardfs: add read_iter/write_iter opeations
Adapted from wrapfs
commit f398bf6a7377 ("Wrapfs: add read_iter/write_iter opeations")

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: Mengyang Li <li.mengyang@stonybrook.edu>
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 35766959
Change-Id: I2b3de59c9682fc705bf21df0de6df81e76fd2e40
2018-01-29 19:40:08 -08:00
Daniel Rosenberg
3c5ff6cce9 ANDROID: sdcardfs: fix ->llseek to update upper and lower offset
Adapted from wrapfs
commit 1d1d23a47baa ("Wrapfs: fix ->llseek to update upper and lower
offsets")

Fixes bug: xfstests generic/257. f_pos consistently is required by and
only by dir_ops->wrapfs_readdir, main_ops is not affected.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: Mengyang Li <li.mengyang@stonybrook.edu>
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 35766959
Change-Id: I360a1368ac37ea8966910a58972b81504031d437
2018-01-29 19:40:08 -08:00
Daniel Rosenberg
b74adc48e5 ANDROID: sdcardfs: copy lower inode attributes in ->ioctl
Adapted from wrapfs
commit fbc9c6f83ea6 ("Wrapfs: copy lower inode attributes in ->ioctl")
commit e97d8e26cc9e ("Wrapfs: use file_inode helper")

Some ioctls (e.g., EXT2_IOC_SETFLAGS) can change inode attributes, so copy
them from lower inode.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 35766959
Change-Id: I0f12684b9dbd4088b4a622c7ea9c03087f40e572
2018-01-29 19:40:08 -08:00
Daniel Rosenberg
0a6820ea75 ANDROID: sdcardfs: remove unnecessary call to do_munmap
Adapted from wrapfs
commit 5be6de9ecf02 ("Wrapfs: use vm_munmap in ->mmap")
commit 2c9f6014a8bb ("Wrapfs: remove unnecessary call
to vm_unmap in ->mmap")

Code is unnecessary and causes deadlocks in newer kernels.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 35766959
Change-Id: Ia252d60c60799d7e28fc5f1f0f5b5ec2430a2379
2018-01-29 19:40:08 -08:00
Daniel Rosenberg
cab2781abb ANDROID: sdcardfs: Fix style issues in macros
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 35331000
Change-Id: I89c4035029dc2236081a7685c55cac595d9e7ebf
2018-01-29 19:40:07 -08:00
Daniel Rosenberg
e265634a01 ANDROID: sdcardfs: Use seq_puts over seq_printf
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 35331000
Change-Id: I3795ec61ce61e324738815b1ce3b0e09b25d723f
2018-01-29 19:40:07 -08:00
Daniel Rosenberg
f2f16403af ANDROID: sdcardfs: Use to kstrout
Switch from deprecated simple_strtoul to kstrout

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 35331000
Change-Id: If18bd133b4d2877f71e58b58fc31371ff6613ed5
2018-01-29 19:40:07 -08:00
Daniel Rosenberg
8cfe3bf214 ANDROID: sdcardfs: Use pr_[...] instead of printk
Signed-off-by: Daniel Rosenberg <drosen@google.com>
Bug: 35331000
Change-Id: Ibc635ec865750530d32b87067779f681fe58a003
2018-01-29 19:40:07 -08:00