linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Zoran Markovic <zmarkovic@sierrawireless.com>,
	Casey Schaufler <casey@schaufler-ca.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-security-module@vger.kernel.org
Subject: [PATCH AUTOSEL 4.9 039/107] smack: fix access permissions for keyring
Date: Mon, 28 Jan 2019 11:18:39 -0500	[thread overview]
Message-ID: <20190128161947.57405-39-sashal@kernel.org> (raw)
In-Reply-To: <20190128161947.57405-1-sashal@kernel.org>

From: Zoran Markovic <zmarkovic@sierrawireless.com>

[ Upstream commit 5b841bfab695e3b8ae793172a9ff7990f99cc3e2 ]

Function smack_key_permission() only issues smack requests for the
following operations:
 - KEY_NEED_READ (issues MAY_READ)
 - KEY_NEED_WRITE (issues MAY_WRITE)
 - KEY_NEED_LINK (issues MAY_WRITE)
 - KEY_NEED_SETATTR (issues MAY_WRITE)
A blank smack request is issued in all other cases, resulting in
smack access being granted if there is any rule defined between
subject and object, or denied with -EACCES otherwise.

Request MAY_READ access for KEY_NEED_SEARCH and KEY_NEED_VIEW.
Fix the logic in the unlikely case when both MAY_READ and
MAY_WRITE are needed. Validate access permission field for valid
contents.

Signed-off-by: Zoran Markovic <zmarkovic@sierrawireless.com>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Cc: Casey Schaufler <casey@schaufler-ca.com>
Cc: James Morris <jmorris@namei.org>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 security/smack/smack_lsm.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index fb7c534fb57d..aeb3ba70f907 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -4362,6 +4362,12 @@ static int smack_key_permission(key_ref_t key_ref,
 	int request = 0;
 	int rc;
 
+	/*
+	 * Validate requested permissions
+	 */
+	if (perm & ~KEY_NEED_ALL)
+		return -EINVAL;
+
 	keyp = key_ref_to_ptr(key_ref);
 	if (keyp == NULL)
 		return -EINVAL;
@@ -4381,10 +4387,10 @@ static int smack_key_permission(key_ref_t key_ref,
 	ad.a.u.key_struct.key = keyp->serial;
 	ad.a.u.key_struct.key_desc = keyp->description;
 #endif
-	if (perm & KEY_NEED_READ)
-		request = MAY_READ;
+	if (perm & (KEY_NEED_READ | KEY_NEED_SEARCH | KEY_NEED_VIEW))
+		request |= MAY_READ;
 	if (perm & (KEY_NEED_WRITE | KEY_NEED_LINK | KEY_NEED_SETATTR))
-		request = MAY_WRITE;
+		request |= MAY_WRITE;
 	rc = smk_access(tkp, keyp->security, request, &ad);
 	rc = smk_bu_note("key access", tkp, keyp->security, request, rc);
 	return rc;
-- 
2.19.1


  parent reply	other threads:[~2019-01-28 16:21 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-28 16:18 [PATCH AUTOSEL 4.9 001/107] drm/bufs: Fix Spectre v1 vulnerability Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 002/107] staging: iio: adc: ad7280a: handle error from __ad7280_read32() Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 003/107] ASoC: Intel: mrfld: fix uninitialized variable access Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 004/107] gpu: ipu-v3: image-convert: Prevent race between run and unprepare Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 005/107] ath9k: dynack: use authentication messages for 'late' ack Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 006/107] scsi: lpfc: Correct LCB RJT handling Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 007/107] platform/x86: asus-nb-wmi: Map 0x35 to KEY_SCREENLOCK Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 008/107] ARM: 8808/1: kexec:offline panic_smp_self_stop CPU Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 009/107] dlm: Don't swamp the CPU with callbacks queued during recovery Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 010/107] x86/PCI: Fix Broadcom CNB20LE unintended sign extension (redux) Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 011/107] powerpc/pseries: add of_node_put() in dlpar_detach_node() Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 012/107] drm/vc4: ->x_scaling[1] should never be set to VC4_SCALING_NONE Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 013/107] serial: fsl_lpuart: clear parity enable bit when disable parity Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 014/107] serial: core: Allow processing sysrq at port unlock time Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 015/107] ptp: check gettime64 return code in PTP_SYS_OFFSET ioctl Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 016/107] staging:iio:ad2s90: Make probe handle spi_setup failure Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 017/107] staging: iio: ad7780: update voltage on read Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 018/107] ARM: OMAP2+: hwmod: Fix some section annotations Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 019/107] modpost: validate symbol names also in find_elf_symbol Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 020/107] perf tools: Add Hygon Dhyana support Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 021/107] soc/tegra: Don't leak device tree node reference Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 022/107] media: mtk-vcodec: Release device nodes in mtk_vcodec_init_enc_pm() Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 023/107] dmaengine: xilinx_dma: Remove __aligned attribute on zynqmp_dma_desc_ll Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 024/107] iio: accel: kxcjk1013: Add KIOX010A ACPI Hardware-ID Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 025/107] media: adv*/tc358743/ths8200: fill in min width/height/pixelclock Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 026/107] f2fs: move dir data flush to write checkpoint process Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 027/107] f2fs: avoid build warn of fall_through Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 028/107] f2fs: fix wrong return value of f2fs_acl_create Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 029/107] sunvdc: Do not spin in an infinite loop when vio_ldc_send() returns EAGAIN Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 030/107] soc: bcm: brcmstb: Don't leak device tree node reference Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 031/107] nfsd4: fix crash on writing v4_end_grace before nfsd startup Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 032/107] Thermal: do not clear passive state during system sleep Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 033/107] firmware/efi: Add NULL pointer checks in efivars API functions Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 034/107] arm64: ftrace: don't adjust the LR value Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 035/107] ARM: dts: mmp2: fix TWSI2 Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 036/107] ARM: mmp/mmp2: dt: enable the clock Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 037/107] x86/fpu: Add might_fault() to user_insn() Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 038/107] media: DaVinci-VPBE: fix error handling in vpbe_initialize() Sasha Levin
2019-01-28 16:18 ` Sasha Levin [this message]
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 040/107] usb: hub: delay hub autosuspend if USB3 port is still link training Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 041/107] timekeeping: Use proper seqcount initializer Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 042/107] clk: sunxi-ng: a33: Set CLK_SET_RATE_PARENT for all audio module clocks Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 043/107] iommu/amd: Fix amd_iommu=force_isolation Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 044/107] ARM: dts: Fix OMAP4430 SDP Ethernet startup Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 045/107] mips: bpf: fix encoding bug for mm_srlv32_op Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 046/107] tracing: Have trace_stack nr_entries compare not be so subtle Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 047/107] Input: rotary-encoder - don't log EPROBE_DEFER to kernel log Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 048/107] iommu/arm-smmu: Add support for qcom,smmu-v2 variant Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 049/107] iommu/arm-smmu-v3: Use explicit mb() when moving cons pointer Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 050/107] sata_rcar: fix deferred probing Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 051/107] clk: imx6sl: ensure MMDC CH0 handshake is bypassed Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 052/107] cpuidle: big.LITTLE: fix refcount leak Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 053/107] i2c-axxia: check for error conditions first Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 054/107] udf: Fix BUG on corrupted inode Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 055/107] ARM: pxa: avoid section mismatch warning Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 056/107] ASoC: fsl: Fix SND_SOC_EUKREA_TLV320 build error on i.MX8M Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 057/107] ARM: mmp: fix timer_init calls Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 058/107] memstick: Prevent memstick host from getting runtime suspended during card detection Sasha Levin
2019-01-28 16:18 ` [PATCH AUTOSEL 4.9 059/107] tty: serial: samsung: Properly set flags in autoCTS mode Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 060/107] perf header: Fix unchecked usage of strncpy() Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 061/107] perf probe: " Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 062/107] KVM: s390: unregister debug feature on failing arch init Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 063/107] arm64: KVM: Skip MMIO insn after emulation Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 064/107] powerpc/uaccess: fix warning/error with access_ok() Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 065/107] mac80211: fix radiotap vendor presence bitmap handling Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 066/107] xfrm6_tunnel: Fix spi check in __xfrm6_tunnel_alloc_spi Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 067/107] Bluetooth: Fix unnecessary error message for HCI request completion Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 068/107] scsi: smartpqi: correct host serial num for ssa Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 069/107] scsi: smartpqi: correct volume status Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 070/107] cw1200: Fix concurrency use-after-free bugs in cw1200_hw_scan() Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 071/107] drbd: narrow rcu_read_lock in drbd_sync_handshake Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 072/107] drbd: disconnect, if the wrong UUIDs are attached on a connected peer Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 073/107] drbd: skip spurious timeout (ping-timeo) when failing promote Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 074/107] drbd: Avoid Clang warning about pointless switch statment Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 075/107] video: clps711x-fb: release disp device node in probe() Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 076/107] fbdev: fbmem: behave better with small rotated displays and many CPUs Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 077/107] i40e: define proper net_device::neigh_priv_len Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 078/107] igb: Fix an issue that PME is not enabled during runtime suspend Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 079/107] fbdev: fbcon: Fix unregister crash when more than one framebuffer Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 080/107] pinctrl: meson: meson8: fix the GPIO function for the GPIOAO pins Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 081/107] pinctrl: meson: meson8b: " Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 082/107] KVM: x86: svm: report MSR_IA32_MCG_EXT_CTL as unsupported Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 083/107] NFS: nfs_compare_mount_options always compare auth flavors Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 084/107] hwmon: (lm80) fix a missing check of the status of SMBus read Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 085/107] hwmon: (lm80) fix a missing check of bus read in lm80 probe Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 086/107] seq_buf: Make seq_buf_puts() null-terminate the buffer Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 087/107] crypto: ux500 - Use proper enum in cryp_set_dma_transfer Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 088/107] crypto: ux500 - Use proper enum in hash_set_dma_transfer Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 089/107] MIPS: ralink: Select CONFIG_CPU_MIPSR2_IRQ_VI on MT7620/8 Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 090/107] cifs: check ntwrk_buf_start for NULL before dereferencing it Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 091/107] um: Avoid marking pages with "changed protection" Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 092/107] niu: fix missing checks of niu_pci_eeprom_read Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 093/107] f2fs: fix sbi->extent_list corruption issue Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 094/107] scripts/decode_stacktrace: only strip base path when a prefix of the path Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 095/107] mm/page_owner: clamp read count to PAGE_SIZE Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 096/107] ocfs2: don't clear bh uptodate for block read Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 097/107] isdn: hisax: hfc_pci: Fix a possible concurrency use-after-free bug in HFCPCI_l1hw() Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 098/107] gdrom: fix a memory leak bug Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 099/107] fsl/fman: Use GFP_ATOMIC in {memac,tgec}_add_hash_mac_address() Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 100/107] block/swim3: Fix -EBUSY error when re-opening device after unmount Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 101/107] thermal: generic-adc: Fix adc to temp interpolation Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 102/107] HID: lenovo: Add checks to fix of_led_classdev_register Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 103/107] fs/proc/base.c: use ns_capable instead of capable for timerslack_ns Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 104/107] kernel/hung_task.c: break RCU locks based on jiffies Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 105/107] proc/sysctl: fix return error for proc_doulongvec_minmax() Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 106/107] fs/epoll: drop ovflist branch prediction Sasha Levin
2019-01-28 16:19 ` [PATCH AUTOSEL 4.9 107/107] exec: load_script: don't blindly truncate shebang string Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190128161947.57405-39-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=casey@schaufler-ca.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=serge@hallyn.com \
    --cc=stable@vger.kernel.org \
    --cc=zmarkovic@sierrawireless.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).