Userspace libraries, e.g. glibc's dprintf(), expect the default return value
for invalid seek situations: -ESPIPE, but when the IO was over /dev/kmsg the
current state of kernel code was returning the generic case of an -EINVAL.
Hence, userspace programs were not behaving as expected or documented.
With this patch we add SEEK_CUR case returning the expected value and also a
simple mention of it in kernel's documentation for those relying on that for
guidance.
Signed-off-by: Bruno Meneguele <bmeneg(a)redhat.com>
---
Documentation/ABI/testing/dev-kmsg | 2 ++
kernel/printk/printk.c | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/Documentation/ABI/testing/dev-kmsg b/Documentation/ABI/testing/dev-kmsg
index f307506eb54c..8533d28e6fda 100644
--- a/Documentation/ABI/testing/dev-kmsg
+++ b/Documentation/ABI/testing/dev-kmsg
@@ -56,6 +56,8 @@ Description: The /dev/kmsg character device node provides userspace access
seek after the last record available at the time
the last SYSLOG_ACTION_CLEAR was issued.
+ While SEEK_CUR sets -ESPIPE (invalid seek) to errno.
+
The output format consists of a prefix carrying the syslog
prefix including priority and facility, the 64 bit message
sequence number and the monotonic timestamp in microseconds,
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index ad4606234545..d02606723d2d 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -963,6 +963,10 @@ static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence)
user->idx = log_next_idx;
user->seq = log_next_seq;
break;
+ case SEEK_CUR:
+ /* return the default errno for invalid seek */
+ ret = -ESPIPE;
+ break;
default:
ret = -EINVAL;
}
--
2.24.1
This is the start of the stable review cycle for the 4.19.111 release.
There are 89 patches in this series, all will be posted as a response
to this one. If anyone has any issues with these being applied, please
let me know.
Responses should be made by Thu, 19 Mar 2020 10:31:16 +0000.
Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.111-r…
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Linux 4.19.111-rc1
Sven Eckelmann <sven(a)narfation.org>
batman-adv: Avoid free/alloc race when handling OGM2 buffer
Vladis Dronov <vdronov(a)redhat.com>
efi: Add a sanity check to efivar_store_raw()
Karsten Graul <kgraul(a)linux.ibm.com>
net/smc: cancel event worker during device removal
Karsten Graul <kgraul(a)linux.ibm.com>
net/smc: check for valid ib_client_data
Eric Dumazet <edumazet(a)google.com>
ipv6: restrict IPV6_ADDRFORM operation
Wolfram Sang <wsa+renesas(a)sang-engineering.com>
i2c: acpi: put device when verifying client fails
Daniel Drake <drake(a)endlessm.com>
iommu/vt-d: Ignore devices with out-of-spec domain number
Zhenzhong Duan <zhenzhong.duan(a)gmail.com>
iommu/vt-d: Fix the wrong printing in RHSA parsing
Jakub Kicinski <kuba(a)kernel.org>
netfilter: nft_tunnel: add missing attribute validation for tunnels
Jakub Kicinski <kuba(a)kernel.org>
netfilter: nft_payload: add missing attribute validation for payload csum flags
Jakub Kicinski <kuba(a)kernel.org>
netfilter: cthelper: add missing attribute validation for cthelper
Tommi Rantala <tommi.t.rantala(a)nokia.com>
perf bench futex-wake: Restore thread count default to online CPU count
Jakub Kicinski <kuba(a)kernel.org>
nl80211: add missing attribute validation for channel switch
Jakub Kicinski <kuba(a)kernel.org>
nl80211: add missing attribute validation for beacon report scanning
Jakub Kicinski <kuba(a)kernel.org>
nl80211: add missing attribute validation for critical protocol indication
Hamish Martin <hamish.martin(a)alliedtelesis.co.nz>
i2c: gpio: suppress error on probe defer
Zhenyu Wang <zhenyuw(a)linux.intel.com>
drm/i915/gvt: Fix unnecessary schedule timer when no vGPU exits
Charles Keepax <ckeepax(a)opensource.cirrus.com>
pinctrl: core: Remove extra kref_get which blocks hogs being freed
Nicolas Belin <nbelin(a)baylibre.com>
pinctrl: meson-gxl: fix GPIOX sdio pins
Sven Eckelmann <sven(a)narfation.org>
batman-adv: Don't schedule OGM for disabled interface
Yonghyun Hwang <yonghyun(a)google.com>
iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page
Hans de Goede <hdegoede(a)redhat.com>
iommu/vt-d: dmar: replace WARN_TAINT with pr_warn + add_taint
Marc Zyngier <maz(a)kernel.org>
iommu/dma: Fix MSI reservation allocation
Tony Luck <tony.luck(a)intel.com>
x86/mce: Fix logic and comments around MSR_PPIN_CTL
Felix Fietkau <nbd(a)nbd.name>
mt76: fix array overflow on receiving too many fragments for a packet
Sai Praneeth <sai.praneeth.prakhya(a)intel.com>
efi: Make efi_rts_work accessible to efi page fault handler
Vladis Dronov <vdronov(a)redhat.com>
efi: Fix a race and a buffer overflow while reading efivars via sysfs
Wolfram Sang <wsa(a)the-dreams.de>
macintosh: windfarm: fix MODINFO regression
Eugeniy Paltsev <Eugeniy.Paltsev(a)synopsys.com>
ARC: define __ALIGN_STR and __ALIGN symbols for ARC
Vitaly Kuznetsov <vkuznets(a)redhat.com>
KVM: x86: clear stale x86_emulate_ctxt->intercept value
Al Viro <viro(a)zeniv.linux.org.uk>
gfs2_atomic_open(): fix O_EXCL|O_CREAT handling on cold dcache
Al Viro <viro(a)zeniv.linux.org.uk>
cifs_atomic_open(): fix double-put on late allocation failure
Steven Rostedt (VMware) <rostedt(a)goodmis.org>
ktest: Add timeout for ssh sync testing
Colin Ian King <colin.king(a)canonical.com>
drm/amd/display: remove duplicated assignment to grph_obj_type
Hillf Danton <hdanton(a)sina.com>
workqueue: don't use wq_select_unbound_cpu() for bound works
Vasily Averin <vvs(a)virtuozzo.com>
netfilter: x_tables: xt_mttg_seq_next should increase position index
Vasily Averin <vvs(a)virtuozzo.com>
netfilter: xt_recent: recent_seq_next should increase position index
Vasily Averin <vvs(a)virtuozzo.com>
netfilter: synproxy: synproxy_cpu_seq_next should increase position index
Vasily Averin <vvs(a)virtuozzo.com>
netfilter: nf_conntrack: ct_cpu_seq_next should increase position index
Hans de Goede <hdegoede(a)redhat.com>
iommu/vt-d: quirk_ioat_snb_local_iommu: replace WARN_TAINT with pr_warn + add_taint
Halil Pasic <pasic(a)linux.ibm.com>
virtio-blk: fix hw_queue stopped on arbitrary error
Dan Moulding <dmoulding(a)me.com>
iwlwifi: mvm: Do not require PHY_SKU NVM section for 3168 devices
Michal Koutný <mkoutny(a)suse.com>
cgroup: Iterate tasks that did not finish do_exit()
Vasily Averin <vvs(a)virtuozzo.com>
cgroup: cgroup_procs_next should increase position index
Mahesh Bandewar <maheshb(a)google.com>
macvlan: add cond_resched() during multicast processing
Jakub Kicinski <kuba(a)kernel.org>
net: fec: validate the new settings in fec_enet_set_coalesce()
Eric Dumazet <edumazet(a)google.com>
slip: make slhc_compress() more robust against malicious packets
Eric Dumazet <edumazet(a)google.com>
bonding/alb: make sure arp header is pulled before accessing it
Jakub Kicinski <kuba(a)kernel.org>
devlink: validate length of region addr/len
Jakub Kicinski <kuba(a)kernel.org>
tipc: add missing attribute validation for MTU property
Hangbin Liu <liuhangbin(a)gmail.com>
net/ipv6: remove the old peer route if change it to a new one
Hangbin Liu <liuhangbin(a)gmail.com>
net/ipv6: need update peer route when modify metric
Hangbin Liu <liuhangbin(a)gmail.com>
selftests/net/fib_tests: update addr_metric_test for peer route testing
Heiner Kallweit <hkallweit1(a)gmail.com>
net: phy: fix MDIO bus PM PHY resuming
Jakub Kicinski <kuba(a)kernel.org>
nfc: add missing attribute validation for vendor subcommand
Jakub Kicinski <kuba(a)kernel.org>
nfc: add missing attribute validation for deactivate target
Jakub Kicinski <kuba(a)kernel.org>
nfc: add missing attribute validation for SE API
Jakub Kicinski <kuba(a)kernel.org>
team: add missing attribute validation for array index
Jakub Kicinski <kuba(a)kernel.org>
team: add missing attribute validation for port ifindex
Jakub Kicinski <kuba(a)kernel.org>
net: fq: add missing attribute validation for orphan mask
Jakub Kicinski <kuba(a)kernel.org>
macsec: add missing attribute validation for port
Jakub Kicinski <kuba(a)kernel.org>
can: add missing attribute validation for termination
Jakub Kicinski <kuba(a)kernel.org>
nl802154: add missing attribute validation for dev_type
Jakub Kicinski <kuba(a)kernel.org>
nl802154: add missing attribute validation
Jakub Kicinski <kuba(a)kernel.org>
fib: add missing attribute validation for tun_id
Jakub Kicinski <kuba(a)kernel.org>
devlink: validate length of param values
Eric Dumazet <edumazet(a)google.com>
net: memcg: fix lockdep splat in inet_csk_accept()
Shakeel Butt <shakeelb(a)google.com>
net: memcg: late association of sock to memcg
Shakeel Butt <shakeelb(a)google.com>
cgroup: memcg: net: do not associate sock with unrelated cgroup
Vasundhara Volam <vasundhara-v.volam(a)broadcom.com>
bnxt_en: reinitialize IRQs when MTU is modified
Edward Cree <ecree(a)solarflare.com>
sfc: detach from cb_page in efx_copy_channel()
You-Sheng Yang <vicamo.yang(a)canonical.com>
r8152: check disconnect status after long sleep
Colin Ian King <colin.king(a)canonical.com>
net: systemport: fix index check to avoid an array out of bounds access
Remi Pommarel <repk(a)triplefau.lt>
net: stmmac: dwmac1000: Disable ACS if enhanced descs are not used
Willem de Bruijn <willemb(a)google.com>
net/packet: tpacket_rcv: do not increment ring index on drop
Dan Carpenter <dan.carpenter(a)oracle.com>
net: nfc: fix bounds checking bugs on "pipe"
Dmitry Bogdanov <dbogdanov(a)marvell.com>
net: macsec: update SCI upon MAC address change.
Pablo Neira Ayuso <pablo(a)netfilter.org>
netlink: Use netlink header as base to calculate bad attribute offset
Hangbin Liu <liuhangbin(a)gmail.com>
net/ipv6: use configured metric when add peer route
Mahesh Bandewar <maheshb(a)google.com>
ipvlan: don't deref eth hdr before checking it's set
Eric Dumazet <edumazet(a)google.com>
ipvlan: do not use cond_resched_rcu() in ipvlan_process_multicast()
Jiri Wiesner <jwiesner(a)suse.com>
ipvlan: do not add hardware address of master to its unicast filter list
Mahesh Bandewar <maheshb(a)google.com>
ipvlan: add cond_resched_rcu() while processing muticast backlog
Hangbin Liu <liuhangbin(a)gmail.com>
ipv6/addrconf: call ipv6_mc_up() for non-Ethernet interface
Dmitry Yakunin <zeil(a)yandex-team.ru>
inet_diag: return classid for all socket types
Eric Dumazet <edumazet(a)google.com>
gre: fix uninit-value in __iptunnel_pull_header
Dmitry Yakunin <zeil(a)yandex-team.ru>
cgroup, netclassid: periodically release file_lock on classid updating
Florian Fainelli <f.fainelli(a)gmail.com>
net: phy: Avoid multiple suspends
David S. Miller <davem(a)davemloft.net>
phy: Revert toggling reset changes.
-------------
Diffstat:
Documentation/filesystems/porting | 7 +++
Makefile | 4 +-
arch/arc/include/asm/linkage.h | 2 +
arch/x86/kernel/cpu/mcheck/mce_intel.c | 9 ++--
arch/x86/kvm/emulate.c | 1 +
drivers/block/virtio_blk.c | 8 ++--
drivers/firmware/efi/efivars.c | 32 +++++++++----
drivers/firmware/efi/runtime-wrappers.c | 53 ++++------------------
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 3 +-
drivers/gpu/drm/i915/gvt/vgpu.c | 12 +++--
drivers/i2c/busses/i2c-gpio.c | 2 +-
drivers/i2c/i2c-core-acpi.c | 10 +++-
drivers/iommu/dma-iommu.c | 16 +++----
drivers/iommu/dmar.c | 21 ++++++---
drivers/iommu/intel-iommu.c | 13 ++++--
drivers/macintosh/windfarm_ad7417_sensor.c | 7 +++
drivers/macintosh/windfarm_fcu_controls.c | 7 +++
drivers/macintosh/windfarm_lm75_sensor.c | 16 ++++++-
drivers/macintosh/windfarm_lm87_sensor.c | 7 +++
drivers/macintosh/windfarm_max6690_sensor.c | 7 +++
drivers/macintosh/windfarm_smu_sat.c | 7 +++
drivers/net/bonding/bond_alb.c | 20 ++++----
drivers/net/can/dev.c | 1 +
drivers/net/ethernet/broadcom/bcmsysport.c | 2 +-
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 +-
drivers/net/ethernet/freescale/fec_main.c | 6 +--
drivers/net/ethernet/sfc/efx.c | 1 +
.../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 3 +-
drivers/net/ipvlan/ipvlan_core.c | 19 ++++----
drivers/net/ipvlan/ipvlan_main.c | 5 +-
drivers/net/macsec.c | 12 +++--
drivers/net/macvlan.c | 2 +
drivers/net/phy/phy_device.c | 18 +++++---
drivers/net/slip/slhc.c | 14 ++++--
drivers/net/team/team.c | 2 +
drivers/net/usb/r8152.c | 8 ++++
drivers/net/wireless/intel/iwlwifi/mvm/nvm.c | 3 +-
drivers/net/wireless/mediatek/mt76/dma.c | 9 ++--
drivers/pinctrl/core.c | 1 -
drivers/pinctrl/meson/pinctrl-meson-gxl.c | 4 +-
fs/cifs/dir.c | 1 -
fs/gfs2/inode.c | 2 +-
fs/open.c | 3 --
include/linux/cgroup.h | 1 +
include/linux/efi.h | 36 +++++++++++++++
include/linux/inet_diag.h | 18 +++++---
include/linux/phy.h | 2 +
include/net/fib_rules.h | 1 +
kernel/cgroup/cgroup.c | 37 +++++++++++----
kernel/workqueue.c | 14 +++---
mm/memcontrol.c | 14 +-----
net/batman-adv/bat_iv_ogm.c | 4 ++
net/batman-adv/bat_v_ogm.c | 42 +++++++++++++----
net/batman-adv/types.h | 4 ++
net/core/devlink.c | 33 +++++++++-----
net/core/netclassid_cgroup.c | 47 +++++++++++++++----
net/core/sock.c | 5 +-
net/ieee802154/nl_policy.c | 6 +++
net/ipv4/gre_demux.c | 12 ++++-
net/ipv4/inet_connection_sock.c | 20 ++++++++
net/ipv4/inet_diag.c | 44 ++++++++----------
net/ipv4/raw_diag.c | 5 +-
net/ipv4/udp_diag.c | 5 +-
net/ipv6/addrconf.c | 49 +++++++++++++++-----
net/ipv6/ipv6_sockglue.c | 10 +++-
net/netfilter/nf_conntrack_standalone.c | 2 +-
net/netfilter/nf_synproxy_core.c | 2 +-
net/netfilter/nfnetlink_cthelper.c | 2 +
net/netfilter/nft_payload.c | 1 +
net/netfilter/nft_tunnel.c | 2 +
net/netfilter/x_tables.c | 6 +--
net/netfilter/xt_recent.c | 2 +-
net/netlink/af_netlink.c | 2 +-
net/nfc/hci/core.c | 19 ++++++--
net/nfc/netlink.c | 4 ++
net/packet/af_packet.c | 13 +++---
net/sched/sch_fq.c | 1 +
net/sctp/diag.c | 8 +---
net/smc/smc_ib.c | 3 ++
net/tipc/netlink.c | 3 +-
net/wireless/nl80211.c | 5 ++
tools/perf/bench/futex-wake.c | 4 +-
tools/testing/ktest/ktest.pl | 2 +-
tools/testing/selftests/net/fib_tests.sh | 34 ++++++++++++--
84 files changed, 625 insertions(+), 283 deletions(-)
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 870b4333a62e45b0b2000d14b301b7b8b8cad9da
Gitweb: https://git.kernel.org/tip/870b4333a62e45b0b2000d14b301b7b8b8cad9da
Author: Borislav Petkov <bp(a)suse.de>
AuthorDate: Wed, 18 Mar 2020 19:27:48 +01:00
Committer: Borislav Petkov <bp(a)suse.de>
CommitterDate: Thu, 19 Mar 2020 10:55:56 +01:00
x86/ioremap: Fix CONFIG_EFI=n build
In order to use efi_mem_type(), one needs CONFIG_EFI enabled. Otherwise
that function is undefined. Use IS_ENABLED() to check and avoid the
ifdeffery as the compiler optimizes away the following unreachable code
then.
Fixes: 985e537a4082 ("x86/ioremap: Map EFI runtime services data as encrypted for SEV")
Reported-by: Randy Dunlap <rdunlap(a)infradead.org>
Signed-off-by: Borislav Petkov <bp(a)suse.de>
Tested-by: Randy Dunlap <rdunlap(a)infradead.org>
Cc: Tom Lendacky <thomas.lendacky(a)amd.com>
Cc: <stable(a)vger.kernel.org>
Link: https://lkml.kernel.org/r/7561e981-0d9b-d62c-0ef2-ce6007aff1ab@infradead.org
---
arch/x86/mm/ioremap.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 935a91e..18c637c 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -115,6 +115,9 @@ static void __ioremap_check_other(resource_size_t addr, struct ioremap_desc *des
if (!sev_active())
return;
+ if (!IS_ENABLED(CONFIG_EFI))
+ return;
+
if (efi_mem_type(addr) == EFI_RUNTIME_SERVICES_DATA)
desc->flags |= IORES_MAP_ENCRYPTED;
}
Hi,
On Sun, Jan 5, 2020 at 2:47 PM David Miller <davem(a)davemloft.net> wrote:
>
> From: Wen Gong <wgong(a)codeaurora.org>
> Date: Fri, 3 Jan 2020 12:50:16 +0800
>
> > The len used for skb_put_padto is wrong, it need to add len of hdr.
>
> Thanks, applied.
I noticed this patch is in mainline now as:
ce57785bf91b net: qrtr: fix len of skb_put_padto in qrtr_node_enqueue
Though I'm not an expert on the code, it feels like a stable candidate
unless someone objects.
-Doug
Please pick the following commits for the 4.19 branch:
2507e6ab7a9a wimax: i2400: fix memory leak
6f3ef5c25cc7 wimax: i2400: Fix memory leak in i2400m_op_rfkill_sw_toggle
I previously sent these to you for other stable branches, but
accidentally missed 4.19.
Ben.
--
Ben Hutchings, Software Developer Codethink Ltd
https://www.codethink.co.uk/ Dale House, 35 Dale Street
Manchester, M1 2HF, United Kingdom
This is a note to let you know that I've just added the patch titled
nvmem: check for NULL reg_read and reg_write before dereferencing
to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-next branch.
The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release
during the merge window.
If you have any questions about this process, please let me know.
>From 3c91ef69a3e94f78546b246225ed573fbf1735b4 Mon Sep 17 00:00:00 2001
From: Nicholas Johnson <nicholas.johnson-opensource(a)outlook.com.au>
Date: Tue, 10 Mar 2020 13:22:52 +0000
Subject: nvmem: check for NULL reg_read and reg_write before dereferencing
Return -EPERM if reg_read is NULL in bin_attr_nvmem_read() or if
reg_write is NULL in bin_attr_nvmem_write().
This prevents NULL dereferences such as the one described in
03cd45d2e219 ("thunderbolt: Prevent crash if non-active NVMem file is
read")
Signed-off-by: Nicholas Johnson <nicholas.johnson-opensource(a)outlook.com.au>
Cc: stable <stable(a)vger.kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla(a)linaro.org>
Link: https://lore.kernel.org/r/20200310132257.23358-10-srinivas.kandagatla@linar…
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
---
drivers/nvmem/nvmem-sysfs.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/nvmem/nvmem-sysfs.c b/drivers/nvmem/nvmem-sysfs.c
index 9e0c429cd08a..8759c4470012 100644
--- a/drivers/nvmem/nvmem-sysfs.c
+++ b/drivers/nvmem/nvmem-sysfs.c
@@ -56,6 +56,9 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj,
count = round_down(count, nvmem->word_size);
+ if (!nvmem->reg_read)
+ return -EPERM;
+
rc = nvmem->reg_read(nvmem->priv, pos, buf, count);
if (rc)
@@ -90,6 +93,9 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
count = round_down(count, nvmem->word_size);
+ if (!nvmem->reg_write)
+ return -EPERM;
+
rc = nvmem->reg_write(nvmem->priv, pos, buf, count);
if (rc)
--
2.25.2
This is a note to let you know that I've just added the patch titled
nvmem: release the write-protect pin
to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-next branch.
The patch will show up in the next release of the linux-next tree
(usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release
during the merge window.
If you have any questions about this process, please let me know.
>From a9c3766cb19cdadf2776aba41b64470002645894 Mon Sep 17 00:00:00 2001
From: Khouloud Touil <ktouil(a)baylibre.com>
Date: Tue, 10 Mar 2020 13:22:50 +0000
Subject: nvmem: release the write-protect pin
Put the write-protect GPIO descriptor in nvmem_release() so that it can
be automatically released when the associated device's reference count
drops to 0.
Fixes: 2a127da461a9 ("nvmem: add support for the write-protect pin")
Reported-by: Geert Uytterhoeven <geert(a)linux-m68k.org>
Signed-off-by: Khouloud Touil <ktouil(a)baylibre.com>
Cc: stable <stable(a)vger.kernel.org>
[Bartosz: tweak the commit message]
Signed-off-by: Bartosz Golaszewski <bgolaszewski(a)baylibre.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla(a)linaro.org>
Link: https://lore.kernel.org/r/20200310132257.23358-8-srinivas.kandagatla@linaro…
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
---
drivers/nvmem/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 2758d90d63b7..c05c4f4a7b9e 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -72,6 +72,7 @@ static void nvmem_release(struct device *dev)
struct nvmem_device *nvmem = to_nvmem_device(dev);
ida_simple_remove(&nvmem_ida, nvmem->id);
+ gpiod_put(nvmem->wp_gpio);
kfree(nvmem);
}
--
2.25.2
From: Eric Biggers <ebiggers(a)google.com>
After request_module(), nothing is stopping the module from being
unloaded until someone takes a reference to it via try_get_module().
The WARN_ONCE() in get_fs_type() is thus user-reachable, via userspace
running 'rmmod' concurrently.
Since WARN_ONCE() is for kernel bugs only, not for user-reachable
situations, downgrade this warning to pr_warn_once().
Keep it printed once only, since the intent of this warning is to detect
a bug in modprobe at boot time. Printing the warning more than once
wouldn't really provide any useful extra information.
Fixes: 41124db869b7 ("fs: warn in case userspace lied about modprobe return")
Acked-by: Luis Chamberlain <mcgrof(a)kernel.org>
Reviewed-by: Jessica Yu <jeyu(a)kernel.org>
Cc: <stable(a)vger.kernel.org> # v4.13+
Cc: Alexei Starovoitov <ast(a)kernel.org>
Cc: Andrew Morton <akpm(a)linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Cc: Jeff Vander Stoep <jeffv(a)google.com>
Cc: Kees Cook <keescook(a)chromium.org>
Cc: NeilBrown <neilb(a)suse.com>
Signed-off-by: Eric Biggers <ebiggers(a)google.com>
---
fs/filesystems.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/filesystems.c b/fs/filesystems.c
index 77bf5f95362da..90b8d879fbaf3 100644
--- a/fs/filesystems.c
+++ b/fs/filesystems.c
@@ -272,7 +272,9 @@ struct file_system_type *get_fs_type(const char *name)
fs = __get_fs_type(name, len);
if (!fs && (request_module("fs-%.*s", len, name) == 0)) {
fs = __get_fs_type(name, len);
- WARN_ONCE(!fs, "request_module fs-%.*s succeeded, but still no fs?\n", len, name);
+ if (!fs)
+ pr_warn_once("request_module fs-%.*s succeeded, but still no fs?\n",
+ len, name);
}
if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
--
2.25.1
From: Eric Biggers <ebiggers(a)google.com>
It's long been possible to disable kernel module autoloading completely
(while still allowing manual module insertion) by setting
/proc/sys/kernel/modprobe to the empty string. This can be preferable
to setting it to a nonexistent file since it avoids the overhead of an
attempted execve(), avoids potential deadlocks, and avoids the call to
security_kernel_module_request() and thus on SELinux-based systems
eliminates the need to write SELinux rules to dontaudit module_request.
However, when module autoloading is disabled in this way,
request_module() returns 0. This is broken because callers expect 0 to
mean that the module was successfully loaded.
Apparently this was never noticed because this method of disabling
module autoloading isn't used much, and also most callers don't use the
return value of request_module() since it's always necessary to check
whether the module registered its functionality or not anyway. But
improperly returning 0 can indeed confuse a few callers, for example
get_fs_type() in fs/filesystems.c where it causes a WARNING to be hit:
if (!fs && (request_module("fs-%.*s", len, name) == 0)) {
fs = __get_fs_type(name, len);
WARN_ONCE(!fs, "request_module fs-%.*s succeeded, but still no fs?\n", len, name);
}
This is easily reproduced with:
echo > /proc/sys/kernel/modprobe
mount -t NONEXISTENT none /
It causes:
request_module fs-NONEXISTENT succeeded, but still no fs?
WARNING: CPU: 1 PID: 1106 at fs/filesystems.c:275 get_fs_type+0xd6/0xf0
[...]
This should actually use pr_warn_once() rather than WARN_ONCE(), since
it's also user-reachable if userspace immediately unloads the module.
Regardless, request_module() should correctly return an error when it
fails. So let's make it return -ENOENT, which matches the error when
the modprobe binary doesn't exist.
I've also sent patches to document and test this case.
Acked-by: Luis Chamberlain <mcgrof(a)kernel.org>
Reviewed-by: Jessica Yu <jeyu(a)kernel.org>
Reviewed-by: Kees Cook <keescook(a)chromium.org>
Cc: stable(a)vger.kernel.org
Cc: Alexei Starovoitov <ast(a)kernel.org>
Cc: Andrew Morton <akpm(a)linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Cc: Jeff Vander Stoep <jeffv(a)google.com>
Cc: NeilBrown <neilb(a)suse.com>
Signed-off-by: Eric Biggers <ebiggers(a)google.com>
---
kernel/kmod.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/kmod.c b/kernel/kmod.c
index bc6addd9152b4..a2de58de6ab62 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -120,7 +120,7 @@ static int call_modprobe(char *module_name, int wait)
* invoke it.
*
* If module auto-loading support is disabled then this function
- * becomes a no-operation.
+ * simply returns -ENOENT.
*/
int __request_module(bool wait, const char *fmt, ...)
{
@@ -137,7 +137,7 @@ int __request_module(bool wait, const char *fmt, ...)
WARN_ON_ONCE(wait && current_is_async());
if (!modprobe_path[0])
- return 0;
+ return -ENOENT;
va_start(args, fmt);
ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
--
2.25.1
From: Eric Biggers <ebiggers(a)google.com>
After request_module(), nothing is stopping the module from being
unloaded until someone takes a reference to it via try_get_module().
The WARN_ONCE() in get_fs_type() is thus user-reachable, via userspace
running 'rmmod' concurrently.
Since WARN_ONCE() is for kernel bugs only, not for user-reachable
situations, downgrade this warning to pr_warn_once().
Acked-by: Luis Chamberlain <mcgrof(a)kernel.org>
Cc: stable(a)vger.kernel.org
Cc: Alexei Starovoitov <ast(a)kernel.org>
Cc: Andrew Morton <akpm(a)linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Cc: Jeff Vander Stoep <jeffv(a)google.com>
Cc: Jessica Yu <jeyu(a)kernel.org>
Cc: Kees Cook <keescook(a)chromium.org>
Cc: NeilBrown <neilb(a)suse.com>
Signed-off-by: Eric Biggers <ebiggers(a)google.com>
---
fs/filesystems.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/filesystems.c b/fs/filesystems.c
index 77bf5f95362da..90b8d879fbaf3 100644
--- a/fs/filesystems.c
+++ b/fs/filesystems.c
@@ -272,7 +272,9 @@ struct file_system_type *get_fs_type(const char *name)
fs = __get_fs_type(name, len);
if (!fs && (request_module("fs-%.*s", len, name) == 0)) {
fs = __get_fs_type(name, len);
- WARN_ONCE(!fs, "request_module fs-%.*s succeeded, but still no fs?\n", len, name);
+ if (!fs)
+ pr_warn_once("request_module fs-%.*s succeeded, but still no fs?\n",
+ len, name);
}
if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
--
2.25.1