e04ba5f57f
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmU45eIACgkQONu9yGCS aT6OGw//TD8VOR/VIUsdCH4keamvfoOjW7IdUMI6WWrXGw4TBQhOb1S5OFmUXLIW 1TQKvnJSpkukW9oQXChEPiVm9LMXq0dsWOaI11I23HmAzenZQ+cdHLFa8Rod3DeJ t17qefmsZxvI3U5nXJiCYRlUcqWF8rgpYR8NaJass8xOOGKEDk9JMXy1hvCG1N8C 1Zvth4wJmaDvJxSLHCL0gZkYBQBddePtrHwxWqLJ9vwUJEHGWf6AlwaASFUtRMut am2sWYx7aDKQT4w6B4MEJfA3bcTbLAglZG5s85ENhYYAMYW+cX/YtQH182KcpRTx mRmDc2vk1tJsSAuuE94OAAESjCdWF7V5SUkk/GLawnRiR7NeOax7vvS634uPtN+g LdTOlWMlcum46LmrJd6pu7oLXyZHGrr0/cBPewwYTlcRsmSS+WADUfH1yZL14lDC Nf8JASLIj68jrxnTn1lWGtShn8unNV9ZVauA8krsXJzvgjYNpaQSRhxOnltc+Zuy GFC0oipwgbzM8Y3lSPfF8rwBA85tmvF397oBM5c4uzZ+ULn7XWPJG+wIYtk7R9N7 57rKAKyu+s3hHEUCyF7Z/HF7pHiL6vg4hQzhgIKqDMYkZmyHYV3iIAy5j5jvCkvD 8zjBiV3iBC9PYzNYghVRVm5LjRwlXvqSpy88YwgkB1iD+5rZ3RQ= =PvGf -----END PGP SIGNATURE----- Merge 5.10.199 into android12-5.10-lts Changes in 5.10.199 RDMA/srp: Make struct scsi_cmnd and struct srp_request adjacent RDMA/srp: Do not call scsi_done() from srp_abort() RDMA/cxgb4: Check skb value for failure to allocate perf/arm-cmn: Fix the unhandled overflow status of counter 4 to 7 lib/test_meminit: fix off-by-one error in test_pages() HID: logitech-hidpp: Fix kernel crash on receiver USB disconnect quota: Fix slow quotaoff net: prevent address rewrite in kernel_bind() drm/msm/dp: do not reinitialize phy unless retry during link training drm/msm/dsi: skip the wait for video mode done if not applicable drm/msm/dpu: change _dpu_plane_calc_bw() to use u64 to avoid overflow ravb: Fix up dma_free_coherent() call in ravb_remove() ieee802154: ca8210: Fix a potential UAF in ca8210_probe mlxsw: fix mlxsw_sp2_nve_vxlan_learning_set() return type xen-netback: use default TX queue size for vifs riscv, bpf: Factor out emit_call for kernel and bpf context riscv, bpf: Sign-extend return values drm/vmwgfx: fix typo of sizeof argument net: macsec: indicate next pn update when offloading net: phy: mscc: macsec: reject PN update requests ixgbe: fix crash with empty VF macvlan list net: nfc: fix races in nfc_llcp_sock_get() and nfc_llcp_sock_get_sn() pinctrl: renesas: rzn1: Enable missing PINMUX nfc: nci: assert requested protocol is valid workqueue: Override implicit ordered attribute in workqueue_apply_unbound_cpumask() Revert "spi: zynqmp-gqspi: fix clock imbalance on probe failure" Revert "spi: spi-zynqmp-gqspi: Fix runtime PM imbalance in zynqmp_qspi_probe" net: add sysctl accept_ra_min_rtr_lft net: change accept_ra_min_rtr_lft to affect all RA lifetimes net: release reference to inet6_dev pointer media: mtk-jpeg: Fix use after free bug due to uncanceled work dmaengine: stm32-mdma: abort resume if no ongoing transfer usb: xhci: xhci-ring: Use sysdev for mapping bounce buffer net: usb: dm9601: fix uninitialized variable use in dm9601_mdio_read usb: dwc3: Soft reset phy on probe for host usb: musb: Get the musb_qh poniter after musb_giveback usb: musb: Modify the "HWVers" register address iio: pressure: bmp280: Fix NULL pointer exception iio: pressure: dps310: Adjust Timeout Settings iio: pressure: ms5611: ms5611_prom_is_valid false negative bug x86/cpu: Fix AMD erratum #1485 on Zen4-based CPUs mcb: remove is_added flag from mcb_device struct thunderbolt: Check that lane 1 is in CL0 before enabling lane bonding libceph: use kernel_connect() ceph: fix incorrect revoked caps assert in ceph_fill_file_size() ceph: fix type promotion bug on 32bit systems Input: powermate - fix use-after-free in powermate_config_complete Input: psmouse - fix fast_reconnect function for PS/2 mode Input: xpad - add PXN V900 support Input: i8042 - add Fujitsu Lifebook E5411 to i8042 quirk table Input: goodix - ensure int GPIO is in input for gpio_count == 1 && gpio_int_idx == 0 case tee: amdtee: fix use-after-free vulnerability in amdtee_close_session cgroup: Remove duplicates in cgroup v1 tasks file pinctrl: avoid unsafe code pattern in find_pinctrl() counter: microchip-tcb-capture: Fix the use of internal GCLK logic usb: gadget: udc-xilinx: replace memcpy with memcpy_toio usb: gadget: ncm: Handle decoding of multiple NTB's in unwrap call dmaengine: mediatek: Fix deadlock caused by synchronize_irq() powerpc/8xx: Fix pte_access_permitted() for PAGE_NONE powerpc/64e: Fix wrong test in __ptep_test_and_clear_young() x86/alternatives: Disable KASAN in apply_alternatives() arm64: report EL1 UNDEFs better arm64: die(): pass 'err' as long arm64: consistently pass ESR_ELx to die() arm64: rework FPAC exception handling arm64: rework BTI exception handling arm64: allow kprobes on EL0 handlers arm64: split EL0/EL1 UNDEF handlers arm64: factor out EL1 SSBS emulation hook arm64: factor insn read out of call_undef_hook() arm64: rework EL0 MRS emulation arm64: armv8_deprecated: fold ops into insn_emulation arm64: armv8_deprecated move emulation functions arm64: armv8_deprecated: move aarch32 helper earlier arm64: armv8_deprecated: rework deprected instruction handling arm64: armv8_deprecated: fix unused-function error RDMA/srp: Set scmnd->result only when scmnd is not NULL RDMA/srp: Fix srp_abort() ravb: Fix use-after-free issue in ravb_tx_timeout_work() dev_forward_skb: do not scrub skb mark within the same name space lib/Kconfig.debug: do not enable DEBUG_PREEMPT by default mm/memory_hotplug: rate limit page migration warnings Documentation: sysctl: align cells in second content column usb: hub: Guard against accesses to uninitialized BOS descriptors Bluetooth: hci_event: Ignore NULL link key Bluetooth: Reject connection with the device which has same BD_ADDR Bluetooth: Fix a refcnt underflow problem for hci_conn Bluetooth: vhci: Fix race when opening vhci device Bluetooth: hci_event: Fix coding style Bluetooth: avoid memcmp() out of bounds warning ice: fix over-shifted variable ice: reset first in crash dump kernels nfc: nci: fix possible NULL pointer dereference in send_acknowledge() regmap: fix NULL deref on lookup KVM: x86: Mask LVTPC when handling a PMI x86/sev: Disable MMIO emulation from user mode x86/sev: Check IOBM for IOIO exceptions from user-space x86/sev: Check for user-space IOIO pointing to kernel space tcp: check mptcp-level constraints for backlog coalescing netfilter: nft_payload: fix wrong mac header matching nvmet-tcp: Fix a possible UAF in queue intialization setup drm/i915: Retry gtt fault when out of fence registers qed: fix LL2 RX buffer allocation xfrm: fix a data-race in xfrm_gen_index() xfrm: interface: use DEV_STATS_INC() net: ipv4: fix return value check in esp_remove_trailer net: ipv6: fix return value check in esp_remove_trailer net: rfkill: gpio: prevent value glitch during probe tcp: fix excessive TLP and RACK timeouts from HZ rounding tcp: tsq: relax tcp_small_queue_check() when rtx queue contains a single skb tun: prevent negative ifindex ipv4: fib: annotate races around nh->nh_saddr_genid and nh->nh_saddr net: usb: smsc95xx: Fix an error code in smsc95xx_reset() i40e: prevent crash on probe if hw registers have invalid values net: dsa: bcm_sf2: Fix possible memory leak in bcm_sf2_mdio_register() net/sched: sch_hfsc: upgrade 'rt' to 'sc' when it becomes a inner curve neighbor: tracing: Move pin6 inside CONFIG_IPV6=y section netfilter: nft_set_rbtree: .deactivate fails if element has expired net: pktgen: Fix interface flags printing thunderbolt: Workaround an IOMMU fault on certain systems with Intel Maple Ridge resource: Add irqresource_disabled() ACPI: Drop acpi_dev_irqresource_disabled() ACPI: resources: Add DMI-based legacy IRQ override quirk ACPI: resource: Skip IRQ override on Asus Vivobook K3402ZA/K3502ZA ACPI: resource: Add ASUS model S5402ZA to quirks ACPI: resource: Skip IRQ override on Asus Vivobook S5602ZA ACPI: resource: Add Asus ExpertBook B2502 to Asus quirks ACPI: resource: Skip IRQ override on Asus Expertbook B2402CBA ACPI: resource: Skip IRQ override on ASUS ExpertBook B1502CBA ACPI: resource: Skip IRQ override on ASUS ExpertBook B1402CBA selftests/vm: make charge_reserved_hugetlb.sh work with existing cgroup setting selftests/mm: fix awk usage in charge_reserved_hugetlb.sh and hugetlb_reparenting_test.sh that may cause error usb: core: Track SuperSpeed Plus GenXxY xhci: cleanup xhci_hub_control port references xhci: move port specific items such as state completions to port structure xhci: rename resume_done to resume_timestamp xhci: clear usb2 resume related variables in one place. xhci: decouple usb2 port resume and get_port_status request handling xhci: track port suspend state correctly in unsuccessful resume cases serial: 8250: omap: Fix imprecise external abort for omap_8250_pm() serial: 8250_omap: Fix errors with no_console_suspend drm/amd/display: only check available pipe to disable vbios mode. drm/amd/display: Don't set dpms_off for seamless boot drm/connector: Give connector sysfs devices there own device_type drm/connector: Add a fwnode pointer to drm_connector and register with ACPI (v2) drm/connector: Add drm_connector_find_by_fwnode() function (v3) drm/connector: Add support for out-of-band hotplug notification (v3) usb: typec: altmodes/displayport: Notify drm subsys of hotplug events usb: typec: altmodes/displayport: Signal hpd low when exiting mode ARM: dts: ti: omap: Fix noisy serial with overrun-throttle-ms for mapphone btrfs: return -EUCLEAN for delayed tree ref with a ref count not equals to 1 btrfs: initialize start_slot in btrfs_log_prealloc_extents i2c: mux: Avoid potential false error message in i2c_mux_add_adapter overlayfs: set ctime when setting mtime and atime gpio: timberdale: Fix potential deadlock on &tgpio->lock ata: libata-eh: Fix compilation warning in ata_eh_link_report() tracing: relax trace_event_eval_update() execution with cond_resched() HID: holtek: fix slab-out-of-bounds Write in holtek_kbd_input_event Bluetooth: Avoid redundant authentication Bluetooth: hci_core: Fix build warnings wifi: cfg80211: Fix 6GHz scan configuration wifi: mac80211: allow transmitting EAPOL frames with tainted key wifi: cfg80211: avoid leaking stack data into trace regulator/core: Revert "fix kobject release warning and memory leak in regulator_register()" sky2: Make sure there is at least one frag_addr available ipv4/fib: send notify when delete source address routes drm: panel-orientation-quirks: Add quirk for One Mix 2S btrfs: fix some -Wmaybe-uninitialized warnings in ioctl.c HID: multitouch: Add required quirk for Synaptics 0xcd7e device platform/x86: touchscreen_dmi: Add info for the Positivo C4128B net/mlx5: Handle fw tracer change ownership event based on MTRC Bluetooth: hci_event: Fix using memcmp when comparing keys mtd: rawnand: qcom: Unmap the right resource upon probe failure mtd: rawnand: marvell: Ensure program page operations are successful mtd: rawnand: arasan: Ensure program page operations are successful mtd: spinand: micron: correct bitmask for ecc status mtd: physmap-core: Restore map_rom fallback mmc: core: sdio: hold retuning if sdio in 1-bit mode mmc: core: Capture correct oemid-bits for eMMC cards Revert "pinctrl: avoid unsafe code pattern in find_pinctrl()" pNFS: Fix a hang in nfs4_evict_inode() ACPI: irq: Fix incorrect return value in acpi_register_gsi() nvme-pci: add BOGUS_NID for Intel 0a54 device nvme-rdma: do not try to stop unallocated queues USB: serial: option: add Telit LE910C4-WWX 0x1035 composition USB: serial: option: add entry for Sierra EM9191 with new firmware USB: serial: option: add Fibocom to DELL custom modem FM101R-GL perf: Disallow mis-matched inherited group reads s390/pci: fix iommu bitmap allocation platform/x86: asus-wmi: Change ASUS_WMI_BRN_DOWN code from 0x20 to 0x2e platform/x86: asus-wmi: Map 0x2a code, Ignore 0x2b and 0x2c events gpio: vf610: set value before the direction to avoid a glitch ASoC: pxa: fix a memory leak in probe() phy: mapphone-mdm6600: Fix runtime disable on probe phy: mapphone-mdm6600: Fix runtime PM for remove phy: mapphone-mdm6600: Fix pinctrl_pm handling for sleep pins Bluetooth: hci_sock: fix slab oob read in create_monitor_event Bluetooth: hci_sock: Correctly bounds check and pad HCI_MON_NEW_INDEX name xfrm6: fix inet6_dev refcount underflow problem Linux 5.10.199 NOTE, this reverts the following commits in order to apply things cleanly and avoid ABI breakage. Due to the complexity involved, individual reverts would not work properly:fc778e9d79
xhci: track port suspend state correctly in unsuccessful resume cases1c034c6e22
xhci: decouple usb2 port resume and get_port_status request handling92088dd886
xhci: clear usb2 resume related variables in one place.e7abc4b18d
xhci: rename resume_done to resume_timestampd44c9285ce
xhci: move port specific items such as state completions to port structuree2b4de13e5
xhci: cleanup xhci_hub_control port references489818719a
arm64: armv8_deprecated: fix unused-function errorda7603cedb
arm64: armv8_deprecated: rework deprected instruction handling45a26d2a53
arm64: armv8_deprecated: move aarch32 helper earlier0b6a7a9f6d
arm64: armv8_deprecated move emulation functions2202536144
arm64: armv8_deprecated: fold ops into insn_emulation5aa232345e
arm64: rework EL0 MRS emulation15e964971f
arm64: factor insn read out of call_undef_hook()0edde7fd1c
arm64: factor out EL1 SSBS emulation hook7a76df1ae1
arm64: split EL0/EL1 UNDEF handlers8a8d4cc303
arm64: allow kprobes on EL0 handlers793ed958b6
arm64: rework BTI exception handling9113333d7c
arm64: rework FPAC exception handlinga8d7c8484f
arm64: consistently pass ESR_ELx to die()004bdab6ed
arm64: die(): pass 'err' as long835cb1f78d
arm64: report EL1 UNDEFs better Change-Id: I54f6d79ae4886b808d6e3c017343f1f25c5254c3 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
552 lines
19 KiB
C
552 lines
19 KiB
C
/*
|
|
* Copyright (c) 1982, 1986 Regents of the University of California.
|
|
* All rights reserved.
|
|
*
|
|
* This code is derived from software contributed to Berkeley by
|
|
* Robert Elz at The University of Melbourne.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
* 3. Neither the name of the University nor the names of its contributors
|
|
* may be used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*/
|
|
#ifndef _LINUX_QUOTA_
|
|
#define _LINUX_QUOTA_
|
|
|
|
#include <linux/list.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/rwsem.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/wait.h>
|
|
#include <linux/percpu_counter.h>
|
|
|
|
#include <linux/dqblk_xfs.h>
|
|
#include <linux/dqblk_v1.h>
|
|
#include <linux/dqblk_v2.h>
|
|
|
|
#include <linux/atomic.h>
|
|
#include <linux/uidgid.h>
|
|
#include <linux/projid.h>
|
|
#include <uapi/linux/quota.h>
|
|
|
|
#undef USRQUOTA
|
|
#undef GRPQUOTA
|
|
#undef PRJQUOTA
|
|
enum quota_type {
|
|
USRQUOTA = 0, /* element used for user quotas */
|
|
GRPQUOTA = 1, /* element used for group quotas */
|
|
PRJQUOTA = 2, /* element used for project quotas */
|
|
};
|
|
|
|
/* Masks for quota types when used as a bitmask */
|
|
#define QTYPE_MASK_USR (1 << USRQUOTA)
|
|
#define QTYPE_MASK_GRP (1 << GRPQUOTA)
|
|
#define QTYPE_MASK_PRJ (1 << PRJQUOTA)
|
|
|
|
typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */
|
|
typedef long long qsize_t; /* Type in which we store sizes */
|
|
|
|
struct kqid { /* Type in which we store the quota identifier */
|
|
union {
|
|
kuid_t uid;
|
|
kgid_t gid;
|
|
kprojid_t projid;
|
|
};
|
|
enum quota_type type; /* USRQUOTA (uid) or GRPQUOTA (gid) or PRJQUOTA (projid) */
|
|
};
|
|
|
|
extern bool qid_eq(struct kqid left, struct kqid right);
|
|
extern bool qid_lt(struct kqid left, struct kqid right);
|
|
extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
|
|
extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
|
|
extern bool qid_valid(struct kqid qid);
|
|
|
|
/**
|
|
* make_kqid - Map a user-namespace, type, qid tuple into a kqid.
|
|
* @from: User namespace that the qid is in
|
|
* @type: The type of quota
|
|
* @qid: Quota identifier
|
|
*
|
|
* Maps a user-namespace, type qid tuple into a kernel internal
|
|
* kqid, and returns that kqid.
|
|
*
|
|
* When there is no mapping defined for the user-namespace, type,
|
|
* qid tuple an invalid kqid is returned. Callers are expected to
|
|
* test for and handle handle invalid kqids being returned.
|
|
* Invalid kqids may be tested for using qid_valid().
|
|
*/
|
|
static inline struct kqid make_kqid(struct user_namespace *from,
|
|
enum quota_type type, qid_t qid)
|
|
{
|
|
struct kqid kqid;
|
|
|
|
kqid.type = type;
|
|
switch (type) {
|
|
case USRQUOTA:
|
|
kqid.uid = make_kuid(from, qid);
|
|
break;
|
|
case GRPQUOTA:
|
|
kqid.gid = make_kgid(from, qid);
|
|
break;
|
|
case PRJQUOTA:
|
|
kqid.projid = make_kprojid(from, qid);
|
|
break;
|
|
default:
|
|
BUG();
|
|
}
|
|
return kqid;
|
|
}
|
|
|
|
/**
|
|
* make_kqid_invalid - Explicitly make an invalid kqid
|
|
* @type: The type of quota identifier
|
|
*
|
|
* Returns an invalid kqid with the specified type.
|
|
*/
|
|
static inline struct kqid make_kqid_invalid(enum quota_type type)
|
|
{
|
|
struct kqid kqid;
|
|
|
|
kqid.type = type;
|
|
switch (type) {
|
|
case USRQUOTA:
|
|
kqid.uid = INVALID_UID;
|
|
break;
|
|
case GRPQUOTA:
|
|
kqid.gid = INVALID_GID;
|
|
break;
|
|
case PRJQUOTA:
|
|
kqid.projid = INVALID_PROJID;
|
|
break;
|
|
default:
|
|
BUG();
|
|
}
|
|
return kqid;
|
|
}
|
|
|
|
/**
|
|
* make_kqid_uid - Make a kqid from a kuid
|
|
* @uid: The kuid to make the quota identifier from
|
|
*/
|
|
static inline struct kqid make_kqid_uid(kuid_t uid)
|
|
{
|
|
struct kqid kqid;
|
|
kqid.type = USRQUOTA;
|
|
kqid.uid = uid;
|
|
return kqid;
|
|
}
|
|
|
|
/**
|
|
* make_kqid_gid - Make a kqid from a kgid
|
|
* @gid: The kgid to make the quota identifier from
|
|
*/
|
|
static inline struct kqid make_kqid_gid(kgid_t gid)
|
|
{
|
|
struct kqid kqid;
|
|
kqid.type = GRPQUOTA;
|
|
kqid.gid = gid;
|
|
return kqid;
|
|
}
|
|
|
|
/**
|
|
* make_kqid_projid - Make a kqid from a projid
|
|
* @projid: The kprojid to make the quota identifier from
|
|
*/
|
|
static inline struct kqid make_kqid_projid(kprojid_t projid)
|
|
{
|
|
struct kqid kqid;
|
|
kqid.type = PRJQUOTA;
|
|
kqid.projid = projid;
|
|
return kqid;
|
|
}
|
|
|
|
/**
|
|
* qid_has_mapping - Report if a qid maps into a user namespace.
|
|
* @ns: The user namespace to see if a value maps into.
|
|
* @qid: The kernel internal quota identifier to test.
|
|
*/
|
|
static inline bool qid_has_mapping(struct user_namespace *ns, struct kqid qid)
|
|
{
|
|
return from_kqid(ns, qid) != (qid_t) -1;
|
|
}
|
|
|
|
|
|
extern spinlock_t dq_data_lock;
|
|
|
|
/* Maximal numbers of writes for quota operation (insert/delete/update)
|
|
* (over VFS all formats) */
|
|
#define DQUOT_INIT_ALLOC max(V1_INIT_ALLOC, V2_INIT_ALLOC)
|
|
#define DQUOT_INIT_REWRITE max(V1_INIT_REWRITE, V2_INIT_REWRITE)
|
|
#define DQUOT_DEL_ALLOC max(V1_DEL_ALLOC, V2_DEL_ALLOC)
|
|
#define DQUOT_DEL_REWRITE max(V1_DEL_REWRITE, V2_DEL_REWRITE)
|
|
|
|
/*
|
|
* Data for one user/group kept in memory
|
|
*/
|
|
struct mem_dqblk {
|
|
qsize_t dqb_bhardlimit; /* absolute limit on disk blks alloc */
|
|
qsize_t dqb_bsoftlimit; /* preferred limit on disk blks */
|
|
qsize_t dqb_curspace; /* current used space */
|
|
qsize_t dqb_rsvspace; /* current reserved space for delalloc*/
|
|
qsize_t dqb_ihardlimit; /* absolute limit on allocated inodes */
|
|
qsize_t dqb_isoftlimit; /* preferred inode limit */
|
|
qsize_t dqb_curinodes; /* current # allocated inodes */
|
|
time64_t dqb_btime; /* time limit for excessive disk use */
|
|
time64_t dqb_itime; /* time limit for excessive inode use */
|
|
};
|
|
|
|
/*
|
|
* Data for one quotafile kept in memory
|
|
*/
|
|
struct quota_format_type;
|
|
|
|
struct mem_dqinfo {
|
|
struct quota_format_type *dqi_format;
|
|
int dqi_fmt_id; /* Id of the dqi_format - used when turning
|
|
* quotas on after remount RW */
|
|
struct list_head dqi_dirty_list; /* List of dirty dquots [dq_list_lock] */
|
|
unsigned long dqi_flags; /* DFQ_ flags [dq_data_lock] */
|
|
unsigned int dqi_bgrace; /* Space grace time [dq_data_lock] */
|
|
unsigned int dqi_igrace; /* Inode grace time [dq_data_lock] */
|
|
qsize_t dqi_max_spc_limit; /* Maximum space limit [static] */
|
|
qsize_t dqi_max_ino_limit; /* Maximum inode limit [static] */
|
|
void *dqi_priv;
|
|
};
|
|
|
|
struct super_block;
|
|
|
|
/* Mask for flags passed to userspace */
|
|
#define DQF_GETINFO_MASK (DQF_ROOT_SQUASH | DQF_SYS_FILE)
|
|
/* Mask for flags modifiable from userspace */
|
|
#define DQF_SETINFO_MASK DQF_ROOT_SQUASH
|
|
|
|
enum {
|
|
DQF_INFO_DIRTY_B = DQF_PRIVATE,
|
|
};
|
|
#define DQF_INFO_DIRTY (1 << DQF_INFO_DIRTY_B) /* Is info dirty? */
|
|
|
|
extern void mark_info_dirty(struct super_block *sb, int type);
|
|
static inline int info_dirty(struct mem_dqinfo *info)
|
|
{
|
|
return test_bit(DQF_INFO_DIRTY_B, &info->dqi_flags);
|
|
}
|
|
|
|
enum {
|
|
DQST_LOOKUPS,
|
|
DQST_DROPS,
|
|
DQST_READS,
|
|
DQST_WRITES,
|
|
DQST_CACHE_HITS,
|
|
DQST_ALLOC_DQUOTS,
|
|
DQST_FREE_DQUOTS,
|
|
DQST_SYNCS,
|
|
_DQST_DQSTAT_LAST
|
|
};
|
|
|
|
struct dqstats {
|
|
unsigned long stat[_DQST_DQSTAT_LAST];
|
|
struct percpu_counter counter[_DQST_DQSTAT_LAST];
|
|
};
|
|
|
|
extern struct dqstats dqstats;
|
|
|
|
static inline void dqstats_inc(unsigned int type)
|
|
{
|
|
percpu_counter_inc(&dqstats.counter[type]);
|
|
}
|
|
|
|
static inline void dqstats_dec(unsigned int type)
|
|
{
|
|
percpu_counter_dec(&dqstats.counter[type]);
|
|
}
|
|
|
|
#define DQ_MOD_B 0 /* dquot modified since read */
|
|
#define DQ_BLKS_B 1 /* uid/gid has been warned about blk limit */
|
|
#define DQ_INODES_B 2 /* uid/gid has been warned about inode limit */
|
|
#define DQ_FAKE_B 3 /* no limits only usage */
|
|
#define DQ_READ_B 4 /* dquot was read into memory */
|
|
#define DQ_ACTIVE_B 5 /* dquot is active (dquot_release not called) */
|
|
#define DQ_RELEASING_B 6 /* dquot is in releasing_dquots list waiting
|
|
* to be cleaned up */
|
|
#define DQ_LASTSET_B 7 /* Following 6 bits (see QIF_) are reserved\
|
|
* for the mask of entries set via SETQUOTA\
|
|
* quotactl. They are set under dq_data_lock\
|
|
* and the quota format handling dquot can\
|
|
* clear them when it sees fit. */
|
|
|
|
struct dquot {
|
|
struct hlist_node dq_hash; /* Hash list in memory [dq_list_lock] */
|
|
struct list_head dq_inuse; /* List of all quotas [dq_list_lock] */
|
|
struct list_head dq_free; /* Free list element [dq_list_lock] */
|
|
struct list_head dq_dirty; /* List of dirty dquots [dq_list_lock] */
|
|
struct mutex dq_lock; /* dquot IO lock */
|
|
spinlock_t dq_dqb_lock; /* Lock protecting dq_dqb changes */
|
|
atomic_t dq_count; /* Use count */
|
|
struct super_block *dq_sb; /* superblock this applies to */
|
|
struct kqid dq_id; /* ID this applies to (uid, gid, projid) */
|
|
loff_t dq_off; /* Offset of dquot on disk [dq_lock, stable once set] */
|
|
unsigned long dq_flags; /* See DQ_* */
|
|
struct mem_dqblk dq_dqb; /* Diskquota usage [dq_dqb_lock] */
|
|
};
|
|
|
|
/* Operations which must be implemented by each quota format */
|
|
struct quota_format_ops {
|
|
int (*check_quota_file)(struct super_block *sb, int type); /* Detect whether file is in our format */
|
|
int (*read_file_info)(struct super_block *sb, int type); /* Read main info about file - called on quotaon() */
|
|
int (*write_file_info)(struct super_block *sb, int type); /* Write main info about file */
|
|
int (*free_file_info)(struct super_block *sb, int type); /* Called on quotaoff() */
|
|
int (*read_dqblk)(struct dquot *dquot); /* Read structure for one user */
|
|
int (*commit_dqblk)(struct dquot *dquot); /* Write structure for one user */
|
|
int (*release_dqblk)(struct dquot *dquot); /* Called when last reference to dquot is being dropped */
|
|
int (*get_next_id)(struct super_block *sb, struct kqid *qid); /* Get next ID with existing structure in the quota file */
|
|
|
|
ANDROID_KABI_RESERVE(1);
|
|
ANDROID_KABI_RESERVE(2);
|
|
};
|
|
|
|
/* Operations working with dquots */
|
|
struct dquot_operations {
|
|
int (*write_dquot) (struct dquot *); /* Ordinary dquot write */
|
|
struct dquot *(*alloc_dquot)(struct super_block *, int); /* Allocate memory for new dquot */
|
|
void (*destroy_dquot)(struct dquot *); /* Free memory for dquot */
|
|
int (*acquire_dquot) (struct dquot *); /* Quota is going to be created on disk */
|
|
int (*release_dquot) (struct dquot *); /* Quota is going to be deleted from disk */
|
|
int (*mark_dirty) (struct dquot *); /* Dquot is marked dirty */
|
|
int (*write_info) (struct super_block *, int); /* Write of quota "superblock" */
|
|
/* get reserved quota for delayed alloc, value returned is managed by
|
|
* quota code only */
|
|
qsize_t *(*get_reserved_space) (struct inode *);
|
|
int (*get_projid) (struct inode *, kprojid_t *);/* Get project ID */
|
|
/* Get number of inodes that were charged for a given inode */
|
|
int (*get_inode_usage) (struct inode *, qsize_t *);
|
|
/* Get next ID with active quota structure */
|
|
int (*get_next_id) (struct super_block *sb, struct kqid *qid);
|
|
|
|
ANDROID_KABI_RESERVE(1);
|
|
ANDROID_KABI_RESERVE(2);
|
|
};
|
|
|
|
struct path;
|
|
|
|
/* Structure for communicating via ->get_dqblk() & ->set_dqblk() */
|
|
struct qc_dqblk {
|
|
int d_fieldmask; /* mask of fields to change in ->set_dqblk() */
|
|
u64 d_spc_hardlimit; /* absolute limit on used space */
|
|
u64 d_spc_softlimit; /* preferred limit on used space */
|
|
u64 d_ino_hardlimit; /* maximum # allocated inodes */
|
|
u64 d_ino_softlimit; /* preferred inode limit */
|
|
u64 d_space; /* Space owned by the user */
|
|
u64 d_ino_count; /* # inodes owned by the user */
|
|
s64 d_ino_timer; /* zero if within inode limits */
|
|
/* if not, we refuse service */
|
|
s64 d_spc_timer; /* similar to above; for space */
|
|
int d_ino_warns; /* # warnings issued wrt num inodes */
|
|
int d_spc_warns; /* # warnings issued wrt used space */
|
|
u64 d_rt_spc_hardlimit; /* absolute limit on realtime space */
|
|
u64 d_rt_spc_softlimit; /* preferred limit on RT space */
|
|
u64 d_rt_space; /* realtime space owned */
|
|
s64 d_rt_spc_timer; /* similar to above; for RT space */
|
|
int d_rt_spc_warns; /* # warnings issued wrt RT space */
|
|
};
|
|
|
|
/*
|
|
* Field specifiers for ->set_dqblk() in struct qc_dqblk and also for
|
|
* ->set_info() in struct qc_info
|
|
*/
|
|
#define QC_INO_SOFT (1<<0)
|
|
#define QC_INO_HARD (1<<1)
|
|
#define QC_SPC_SOFT (1<<2)
|
|
#define QC_SPC_HARD (1<<3)
|
|
#define QC_RT_SPC_SOFT (1<<4)
|
|
#define QC_RT_SPC_HARD (1<<5)
|
|
#define QC_LIMIT_MASK (QC_INO_SOFT | QC_INO_HARD | QC_SPC_SOFT | QC_SPC_HARD | \
|
|
QC_RT_SPC_SOFT | QC_RT_SPC_HARD)
|
|
#define QC_SPC_TIMER (1<<6)
|
|
#define QC_INO_TIMER (1<<7)
|
|
#define QC_RT_SPC_TIMER (1<<8)
|
|
#define QC_TIMER_MASK (QC_SPC_TIMER | QC_INO_TIMER | QC_RT_SPC_TIMER)
|
|
#define QC_SPC_WARNS (1<<9)
|
|
#define QC_INO_WARNS (1<<10)
|
|
#define QC_RT_SPC_WARNS (1<<11)
|
|
#define QC_WARNS_MASK (QC_SPC_WARNS | QC_INO_WARNS | QC_RT_SPC_WARNS)
|
|
#define QC_SPACE (1<<12)
|
|
#define QC_INO_COUNT (1<<13)
|
|
#define QC_RT_SPACE (1<<14)
|
|
#define QC_ACCT_MASK (QC_SPACE | QC_INO_COUNT | QC_RT_SPACE)
|
|
#define QC_FLAGS (1<<15)
|
|
|
|
#define QCI_SYSFILE (1 << 0) /* Quota file is hidden from userspace */
|
|
#define QCI_ROOT_SQUASH (1 << 1) /* Root squash turned on */
|
|
#define QCI_ACCT_ENABLED (1 << 2) /* Quota accounting enabled */
|
|
#define QCI_LIMITS_ENFORCED (1 << 3) /* Quota limits enforced */
|
|
|
|
/* Structures for communicating via ->get_state */
|
|
struct qc_type_state {
|
|
unsigned int flags; /* Flags QCI_* */
|
|
unsigned int spc_timelimit; /* Time after which space softlimit is
|
|
* enforced */
|
|
unsigned int ino_timelimit; /* Ditto for inode softlimit */
|
|
unsigned int rt_spc_timelimit; /* Ditto for real-time space */
|
|
unsigned int spc_warnlimit; /* Limit for number of space warnings */
|
|
unsigned int ino_warnlimit; /* Ditto for inodes */
|
|
unsigned int rt_spc_warnlimit; /* Ditto for real-time space */
|
|
unsigned long long ino; /* Inode number of quota file */
|
|
blkcnt_t blocks; /* Number of 512-byte blocks in the file */
|
|
blkcnt_t nextents; /* Number of extents in the file */
|
|
};
|
|
|
|
struct qc_state {
|
|
unsigned int s_incoredqs; /* Number of dquots in core */
|
|
struct qc_type_state s_state[MAXQUOTAS]; /* Per quota type information */
|
|
};
|
|
|
|
/* Structure for communicating via ->set_info */
|
|
struct qc_info {
|
|
int i_fieldmask; /* mask of fields to change in ->set_info() */
|
|
unsigned int i_flags; /* Flags QCI_* */
|
|
unsigned int i_spc_timelimit; /* Time after which space softlimit is
|
|
* enforced */
|
|
unsigned int i_ino_timelimit; /* Ditto for inode softlimit */
|
|
unsigned int i_rt_spc_timelimit;/* Ditto for real-time space */
|
|
unsigned int i_spc_warnlimit; /* Limit for number of space warnings */
|
|
unsigned int i_ino_warnlimit; /* Limit for number of inode warnings */
|
|
unsigned int i_rt_spc_warnlimit; /* Ditto for real-time space */
|
|
};
|
|
|
|
/* Operations handling requests from userspace */
|
|
struct quotactl_ops {
|
|
int (*quota_on)(struct super_block *, int, int, const struct path *);
|
|
int (*quota_off)(struct super_block *, int);
|
|
int (*quota_enable)(struct super_block *, unsigned int);
|
|
int (*quota_disable)(struct super_block *, unsigned int);
|
|
int (*quota_sync)(struct super_block *, int);
|
|
int (*set_info)(struct super_block *, int, struct qc_info *);
|
|
int (*get_dqblk)(struct super_block *, struct kqid, struct qc_dqblk *);
|
|
int (*get_nextdqblk)(struct super_block *, struct kqid *,
|
|
struct qc_dqblk *);
|
|
int (*set_dqblk)(struct super_block *, struct kqid, struct qc_dqblk *);
|
|
int (*get_state)(struct super_block *, struct qc_state *);
|
|
int (*rm_xquota)(struct super_block *, unsigned int);
|
|
|
|
ANDROID_KABI_RESERVE(1);
|
|
ANDROID_KABI_RESERVE(2);
|
|
};
|
|
|
|
struct quota_format_type {
|
|
int qf_fmt_id; /* Quota format id */
|
|
const struct quota_format_ops *qf_ops; /* Operations of format */
|
|
struct module *qf_owner; /* Module implementing quota format */
|
|
struct quota_format_type *qf_next;
|
|
};
|
|
|
|
/**
|
|
* Quota state flags - they actually come in two flavors - for users and groups.
|
|
*
|
|
* Actual typed flags layout:
|
|
* USRQUOTA GRPQUOTA
|
|
* DQUOT_USAGE_ENABLED 0x0001 0x0002
|
|
* DQUOT_LIMITS_ENABLED 0x0004 0x0008
|
|
* DQUOT_SUSPENDED 0x0010 0x0020
|
|
*
|
|
* Following bits are used for non-typed flags:
|
|
* DQUOT_QUOTA_SYS_FILE 0x0040
|
|
* DQUOT_NEGATIVE_USAGE 0x0080
|
|
*/
|
|
enum {
|
|
_DQUOT_USAGE_ENABLED = 0, /* Track disk usage for users */
|
|
_DQUOT_LIMITS_ENABLED, /* Enforce quota limits for users */
|
|
_DQUOT_SUSPENDED, /* User diskquotas are off, but
|
|
* we have necessary info in
|
|
* memory to turn them on */
|
|
_DQUOT_STATE_FLAGS
|
|
};
|
|
#define DQUOT_USAGE_ENABLED (1 << _DQUOT_USAGE_ENABLED * MAXQUOTAS)
|
|
#define DQUOT_LIMITS_ENABLED (1 << _DQUOT_LIMITS_ENABLED * MAXQUOTAS)
|
|
#define DQUOT_SUSPENDED (1 << _DQUOT_SUSPENDED * MAXQUOTAS)
|
|
#define DQUOT_STATE_FLAGS (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED | \
|
|
DQUOT_SUSPENDED)
|
|
/* Other quota flags */
|
|
#define DQUOT_STATE_LAST (_DQUOT_STATE_FLAGS * MAXQUOTAS)
|
|
#define DQUOT_QUOTA_SYS_FILE (1 << DQUOT_STATE_LAST)
|
|
/* Quota file is a special
|
|
* system file and user cannot
|
|
* touch it. Filesystem is
|
|
* responsible for setting
|
|
* S_NOQUOTA, S_NOATIME flags
|
|
*/
|
|
#define DQUOT_NEGATIVE_USAGE (1 << (DQUOT_STATE_LAST + 1))
|
|
/* Allow negative quota usage */
|
|
/* Do not track dirty dquots in a list */
|
|
#define DQUOT_NOLIST_DIRTY (1 << (DQUOT_STATE_LAST + 2))
|
|
|
|
static inline unsigned int dquot_state_flag(unsigned int flags, int type)
|
|
{
|
|
return flags << type;
|
|
}
|
|
|
|
static inline unsigned int dquot_generic_flag(unsigned int flags, int type)
|
|
{
|
|
return (flags >> type) & DQUOT_STATE_FLAGS;
|
|
}
|
|
|
|
/* Bitmap of quota types where flag is set in flags */
|
|
static __always_inline unsigned dquot_state_types(unsigned flags, unsigned flag)
|
|
{
|
|
BUILD_BUG_ON_NOT_POWER_OF_2(flag);
|
|
return (flags / flag) & ((1 << MAXQUOTAS) - 1);
|
|
}
|
|
|
|
#ifdef CONFIG_QUOTA_NETLINK_INTERFACE
|
|
extern void quota_send_warning(struct kqid qid, dev_t dev,
|
|
const char warntype);
|
|
#else
|
|
static inline void quota_send_warning(struct kqid qid, dev_t dev,
|
|
const char warntype)
|
|
{
|
|
return;
|
|
}
|
|
#endif /* CONFIG_QUOTA_NETLINK_INTERFACE */
|
|
|
|
struct quota_info {
|
|
unsigned int flags; /* Flags for diskquotas on this device */
|
|
struct rw_semaphore dqio_sem; /* Lock quota file while I/O in progress */
|
|
struct inode *files[MAXQUOTAS]; /* inodes of quotafiles */
|
|
struct mem_dqinfo info[MAXQUOTAS]; /* Information for each quota type */
|
|
const struct quota_format_ops *ops[MAXQUOTAS]; /* Operations for each type */
|
|
};
|
|
|
|
int register_quota_format(struct quota_format_type *fmt);
|
|
void unregister_quota_format(struct quota_format_type *fmt);
|
|
|
|
struct quota_module_name {
|
|
int qm_fmt_id;
|
|
char *qm_mod_name;
|
|
};
|
|
|
|
#define INIT_QUOTA_MODULE_NAMES {\
|
|
{QFMT_VFS_OLD, "quota_v1"},\
|
|
{QFMT_VFS_V0, "quota_v2"},\
|
|
{QFMT_VFS_V1, "quota_v2"},\
|
|
{0, NULL}}
|
|
|
|
#endif /* _QUOTA_ */
|