clk: ti: clkctrl: Fix returning uninitialized data
Subsystems (6)
Sasha Levin
maintainerPATCH 1/13 clk: ti: clkctrl: Fix returning uninitialized data
From: Tony Lindgren <[email protected]>
[ Upstream commit 41b3588dba6ef4b7995735a97e47ff0aeea6c276 ]
If we do a clk_get() for a clock that does not exists, we have _ti_omap4_clkctrl_xlate() return uninitialized data if no match is found. This can be seen in some cases with SLAB_DEBUG enabled:
Unable to handle kernel paging request at virtual address 5a5a5a5a
...
clk_hw_create_clk.part.33sysc_notifier_callnotifier_call_chainblocking_notifier_call_chaindevice_add
Let's fix this by setting a found flag only when we find a match.
--- drivers/clk/ti/clkctrl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/clk/ti/clkctrl.c +5 -2
@@ -215,6 +215,7 @@ static struct clk_hw *_ti_omap4_clkctrl_xlate(struct of_phandle_args *clkspec, {struct omap_clkctrl_provider *provider = data;struct omap_clkctrl_clk *entry; +bool found = false;if (clkspec->args_count !=2 )return ERR_PTR (-EINVAL );
@@ -224,11 +225,13 @@ static struct clk_hw *_ti_omap4_clkctrl_xlate(struct of_phandle_args *clkspec,list_for_each_entry (entry, &provider->clocks, node) {if (entry->reg_offset == clkspec->args[0 ] && - entry->bit_offset == clkspec->args[1 ]) + entry->bit_offset == clkspec->args[1 ]) { + found = true;break ; + } } -if (!entry) +if (!found)return ERR_PTR (-EINVAL );return entry->clk;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 2/13 efi/bgrt: Drop BGRT status field reserved bits check
From: Hans de Goede <[email protected]>
[ Upstream commit a483fcab38b43fb34a7f12ab1daadd3907f150e2 ]
Starting with ACPI 6.2 bits 1 and 2 of the BGRT status field are no longer reserved. These bits are now used to indicate if the image needs to be rotated before being displayed.
The first device using these bits has now shown up (the GPD MicroPC) and the reserved bits check causes us to reject the valid BGRT table on this device.
Rather then changing the reserved bits check, allowing only the 2 new bits, instead just completely remove it so that we do not end up with a similar problem when more bits are added in the future.
--- drivers/firmware/efi/efi-bgrt.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/firmware/efi/efi-bgrt.c +0 -5
@@ -50,11 +50,6 @@ void __init efi_bgrt_init(struct acpi_table_header *table) bgrt->version); goto out; } -if (bgrt->status &0xfe ) { -pr_notice ("Ignoring BGRT: reserved status bits are non-zero %u\n" , - bgrt->status); - goto out; - }if (bgrt->image_type !=0 ) {pr_notice ("Ignoring BGRT: invalid image type %u (expected 0)\n" , bgrt->image_type);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 3/13 perf/core: Fix perf_sample_regs_user() mm check
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 085ebfe937d7a7a5df1729f35a12d6d655fea68c ]
perf_sample_regs_user() uses 'current->mm' to test for the presence of userspace, but this is insufficient, consider use_mm().
A better test is: '!(current->flags & PF_KTHREAD)', exec() clears PF_KTHREAD after it sets the new ->mm but before it drops to userspace for the first time.
Possibly obsoletes: bf05fc25f268 ("powerpc/perf: Fix oops when kthread execs user process")
--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
@@ -5630,7 +5630,7 @@ static void perf_sample_regs_user(struct perf_regs *regs_user,if (user_mode (regs)) { regs_user->abi =perf_reg_abi (current); regs_user->regs = regs; - }else if (current->mm) { + }else if (!(current->flags &PF_KTHREAD )) {perf_get_regs_user (regs_user, regs, regs_user_copy); }else { regs_user->abi =PERF_SAMPLE_REGS_ABI_NONE ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 4/13 ARM: omap2: remove incorrect __init annotation
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 27e23d8975270df6999f8b5b3156fc0c04927451 ]
omap3xxx_prm_enable_io_wakeup() is marked __init, but its caller is not, so we get a warning with clang-8:
WARNING: vmlinux.o(.text+0x343c8): Section mismatch in reference from the function omap3xxx_prm_late_init() to the function .init.text:omap3xxx_prm_enable_io_wakeup() The function omap3xxx_prm_late_init() references
the function __init omap3xxx_prm_enable_io_wakeup().
This is often because omap3xxx_prm_late_init lacks a __init
annotation or the annotation of omap3xxx_prm_enable_io_wakeup is wrong.
When building with gcc, omap3xxx_prm_enable_io_wakeup() is always inlined, so we never noticed in the past.
--- arch/arm/mach-omap2/prm3xxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-omap2/prm3xxx.c +1 -1
@@ -433,7 +433,7 @@ static void omap3_prm_reconfigure_io_chain(void)* registers, and omap3xxx_prm_reconfigure_io_chain() must be called. * No return value. */ -static void __init omap3xxx_prm_enable_io_wakeup (void ) +static void omap3xxx_prm_enable_io_wakeup (void ) {if (prm_features &PRM_HAS_IO_WAKEUP ) omap2_prm_set_mod_reg_bits(OMAP3430_EN_IO_MASK, WKUP_MOD,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 5/13 be2net: fix link failure after ethtool offline test
In reply to Sasha LevinFrom: Petr Oros <[email protected]>
[ Upstream commit 2e5db6eb3c23e5dc8171eb8f6af7a97ef9fcf3a9 ]
Certain cards in conjunction with certain switches need a little more time for link setup that results in ethtool link test failure after offline test. Patch adds a loop that waits for a link setup finish.
Changes in v2:
- added fixes header
--- .../net/ethernet/emulex/benet/be_ethtool.c | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/net/ethernet/emulex/benet/be_ethtool.c +22 -6
@@ -893,7 +893,7 @@ static void be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data) {struct be_adapter *adapter =netdev_priv (netdev); -int status; +int status, cnt;u8 link_status =0 ;if (adapter->function_caps &BE_FUNCTION_CAPS_SUPER_NIC ) {
@@ -904,6 +904,9 @@ static void be_self_test(struct net_device *netdev, struct ethtool_test *test,memset (data,0 ,sizeof (u64) *ETHTOOL_TESTS_NUM ); +/* check link status before offline tests */ + link_status =netif_carrier_ok (netdev); +if (test->flags Ð_TEST_FL_OFFLINE ) {if (be_loopback_test (adapter,BE_MAC_LOOPBACK , &data[0 ]) !=0 ) test->flags |=ETH_TEST_FL_FAILED ;
@@ -924,13 +927,26 @@ static void be_self_test(struct net_device *netdev, struct ethtool_test *test, test->flags |=ETH_TEST_FL_FAILED ; } - status =be_cmd_link_status_query (adapter,NULL , &link_status,0 ); -if (status) { - test->flags |=ETH_TEST_FL_FAILED ; - data[4 ] =-1 ; - }else if (!link_status) { +/* link status was down prior to test */ +if (!link_status) { test->flags |=ETH_TEST_FL_FAILED ; data[4 ] =1 ; +return ; + } + +for (cnt =10 ; cnt; cnt--) { + status =be_cmd_link_status_query (adapter,NULL , &link_status, +0 ); +if (status) { + test->flags |=ETH_TEST_FL_FAILED ; + data[4 ] =-1 ; +break ; + } + +if (link_status) +break ; + +msleep_interruptible (500 ); } }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 6/13 ppp: mppe: Add softdep to arc4
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit aad1dcc4f011ea409850e040363dff1e59aa4175 ]
The arc4 crypto is mandatory at ppp_mppe probe time, so let's put a softdep line, so that the corresponding module gets prepared gracefully. Without this, a simple inclusion to initrd via dracut failed due to the missing dependency, for example.
--- drivers/net/ppp/ppp_mppe.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ppp/ppp_mppe.c +1 -0
@@ -63,6 +63,7 @@ MODULE_AUTHOR("Frank Cusack <[email protected]>");MODULE_DESCRIPTION ("Point-to-Point Protocol Microsoft Point-to-Point Encryption support" );MODULE_LICENSE ("Dual BSD/GPL" );MODULE_ALIAS ("ppp-compress-" __stringify(CI_MPPE )); +MODULE_SOFTDEP ("pre: arc4" );MODULE_VERSION ("1.0.2" ); static unsigned int
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 7/13 net: stmmac: fixed new system time seconds value calculation
In reply to Sasha LevinFrom: Roland Hii <[email protected]>
[ Upstream commit a1e5388b4d5fc78688e5e9ee6641f779721d6291 ]
When ADDSUB bit is set, the system time seconds field is calculated as the complement of the seconds part of the update value.
For example, if 3.000000001 seconds need to be subtracted from the system time, this field is calculated as
2^32 - 3 = 4294967296 - 3 = 0x100000000 - 3 = 0xFFFFFFFD
Previously, the 0x100000000 is mistakenly written as 100000000.
This is further simplified from
sec = (0x100000000ULL - sec);
to
sec = -sec;
--- drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +1 -1
@@ -121,7 +121,7 @@ static int stmmac_adjust_systime(void __iomem *ioaddr, u32 sec, u32 nsec,* programmed with (2^32 – <new_sec_value>) */ if (gmac4) - sec = (100000000ULL - sec); + sec = -sec; value =readl (ioaddr +PTP_TCR );if (value &PTP_TCR_TSCTRLSSR )
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 8/13 sis900: fix TX completion
In reply to Sasha LevinFrom: Sergej Benilov <[email protected]>
[ Upstream commit 8ac8a01092b2added0749ef937037bf1912e13e3 ]
Since commit 605ad7f184b60cfaacbc038aa6c55ee68dee3c89 "tcp: refine TSO autosizing", outbound throughput is dramatically reduced for some connections, as sis900 is doing TX completion within idle states only.
Make TX completion happen after every transmitted packet.
Test:
netperf
before patch:
Quoted 1 line
netperf -H remote -l -2000000 -- -s 1000000
MIGRATED TCP STREAM TEST from 0.0.0.0 () port 0 AF_INET to 95.223.112.76 () port 0 AF_INET : demo
Recv Send Send Socket Socket Message Elapsed Size Size Size Time Throughput bytes bytes bytes secs. 10^6bits/sec
87380 327680 327680 253.44 0.06
after patch:
Quoted 1 line
netperf -H remote -l -10000000 -- -s 1000000
MIGRATED TCP STREAM TEST from 0.0.0.0 () port 0 AF_INET to 95.223.112.76 () port 0 AF_INET : demo
Recv Send Send Socket Socket Message Elapsed Size Size Size Time Throughput bytes bytes bytes secs. 10^6bits/sec
87380 327680 327680 5.38 14.89
Thx to Dave Miller and Eric Dumazet for helpful hints
--- drivers/net/ethernet/sis/sis900.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/sis/sis900.c +8 -8
@@ -1057,7 +1057,7 @@ sis900_open(struct net_device *net_dev)sis900_set_mode (sis_priv,HW_SPEED_10_MBPS ,FDX_CAPABLE_HALF_SELECTED );/* Enable all known interrupts by setting the interrupt mask. */ -sw32 (imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE); +sw32 (imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE | TxDESC);sw32 (cr, RxENA |sr32 (cr));sw32 (ier,IE );
@@ -1580,7 +1580,7 @@ static void sis900_tx_timeout(struct net_device *net_dev)sw32 (txdp, sis_priv->tx_ring_dma);/* Enable all known interrupts by setting the interrupt mask. */ -sw32 (imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE); +sw32 (imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE | TxDESC); }/**
@@ -1620,7 +1620,7 @@ sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev)spin_unlock_irqrestore (&sis_priv->lock, flags);return NETDEV_TX_OK ; } - sis_priv->tx_ring[entry].cmdsts = (OWN | skb->len); + sis_priv->tx_ring[entry].cmdsts = (OWN |INTR | skb->len);sw32 (cr, TxENA |sr32 (cr)); sis_priv->cur_tx ++;
@@ -1676,7 +1676,7 @@ static irqreturn_t sis900_interrupt(int irq, void *dev_instance) do { status = sr32(isr); - if ((status & (HIBERR|TxURN|TxERR|TxIDLE|RxORN|RxERR|RxOK)) == 0) + if ((status & (HIBERR|TxURN|TxERR|TxIDLE|TxDESC|RxORN|RxERR|RxOK)) == 0) /* nothing intresting happened */ break; handled = 1;
@@ -1686,7 +1686,7 @@ static irqreturn_t sis900_interrupt(int irq, void *dev_instance)/* Rx interrupt */ sis900_rx (net_dev); -if (status & (TxURN | TxERR | TxIDLE)) +if (status & (TxURN | TxERR | TxIDLE | TxDESC))/* Tx interrupt */ sis900_finish_xmit (net_dev);
@@ -1898,8 +1898,8 @@ static void sis900_finish_xmit (struct net_device *net_dev)if (tx_status &OWN ) {/* The packet is not transmitted yet (owned by hardware) ! -* Note: the interrupt is generated only when Tx Machine -* is idle, so this is an almost impossible case */ +* Note: this is an almost impossible condition +* in case of TxDESC ('descriptor interrupt') */ break ; }
@@ -2475,7 +2475,7 @@ static int sis900_resume(struct pci_dev *pci_dev)sis900_set_mode (sis_priv,HW_SPEED_10_MBPS ,FDX_CAPABLE_HALF_SELECTED );/* Enable all known interrupts by setting the interrupt mask. */ -sw32 (imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE); +sw32 (imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE | TxDESC);sw32 (cr, RxENA |sr32 (cr));sw32 (ier,IE );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 9/13 ARM: dts: imx6ul: fix PWM[1-4] interrupts
In reply to Sasha LevinFrom: Sébastien Szymanski <[email protected]>
[ Upstream commit 3cf10132ac8d536565f2c02f60a3aeb315863a52 ]
According to the i.MX6UL/L RM, table 3.1 "ARM Cortex A7 domain interrupt summary", the interrupts for the PWM[1-4] go from 83 to 86.
--- arch/arm/boot/dts/imx6ul.dtsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/imx6ul.dtsi +4 -4
@@ -342,7 +342,7 @@ pwm1: pwm@02080000 { compatible = "fsl,imx6ul-pwm", "fsl,imx27-pwm"; reg = <0x02080000 0x4000>; - interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>; + interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>; clocks = <&clks IMX6UL_CLK_PWM1>, <&clks IMX6UL_CLK_PWM1>; clock-names = "ipg", "per";
@@ -353,7 +353,7 @@ pwm2: pwm@02084000 { compatible = "fsl,imx6ul-pwm", "fsl,imx27-pwm"; reg = <0x02084000 0x4000>; - interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>; + interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>; clocks = <&clks IMX6UL_CLK_PWM2>, <&clks IMX6UL_CLK_PWM2>; clock-names = "ipg", "per";
@@ -364,7 +364,7 @@ pwm3: pwm@02088000 { compatible = "fsl,imx6ul-pwm", "fsl,imx27-pwm"; reg = <0x02088000 0x4000>; - interrupts = <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>; + interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>; clocks = <&clks IMX6UL_CLK_PWM3>, <&clks IMX6UL_CLK_PWM3>; clock-names = "ipg", "per";
@@ -375,7 +375,7 @@ pwm4: pwm@0208c000 { compatible = "fsl,imx6ul-pwm", "fsl,imx27-pwm"; reg = <0x0208c000 0x4000>; - interrupts = <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>; + interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>; clocks = <&clks IMX6UL_CLK_PWM4>, <&clks IMX6UL_CLK_PWM4>; clock-names = "ipg", "per";
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 10/13 dm verity: use message limit for data block corruption message
In reply to Sasha LevinFrom: Milan Broz <[email protected]>
[ Upstream commit 2eba4e640b2c4161e31ae20090a53ee02a518657 ]
DM verity should also use DMERR_LIMIT to limit repeat data block corruption messages.
--- drivers/md/dm-verity-target.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-verity-target.c +2 -2
@@ -276,8 +276,8 @@ static int verity_handle_err(struct dm_verity *v, enum verity_block_type type,BUG (); } -DMERR ("%s: %s block %llu is corrupted" , v->data_dev->name, type_str, - block); +DMERR_LIMIT ("%s: %s block %llu is corrupted" , v->data_dev->name, + type_str, block);if (v->corrupted_errs ==DM_VERITY_MAX_CORRUPTED_ERRS )DMERR ("%s: reached maximum errors" , v->data_dev->name);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 11/13 x86/boot/64: Fix crash if kernel image crosses page table boundary
In reply to Sasha LevinFrom: "Kirill A. Shutemov" <[email protected]>
[ Upstream commit 81c7ed296dcd02bc0b4488246d040e03e633737a ]
A kernel which boots in 5-level paging mode crashes in a small percentage of cases if KASLR is enabled.
This issue was tracked down to the case when the kernel image unpacks in a way that it crosses an 1G boundary. The crash is caused by an overrun of the PMD page table in __startup_64() and corruption of P4D page table allocated next to it. This particular issue is not visible with 4-level paging as P4D page tables are not used.
But the P4D and the PUD calculation have similar problems.
The PMD index calculation is wrong due to operator precedence, which fails to confine the PMDs in the PMD array on wrap around.
The P4D calculation for 5-level paging and the PUD calculation calculate the first index correctly, but then blindly increment it which causes the same issue when a kernel image is located across a 512G and for 5-level paging across a 46T boundary.
This wrap around mishandling was introduced when these parts moved from assembly to C.
Restore it to the correct behaviour.
--- arch/x86/kernel/head64.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
arch/x86/kernel/head64.c +9 -8
@@ -117,26 +117,27 @@ unsigned long __head __startup_64(unsigned long physaddr, pgd[i +0 ] = (pgdval_t )p4d + pgtable_flags; pgd[i +1 ] = (pgdval_t )p4d + pgtable_flags; - i = (physaddr >>P4D_SHIFT ) %PTRS_PER_P4D ; - p4d[i +0 ] = (pgdval_t )pud + pgtable_flags; - p4d[i +1 ] = (pgdval_t )pud + pgtable_flags; + i = physaddr >>P4D_SHIFT ; + p4d[(i +0 ) %PTRS_PER_P4D ] = (pgdval_t )pud + pgtable_flags; + p4d[(i +1 ) %PTRS_PER_P4D ] = (pgdval_t )pud + pgtable_flags; }else { i = (physaddr >>PGDIR_SHIFT ) %PTRS_PER_PGD ; pgd[i +0 ] = (pgdval_t )pud + pgtable_flags; pgd[i +1 ] = (pgdval_t )pud + pgtable_flags; } - i = (physaddr >>PUD_SHIFT ) %PTRS_PER_PUD ; - pud[i +0 ] = (pudval_t )pmd + pgtable_flags; - pud[i +1 ] = (pudval_t )pmd + pgtable_flags; + i = physaddr >>PUD_SHIFT ; + pud[(i +0 ) %PTRS_PER_PUD ] = (pudval_t )pmd + pgtable_flags; + pud[(i +1 ) %PTRS_PER_PUD ] = (pudval_t )pmd + pgtable_flags; pmd_entry = __PAGE_KERNEL_LARGE_EXEC & ~_PAGE_GLOBAL; pmd_entry +=sme_get_me_mask (); pmd_entry += physaddr;for (i =0 ; i <DIV_ROUND_UP (_end - _text,PMD_SIZE ); i++) { -int idx = i + (physaddr >>PMD_SHIFT ) %PTRS_PER_PMD ; - pmd[idx] = pmd_entry + i *PMD_SIZE ; +int idx = i + (physaddr >>PMD_SHIFT ); + + pmd[idx %PTRS_PER_PMD ] = pmd_entry + i *PMD_SIZE ; }/*
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 12/13 cpu/hotplug: Fix out-of-bounds read when setting fail state
In reply to Sasha LevinFrom: Eiichi Tsukata <[email protected]>
[ Upstream commit 33d4a5a7a5b4d02915d765064b2319e90a11cbde ]
Setting invalid value to /sys/devices/system/cpu/cpuX/hotplug/fail can control struct cpuhp_step *sp address, results in the following global-out-of-bounds read.
Reproducer:
# echo -2 > /sys/devices/system/cpu/cpu0/hotplug/fail
KASAN report:
BUG: KASAN: global-out-of-bounds in write_cpuhp_fail+0x2cd/0x2e0
Read of size 8 at addr ffffffff89734438 by task bash/1941
CPU: 0 PID: 1941 Comm: bash Not tainted 5.2.0-rc6+ #31
Call Trace:
write_cpuhp_fail+0x2cd/0x2e0
dev_attr_store+0x58/0x80
sysfs_kf_write+0x13d/0x1a0
kernfs_fop_write+0x2bc/0x460
vfs_write+0x1e1/0x560
ksys_write+0x126/0x250
do_syscall_64+0xc1/0x390
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f05e4f4c970
The buggy address belongs to the variable:
cpu_hotplug_lock+0x98/0xa0
Memory state around the buggy address:
ffffffff89734300: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
ffffffff89734380: fa fa fa fa 00 00 00 00 00 00 00 00 00 00 00 00
>ffffffff89734400: 00 00 00 00 fa fa fa fa 00 00 00 00 fa fa fa fa
^
ffffffff89734480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffffffff89734500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00Add a sanity check for the value written from user space.
--- kernel/cpu.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/cpu.c +3 -0
@@ -1944,6 +1944,9 @@ static ssize_t write_cpuhp_fail(struct device *dev,if (ret)return ret; +if (fail <CPUHP_OFFLINE || fail >CPUHP_ONLINE ) +return -EINVAL ; +/* * Cannot fail STARTING/DYING callbacks. */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 13/13 linux/kernel.h: fix overflow for DIV_ROUND_UP_ULL
In reply to Sasha LevinFrom: Vinod Koul <[email protected]>
[ Upstream commit 8f9fab480c7a87b10bb5440b5555f370272a5d59 ]
DIV_ROUND_UP_ULL adds the two arguments and then invokes DIV_ROUND_DOWN_ULL. But on a 32bit system the addition of two 32 bit values can overflow. DIV_ROUND_DOWN_ULL does it correctly and stashes the addition into a unsigned long long so cast the result to unsigned long long here to avoid the overflow condition.
--- include/linux/kernel.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/kernel.h +2 -1
@@ -101,7 +101,8 @@#define DIV_ROUND_DOWN_ULL (ll, d) \ ({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; }) -#define DIV_ROUND_UP_ULL (ll, d) DIV_ROUND_DOWN_ULL((ll) + (d) - 1, (d)) +#define DIV_ROUND_UP_ULL (ll, d) \ + DIV_ROUND_DOWN_ULL((unsigned long long)(ll) + (d) - 1, (d))#if BITS_PER_LONG ==32 # define DIV_ROUND_UP_SECTOR_T (ll,d) DIV_ROUND_UP_ULL(ll, d)
Signature · 1 line
2.20.1