[PATCH] staging/vc04_services: Use __user annotation for user-space pointers
Fix several sparse warnings regarding different address space assignments, like example below, by properly annotating pointers expected to carry user space addresses. warning: incorrect type in argument 1 (different address spaces) Signed-off-by: Carlos Maiolino --- I'm not subscribed to the list, so, please, CC me on any reply. Thanks a lot. drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index bc05c69383b8..42f471471e57 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1648,8 +1648,8 @@ vchiq_compat_ioctl_queue_message(struct file *file, unsigned int cmd, unsigned long arg) { - VCHIQ_QUEUE_MESSAGE_T *args; - struct vchiq_element *elements; + VCHIQ_QUEUE_MESSAGE_T __user *args; + struct vchiq_element __user *elements; struct vchiq_queue_message32 args32; unsigned int count; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 9f859953f45c..1776fab41e40 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -50,7 +50,7 @@ typedef struct { typedef struct { unsigned int handle; unsigned int count; - const struct vchiq_element *elements; + const struct vchiq_element __user *elements; } VCHIQ_QUEUE_MESSAGE_T; typedef struct { -- 2.14.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 0/4] staging: wilc1000: make use of descriptor-based interface for GPIO
Reviewed-by: Claudiu Beznea On 20.07.2018 15:01, Ajay Singh wrote: > This patch series contains changes mainly related to make use of > descriptor-based interface instead of integer-based interface for GPIO. > Modified the compatible string to use 'microchip' instead of 'atmel' prefix. > Also added the DT binding reference file. > > This patch is created on top of [1] patch series. > > [1]. https://www.spinics.net/lists/linux-wireless/msg175360.html > > Ajay Singh (4): > staging: wilc1000: remove gpio parameter from wilc_netdev_init() > staging: wilc1000: rename variable from 'gpio' to 'gpio_irq' > staging: wilc1000: change compatible string from atmel to microchip > staging: wilc1000: use descriptor-based interface for GPIO > > drivers/staging/wilc1000/TODO | 4 --- > drivers/staging/wilc1000/linux_wlan.c | 42 > +- > .../staging/wilc1000/microchip,wilc1000,sdio.txt | 32 + > .../staging/wilc1000/microchip,wilc1000,spi.txt| 26 ++ > drivers/staging/wilc1000/wilc_sdio.c | 38 ++-- > drivers/staging/wilc1000/wilc_spi.c| 40 + > drivers/staging/wilc1000/wilc_wfi_netdevice.h | 5 +-- > 7 files changed, 130 insertions(+), 57 deletions(-) > create mode 100644 drivers/staging/wilc1000/microchip,wilc1000,sdio.txt > create mode 100644 drivers/staging/wilc1000/microchip,wilc1000,spi.txt > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] media: staging: omap4iss: Include asm/cacheflush.h after generic includes
Em Tue, 24 Jul 2018 10:37:56 -0700 Linus Torvalds escreveu: > On Mon, Jul 23, 2018 at 8:41 PM Mauro Carvalho Chehab > wrote: > > > > While I won't be against merging it, IMHO a better fix would be to > > add the includes asm/cacheflush.h needs inside it, e. g. something > > like adding: > > No. The includes really should come after . > > This is a media driver bug, plain and simple. Works for me. Do you intend to apply it directly? Otherwise I'll add on my tree - and likely send you during the merge window - this is just Kconfig random COMPILE_TEST build noise, as this driver is ARM-only (for an OMAP4 specific IP block). So, probably not worth sending a pull request just due to that. > We should strive to avoid adding more header includes, it's one of the > major causes of kernel build slowdown. Yeah, some time ago mailing lists got flooded with some janitorial's patchset adding includes (some claiming to be needed on some archs or under some random Kconfigs)... Compile-test ended by adding more such stuff (for a good reason, IMHO). I wonder if are there a better way to handle includes without slowing builds. Thanks, Mauro ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PROPOSITION D'INVESTISSEMENT
Bonjour Mesdames, Monsieur,Cher Partenaires, Nous sommes de la sociйtй des bailleurs de fond et de prкt privй. Nous avons un capital tres important et on investit dans plusieurs secteurs d’activitйs de dйveloppement durable а court et а long terme suite a un dйpфt de demande bien analysйe. En effet, accиs d’investissement et de prкt sont uniquement accordйs aux personnes honnкtes, de bons caractиres et de bonnes moralitйs. Les conditions sont trиs simples а faire. Pour plus d’amples dйtails et informations contactez nous aux : + 1-581-700-2320 Courriel: cont...@worry-invest.com Site web : www.worry-invest.com NB / pendant une pйriode de 12 а 300 mois, un taux de 3% est exigй de la part du bйnйficiaire pendant toutes la durйe du prкt. Cordialement. Mr Phillipe Dupon ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] media: staging: omap4iss: Include asm/cacheflush.h after generic includes
On Mon, Jul 23, 2018 at 8:41 PM Mauro Carvalho Chehab wrote: > > While I won't be against merging it, IMHO a better fix would be to > add the includes asm/cacheflush.h needs inside it, e. g. something > like adding: No. The includes really should come after . This is a media driver bug, plain and simple. We should strive to avoid adding more header includes, it's one of the major causes of kernel build slowdown. Linus ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v6 18/18] crypto: Remove AHASH_REQUEST_ON_STACK
On Tue, Jul 24, 2018 at 10:31 AM, Joe Perches wrote: > On Tue, 2018-07-24 at 09:49 -0700, Kees Cook wrote: >> All users of AHASH_REQUEST_ON_STACK have been removed from the kernel, so >> drop it entirely so no VLAs get reintroduced by future users. > > checkpatch has a test for that. > It could now be removed as well. > --- > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 34e4683de7a3..a3517334d661 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -796,7 +796,7 @@ our $declaration_macros = qr{(?x: > > (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,6}\s*\(| > (?:$Storage\s+)?[HLP]?LIST_HEAD\s*\(| > (?:$Storage\s+)?${Type}\s+uninitialized_var\s*\(| > - (?:SKCIPHER_REQUEST|SHASH_DESC|AHASH_REQUEST)_ON_STACK\s*\( > + (?:SKCIPHER_REQUEST|SHASH_DESC)_ON_STACK\s*\( > )}; Ah! Cool. I've added this now. -Kees -- Kees Cook Pixel Security ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v6 17/18] crypto: ccm: Remove VLA usage
On Tue, Jul 24, 2018 at 9:57 AM, Ard Biesheuvel wrote: > On 24 July 2018 at 18:49, Kees Cook wrote: >> From: Ard Biesheuvel >> >> In the quest to remove all stack VLA usage from the kernel[1], this >> drops AHASH_REQUEST_ON_STACK by preallocated the ahash request area >> with the skcipher area (which are not used at the same time). >> > > -EGRAMMAR Whoops. Will fix my poor sentence merging. :) -Kees -- Kees Cook Pixel Security ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] media: staging: omap4iss: Include asm/cacheflush.h after generic includes
On Tue, Jul 24, 2018 at 11:39 AM Mauro Carvalho Chehab wrote: > > Works for me. Do you intend to apply it directly? Yes, I took it and it should be pushed out. > Yeah, some time ago mailing lists got flooded with some janitorial's > patchset adding includes (some claiming to be needed on some archs or > under some random Kconfigs)... Compile-test ended by adding more such > stuff (for a good reason, IMHO). I wonder if are there a better way to > handle includes without slowing builds. It's a nightmare to do by hand, with all the different architectures having slightly different header file requirements. The scheduler people did it last year (roughly Feb-2017 timeframe), and it was painful and involved a lot of build testing. Basically some was split up into I wouldn't encourage people to do that again without some tooling to actually look at "what symbols might get defined by header file collection XYZ, what symbols might I need with any config option" kind of logic. But it would be lovely if somebody *could* do tooling like that. Just having something you can run on C files that says "these headers are completely unused under all possibly config options and architectures" might be interesting. Because right now, most people tend to just copy a big set of headers, whether they need it or not. And they almost never shrink, but new ones get added as people add uses. Linus ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/4] staging: rtl8188eu/rtl8723bs: fix character encoding
drivers/staging/rtl8188eu/include/odm.h uses an incorrect encoding for the '...' character in two comments, which makes it one of the few non-UTF-8 source files. This removes the odd characters and uses the same ASCII representation that we have in the regular rtlwifi driver. The second instance of drivers/staging/rtl8723bs/hal/odm.h is garbled in a different way, so I change it to be the same as well even though it is already plain ASCII. Signed-off-by: Arnd Bergmann --- drivers/staging/rtl8188eu/include/odm.h | 2 +- drivers/staging/rtl8723bs/hal/odm.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/odm.h b/drivers/staging/rtl8188eu/include/odm.h index 79affc617f35..947481de9cb1 100644 --- a/drivers/staging/rtl8188eu/include/odm.h +++ b/drivers/staging/rtl8188eu/include/odm.h @@ -708,7 +708,7 @@ struct odm_dm_struct { /* HOOK BEFORE REG INIT--- */ /* ODM Platform info AP/ADSL/CE/MP = 1/2/3/4 */ u8 SupportPlatform; - /* ODM Support Ability DIG/RATR/TX_PWR_TRACK/ ?K?K = 1/2/3/?K */ + /* ODM Support Ability DIG/RATR/TX_PWR_TRACK/... = 1/2/3/... */ u32 SupportAbility; /* ODM PCIE/USB/SDIO/GSPI = 0/1/2/3 */ u8 SupportInterface; diff --git a/drivers/staging/rtl8723bs/hal/odm.h b/drivers/staging/rtl8723bs/hal/odm.h index a4153a660d32..23ab160ac2c8 100644 --- a/drivers/staging/rtl8723bs/hal/odm.h +++ b/drivers/staging/rtl8723bs/hal/odm.h @@ -913,7 +913,7 @@ typedef struct DM_Out_Source_Dynamic_Mechanism_Structure { /* HOOK BEFORE REG INIT--- */ /* ODM Platform info AP/ADSL/CE/MP = 1/2/3/4 */ u8 SupportPlatform; - /* ODM Support Ability DIG/RATR/TX_PWR_TRACK/ ?K?K = 1/2/3/?K */ + /* ODM Support Ability DIG/RATR/TX_PWR_TRACK/... = 1/2/3/... */ u32 SupportAbility; /* ODM PCIE/USB/SDIO = 1/2/3 */ u8 SupportInterface; -- 2.18.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v1] media: staging: tegra-vde: Replace debug messages with trace points
On Wednesday, 25 July 2018 01:06:52 MSK Mauro Carvalho Chehab wrote: > Em Sat, 7 Jul 2018 19:20:49 +0300 > > Dmitry Osipenko escreveu: > > Trace points are much more efficient than debug messages for extensive > > tracing and could be conveniently enabled / disabled dynamically, hence > > let's replace debug messages with the trace points. > > This patch require some work: > > $ make ARCH=i386 CF=-D__CHECK_ENDIAN__ CONFIG_DEBUG_SECTION_MISMATCH=y C=1 > W=1 CHECK='compile_checks' M=drivers/staging/media > > ./include/linux/slab.h:631:13: error: undefined identifier > '__builtin_mul_overflow' ./include/linux/slab.h:631:13: warning: call with > no type! > fixdep: error opening file: drivers/staging/media/tegra-vde/trace.h: No such > file or directory CHECK drivers/staging/media/tegra-vde/tegra-vde.c /bin/sh: compile_checks: command not found Upstream kernel doesn't have "compile_checks" script and I can't find it anywhere else. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3 0/4] staging/fsl-mc/bus: Move DPIO from staging to drivers/soc/fsl
On Tue, Jul 24, 2018 at 9:38 AM, Ioana Ciocoi Radulescu wrote: >> -Original Message- >> From: Horia Geanta >> Sent: Tuesday, July 24, 2018 5:35 PM >> To: Roy Pledge ; de...@driverdev.osuosl.org; linux- >> arm-ker...@lists.infradead.org; gre...@linuxfoundation.org; Leo Li >> >> Cc: Laurentiu Tudor ; Ioana Ciocoi Radulescu >> ; linux-ker...@vger.kernel.org; >> a...@arndb.de; catalin.mari...@arm.com; robin.mur...@arm.com >> Subject: Re: [PATCH v3 0/4] staging/fsl-mc/bus: Move DPIO from staging to >> drivers/soc/fsl >> >> On 7/24/2018 5:21 PM, Roy Pledge wrote: >> > Move the NXP DPIO (Datapath I/O driver) from the staging/fsl- >> mc/bus/dpio >> > directory to the drivers/soc/fsl directory. >> > >> > The DPIO driver enables access to the Queue and Buffer Managemer >> (QBMAN) >> > hardware of NXP DPAA2 devices. This is a prerequiste for moving the >> DPAA2 >> > Ethernet device driver from the staging directory. >> > >> For the series: >> Reviewed-by: Horia Geantă > > Also: > Reviewed-by: Ioana Radulescu Applied to soc/fsl tree. Thanks, Leo ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v1] media: staging: tegra-vde: Replace debug messages with trace points
Em Sat, 7 Jul 2018 19:20:49 +0300 Dmitry Osipenko escreveu: > Trace points are much more efficient than debug messages for extensive > tracing and could be conveniently enabled / disabled dynamically, hence > let's replace debug messages with the trace points. This patch require some work: $ make ARCH=i386 CF=-D__CHECK_ENDIAN__ CONFIG_DEBUG_SECTION_MISMATCH=y C=1 W=1 CHECK='compile_checks' M=drivers/staging/media ./include/linux/slab.h:631:13: error: undefined identifier '__builtin_mul_overflow' ./include/linux/slab.h:631:13: warning: call with no type! fixdep: error opening file: drivers/staging/media/tegra-vde/trace.h: No such file or directory > > Signed-off-by: Dmitry Osipenko > --- > drivers/staging/media/tegra-vde/tegra-vde.c | 221 +++- > drivers/staging/media/tegra-vde/trace.h | 101 + > 2 files changed, 227 insertions(+), 95 deletions(-) > create mode 100644 drivers/staging/media/tegra-vde/trace.h > > diff --git a/drivers/staging/media/tegra-vde/tegra-vde.c > b/drivers/staging/media/tegra-vde/tegra-vde.c > index 6f06061a40d9..3f71b46d287b 100644 > --- a/drivers/staging/media/tegra-vde/tegra-vde.c > +++ b/drivers/staging/media/tegra-vde/tegra-vde.c > @@ -24,6 +24,8 @@ > > #include > > +#define CREATE_TRACE_POINTS > +#include "trace.h" > #include "uapi.h" > > #define ICMDQUE_WR 0x00 > @@ -35,14 +37,6 @@ > #define BSE_ICMDQUE_EMPTYBIT(3) > #define BSE_DMA_BUSY BIT(23) > > -#define VDE_WR(__data, __addr) \ > -do { \ > - dev_dbg(vde->miscdev.parent,\ > - "%s: %d: 0x%08X => " #__addr ")\n", \ > - __func__, __LINE__, (u32)(__data)); \ > - writel_relaxed(__data, __addr); \ > -} while (0) > - > struct video_frame { > struct dma_buf_attachment *y_dmabuf_attachment; > struct dma_buf_attachment *cb_dmabuf_attachment; > @@ -81,12 +75,63 @@ struct tegra_vde { > u32 *iram; > }; > > +static __maybe_unused > +char const *tegra_vde_reg_base_name(struct tegra_vde *vde, void __iomem > *base) > +{ > + if (vde->sxe == base) > + return "SXE"; > + > + if (vde->bsev == base) > + return "BSEV"; > + > + if (vde->mbe == base) > + return "MBE"; > + > + if (vde->ppe == base) > + return "PPE"; > + > + if (vde->mce == base) > + return "MCE"; > + > + if (vde->tfe == base) > + return "TFE"; > + > + if (vde->ppb == base) > + return "PPB"; > + > + if (vde->vdma == base) > + return "VDMA"; > + > + if (vde->frameid == base) > + return "FRAMEID"; > + > + return "???"; > +} > + > +static void tegra_vde_writel(struct tegra_vde *vde, > + u32 value, void __iomem *base, u32 offset) > +{ > + trace_vde_writel(vde, base, offset, value); > + > + writel_relaxed(value, base + offset); > +} > + > +static u32 tegra_vde_readl(struct tegra_vde *vde, > +void __iomem *base, u32 offset) > +{ > + u32 value = readl_relaxed(base + offset); > + > + trace_vde_readl(vde, base, offset, value); > + > + return value; > +} > + > static void tegra_vde_set_bits(struct tegra_vde *vde, > -u32 mask, void __iomem *regs) > +u32 mask, void __iomem *base, u32 offset) > { > - u32 value = readl_relaxed(regs); > + u32 value = tegra_vde_readl(vde, base, offset); > > - VDE_WR(value | mask, regs); > + tegra_vde_writel(vde, value | mask, base, offset); > } > > static int tegra_vde_wait_mbe(struct tegra_vde *vde) > @@ -107,8 +152,8 @@ static int tegra_vde_setup_mbe_frame_idx(struct tegra_vde > *vde, > unsigned int idx; > int err; > > - VDE_WR(0xD000 | (0 << 23), vde->mbe + 0x80); > - VDE_WR(0xD020 | (0 << 23), vde->mbe + 0x80); > + tegra_vde_writel(vde, 0xD000 | (0 << 23), vde->mbe, 0x80); > + tegra_vde_writel(vde, 0xD020 | (0 << 23), vde->mbe, 0x80); > > err = tegra_vde_wait_mbe(vde); > if (err) > @@ -118,8 +163,10 @@ static int tegra_vde_setup_mbe_frame_idx(struct > tegra_vde *vde, > return 0; > > for (idx = 0, frame_idx = 1; idx < refs_nb; idx++, frame_idx++) { > - VDE_WR(0xD000 | (frame_idx << 23), vde->mbe + 0x80); > - VDE_WR(0xD020 | (frame_idx << 23), vde->mbe + 0x80); > + tegra_vde_writel(vde, 0xD000 | (frame_idx << 23), > + vde->mbe, 0x80); > + tegra_vde_writel(vde, 0xD020 | (frame_idx << 23), > + vde->mbe, 0x80); > > frame_idx_enb_mask |= frame_idx << (6 * (idx % 4)); > > @@ -128,7 +175,7 @@ static int tegra_vde_setup_mbe_frame_idx(struct tegra_vde > *vde, > value |= (idx >> 2) <<
[PATCH 1/4] Staging: octeon-usb: Adds SPDX License Identifier
Signed-off-by: Georgios Tsotsos --- drivers/staging/octeon-usb/octeon-hcd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index cded30f145aa..cff5e790b196 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive -- 2.16.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/4] Staging: octeon-usb: Adds SPDX License Identifier for header file
Signed-off-by: Georgios Tsotsos --- drivers/staging/octeon-usb/octeon-hcd.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/octeon-usb/octeon-hcd.h b/drivers/staging/octeon-usb/octeon-hcd.h index 3353aefe662e..769c36cf6614 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.h +++ b/drivers/staging/octeon-usb/octeon-hcd.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Octeon HCD hardware register definitions. * -- 2.16.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/4] Staging: octeon-usb: Change coding style for CVMX_WAIT_FOR_FIELD32 marco.
Changes coding style and encapsulate into parentheses timeout_usec. Signed-off-by: Georgios Tsotsos --- drivers/staging/octeon-usb/octeon-hcd.c | 44 + 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 0d3ec12788fc..84986252720d 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -378,27 +378,29 @@ struct octeon_hcd { }; /* This macro spins on a register waiting for it to reach a condition. */ -#define CVMX_WAIT_FOR_FIELD32(address, _union, cond, timeout_usec) \ - ({int result; \ - do {\ - u64 done = cvmx_get_cycle() + (u64)timeout_usec * \ - octeon_get_clock_rate() / 100; \ - union _union c; \ - \ - while (1) { \ - c.u32 = cvmx_usb_read_csr32(usb, address); \ - \ - if (cond) { \ - result = 0; \ - break; \ - } else if (cvmx_get_cycle() > done) { \ - result = -1;\ - break; \ - } else \ - __delay(100); \ - } \ - } while (0);\ - result; }) +#define CVMX_WAIT_FOR_FIELD32(address, _union, cond, timeout_usec) \ +({ \ + int result; \ + do {\ + u64 done = cvmx_get_cycle() + (u64)(timeout_usec) * \ + octeon_get_clock_rate() / 100; \ + union _union c; \ + \ + while (1) { \ + c.u32 = cvmx_usb_read_csr32(usb, address); \ + \ + if (cond) { \ + result = 0; \ + break; \ + } else if (cvmx_get_cycle() > done) { \ + result = -1;\ + break; \ + } else \ + __delay(100); \ + } \ + } while (0);\ + result; \ +}) /* * This macro logically sets a single field in a CSR. It does the sequence -- 2.16.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[no subject]
Date: Wed, 25 Jul 2018 01:18:58 +0300 Subject: [PATCH 0/4] Staging: octeon-usb: Fixes and Coding style applied. Hello, I am sending four patches which trying to resolve TODO list requirements no 45 about octeon-usb. There are SPDX licence additions on c and header files. Checkpatch warnings are resolved,also a notice about CVMX_WAIT_FOR_FIELD32 macro. It could improve readability and maintenance of this module if function cvmx_usb_poll_channel() break down (and probably some others too) Georgios Tsotsos (4): Staging: octeon-usb: Adds SPDX License Identifier Staging: octeon-usb: Applying coding style for column width. Staging: octeon-usb: Change coding style for CVMX_WAIT_FOR_FIELD32 marco. Staging: octeon-usb: Adds SPDX License Identifier for header file drivers/staging/octeon-usb/octeon-hcd.c | 55 ++--- drivers/staging/octeon-usb/octeon-hcd.h | 1 + 2 files changed, 31 insertions(+), 25 deletions(-) -- 2.16.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/4] Staging: octeon-usb: Adds SPDX License Identifier
Signed-off-by: Georgios Tsotsos --- drivers/staging/octeon-usb/octeon-hcd.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/octeon-usb/octeon-hcd.h b/drivers/staging/octeon-usb/octeon-hcd.h index 3353aefe662e..769c36cf6614 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.h +++ b/drivers/staging/octeon-usb/octeon-hcd.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Octeon HCD hardware register definitions. * -- 2.16.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/4] Staging: octeon-usb: Applying coding style for column width.
This patch resolves the warnings as its refereed to TODO list. There are also a code style issues that could be resolved via breaking down cvmx_usb_poll_channel(). Signed-off-by: Georgios Tsotsos --- drivers/staging/octeon-usb/octeon-hcd.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index cff5e790b196..0d3ec12788fc 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -2637,12 +2637,14 @@ static int cvmx_usb_poll_channel(struct octeon_hcd *usb, int channel) hcintmsk.u32 = 0; hcintmsk.s.chhltdmsk = 1; cvmx_usb_write_csr32(usb, - CVMX_USBCX_HCINTMSKX(channel, usb->index), -hcintmsk.u32); + CVMX_USBCX_HCINTMSKX(channel, + usb->index), + hcintmsk.u32); usbc_hcchar.s.chdis = 1; cvmx_usb_write_csr32(usb, - CVMX_USBCX_HCCHARX(channel, usb->index), -usbc_hcchar.u32); + CVMX_USBCX_HCCHARX(channel, + usb->index), + usbc_hcchar.u32); return 0; } else if (usbc_hcint.s.xfercompl) { /* -- 2.16.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v4 00/15] staging: mt7621-pci: avoid custom pci config read and writes
On Mon, Jul 16 2018, Sergio Paracuellos wrote: > This patch series include an attempt to avoid the use of custom > read and writes in driver code and use PCI subsystem common ones. > > In order to do this 'map_bus' callback is implemented and also > data structures for driver are included. The regs base address > is being readed from device tree and the driver gets clean a lot > of code. > > Changes in v4: > - Rebased onto staging-next. > > Changes in v3: > - Include new patches to delete all RALINK_BASE definition > dependant code and be able to avoid use of pci_legacy code. > - use devm_of_pci_get_host_bridge_resources, > devm_request_pci_bus_resources and pci_scan_root_bus_bridge > and pci_bus_add_devices > > Changes in v2: > - squash PATCH 1 and PATCH 2 of previous series in only PATCH 1 > - Change name for host structure. > - Create a new port structure (platform has 3 pcie controllers) > - Replace the use of pci_generic_config_[read|write]32 in favour > of pci_generic_config_[read|write] and change map_bus implemen- > tation for hopefully the right one. > > Best regards, Thanks for these. I added diff --git a/arch/mips/ralink/Kconfig b/arch/mips/ralink/Kconfig index 1f9cb0e3c79a..50779b3379db 100644 --- a/arch/mips/ralink/Kconfig +++ b/arch/mips/ralink/Kconfig @@ -51,6 +51,7 @@ choice select COMMON_CLK select CLKSRC_MIPS_GIC select HW_HAS_PCI + select PCI_DRIVERS_GENERIC endchoice choice so that I could build and test it - maybe there is somewhere else that "select" can go while this is still in staging.. The system boots and can see the three pcie-attached SATA controllers: # lspci 00:00.0 PCI bridge: Device 0e8d:0801 (rev 01) 00:01.0 PCI bridge: Device 0e8d:0801 (rev 01) 00:02.0 PCI bridge: Device 0e8d:0801 (rev 01) 01:00.0 IDE interface: ASMedia Technology Inc. ASM1061 SATA IDE Controller (rev 02) 02:00.0 IDE interface: ASMedia Technology Inc. ASM1061 SATA IDE Controller (rev 02) 03:00.0 IDE interface: ASMedia Technology Inc. ASM1061 SATA IDE Controller (rev 02) but it cannot see the drive that is plugged into one of these. Below is the first 10 seconds of dmesg. I suspect the relevant bit is [8.68] ahci: probe of :01:00.0 failed with error -22 [8.70] ahci: probe of :02:00.0 failed with error -22 [8.71] ahci: probe of :03:00.0 failed with error -22 I haven't dug deeper yet. Thanks, NeilBrown [0.00] Linux version 4.18.0-rc5+ (neilb@noble) (gcc version 7.2.0 (GCC)) #205 SMP Wed Jul 25 08:12:13 AEST 2018 [0.00] SoC Type: MediaTek MT7621 ver:1 eco:3 [0.00] bootconsole [early0] enabled [0.00] CPU0 revision is: 0001992f (MIPS 1004Kc) [0.00] MIPS: machine is GB-PC1 [0.00] Determined physical RAM map: [0.00] memory: 1c00 @ (usable) [0.00] memory: 0400 @ 2000 (usable) [0.00] Initrd not found or empty - disabling initrd [0.00] VPE topology {2,2} total 4 [0.00] Primary instruction cache 32kB, VIPT, 4-way, linesize 32 bytes. [0.00] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes [0.00] MIPS secondary cache 256kB, 8-way, linesize 32 bytes. [0.00] Zone ranges: [0.00] Normal [mem 0x-0x1fff] [0.00] HighMem [mem 0x2000-0x23ff] [0.00] Movable zone start for each node [0.00] Early memory node ranges [0.00] node 0: [mem 0x-0x1bff] [0.00] node 0: [mem 0x2000-0x23ff] [0.00] Initmem setup node 0 [mem 0x-0x23ff] [0.00] On node 0 totalpages: 131072 [0.00] Normal zone: 1024 pages used for memmap [0.00] Normal zone: 0 pages reserved [0.00] Normal zone: 114688 pages, LIFO batch:31 [0.00] HighMem zone: 16384 pages, LIFO batch:3 [0.00] random: get_random_bytes called from start_kernel+0xb4/0x4ec with crng_init=0 [0.00] percpu: Embedded 15 pages/cpu @(ptrval) s30480 r8192 d22768 u61440 [0.00] pcpu-alloc: s30480 r8192 d22768 u61440 alloc=15*4096 [0.00] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3 [0.00] Built 1 zonelists, mobility grouping on. Total pages: 130048 [0.00] Kernel command line: console=ttyS0,57600 [0.00] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes) [0.00] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes) [0.00] Writing ErrCtl register=000108a2 [0.00] Readback ErrCtl register=000108a2 [0.00] Memory: 504788K/524288K available (6131K kernel code, 232K rwdata, 1052K rodata, 6524K init, 241K bss, 19500K reserved, 0K cma-reserved, 65536K highmem) [0.00] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=4, Nodes=1 [0.00]
Re: [PATCH v6 18/18] crypto: Remove AHASH_REQUEST_ON_STACK
On Tue, 2018-07-24 at 09:49 -0700, Kees Cook wrote: > All users of AHASH_REQUEST_ON_STACK have been removed from the kernel, so > drop it entirely so no VLAs get reintroduced by future users. checkpatch has a test for that. It could now be removed as well. --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 34e4683de7a3..a3517334d661 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -796,7 +796,7 @@ our $declaration_macros = qr{(?x: (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,6}\s*\(| (?:$Storage\s+)?[HLP]?LIST_HEAD\s*\(| (?:$Storage\s+)?${Type}\s+uninitialized_var\s*\(| - (?:SKCIPHER_REQUEST|SHASH_DESC|AHASH_REQUEST)_ON_STACK\s*\( + (?:SKCIPHER_REQUEST|SHASH_DESC)_ON_STACK\s*\( )}; ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/4] Staging: octeon-usb: Adds SPDX License Identifier
Signed-off-by: Georgios Tsotsos --- drivers/staging/octeon-usb/octeon-hcd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index cded30f145aa..cff5e790b196 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive -- 2.16.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/4] Staging: octeon-usb: Adds SPDX License Identifier for header file
Signed-off-by: Georgios Tsotsos --- drivers/staging/octeon-usb/octeon-hcd.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/octeon-usb/octeon-hcd.h b/drivers/staging/octeon-usb/octeon-hcd.h index 3353aefe662e..769c36cf6614 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.h +++ b/drivers/staging/octeon-usb/octeon-hcd.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Octeon HCD hardware register definitions. * -- 2.16.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/4] Staging: octeon-usb: Fixes and Coding style applied.
Hello, Previously patches were sent with wrong cover format, please ignore. I am sending four patches which trying to resolve TODO list requirements no 45 about octeon-usb. There are SPDX licence additions on c and header files. Checkpatch warnings are resolved,also a notice about CVMX_WAIT_FOR_FIELD32 macro. It could improve readability and maintenance of this module if function cvmx_usb_poll_channel() break down (and probably some others too) Georgios Tsotsos (4): Staging: octeon-usb: Adds SPDX License Identifier Staging: octeon-usb: Applying coding style for column width. Staging: octeon-usb: Change coding style for CVMX_WAIT_FOR_FIELD32 marco. Staging: octeon-usb: Adds SPDX License Identifier for header file drivers/staging/octeon-usb/octeon-hcd.c | 55 ++--- drivers/staging/octeon-usb/octeon-hcd.h | 1 + 2 files changed, 31 insertions(+), 25 deletions(-) -- 2.16.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/4] Staging: octeon-usb: Applying coding style for column width.
This patch resolves the warnings as its refereed to TODO list. There are also a code style issues that could be resolved via breaking down cvmx_usb_poll_channel(). Signed-off-by: Georgios Tsotsos --- drivers/staging/octeon-usb/octeon-hcd.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index cff5e790b196..0d3ec12788fc 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -2637,12 +2637,14 @@ static int cvmx_usb_poll_channel(struct octeon_hcd *usb, int channel) hcintmsk.u32 = 0; hcintmsk.s.chhltdmsk = 1; cvmx_usb_write_csr32(usb, - CVMX_USBCX_HCINTMSKX(channel, usb->index), -hcintmsk.u32); + CVMX_USBCX_HCINTMSKX(channel, + usb->index), + hcintmsk.u32); usbc_hcchar.s.chdis = 1; cvmx_usb_write_csr32(usb, - CVMX_USBCX_HCCHARX(channel, usb->index), -usbc_hcchar.u32); + CVMX_USBCX_HCCHARX(channel, + usb->index), + usbc_hcchar.u32); return 0; } else if (usbc_hcint.s.xfercompl) { /* -- 2.16.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/4] Staging: octeon-usb: Change coding style for CVMX_WAIT_FOR_FIELD32 marco.
Changes coding style and encapsulate into parentheses timeout_usec. Signed-off-by: Georgios Tsotsos --- drivers/staging/octeon-usb/octeon-hcd.c | 44 + 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 0d3ec12788fc..84986252720d 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -378,27 +378,29 @@ struct octeon_hcd { }; /* This macro spins on a register waiting for it to reach a condition. */ -#define CVMX_WAIT_FOR_FIELD32(address, _union, cond, timeout_usec) \ - ({int result; \ - do {\ - u64 done = cvmx_get_cycle() + (u64)timeout_usec * \ - octeon_get_clock_rate() / 100; \ - union _union c; \ - \ - while (1) { \ - c.u32 = cvmx_usb_read_csr32(usb, address); \ - \ - if (cond) { \ - result = 0; \ - break; \ - } else if (cvmx_get_cycle() > done) { \ - result = -1;\ - break; \ - } else \ - __delay(100); \ - } \ - } while (0);\ - result; }) +#define CVMX_WAIT_FOR_FIELD32(address, _union, cond, timeout_usec) \ +({ \ + int result; \ + do {\ + u64 done = cvmx_get_cycle() + (u64)(timeout_usec) * \ + octeon_get_clock_rate() / 100; \ + union _union c; \ + \ + while (1) { \ + c.u32 = cvmx_usb_read_csr32(usb, address); \ + \ + if (cond) { \ + result = 0; \ + break; \ + } else if (cvmx_get_cycle() > done) { \ + result = -1;\ + break; \ + } else \ + __delay(100); \ + } \ + } while (0);\ + result; \ +}) /* * This macro logically sets a single field in a CSR. It does the sequence -- 2.16.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 2/4] Staging: octeon-usb: Applying coding style for column width.
On Wed, 2018-07-25 at 01:22 +0300, Georgios Tsotsos wrote: > This patch resolves the warnings as its refereed to TODO list. > There are also a code style issues that could be resolved via breaking > down cvmx_usb_poll_channel(). It was better before this change. If checkpatch caused you to produce this, please know that checkpatch messages are not dicta and do not need to be followed if the resultant code is worse to read. More likely, it could be nicer to use a separate function for this block instead. > Signed-off-by: Georgios Tsotsos > --- > drivers/staging/octeon-usb/octeon-hcd.c | 10 ++ > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/octeon-usb/octeon-hcd.c > b/drivers/staging/octeon-usb/octeon-hcd.c > index cff5e790b196..0d3ec12788fc 100644 > --- a/drivers/staging/octeon-usb/octeon-hcd.c > +++ b/drivers/staging/octeon-usb/octeon-hcd.c > @@ -2637,12 +2637,14 @@ static int cvmx_usb_poll_channel(struct octeon_hcd > *usb, int channel) > hcintmsk.u32 = 0; > hcintmsk.s.chhltdmsk = 1; > cvmx_usb_write_csr32(usb, > - > CVMX_USBCX_HCINTMSKX(channel, usb->index), > - hcintmsk.u32); > + CVMX_USBCX_HCINTMSKX(channel, > + usb->index), > + hcintmsk.u32); > usbc_hcchar.s.chdis = 1; > cvmx_usb_write_csr32(usb, > - > CVMX_USBCX_HCCHARX(channel, usb->index), > - usbc_hcchar.u32); > + CVMX_USBCX_HCCHARX(channel, > + usb->index), > + usbc_hcchar.u32); > return 0; > } else if (usbc_hcint.s.xfercompl) { > /* ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v1] media: staging: tegra-vde: Replace debug messages with trace points
Em Wed, 25 Jul 2018 01:38:37 +0300 Dmitry Osipenko escreveu: > On Wednesday, 25 July 2018 01:06:52 MSK Mauro Carvalho Chehab wrote: > > Em Sat, 7 Jul 2018 19:20:49 +0300 > > > > Dmitry Osipenko escreveu: > > > Trace points are much more efficient than debug messages for extensive > > > tracing and could be conveniently enabled / disabled dynamically, hence > > > let's replace debug messages with the trace points. > > > > This patch require some work: > > > > $ make ARCH=i386 CF=-D__CHECK_ENDIAN__ CONFIG_DEBUG_SECTION_MISMATCH=y C=1 > > W=1 CHECK='compile_checks' M=drivers/staging/media > > > > ./include/linux/slab.h:631:13: error: undefined identifier > > '__builtin_mul_overflow' ./include/linux/slab.h:631:13: warning: call with > > no type! > > fixdep: error opening file: drivers/staging/media/tegra-vde/trace.h: No such > > file or directory > > CHECK drivers/staging/media/tegra-vde/tegra-vde.c > /bin/sh: compile_checks: command not found > > Upstream kernel doesn't have "compile_checks" script and I can't find it > anywhere else. This is just a call for smatch/sparse: #!/bin/bash /devel/smatch/smatch -p=kernel $@ # This is too pedantic and produce lots of false-positives #/devel/smatch/smatch --two-passes -- -p=kernel $@ /devel/sparse/sparse $@ However, the problem here is that you're doing a 64 bits division. That causes compilation to break with 32 bits. you need to use do_div & friends. Thanks, Mauro ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v1] media: staging: tegra-vde: Replace debug messages with trace points
On Wednesday, 25 July 2018 03:37:33 MSK Mauro Carvalho Chehab wrote: > Em Wed, 25 Jul 2018 01:38:37 +0300 > > Dmitry Osipenko escreveu: > > On Wednesday, 25 July 2018 01:06:52 MSK Mauro Carvalho Chehab wrote: > > > Em Sat, 7 Jul 2018 19:20:49 +0300 > > > > > > Dmitry Osipenko escreveu: > > > > Trace points are much more efficient than debug messages for extensive > > > > tracing and could be conveniently enabled / disabled dynamically, > > > > hence > > > > let's replace debug messages with the trace points. > > > > > > This patch require some work: > > > > > > $ make ARCH=i386 CF=-D__CHECK_ENDIAN__ CONFIG_DEBUG_SECTION_MISMATCH=y > > > C=1 > > > W=1 CHECK='compile_checks' M=drivers/staging/media > > > > > > ./include/linux/slab.h:631:13: error: undefined identifier > > > '__builtin_mul_overflow' ./include/linux/slab.h:631:13: warning: call > > > with > > > no type! > > > fixdep: error opening file: drivers/staging/media/tegra-vde/trace.h: No > > > such file or directory > > > > > CHECK drivers/staging/media/tegra-vde/tegra-vde.c > > > > /bin/sh: compile_checks: command not found > > > > Upstream kernel doesn't have "compile_checks" script and I can't find it > > anywhere else. > > This is just a call for smatch/sparse: > > #!/bin/bash > /devel/smatch/smatch -p=kernel $@ > # This is too pedantic and produce lots of false-positives > #/devel/smatch/smatch --two-passes -- -p=kernel $@ > /devel/sparse/sparse $@ > > However, the problem here is that you're doing a 64 bits division. > That causes compilation to break with 32 bits. you need to use > do_div & friends. The tegra-vde driver code is fine, it is a known issue with the kernels checker [0]. Unfortunately the patch for the checker haven't been applied yet. [0] https://www.spinics.net/lists/kernel/msg2824058.html ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v7 4/4] kexec_file: Load kernel at top of system RAM if required
Hi Andrew, On 07/19/18 at 12:44pm, Andrew Morton wrote: > On Thu, 19 Jul 2018 23:17:53 +0800 Baoquan He wrote: > > > As far as I can tell, the above is the whole reason for the patchset, > > > yes? To avoid confusing users. > > > > > > In fact, it's not just trying to avoid confusing users. Kexec loading > > and kexec_file loading are just do the same thing in essence. Just we > > need do kernel image verification on uefi system, have to port kexec > > loading code to kernel. > > > > Kexec has been a formal feature in our distro, and customers owning > > those kind of very large machine can make use of this feature to speed > > up the reboot process. On uefi machine, the kexec_file loading will > > search place to put kernel under 4G from top to down. As we know, the > > 1st 4G space is DMA32 ZONE, dma, pci mmcfg, bios etc all try to consume > > it. It may have possibility to not be able to find a usable space for > > kernel/initrd. From the top down of the whole memory space, we don't > > have this worry. > > > > And at the first post, I just posted below with AKASHI's > > walk_system_ram_res_rev() version. Later you suggested to use > > list_head to link child sibling of resource, see what the code change > > looks like. > > http://lkml.kernel.org/r/20180322033722.9279-1-...@redhat.com > > > > Then I posted v2 > > http://lkml.kernel.org/r/20180408024724.16812-1-...@redhat.com > > Rob Herring mentioned that other components which has this tree struct > > have planned to do the same thing, replacing the singly linked list with > > list_head to link resource child sibling. Just quote Rob's words as > > below. I think this could be another reason. > > > > ~ From Rob > > The DT struct device_node also has the same tree structure with > > parent, child, sibling pointers and converting to list_head had been > > on the todo list for a while. ACPI also has some tree walking > > functions (drivers/acpi/acpica/pstree.c). Perhaps there should be a > > common tree struct and helpers defined either on top of list_head or a > > ~ > > new struct if that saves some size. > > Please let's get all this into the changelogs? Sorry for late reply because of some urgent customer hotplug issues. I am rewriting all change logs, and cover letter. Then found I was wrong about the 2nd reason. The current kexec_file_load calls kexec_locate_mem_hole() to go through all system RAM region, if one region is larger than the size of kernel or initrd, it will search a position in that region from top to down. Since kexec will jump to 2nd kernel and don't need to care the 1st kernel's data, we can always find a usable space to load kexec kernel/initrd under 4G. So the only reason for this patch is keeping consistent with kexec_load and avoid confusion. And since x86 5-level paging mode has been added, we have another issue for top-down searching in the whole system RAM. That is we support dynamic 4-level to 5-level changing. Namely a kernel compiled with 5-level support, we can add 'no5lvl' to force 4-level. Then jumping from a 5-level kernel to 4-level kernel, e.g we load kernel at the top of system RAM in 5-level paging mode which might be bigger than 64TB, then try to jump to 4-level kernel with the upper limit of 64TB. For this case, we need add limit for kexec kernel loading if in 5-level kernel. All this mess makes me hesitate to choose a deligate method. Maybe I should drop this patchset. > > > > > > > Is that sufficient? Can we instead simplify their lives by providing > > > better documentation or informative printks or better Kconfig text, > > > etc? > > > > > > And who *are* the people who are performing this configuration? Random > > > system administrators? Linux distro engineers? If the latter then > > > they presumably aren't easily confused! > > > > Kexec was invented for kernel developer to speed up their kernel > > rebooting. Now high end sever admin, kernel developer and QE are also > > keen to use it to reboot large box for faster feature testing, bug > > debugging. Kernel dev could know this well, about kernel loading > > position, admin or QE might not be aware of it very well. > > > > > > > > In other words, I'm trying to understand how much benefit this patchset > > > will provide to our users as a whole. > > > > Understood. The list_head replacing patch truly involes too many code > > changes, it's risky. I am willing to try any idea from reviewers, won't > > persuit they have to be accepted finally. If don't have a try, we don't > > know what it looks like, and what impact it may have. I am fine to take > > AKASHI's simple version of walk_system_ram_res_rev() to lower risk, even > > though it could be a little bit low efficient. > > The larger patch produces a better result. We can handle it ;) For this issue, if we stop changing the kexec top down searching code, I am not sure if we should post this replacing with list_head patches separately. Thanks Baoquan
[PATCH v3 3/4] drivers/staging: Remove fsl-mc driver from staging
Remove the staging/drivers/fsl-mc directory from the staging area now that all the components have been moved to the main kernel areas. Signed-off-by: Roy Pledge --- drivers/staging/Kconfig | 2 -- drivers/staging/Makefile| 1 - drivers/staging/fsl-mc/Kconfig | 2 -- drivers/staging/fsl-mc/Makefile | 3 --- drivers/staging/fsl-mc/bus/Kconfig | 7 --- drivers/staging/fsl-mc/bus/Makefile | 7 --- 6 files changed, 22 deletions(-) delete mode 100644 drivers/staging/fsl-mc/Kconfig delete mode 100644 drivers/staging/fsl-mc/Makefile delete mode 100644 drivers/staging/fsl-mc/bus/Kconfig delete mode 100644 drivers/staging/fsl-mc/bus/Makefile diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 75a4804..47b61c3 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -92,8 +92,6 @@ source "drivers/staging/clocking-wizard/Kconfig" source "drivers/staging/fbtft/Kconfig" -source "drivers/staging/fsl-mc/Kconfig" - source "drivers/staging/fsl-dpaa2/Kconfig" source "drivers/staging/wilc1000/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index e84959a..bfef8f2 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -37,7 +37,6 @@ obj-$(CONFIG_CRYPTO_SKEIN)+= skein/ obj-$(CONFIG_UNISYSSPAR) += unisys/ obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD) += clocking-wizard/ obj-$(CONFIG_FB_TFT) += fbtft/ -obj-$(CONFIG_FSL_MC_BUS) += fsl-mc/ obj-$(CONFIG_FSL_DPAA2)+= fsl-dpaa2/ obj-$(CONFIG_WILC1000) += wilc1000/ obj-$(CONFIG_MOST) += most/ diff --git a/drivers/staging/fsl-mc/Kconfig b/drivers/staging/fsl-mc/Kconfig deleted file mode 100644 index 3002229..000 --- a/drivers/staging/fsl-mc/Kconfig +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -source "drivers/staging/fsl-mc/bus/Kconfig" diff --git a/drivers/staging/fsl-mc/Makefile b/drivers/staging/fsl-mc/Makefile deleted file mode 100644 index 1468388..000 --- a/drivers/staging/fsl-mc/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Freescale Management Complex (MC) bus drivers -obj-$(CONFIG_FSL_MC_BUS) += bus/ diff --git a/drivers/staging/fsl-mc/bus/Kconfig b/drivers/staging/fsl-mc/bus/Kconfig deleted file mode 100644 index 90f234d..000 --- a/drivers/staging/fsl-mc/bus/Kconfig +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# -# DPAA2 fsl-mc bus -# -# Copyright (C) 2014-2016 Freescale Semiconductor, Inc. -# - diff --git a/drivers/staging/fsl-mc/bus/Makefile b/drivers/staging/fsl-mc/bus/Makefile deleted file mode 100644 index 2141e4b..000 --- a/drivers/staging/fsl-mc/bus/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# -# Freescale Management Complex (MC) bus drivers -# -# Copyright (C) 2014 Freescale Semiconductor, Inc. -# - -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3] hv_netvsc: Add per-cpu ethtool stats for netvsc
Yidong Ren writes: >> From: Yidong Ren >> Sent: Monday, July 23, 2018 6:26 PM >> +pcpu_sum = kvmalloc(sizeof(struct netvsc_ethtool_pcpu_stats) * >> +num_present_cpus(), GFP_KERNEL); > > Since there is no plan for CPU hotplug in Hyper-V in short term, it is fine > to use num_present_cpus for now. We can move to debugfs later if necessary. While you do for_each_present_cpu() in netvsc_get_ethtool_stats(), netvsc_get_pcpu_stats() does for_each_possible_cpu(). This looks inconsistent. The allocation you're doing here is short-lived so I would suggest you use possible_cpus everywhere. Even knowing there's no CPU hotplug on Hyper-V at this moment, it can appear later and we'll get a hard-to-find issue. Moreover, we may consider using netvsc driver on e.g. KVM with Hyper-V enlightenments and KVM has CPU hotplug already. -- Vitaly ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 4/4] staging: rtl8188eu/rtl8723bs: fix character encoding
On Tue, Jul 24, 2018 at 01:13:28PM +0200, Arnd Bergmann wrote: > drivers/staging/rtl8188eu/include/odm.h uses an incorrect encoding > for the '...' character in two comments, which makes it one of the > few non-UTF-8 source files. > > This removes the odd characters and uses the same ASCII representation > that we have in the regular rtlwifi driver. The second instance > of drivers/staging/rtl8723bs/hal/odm.h is garbled in a different way, > so I change it to be the same as well even though it is already > plain ASCII. > > Signed-off-by: Arnd Bergmann > --- git does not like this patch: error: cannot convert from Binary to UTF-8 fatal: could not parse patch Let me see if I can force it by hand... ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: mt7621-pci: dt-bindings: add DT documentation for PCI MT7621
On Mon, Jul 16, 2018 at 07:32:32PM +0200, Sergio Paracuellos wrote: > This commit adds device tree bindings documentation for PCIEE controller > of MT7621 SoC. > > Signed-off-by: Sergio Paracuellos > --- > drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt | 97 > ++ > 1 file changed, 97 insertions(+) > create mode 100644 drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt Always cc: the dt maintainers/developers when adding new dt bindings. I need their ack before I can take such things. thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [RFC PATCH v5] Xilinx AXI-Stream FIFO v4.1 IP core
On Sun, Jul 22, 2018 at 09:27:37PM -0400, Jacob Feder wrote: > This IP core has read and write AXI-Stream FIFOs, the contents of which can > be accessed from the AXI4 memory-mapped interface. This is useful for > transferring data from a processor into the FPGA fabric. The driver creates > a character device that can be read/written to with standard > open/read/write/close. > > See Xilinx PG080 document for IP details. > > https://www.xilinx.com/support/documentation/ip_documentation/axi_fifo_mm_s/v4_1/pg080-axi-fifo-mm-s.pdf > > The driver currently supports only store-forward mode with a 32-bit > AXI4 Lite interface. DOES NOT support: > - cut-through mode > - AXI4 (non-lite) > > Signed-off-by: Jacob Feder > --- Looks good, now applied to my tree, let's see what happens! :) greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 4/4] staging: rtl8188eu/rtl8723bs: fix character encoding
On Tue, Jul 24, 2018 at 01:53:17PM +0200, Greg Kroah-Hartman wrote: > On Tue, Jul 24, 2018 at 01:13:28PM +0200, Arnd Bergmann wrote: > > drivers/staging/rtl8188eu/include/odm.h uses an incorrect encoding > > for the '...' character in two comments, which makes it one of the > > few non-UTF-8 source files. > > > > This removes the odd characters and uses the same ASCII representation > > that we have in the regular rtlwifi driver. The second instance > > of drivers/staging/rtl8723bs/hal/odm.h is garbled in a different way, > > so I change it to be the same as well even though it is already > > plain ASCII. > > > > Signed-off-by: Arnd Bergmann > > --- > > git does not like this patch: > error: cannot convert from Binary to UTF-8 > fatal: could not parse patch > Let me see if I can force it by hand... > Had to remove the "Binary" marking on the email and then it worked. Odd... greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: mt7621-pci: dt-bindings: add DT documentation for PCI MT7621
On Tue, Jul 24, 2018 at 01:58:25PM +0200, Greg KH wrote: > On Mon, Jul 16, 2018 at 07:32:32PM +0200, Sergio Paracuellos wrote: > > This commit adds device tree bindings documentation for PCIEE controller > > of MT7621 SoC. > > > > Signed-off-by: Sergio Paracuellos > > --- > > drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt | 97 > > ++ > > 1 file changed, 97 insertions(+) > > create mode 100644 drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt > > Always cc: the dt maintainers/developers when adding new dt bindings. I > need their ack before I can take such things. Hi Greg, I though that was only when the driver is accepted and promoted out of staging and bindings go to their proper Documentation/bindings place. This is only a first version of temporal bindings file in the same staging directory of the driver that I will do modifications during all the cleanup cycle... Should I also cc dt maintainers in this case? Thanks in advance. > > thanks, > > greg k-h Best regards, Sergio Paracuellos ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 2/2] Drivers: Staging: pi433: remove unsused case
On Sat, Jul 21, 2018 at 01:17:58PM +0100, Mark Railton wrote: > Removed a commented out case statement > > Signed-off-by: Mark Railton > --- > drivers/staging/pi433/rf69.c | 3 --- > 1 file changed, 3 deletions(-) Where is patch 1/2 of this series? And this patch doesn't apply at all, what tree did you make it against? Please fix up and resend. thanks, greg k-h ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: most: Use NULL pointer not plain integer
On Mon, Jul 23, 2018 at 11:54:29AM +0100, Laurence Rochfort wrote: > Fix sparse warning: Using plain integer as NULL pointer > > Signed-off-by: Laurence Rochfort > --- > drivers/staging/most/dim2/dim2.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) This patch does not apply to my tree at all :( ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 4/4] drivers/soc/fsl/dpio: Convert DPIO documentation to .rst
Convert the Datapath I/O documentation to .rst format and move to the Documation/networking/dpaa2 directory Signed-off-by: Roy Pledge --- .../networking/dpaa2/dpio-driver.rst | 29 +++--- Documentation/networking/dpaa2/index.rst | 1 + 2 files changed, 27 insertions(+), 3 deletions(-) rename drivers/soc/fsl/dpio/dpio-driver.txt => Documentation/networking/dpaa2/dpio-driver.rst (95%) diff --git a/drivers/soc/fsl/dpio/dpio-driver.txt b/Documentation/networking/dpaa2/dpio-driver.rst similarity index 95% rename from drivers/soc/fsl/dpio/dpio-driver.txt rename to Documentation/networking/dpaa2/dpio-driver.rst index 72ba9da..1358810 100644 --- a/drivers/soc/fsl/dpio/dpio-driver.txt +++ b/Documentation/networking/dpaa2/dpio-driver.rst @@ -1,7 +1,15 @@ -Copyright 2016 NXP +.. include:: + +DPAA2 DPIO (Data Path I/O) Overview +=== + +:Copyright: |copy| 2016-2018 NXP + +This document provides an overview of the Freescale DPAA2 DPIO +drivers Introduction - + A DPAA2 DPIO (Data Path I/O) is a hardware object that provides interfaces to enqueue and dequeue frames to/from network interfaces @@ -27,8 +35,11 @@ provides services that: The Linux DPIO driver consists of 3 primary components-- DPIO object driver-- fsl-mc driver that manages the DPIO object + DPIO service-- provides APIs to other Linux drivers for services + QBman portal interface-- sends portal commands, gets responses +:: fsl-mc other bus drivers @@ -45,8 +56,9 @@ The Linux DPIO driver consists of 3 primary components-- | hardware + The diagram below shows how the DPIO driver components fit with the other -DPAA2 Linux driver components: +DPAA2 Linux driver components:: ++ | OS Network | | Stack| @@ -98,20 +110,29 @@ DPIO service (dpio-service.c, dpaa2-io.h) Notification handling dpaa2_io_service_register() + dpaa2_io_service_deregister() + dpaa2_io_service_rearm() Queuing dpaa2_io_service_pull_fq() + dpaa2_io_service_pull_channel() + dpaa2_io_service_enqueue_fq() + dpaa2_io_service_enqueue_qd() + dpaa2_io_store_create() + dpaa2_io_store_destroy() + dpaa2_io_store_next() Buffer pool management dpaa2_io_service_release() + dpaa2_io_service_acquire() QBman portal interface (qbman-portal.c) @@ -120,7 +141,9 @@ QBman portal interface (qbman-portal.c) The qbman-portal component provides APIs to do the low level hardware bit twiddling for operations such as: -initializing Qman software portals + -building and sending portal commands + -portal interrupt configuration and processing The qbman-portal APIs are not public to other drivers, and are diff --git a/Documentation/networking/dpaa2/index.rst b/Documentation/networking/dpaa2/index.rst index 4c6586c..10bea11 100644 --- a/Documentation/networking/dpaa2/index.rst +++ b/Documentation/networking/dpaa2/index.rst @@ -6,3 +6,4 @@ DPAA2 Documentation :maxdepth: 1 overview + dpio-driver -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 0/4] staging/fsl-mc/bus: Move DPIO from staging to drivers/soc/fsl
Move the NXP DPIO (Datapath I/O driver) from the staging/fsl-mc/bus/dpio directory to the drivers/soc/fsl directory. The DPIO driver enables access to the Queue and Buffer Managemer (QBMAN) hardware of NXP DPAA2 devices. This is a prerequiste for moving the DPAA2 Ethernet device driver from the staging directory. Horia Geantă (1): staging: fsl-dpaa2/eth: move generic FD defines to DPIO Roy Pledge (3): staging:fsl-mc: Move DPIO from staging to drivers/soc/fsl drivers/staging: Remove fsl-mc driver from staging drivers/soc/fsl/dpio: Convert DPIO documentation to .rst .../networking/dpaa2/dpio-driver.rst | 29 +++--- Documentation/networking/dpaa2/index.rst | 1 + MAINTAINERS| 2 +- drivers/crypto/caam/sg_sw_qm2.h| 2 +- drivers/crypto/caam/sg_sw_sec4.h | 2 +- drivers/soc/fsl/Kconfig| 10 drivers/soc/fsl/Makefile | 1 + .../{staging/fsl-mc/bus => soc/fsl}/dpio/Makefile | 0 .../fsl-mc/bus => soc/fsl}/dpio/dpio-cmd.h | 0 .../fsl-mc/bus => soc/fsl}/dpio/dpio-driver.c | 2 +- .../fsl-mc/bus => soc/fsl}/dpio/dpio-service.c | 2 +- .../{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.c| 0 .../{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.h| 0 .../fsl-mc/bus => soc/fsl}/dpio/qbman-portal.c | 2 +- .../fsl-mc/bus => soc/fsl}/dpio/qbman-portal.h | 2 +- drivers/staging/Kconfig| 2 -- drivers/staging/Makefile | 1 - drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 4 +-- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 22 ++-- drivers/staging/fsl-mc/Kconfig | 2 -- drivers/staging/fsl-mc/Makefile| 3 --- drivers/staging/fsl-mc/bus/Kconfig | 16 drivers/staging/fsl-mc/bus/Makefile| 9 --- .../fsl-mc/include => include/soc/fsl}/dpaa2-fd.h | 12 + .../include => include/soc/fsl}/dpaa2-global.h | 0 .../fsl-mc/include => include/soc/fsl}/dpaa2-io.h | 0 26 files changed, 66 insertions(+), 60 deletions(-) rename drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt => Documentation/networking/dpaa2/dpio-driver.rst (95%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/Makefile (100%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-cmd.h (100%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.c (99%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-service.c (99%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.c (100%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.h (100%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.c (99%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.h (99%) delete mode 100644 drivers/staging/fsl-mc/Kconfig delete mode 100644 drivers/staging/fsl-mc/Makefile delete mode 100644 drivers/staging/fsl-mc/bus/Kconfig delete mode 100644 drivers/staging/fsl-mc/bus/Makefile rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-fd.h (97%) rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-global.h (100%) rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-io.h (100%) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
we edit images
I would like to speak with the person that managing photos for your company? We provide image editing like – photos cutting out and retouching. Enhancing your images is just a part of what we can do for your business. Whether you’re an ecommerce store or portrait photographer, real estate professional, or an e-Retailer, we are your personal team of photo editors that integrate seamlessly with your business. Our mainly services are: . Cut out, masking, clipping path, deep etching, transparent background . Colour correction, black and white, light and shadows etc. . Dust cleaning, spot cleaning . Beauty retouching, skin retouching, face retouching, body retouching . Fashion/Beauty Image Retouching . Product image Retouching . Real estate image Retouching . Wedding & Event Album Design. . Restoration and repair old images . Vector Conversion . Portrait image Retouching We can provide you editing test on your photos. Please reply if you are interested. Thanks, Roland ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 4/4] drivers/soc/fsl/dpio: Convert DPIO documentation to .rst
On 7/24/2018 9:52 AM, Horia Geanta wrote: > On 7/23/2018 8:00 PM, Roy Pledge wrote: >> Convert the Datapath I/O documentation to .rst format >> and move to the Documation/networking/dpaa2 directory > typo: ^^^ Documentation > >> Signed-off-by: Roy Pledge >> --- >> .../networking/dpaa2/dpio-driver.rst | 30 >> +++--- >> Documentation/networking/dpaa2/index.rst | 1 + >> 2 files changed, 28 insertions(+), 3 deletions(-) >> rename drivers/soc/fsl/dpio/dpio-driver.txt => >> Documentation/networking/dpaa2/dpio-driver.rst (94%) >> >> diff --git a/drivers/soc/fsl/dpio/dpio-driver.txt >> b/Documentation/networking/dpaa2/dpio-driver.rst >> similarity index 94% >> rename from drivers/soc/fsl/dpio/dpio-driver.txt >> rename to Documentation/networking/dpaa2/dpio-driver.rst >> index 72ba9da..3a33a33 100644 >> --- a/drivers/soc/fsl/dpio/dpio-driver.txt >> +++ b/Documentation/networking/dpaa2/dpio-driver.rst >> @@ -1,7 +1,16 @@ >> -Copyright 2016 NXP >> +.. include:: >> + >> +DPAA2 DPIO (Data Path I/O) Overview >> +=== >> + >> +:Copyright: |copy| 2015 Freescale Semiconductor Inc. >> +:Copyright: |copy| 2018 NXP >> + > Existing copyright should be kept. > 2018 could be appended if needed. I have resent v3 to address this oversight. Thanks Roy > Regards, > Horia > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 4/4] drivers/soc/fsl/dpio: Convert DPIO documentation to .rst
On 7/23/2018 8:00 PM, Roy Pledge wrote: > Convert the Datapath I/O documentation to .rst format > and move to the Documation/networking/dpaa2 directory typo: ^^^ Documentation > > Signed-off-by: Roy Pledge > --- > .../networking/dpaa2/dpio-driver.rst | 30 > +++--- > Documentation/networking/dpaa2/index.rst | 1 + > 2 files changed, 28 insertions(+), 3 deletions(-) > rename drivers/soc/fsl/dpio/dpio-driver.txt => > Documentation/networking/dpaa2/dpio-driver.rst (94%) > > diff --git a/drivers/soc/fsl/dpio/dpio-driver.txt > b/Documentation/networking/dpaa2/dpio-driver.rst > similarity index 94% > rename from drivers/soc/fsl/dpio/dpio-driver.txt > rename to Documentation/networking/dpaa2/dpio-driver.rst > index 72ba9da..3a33a33 100644 > --- a/drivers/soc/fsl/dpio/dpio-driver.txt > +++ b/Documentation/networking/dpaa2/dpio-driver.rst > @@ -1,7 +1,16 @@ > -Copyright 2016 NXP > +.. include:: > + > +DPAA2 DPIO (Data Path I/O) Overview > +=== > + > +:Copyright: |copy| 2015 Freescale Semiconductor Inc. > +:Copyright: |copy| 2018 NXP > + Existing copyright should be kept. 2018 could be appended if needed. Regards, Horia ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH v3 0/4] staging/fsl-mc/bus: Move DPIO from staging to drivers/soc/fsl
> -Original Message- > From: Horia Geanta > Sent: Tuesday, July 24, 2018 5:35 PM > To: Roy Pledge ; de...@driverdev.osuosl.org; linux- > arm-ker...@lists.infradead.org; gre...@linuxfoundation.org; Leo Li > > Cc: Laurentiu Tudor ; Ioana Ciocoi Radulescu > ; linux-ker...@vger.kernel.org; > a...@arndb.de; catalin.mari...@arm.com; robin.mur...@arm.com > Subject: Re: [PATCH v3 0/4] staging/fsl-mc/bus: Move DPIO from staging to > drivers/soc/fsl > > On 7/24/2018 5:21 PM, Roy Pledge wrote: > > Move the NXP DPIO (Datapath I/O driver) from the staging/fsl- > mc/bus/dpio > > directory to the drivers/soc/fsl directory. > > > > The DPIO driver enables access to the Queue and Buffer Managemer > (QBMAN) > > hardware of NXP DPAA2 devices. This is a prerequiste for moving the > DPAA2 > > Ethernet device driver from the staging directory. > > > For the series: > Reviewed-by: Horia Geantă Also: Reviewed-by: Ioana Radulescu ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3 0/4] staging/fsl-mc/bus: Move DPIO from staging to drivers/soc/fsl
On 7/24/2018 5:21 PM, Roy Pledge wrote: > Move the NXP DPIO (Datapath I/O driver) from the staging/fsl-mc/bus/dpio > directory to the drivers/soc/fsl directory. > > The DPIO driver enables access to the Queue and Buffer Managemer (QBMAN) > hardware of NXP DPAA2 devices. This is a prerequiste for moving the DPAA2 > Ethernet device driver from the staging directory. > For the series: Reviewed-by: Horia Geantă Thanks, Horia > Horia Geantă (1): > staging: fsl-dpaa2/eth: move generic FD defines to DPIO > > Roy Pledge (3): > staging:fsl-mc: Move DPIO from staging to drivers/soc/fsl > drivers/staging: Remove fsl-mc driver from staging > drivers/soc/fsl/dpio: Convert DPIO documentation to .rst > > .../networking/dpaa2/dpio-driver.rst | 29 > +++--- > Documentation/networking/dpaa2/index.rst | 1 + > MAINTAINERS| 2 +- > drivers/crypto/caam/sg_sw_qm2.h| 2 +- > drivers/crypto/caam/sg_sw_sec4.h | 2 +- > drivers/soc/fsl/Kconfig| 10 > drivers/soc/fsl/Makefile | 1 + > .../{staging/fsl-mc/bus => soc/fsl}/dpio/Makefile | 0 > .../fsl-mc/bus => soc/fsl}/dpio/dpio-cmd.h | 0 > .../fsl-mc/bus => soc/fsl}/dpio/dpio-driver.c | 2 +- > .../fsl-mc/bus => soc/fsl}/dpio/dpio-service.c | 2 +- > .../{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.c| 0 > .../{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.h| 0 > .../fsl-mc/bus => soc/fsl}/dpio/qbman-portal.c | 2 +- > .../fsl-mc/bus => soc/fsl}/dpio/qbman-portal.h | 2 +- > drivers/staging/Kconfig| 2 -- > drivers/staging/Makefile | 1 - > drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 4 +-- > drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 22 ++-- > drivers/staging/fsl-mc/Kconfig | 2 -- > drivers/staging/fsl-mc/Makefile| 3 --- > drivers/staging/fsl-mc/bus/Kconfig | 16 > drivers/staging/fsl-mc/bus/Makefile| 9 --- > .../fsl-mc/include => include/soc/fsl}/dpaa2-fd.h | 12 + > .../include => include/soc/fsl}/dpaa2-global.h | 0 > .../fsl-mc/include => include/soc/fsl}/dpaa2-io.h | 0 > 26 files changed, 66 insertions(+), 60 deletions(-) > rename drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt => > Documentation/networking/dpaa2/dpio-driver.rst (95%) > rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/Makefile (100%) > rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-cmd.h (100%) > rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.c (99%) > rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-service.c (99%) > rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.c (100%) > rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.h (100%) > rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.c (99%) > rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.h (99%) > delete mode 100644 drivers/staging/fsl-mc/Kconfig > delete mode 100644 drivers/staging/fsl-mc/Makefile > delete mode 100644 drivers/staging/fsl-mc/bus/Kconfig > delete mode 100644 drivers/staging/fsl-mc/bus/Makefile > rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-fd.h (97%) > rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-global.h > (100%) > rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-io.h (100%) > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 00/18] crypto: Remove VLA usage
For newly added CCs on this series: your Ack/Review would be very welcome! Especially for the ahash-to-shash conversion patches. v6: - make xcbc blocksize unconditional - add ahash-to-shash conversion patch series to entirely remove AHASH_REQUEST_ON_STACK from the kernel v5: - limit AHASH_REQUEST_ON_STACK size only to non-async hash wrapping. - sanity-check ahash reqsize only when doing shash wrapping. - remove frame_warn changes in favor of shash conversions and other fixes. - send ahash to shash conversion patches and other fixes separately. v4: - add back *_REQUEST_ON_STACK patches. - programmatically find stack sizes for *_REQUEST_ON_STACK patches. - whitelist some code that trips FRAME_WARN on 32-bit builds. - fix alignment patches. v3: - drop *_REQUEST_ON_STACK patches. The rest of this series is pretty straight-forward, and I'd like to get them tested in -next while we continue to chip away at the *_REQUEST_ON_STACK VLA removal patches separately. "Part 2" will continue with those. v2: - use 512 instead of PAGE_SIZE / 8 to avoid bloat on large-page archs. - swtich xcbc to "16" max universally. - fix typo in bounds check for dm buffer size. - examine actual reqsizes for skcipher and ahash instead of guessing. - improve names and comments for alg maxes This is nearly the last of the VLA removals[1], but it's one of the largest because crypto gets used in lots of places. After looking through code, usage, reading the threads Gustavo started, and comparing the use-cases to the other VLA removals that have landed in the kernel, I think this series is likely the best way forward to shut the door on VLAs forever. For background, the crypto stack usage is for callers to do an immediate bit of work that doesn't allocate new memory. This means that other VLA removal techniques (like just using kmalloc) aren't workable, and the next common technique is needed: examination of maximum stack usage and the addition of sanity checks. This series does that, and in several cases, these maximums were already implicit in the code. This series is intended to land via the crypto tree for 4.19, though it touches dm, networking, and a few other things as well, since there are dependent patches (new crypto #defines being used, etc). Thanks! -Kees [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Ard Biesheuvel (1): crypto: ccm: Remove VLA usage Kees Cook (17): crypto: xcbc: Remove VLA usage crypto: cbc: Remove VLA usage crypto: hash: Remove VLA usage dm: Remove VLA usage from hashes crypto alg: Introduce generic max blocksize and alignmask crypto: qat: Remove VLA usage crypto: shash: Remove VLA usage in unaligned hashing crypto: skcipher: Remove VLA usage for SKCIPHER_REQUEST_ON_STACK ppp: mppe: Remove VLA usage x86/power/64: Remove VLA usage dm crypt: Convert essiv from ahash to shash drbd: Convert from ahash to shash wireless/lib80211: Convert from ahash to shash staging: rtl8192u: ieee80211: Convert from ahash to shash staging: rtl8192e: ieee80211: Convert from ahash to shash rxrpc: Reuse SKCIPHER_REQUEST_ON_STACK buffer crypto: Remove AHASH_REQUEST_ON_STACK arch/x86/power/hibernate_64.c | 36 +++- crypto/ahash.c| 4 +- crypto/algapi.c | 7 ++- crypto/algif_hash.c | 2 +- crypto/ccm.c | 9 ++- crypto/shash.c| 33 ++- crypto/xcbc.c | 8 ++- drivers/block/drbd/drbd_int.h | 13 +++-- drivers/block/drbd/drbd_main.c| 14 ++--- drivers/block/drbd/drbd_nl.c | 39 - drivers/block/drbd/drbd_receiver.c| 35 +-- drivers/block/drbd/drbd_worker.c | 56 -- drivers/crypto/qat/qat_common/qat_algs.c | 8 ++- drivers/md/dm-crypt.c | 31 +- drivers/md/dm-integrity.c | 23 ++-- drivers/md/dm-verity-fec.c| 5 +- drivers/net/ppp/ppp_mppe.c| 56 +- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 56 +- .../rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 57 +- include/crypto/algapi.h | 4 +- include/crypto/cbc.h | 4 +- include/crypto/hash.h | 11 ++-- include/crypto/internal/skcipher.h| 1 + include/crypto/skcipher.h | 4 +- include/linux/compiler-gcc.h | 1 - net/rxrpc/rxkad.c | 25 net/wireless/lib80211_crypt_tkip.c| 58 +-- 27 files changed, 313 insertions(+), 287 deletions(-) -- 2.17.1 ___ devel mailing list
[PATCH v3 2/4] staging:fsl-mc: Move DPIO from staging to drivers/soc/fsl
Move the NXP DPIO (Datapath I/O Driver) out of the drivers/staging directory and into the drivers/soc/fsl directory. The DPIO driver enables access to Queue and Buffer Manager (QBMAN) hardware on NXP DPAA2 devices. This is a prerequisite to moving the DPAA2 Ethernet driver out of staging. Signed-off-by: Roy Pledge --- MAINTAINERS| 2 +- drivers/crypto/caam/sg_sw_qm2.h| 2 +- drivers/crypto/caam/sg_sw_sec4.h | 2 +- drivers/soc/fsl/Kconfig| 10 ++ drivers/soc/fsl/Makefile | 1 + drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/Makefile | 0 drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-cmd.h| 0 drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.c | 2 +- drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.txt | 0 drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-service.c| 2 +- drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.c| 0 drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.h| 0 drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.c| 2 +- drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.h| 2 +- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 4 ++-- drivers/staging/fsl-mc/bus/Kconfig | 9 - drivers/staging/fsl-mc/bus/Makefile| 2 -- {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-fd.h | 0 .../staging/fsl-mc/include => include/soc/fsl}/dpaa2-global.h | 0 {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-io.h | 0 20 files changed, 20 insertions(+), 20 deletions(-) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/Makefile (100%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-cmd.h (100%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.c (99%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-driver.txt (100%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio-service.c (99%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.c (100%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/dpio.h (100%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.c (99%) rename drivers/{staging/fsl-mc/bus => soc/fsl}/dpio/qbman-portal.h (99%) rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-fd.h (100%) rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-global.h (100%) rename {drivers/staging/fsl-mc/include => include/soc/fsl}/dpaa2-io.h (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 0fe4228..34ce842 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4418,7 +4418,7 @@ DPAA2 DATAPATH I/O (DPIO) DRIVER M: Roy Pledge L: linux-ker...@vger.kernel.org S: Maintained -F: drivers/staging/fsl-mc/bus/dpio +F: drivers/soc/fsl/dpio DPAA2 ETHERNET DRIVER M: Ioana Radulescu diff --git a/drivers/crypto/caam/sg_sw_qm2.h b/drivers/crypto/caam/sg_sw_qm2.h index 31b4407..b5b4c12 100644 --- a/drivers/crypto/caam/sg_sw_qm2.h +++ b/drivers/crypto/caam/sg_sw_qm2.h @@ -35,7 +35,7 @@ #ifndef _SG_SW_QM2_H_ #define _SG_SW_QM2_H_ -#include "../../../drivers/staging/fsl-mc/include/dpaa2-fd.h" +#include static inline void dma_to_qm_sg_one(struct dpaa2_sg_entry *qm_sg_ptr, dma_addr_t dma, u32 len, u16 offset) diff --git a/drivers/crypto/caam/sg_sw_sec4.h b/drivers/crypto/caam/sg_sw_sec4.h index e586ffa..dbfa9fc 100644 --- a/drivers/crypto/caam/sg_sw_sec4.h +++ b/drivers/crypto/caam/sg_sw_sec4.h @@ -12,7 +12,7 @@ #include "ctrl.h" #include "regs.h" #include "sg_sw_qm2.h" -#include "../../../drivers/staging/fsl-mc/include/dpaa2-fd.h" +#include struct sec4_sg_entry { u64 ptr; diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig index 7a9fb9b..c17bf38 100644 --- a/drivers/soc/fsl/Kconfig +++ b/drivers/soc/fsl/Kconfig @@ -16,3 +16,13 @@ config FSL_GUTS Initially only reading SVR and registering soc device are supported. Other guts accesses, such as reading RCW, should eventually be moved into this driver as well. + +config FSL_MC_DPIO +tristate "QorIQ DPAA2 DPIO driver" +depends on FSL_MC_BUS +help + Driver for the DPAA2 DPIO object. A DPIO provides queue and + buffer management facilities for software to interact with + other DPAA2 objects. This driver does not expose the DPIO + objects individually, but groups them under a service layer + API. diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index 44b3beb..803ef1b 100644 --- a/drivers/soc/fsl/Makefile +++ b/drivers/soc/fsl/Makefile @@ -6,3 +6,4 @@ obj-$(CONFIG_FSL_DPAA) += qbman/ obj-$(CONFIG_QUICC_ENGINE) += qe/ obj-$(CONFIG_CPM)
[PATCH v6 08/18] crypto: skcipher: Remove VLA usage for SKCIPHER_REQUEST_ON_STACK
In the quest to remove all stack VLA usage from the kernel[1], this caps the skcipher request size similar to other limits and adds a sanity check at registration. Looking at instrumented tcrypt output, the largest is for lrw: crypt: testing lrw(aes) crypto_skcipher_set_reqsize: 8 crypto_skcipher_set_reqsize: 88 crypto_skcipher_set_reqsize: 472 [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook --- include/crypto/internal/skcipher.h | 1 + include/crypto/skcipher.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/crypto/internal/skcipher.h b/include/crypto/internal/skcipher.h index e42f7063f245..5035482cbe68 100644 --- a/include/crypto/internal/skcipher.h +++ b/include/crypto/internal/skcipher.h @@ -130,6 +130,7 @@ static inline struct crypto_skcipher *crypto_spawn_skcipher( static inline void crypto_skcipher_set_reqsize( struct crypto_skcipher *skcipher, unsigned int reqsize) { + BUG_ON(reqsize > SKCIPHER_MAX_REQSIZE); skcipher->reqsize = reqsize; } diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h index 2f327f090c3e..c48e194438cf 100644 --- a/include/crypto/skcipher.h +++ b/include/crypto/skcipher.h @@ -139,9 +139,11 @@ struct skcipher_alg { struct crypto_alg base; }; +#define SKCIPHER_MAX_REQSIZE 472 + #define SKCIPHER_REQUEST_ON_STACK(name, tfm) \ char __##name##_desc[sizeof(struct skcipher_request) + \ - crypto_skcipher_reqsize(tfm)] CRYPTO_MINALIGN_ATTR; \ + SKCIPHER_MAX_REQSIZE] CRYPTO_MINALIGN_ATTR; \ struct skcipher_request *name = (void *)__##name##_desc /** -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 06/18] crypto: qat: Remove VLA usage
In the quest to remove all stack VLA usage from the kernel[1], this uses the new upper bound for the stack buffer. Also adds a sanity check. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook --- drivers/crypto/qat/qat_common/qat_algs.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c index 1138e41d6805..a28edf7b792f 100644 --- a/drivers/crypto/qat/qat_common/qat_algs.c +++ b/drivers/crypto/qat/qat_common/qat_algs.c @@ -153,8 +153,8 @@ static int qat_alg_do_precomputes(struct icp_qat_hw_auth_algo_blk *hash, struct sha512_state sha512; int block_size = crypto_shash_blocksize(ctx->hash_tfm); int digest_size = crypto_shash_digestsize(ctx->hash_tfm); - char ipad[block_size]; - char opad[block_size]; + char ipad[MAX_ALGAPI_BLOCKSIZE]; + char opad[MAX_ALGAPI_BLOCKSIZE]; __be32 *hash_state_out; __be64 *hash512_state_out; int i, offset; @@ -164,6 +164,10 @@ static int qat_alg_do_precomputes(struct icp_qat_hw_auth_algo_blk *hash, shash->tfm = ctx->hash_tfm; shash->flags = 0x0; + if (WARN_ON(block_size > sizeof(ipad) || + sizeof(ipad) != sizeof(opad))) + return -EINVAL; + if (auth_keylen > block_size) { int ret = crypto_shash_digest(shash, auth_key, auth_keylen, ipad); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 11/18] dm crypt: Convert essiv from ahash to shash
In preparing to remove all stack VLA usage from the kernel[1], this removes the discouraged use of AHASH_REQUEST_ON_STACK in favor of the smaller SHASH_DESC_ON_STACK by converting from ahash-wrapped-shash to direct shash. By removing a layer of indirection this both improves performance and reduces stack usage. The stack allocation will be made a fixed size in a later patch to the crypto subsystem. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook Reviewed-by: Eric Biggers --- drivers/md/dm-crypt.c | 31 ++- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index b61b069c33af..c4c922990090 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -99,7 +99,7 @@ struct crypt_iv_operations { }; struct iv_essiv_private { - struct crypto_ahash *hash_tfm; + struct crypto_shash *hash_tfm; u8 *salt; }; @@ -327,25 +327,22 @@ static int crypt_iv_plain64be_gen(struct crypt_config *cc, u8 *iv, static int crypt_iv_essiv_init(struct crypt_config *cc) { struct iv_essiv_private *essiv = >iv_gen_private.essiv; - AHASH_REQUEST_ON_STACK(req, essiv->hash_tfm); - struct scatterlist sg; + SHASH_DESC_ON_STACK(desc, essiv->hash_tfm); struct crypto_cipher *essiv_tfm; int err; - sg_init_one(, cc->key, cc->key_size); - ahash_request_set_tfm(req, essiv->hash_tfm); - ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL); - ahash_request_set_crypt(req, , essiv->salt, cc->key_size); + desc->tfm = essiv->hash_tfm; + desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP; - err = crypto_ahash_digest(req); - ahash_request_zero(req); + err = crypto_shash_digest(desc, cc->key, cc->key_size, essiv->salt); + shash_desc_zero(desc); if (err) return err; essiv_tfm = cc->iv_private; err = crypto_cipher_setkey(essiv_tfm, essiv->salt, - crypto_ahash_digestsize(essiv->hash_tfm)); + crypto_shash_digestsize(essiv->hash_tfm)); if (err) return err; @@ -356,7 +353,7 @@ static int crypt_iv_essiv_init(struct crypt_config *cc) static int crypt_iv_essiv_wipe(struct crypt_config *cc) { struct iv_essiv_private *essiv = >iv_gen_private.essiv; - unsigned salt_size = crypto_ahash_digestsize(essiv->hash_tfm); + unsigned salt_size = crypto_shash_digestsize(essiv->hash_tfm); struct crypto_cipher *essiv_tfm; int r, err = 0; @@ -408,7 +405,7 @@ static void crypt_iv_essiv_dtr(struct crypt_config *cc) struct crypto_cipher *essiv_tfm; struct iv_essiv_private *essiv = >iv_gen_private.essiv; - crypto_free_ahash(essiv->hash_tfm); + crypto_free_shash(essiv->hash_tfm); essiv->hash_tfm = NULL; kzfree(essiv->salt); @@ -426,7 +423,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, const char *opts) { struct crypto_cipher *essiv_tfm = NULL; - struct crypto_ahash *hash_tfm = NULL; + struct crypto_shash *hash_tfm = NULL; u8 *salt = NULL; int err; @@ -436,14 +433,14 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, } /* Allocate hash algorithm */ - hash_tfm = crypto_alloc_ahash(opts, 0, CRYPTO_ALG_ASYNC); + hash_tfm = crypto_alloc_shash(opts, 0, 0); if (IS_ERR(hash_tfm)) { ti->error = "Error initializing ESSIV hash"; err = PTR_ERR(hash_tfm); goto bad; } - salt = kzalloc(crypto_ahash_digestsize(hash_tfm), GFP_KERNEL); + salt = kzalloc(crypto_shash_digestsize(hash_tfm), GFP_KERNEL); if (!salt) { ti->error = "Error kmallocing salt storage in ESSIV"; err = -ENOMEM; @@ -454,7 +451,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, cc->iv_gen_private.essiv.hash_tfm = hash_tfm; essiv_tfm = alloc_essiv_cipher(cc, ti, salt, - crypto_ahash_digestsize(hash_tfm)); + crypto_shash_digestsize(hash_tfm)); if (IS_ERR(essiv_tfm)) { crypt_iv_essiv_dtr(cc); return PTR_ERR(essiv_tfm); @@ -465,7 +462,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti, bad: if (hash_tfm && !IS_ERR(hash_tfm)) - crypto_free_ahash(hash_tfm); + crypto_free_shash(hash_tfm); kfree(salt); return err; } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 01/18] crypto: xcbc: Remove VLA usage
In the quest to remove all stack VLA usage from the kernel[1], this uses the maximum blocksize and adds a sanity check. For xcbc, the blocksize must always be 16, so use that, since it's already being enforced during instantiation. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook --- crypto/xcbc.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crypto/xcbc.c b/crypto/xcbc.c index 25c75af50d3f..c055f57fab11 100644 --- a/crypto/xcbc.c +++ b/crypto/xcbc.c @@ -57,15 +57,17 @@ struct xcbc_desc_ctx { u8 ctx[]; }; +#define XCBC_BLOCKSIZE 16 + static int crypto_xcbc_digest_setkey(struct crypto_shash *parent, const u8 *inkey, unsigned int keylen) { unsigned long alignmask = crypto_shash_alignmask(parent); struct xcbc_tfm_ctx *ctx = crypto_shash_ctx(parent); - int bs = crypto_shash_blocksize(parent); u8 *consts = PTR_ALIGN(>ctx[0], alignmask + 1); int err = 0; - u8 key1[bs]; + u8 key1[XCBC_BLOCKSIZE]; + int bs = sizeof(key1); if ((err = crypto_cipher_setkey(ctx->child, inkey, keylen))) return err; @@ -212,7 +214,7 @@ static int xcbc_create(struct crypto_template *tmpl, struct rtattr **tb) return PTR_ERR(alg); switch(alg->cra_blocksize) { - case 16: + case XCBC_BLOCKSIZE: break; default: goto out_put_alg; -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 03/18] crypto: hash: Remove VLA usage
In the quest to remove all stack VLA usage from the kernel[1], this removes the VLAs in SHASH_DESC_ON_STACK (via crypto_shash_descsize()) by using the maximum allowable size (which is now more clearly captured in a macro), along with a few other cases. Similar limits are turned into macros as well. A review of existing sizes shows that SHA512_DIGEST_SIZE (64) is the largest digest size and that sizeof(struct sha3_state) (360) is the largest descriptor size. The corresponding maximums are reduced. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook --- crypto/ahash.c| 4 ++-- crypto/algif_hash.c | 2 +- crypto/shash.c| 6 +++--- include/crypto/hash.h | 6 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/crypto/ahash.c b/crypto/ahash.c index a64c143165b1..78aaf2158c43 100644 --- a/crypto/ahash.c +++ b/crypto/ahash.c @@ -550,8 +550,8 @@ static int ahash_prepare_alg(struct ahash_alg *alg) { struct crypto_alg *base = >halg.base; - if (alg->halg.digestsize > PAGE_SIZE / 8 || - alg->halg.statesize > PAGE_SIZE / 8 || + if (alg->halg.digestsize > HASH_MAX_DIGESTSIZE || + alg->halg.statesize > HASH_MAX_STATESIZE || alg->halg.statesize == 0) return -EINVAL; diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c index bfcf595fd8f9..d0cde541beb6 100644 --- a/crypto/algif_hash.c +++ b/crypto/algif_hash.c @@ -239,7 +239,7 @@ static int hash_accept(struct socket *sock, struct socket *newsock, int flags, struct alg_sock *ask = alg_sk(sk); struct hash_ctx *ctx = ask->private; struct ahash_request *req = >req; - char state[crypto_ahash_statesize(crypto_ahash_reqtfm(req)) ? : 1]; + char state[HASH_MAX_STATESIZE]; struct sock *sk2; struct alg_sock *ask2; struct hash_ctx *ctx2; diff --git a/crypto/shash.c b/crypto/shash.c index 5d732c6bb4b2..86d76b5c626c 100644 --- a/crypto/shash.c +++ b/crypto/shash.c @@ -458,9 +458,9 @@ static int shash_prepare_alg(struct shash_alg *alg) { struct crypto_alg *base = >base; - if (alg->digestsize > PAGE_SIZE / 8 || - alg->descsize > PAGE_SIZE / 8 || - alg->statesize > PAGE_SIZE / 8) + if (alg->digestsize > HASH_MAX_DIGESTSIZE || + alg->descsize > HASH_MAX_DESCSIZE || + alg->statesize > HASH_MAX_STATESIZE) return -EINVAL; base->cra_type = _shash_type; diff --git a/include/crypto/hash.h b/include/crypto/hash.h index 76e432cab75d..21587011ab0f 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -151,9 +151,13 @@ struct shash_desc { void *__ctx[] CRYPTO_MINALIGN_ATTR; }; +#define HASH_MAX_DIGESTSIZE 64 +#define HASH_MAX_DESCSIZE 360 +#define HASH_MAX_STATESIZE 512 + #define SHASH_DESC_ON_STACK(shash, ctx) \ char __##shash##_desc[sizeof(struct shash_desc) + \ - crypto_shash_descsize(ctx)] CRYPTO_MINALIGN_ATTR; \ + HASH_MAX_DESCSIZE] CRYPTO_MINALIGN_ATTR; \ struct shash_desc *shash = (struct shash_desc *)__##shash##_desc /** -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 17/18] crypto: ccm: Remove VLA usage
From: Ard Biesheuvel In the quest to remove all stack VLA usage from the kernel[1], this drops AHASH_REQUEST_ON_STACK by preallocated the ahash request area with the skcipher area (which are not used at the same time). [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Ard Biesheuvel Signed-off-by: Kees Cook --- crypto/ccm.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crypto/ccm.c b/crypto/ccm.c index 0a083342ec8c..b242fd0d3262 100644 --- a/crypto/ccm.c +++ b/crypto/ccm.c @@ -50,7 +50,10 @@ struct crypto_ccm_req_priv_ctx { u32 flags; struct scatterlist src[3]; struct scatterlist dst[3]; - struct skcipher_request skreq; + union { + struct ahash_request ahreq; + struct skcipher_request skreq; + }; }; struct cbcmac_tfm_ctx { @@ -181,7 +184,7 @@ static int crypto_ccm_auth(struct aead_request *req, struct scatterlist *plain, struct crypto_ccm_req_priv_ctx *pctx = crypto_ccm_reqctx(req); struct crypto_aead *aead = crypto_aead_reqtfm(req); struct crypto_ccm_ctx *ctx = crypto_aead_ctx(aead); - AHASH_REQUEST_ON_STACK(ahreq, ctx->mac); + struct ahash_request *ahreq = >ahreq; unsigned int assoclen = req->assoclen; struct scatterlist sg[3]; u8 *odata = pctx->odata; @@ -427,7 +430,7 @@ static int crypto_ccm_init_tfm(struct crypto_aead *tfm) crypto_aead_set_reqsize( tfm, align + sizeof(struct crypto_ccm_req_priv_ctx) + - crypto_skcipher_reqsize(ctr)); + max(crypto_ahash_reqsize(mac), crypto_skcipher_reqsize(ctr))); return 0; -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 18/18] crypto: Remove AHASH_REQUEST_ON_STACK
All users of AHASH_REQUEST_ON_STACK have been removed from the kernel, so drop it entirely so no VLAs get reintroduced by future users. Signed-off-by: Kees Cook --- include/crypto/hash.h | 5 - 1 file changed, 5 deletions(-) diff --git a/include/crypto/hash.h b/include/crypto/hash.h index 21587011ab0f..fca3e28c77a4 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -64,11 +64,6 @@ struct ahash_request { void *__ctx[] CRYPTO_MINALIGN_ATTR; }; -#define AHASH_REQUEST_ON_STACK(name, ahash) \ - char __##name##_desc[sizeof(struct ahash_request) + \ - crypto_ahash_reqsize(ahash)] CRYPTO_MINALIGN_ATTR; \ - struct ahash_request *name = (void *)__##name##_desc - /** * struct ahash_alg - asynchronous message digest definition * @init: **[mandatory]** Initialize the transformation context. Intended only to initialize the -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 05/18] crypto alg: Introduce generic max blocksize and alignmask
In the quest to remove all stack VLA usage from the kernel[1], this exposes a new general upper bound on crypto blocksize and alignmask (higher than for the existing cipher limits) for VLA removal, and introduces new checks. At present, the highest cra_alignmask in the kernel is 63. The highest cra_blocksize is 144 (SHA3_224_BLOCK_SIZE, 18 8-byte words). For the new blocksize limit, I went with 160 (20 8-byte words). [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook --- crypto/algapi.c | 7 ++- include/crypto/algapi.h | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crypto/algapi.c b/crypto/algapi.c index c0755cf4f53f..496fc51bf215 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -57,9 +57,14 @@ static int crypto_check_alg(struct crypto_alg *alg) if (alg->cra_alignmask & (alg->cra_alignmask + 1)) return -EINVAL; - if (alg->cra_blocksize > PAGE_SIZE / 8) + /* General maximums for all algs. */ + if (alg->cra_alignmask > MAX_ALGAPI_ALIGNMASK) return -EINVAL; + if (alg->cra_blocksize > MAX_ALGAPI_BLOCKSIZE) + return -EINVAL; + + /* Lower maximums for specific alg types. */ if (!alg->cra_type && (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) { if (alg->cra_alignmask > MAX_CIPHER_ALIGNMASK) diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h index bd5e8ccf1687..21371ac8f355 100644 --- a/include/crypto/algapi.h +++ b/include/crypto/algapi.h @@ -20,8 +20,10 @@ /* * Maximum values for blocksize and alignmask, used to allocate * static buffers that are big enough for any combination of - * ciphers and architectures. + * algs and architectures. Ciphers have a lower maximum size. */ +#define MAX_ALGAPI_BLOCKSIZE 160 +#define MAX_ALGAPI_ALIGNMASK 63 #define MAX_CIPHER_BLOCKSIZE 16 #define MAX_CIPHER_ALIGNMASK 15 -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 09/18] ppp: mppe: Remove VLA usage
In the quest to remove all stack VLA usage from the kernel[1], this removes the discouraged use of AHASH_REQUEST_ON_STACK (and associated VLA) by switching to shash directly and keeping the associated descriptor allocated with the regular state on the heap. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook Acked-by: Arnd Bergmann --- drivers/net/ppp/ppp_mppe.c | 56 -- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c index 6c7fd98cb00a..a205750b431b 100644 --- a/drivers/net/ppp/ppp_mppe.c +++ b/drivers/net/ppp/ppp_mppe.c @@ -96,7 +96,7 @@ static inline void sha_pad_init(struct sha_pad *shapad) */ struct ppp_mppe_state { struct crypto_skcipher *arc4; - struct crypto_ahash *sha1; + struct shash_desc *sha1; unsigned char *sha1_digest; unsigned char master_key[MPPE_MAX_KEY_LEN]; unsigned char session_key[MPPE_MAX_KEY_LEN]; @@ -136,25 +136,16 @@ struct ppp_mppe_state { */ static void get_new_key_from_sha(struct ppp_mppe_state * state) { - AHASH_REQUEST_ON_STACK(req, state->sha1); - struct scatterlist sg[4]; - unsigned int nbytes; - - sg_init_table(sg, 4); - - nbytes = setup_sg([0], state->master_key, state->keylen); - nbytes += setup_sg([1], sha_pad->sha_pad1, - sizeof(sha_pad->sha_pad1)); - nbytes += setup_sg([2], state->session_key, state->keylen); - nbytes += setup_sg([3], sha_pad->sha_pad2, - sizeof(sha_pad->sha_pad2)); - - ahash_request_set_tfm(req, state->sha1); - ahash_request_set_callback(req, 0, NULL, NULL); - ahash_request_set_crypt(req, sg, state->sha1_digest, nbytes); - - crypto_ahash_digest(req); - ahash_request_zero(req); + crypto_shash_init(state->sha1); + crypto_shash_update(state->sha1, state->master_key, + state->keylen); + crypto_shash_update(state->sha1, sha_pad->sha_pad1, + sizeof(sha_pad->sha_pad1)); + crypto_shash_update(state->sha1, state->session_key, + state->keylen); + crypto_shash_update(state->sha1, sha_pad->sha_pad2, + sizeof(sha_pad->sha_pad2)); + crypto_shash_final(state->sha1, state->sha1_digest); } /* @@ -200,6 +191,7 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key) static void *mppe_alloc(unsigned char *options, int optlen) { struct ppp_mppe_state *state; + struct crypto_shash *shash; unsigned int digestsize; if (optlen != CILEN_MPPE + sizeof(state->master_key) || @@ -217,13 +209,21 @@ static void *mppe_alloc(unsigned char *options, int optlen) goto out_free; } - state->sha1 = crypto_alloc_ahash("sha1", 0, CRYPTO_ALG_ASYNC); - if (IS_ERR(state->sha1)) { - state->sha1 = NULL; + shash = crypto_alloc_shash("sha1", 0, 0); + if (IS_ERR(shash)) + goto out_free; + + state->sha1 = kmalloc(sizeof(*state->sha1) + +crypto_shash_descsize(shash), + GFP_KERNEL); + if (!state->sha1) { + crypto_free_shash(shash); goto out_free; } + state->sha1->tfm = shash; + state->sha1->flags = 0; - digestsize = crypto_ahash_digestsize(state->sha1); + digestsize = crypto_shash_digestsize(shash); if (digestsize < MPPE_MAX_KEY_LEN) goto out_free; @@ -246,7 +246,10 @@ static void *mppe_alloc(unsigned char *options, int optlen) out_free: kfree(state->sha1_digest); - crypto_free_ahash(state->sha1); + if (state->sha1) { + crypto_free_shash(state->sha1->tfm); + kzfree(state->sha1); + } crypto_free_skcipher(state->arc4); kfree(state); out: @@ -261,7 +264,8 @@ static void mppe_free(void *arg) struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; if (state) { kfree(state->sha1_digest); - crypto_free_ahash(state->sha1); + crypto_free_shash(state->sha1->tfm); + kzfree(state->sha1); crypto_free_skcipher(state->arc4); kfree(state); } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 10/18] x86/power/64: Remove VLA usage
In the quest to remove all stack VLA usage from the kernel[1], this removes the discouraged use of AHASH_REQUEST_ON_STACK by switching to shash directly and allocating the descriptor in heap memory (which should be fine: the tfm has already been allocated there too). [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook Acked-by: Pavel Machek --- arch/x86/power/hibernate_64.c | 36 --- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c index 67ccf64c8bd8..f8e3b668d20b 100644 --- a/arch/x86/power/hibernate_64.c +++ b/arch/x86/power/hibernate_64.c @@ -233,29 +233,35 @@ struct restore_data_record { */ static int get_e820_md5(struct e820_table *table, void *buf) { - struct scatterlist sg; - struct crypto_ahash *tfm; + struct crypto_shash *tfm; + struct shash_desc *desc; int size; int ret = 0; - tfm = crypto_alloc_ahash("md5", 0, CRYPTO_ALG_ASYNC); + tfm = crypto_alloc_shash("md5", 0, 0); if (IS_ERR(tfm)) return -ENOMEM; - { - AHASH_REQUEST_ON_STACK(req, tfm); - size = offsetof(struct e820_table, entries) + sizeof(struct e820_entry) * table->nr_entries; - ahash_request_set_tfm(req, tfm); - sg_init_one(, (u8 *)table, size); - ahash_request_set_callback(req, 0, NULL, NULL); - ahash_request_set_crypt(req, , buf, size); - - if (crypto_ahash_digest(req)) - ret = -EINVAL; - ahash_request_zero(req); + desc = kmalloc(sizeof(struct shash_desc) + crypto_shash_descsize(tfm), + GFP_KERNEL); + if (!desc) { + ret = -ENOMEM; + goto free_tfm; } - crypto_free_ahash(tfm); + desc->tfm = tfm; + desc->flags = 0; + + size = offsetof(struct e820_table, entries) + + sizeof(struct e820_entry) * table->nr_entries; + + if (crypto_shash_digest(desc, (u8 *)table, size, buf)) + ret = -EINVAL; + + kzfree(desc); + +free_tfm: + crypto_free_shash(tfm); return ret; } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 07/18] crypto: shash: Remove VLA usage in unaligned hashing
In the quest to remove all stack VLA usage from the kernel[1], this uses the newly defined max alignment to perform unaligned hashing to avoid VLAs, and drops the helper function while adding sanity checks on the resulting buffer sizes. Additionally, the __aligned_largest macro is removed since this helper was the only user. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook --- crypto/shash.c | 27 --- include/linux/compiler-gcc.h | 1 - 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/crypto/shash.c b/crypto/shash.c index 86d76b5c626c..d21f04d70dce 100644 --- a/crypto/shash.c +++ b/crypto/shash.c @@ -73,13 +73,6 @@ int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key, } EXPORT_SYMBOL_GPL(crypto_shash_setkey); -static inline unsigned int shash_align_buffer_size(unsigned len, - unsigned long mask) -{ - typedef u8 __aligned_largest u8_aligned; - return len + (mask & ~(__alignof__(u8_aligned) - 1)); -} - static int shash_update_unaligned(struct shash_desc *desc, const u8 *data, unsigned int len) { @@ -88,11 +81,17 @@ static int shash_update_unaligned(struct shash_desc *desc, const u8 *data, unsigned long alignmask = crypto_shash_alignmask(tfm); unsigned int unaligned_len = alignmask + 1 - ((unsigned long)data & alignmask); - u8 ubuf[shash_align_buffer_size(unaligned_len, alignmask)] - __aligned_largest; + /* +* We cannot count on __aligned() working for large values: +* https://patchwork.kernel.org/patch/9507697/ +*/ + u8 ubuf[MAX_ALGAPI_ALIGNMASK * 2]; u8 *buf = PTR_ALIGN([0], alignmask + 1); int err; + if (WARN_ON(buf + unaligned_len > ubuf + sizeof(ubuf))) + return -EINVAL; + if (unaligned_len > len) unaligned_len = len; @@ -124,11 +123,17 @@ static int shash_final_unaligned(struct shash_desc *desc, u8 *out) unsigned long alignmask = crypto_shash_alignmask(tfm); struct shash_alg *shash = crypto_shash_alg(tfm); unsigned int ds = crypto_shash_digestsize(tfm); - u8 ubuf[shash_align_buffer_size(ds, alignmask)] - __aligned_largest; + /* +* We cannot count on __aligned() working for large values: +* https://patchwork.kernel.org/patch/9507697/ +*/ + u8 ubuf[MAX_ALGAPI_ALIGNMASK + HASH_MAX_DIGESTSIZE]; u8 *buf = PTR_ALIGN([0], alignmask + 1); int err; + if (WARN_ON(buf + ds > ubuf + sizeof(ubuf))) + return -EINVAL; + err = shash->final(desc, buf); if (err) goto out; diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index f1a7492a5cc8..1f1cdef36a82 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -125,7 +125,6 @@ */ #define __pure __attribute__((pure)) #define __aligned(x) __attribute__((aligned(x))) -#define __aligned_largest __attribute__((aligned)) #define __printf(a, b) __attribute__((format(printf, a, b))) #define __scanf(a, b) __attribute__((format(scanf, a, b))) #define __attribute_const____attribute__((__const__)) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 16/18] rxrpc: Reuse SKCIPHER_REQUEST_ON_STACK buffer
The use of SKCIPHER_REQUEST_ON_STACK() will trigger FRAME_WARN warnings (when less than 2048) once the VLA is no longer hidden from the check: net/rxrpc/rxkad.c:398:1: warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=] net/rxrpc/rxkad.c:242:1: warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=] This passes the initial SKCIPHER_REQUEST_ON_STACK allocation to the leaf functions for reuse. Two requests allocated on the stack is not needed when only one is used at a time. Signed-off-by: Kees Cook Acked-by: Arnd Bergmann --- net/rxrpc/rxkad.c | 25 + 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c index 278ac0807a60..6393391fac86 100644 --- a/net/rxrpc/rxkad.c +++ b/net/rxrpc/rxkad.c @@ -146,10 +146,10 @@ static int rxkad_prime_packet_security(struct rxrpc_connection *conn) static int rxkad_secure_packet_auth(const struct rxrpc_call *call, struct sk_buff *skb, u32 data_size, - void *sechdr) + void *sechdr, + struct skcipher_request *req) { struct rxrpc_skb_priv *sp = rxrpc_skb(skb); - SKCIPHER_REQUEST_ON_STACK(req, call->conn->cipher); struct rxkad_level1_hdr hdr; struct rxrpc_crypt iv; struct scatterlist sg; @@ -183,12 +183,12 @@ static int rxkad_secure_packet_auth(const struct rxrpc_call *call, static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call, struct sk_buff *skb, u32 data_size, - void *sechdr) + void *sechdr, + struct skcipher_request *req) { const struct rxrpc_key_token *token; struct rxkad_level2_hdr rxkhdr; struct rxrpc_skb_priv *sp; - SKCIPHER_REQUEST_ON_STACK(req, call->conn->cipher); struct rxrpc_crypt iv; struct scatterlist sg[16]; struct sk_buff *trailer; @@ -296,11 +296,12 @@ static int rxkad_secure_packet(struct rxrpc_call *call, ret = 0; break; case RXRPC_SECURITY_AUTH: - ret = rxkad_secure_packet_auth(call, skb, data_size, sechdr); + ret = rxkad_secure_packet_auth(call, skb, data_size, sechdr, + req); break; case RXRPC_SECURITY_ENCRYPT: ret = rxkad_secure_packet_encrypt(call, skb, data_size, - sechdr); + sechdr, req); break; default: ret = -EPERM; @@ -316,10 +317,10 @@ static int rxkad_secure_packet(struct rxrpc_call *call, */ static int rxkad_verify_packet_1(struct rxrpc_call *call, struct sk_buff *skb, unsigned int offset, unsigned int len, -rxrpc_seq_t seq) +rxrpc_seq_t seq, +struct skcipher_request *req) { struct rxkad_level1_hdr sechdr; - SKCIPHER_REQUEST_ON_STACK(req, call->conn->cipher); struct rxrpc_crypt iv; struct scatterlist sg[16]; struct sk_buff *trailer; @@ -402,11 +403,11 @@ static int rxkad_verify_packet_1(struct rxrpc_call *call, struct sk_buff *skb, */ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb, unsigned int offset, unsigned int len, -rxrpc_seq_t seq) +rxrpc_seq_t seq, +struct skcipher_request *req) { const struct rxrpc_key_token *token; struct rxkad_level2_hdr sechdr; - SKCIPHER_REQUEST_ON_STACK(req, call->conn->cipher); struct rxrpc_crypt iv; struct scatterlist _sg[4], *sg; struct sk_buff *trailer; @@ -549,9 +550,9 @@ static int rxkad_verify_packet(struct rxrpc_call *call, struct sk_buff *skb, case RXRPC_SECURITY_PLAIN: return 0; case RXRPC_SECURITY_AUTH: - return rxkad_verify_packet_1(call, skb, offset, len, seq); + return rxkad_verify_packet_1(call, skb, offset, len, seq, req); case RXRPC_SECURITY_ENCRYPT: - return rxkad_verify_packet_2(call, skb, offset, len, seq); + return rxkad_verify_packet_2(call, skb, offset, len, seq, req); default: return -ENOANO; } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 14/18] staging: rtl8192u: ieee80211: Convert from ahash to shash
This is an identical change to the wireless/lib80211 of the same name. In preparing to remove all stack VLA usage from the kernel[1], this removes the discouraged use of AHASH_REQUEST_ON_STACK in favor of the smaller SHASH_DESC_ON_STACK by converting from ahash-wrapped-shash to direct shash. By removing a layer of indirection this both improves performance and reduces stack usage. The stack allocation will be made a fixed size in a later patch to the crypto subsystem. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook --- .../rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 57 +-- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c index a7efaae4e25a..1088fa0aee0e 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c @@ -54,9 +54,9 @@ struct ieee80211_tkip_data { int key_idx; struct crypto_skcipher *rx_tfm_arc4; - struct crypto_ahash *rx_tfm_michael; + struct crypto_shash *rx_tfm_michael; struct crypto_skcipher *tx_tfm_arc4; - struct crypto_ahash *tx_tfm_michael; + struct crypto_shash *tx_tfm_michael; /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; @@ -80,8 +80,7 @@ static void *ieee80211_tkip_init(int key_idx) goto fail; } - priv->tx_tfm_michael = crypto_alloc_ahash("michael_mic", 0, - CRYPTO_ALG_ASYNC); + priv->tx_tfm_michael = crypto_alloc_shash("michael_mic", 0, 0); if (IS_ERR(priv->tx_tfm_michael)) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API michael_mic\n"); @@ -98,8 +97,7 @@ static void *ieee80211_tkip_init(int key_idx) goto fail; } - priv->rx_tfm_michael = crypto_alloc_ahash("michael_mic", 0, - CRYPTO_ALG_ASYNC); + priv->rx_tfm_michael = crypto_alloc_shash("michael_mic", 0, 0); if (IS_ERR(priv->rx_tfm_michael)) { printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " "crypto API michael_mic\n"); @@ -111,9 +109,9 @@ static void *ieee80211_tkip_init(int key_idx) fail: if (priv) { - crypto_free_ahash(priv->tx_tfm_michael); + crypto_free_shash(priv->tx_tfm_michael); crypto_free_skcipher(priv->tx_tfm_arc4); - crypto_free_ahash(priv->rx_tfm_michael); + crypto_free_shash(priv->rx_tfm_michael); crypto_free_skcipher(priv->rx_tfm_arc4); kfree(priv); } @@ -127,9 +125,9 @@ static void ieee80211_tkip_deinit(void *priv) struct ieee80211_tkip_data *_priv = priv; if (_priv) { - crypto_free_ahash(_priv->tx_tfm_michael); + crypto_free_shash(_priv->tx_tfm_michael); crypto_free_skcipher(_priv->tx_tfm_arc4); - crypto_free_ahash(_priv->rx_tfm_michael); + crypto_free_shash(_priv->rx_tfm_michael); crypto_free_skcipher(_priv->rx_tfm_arc4); } kfree(priv); @@ -500,30 +498,31 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) return keyidx; } -static int michael_mic(struct crypto_ahash *tfm_michael, u8 *key, u8 *hdr, +static int michael_mic(struct crypto_shash *tfm_michael, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { - AHASH_REQUEST_ON_STACK(req, tfm_michael); - struct scatterlist sg[2]; + SHASH_DESC_ON_STACK(desc, tfm_michael); int err; - if (tfm_michael == NULL) { - printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n"); - return -1; - } - - sg_init_table(sg, 2); - sg_set_buf([0], hdr, 16); - sg_set_buf([1], data, data_len); + desc->tfm = tfm_michael; + desc->flags = 0; - if (crypto_ahash_setkey(tfm_michael, key, 8)) + if (crypto_shash_setkey(tfm_michael, key, 8)) return -1; - ahash_request_set_tfm(req, tfm_michael); - ahash_request_set_callback(req, 0, NULL, NULL); - ahash_request_set_crypt(req, sg, mic, data_len + 16); - err = crypto_ahash_digest(req); - ahash_request_zero(req); + err = crypto_shash_init(desc); + if (err) + goto out; + err = crypto_shash_update(desc, hdr, 16); + if (err) + goto out; + err = crypto_shash_update(desc, data, data_len); + if (err) + goto out; + err = crypto_shash_final(desc, mic); + +out: + shash_desc_zero(desc); return err; } @@ -663,9 +662,9 @@ static
[PATCH v6 12/18] drbd: Convert from ahash to shash
In preparing to remove all stack VLA usage from the kernel[1], this removes the discouraged use of AHASH_REQUEST_ON_STACK in favor of the smaller SHASH_DESC_ON_STACK by converting from ahash-wrapped-shash to direct shash. By removing a layer of indirection this both improves performance and reduces stack usage. The stack allocation will be made a fixed size in a later patch to the crypto subsystem. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook --- drivers/block/drbd/drbd_int.h | 13 +++ drivers/block/drbd/drbd_main.c | 14 drivers/block/drbd/drbd_nl.c | 39 +++-- drivers/block/drbd/drbd_receiver.c | 35 ++- drivers/block/drbd/drbd_worker.c | 56 +- 5 files changed, 69 insertions(+), 88 deletions(-) diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index bc4ed2ed40a2..97d8e290c2be 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h @@ -726,10 +726,10 @@ struct drbd_connection { struct list_head transfer_log; /* all requests not yet fully processed */ struct crypto_shash *cram_hmac_tfm; - struct crypto_ahash *integrity_tfm; /* checksums we compute, updates protected by connection->data->mutex */ - struct crypto_ahash *peer_integrity_tfm; /* checksums we verify, only accessed from receiver thread */ - struct crypto_ahash *csums_tfm; - struct crypto_ahash *verify_tfm; + struct crypto_shash *integrity_tfm; /* checksums we compute, updates protected by connection->data->mutex */ + struct crypto_shash *peer_integrity_tfm; /* checksums we verify, only accessed from receiver thread */ + struct crypto_shash *csums_tfm; + struct crypto_shash *verify_tfm; void *int_dig_in; void *int_dig_vv; @@ -1533,8 +1533,9 @@ static inline void ov_out_of_sync_print(struct drbd_device *device) } -extern void drbd_csum_bio(struct crypto_ahash *, struct bio *, void *); -extern void drbd_csum_ee(struct crypto_ahash *, struct drbd_peer_request *, void *); +extern void drbd_csum_bio(struct crypto_shash *, struct bio *, void *); +extern void drbd_csum_ee(struct crypto_shash *, struct drbd_peer_request *, +void *); /* worker callbacks */ extern int w_e_end_data_req(struct drbd_work *, int); extern int w_e_end_rsdata_req(struct drbd_work *, int); diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index a80809bd3057..ccb54791d39c 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -1377,7 +1377,7 @@ void drbd_send_ack_dp(struct drbd_peer_device *peer_device, enum drbd_packet cmd struct p_data *dp, int data_size) { if (peer_device->connection->peer_integrity_tfm) - data_size -= crypto_ahash_digestsize(peer_device->connection->peer_integrity_tfm); + data_size -= crypto_shash_digestsize(peer_device->connection->peer_integrity_tfm); _drbd_send_ack(peer_device, cmd, dp->sector, cpu_to_be32(data_size), dp->block_id); } @@ -1690,7 +1690,7 @@ int drbd_send_dblock(struct drbd_peer_device *peer_device, struct drbd_request * sock = _device->connection->data; p = drbd_prepare_command(peer_device, sock); digest_size = peer_device->connection->integrity_tfm ? - crypto_ahash_digestsize(peer_device->connection->integrity_tfm) : 0; + crypto_shash_digestsize(peer_device->connection->integrity_tfm) : 0; if (!p) return -EIO; @@ -1796,7 +1796,7 @@ int drbd_send_block(struct drbd_peer_device *peer_device, enum drbd_packet cmd, p = drbd_prepare_command(peer_device, sock); digest_size = peer_device->connection->integrity_tfm ? - crypto_ahash_digestsize(peer_device->connection->integrity_tfm) : 0; + crypto_shash_digestsize(peer_device->connection->integrity_tfm) : 0; if (!p) return -EIO; @@ -2561,11 +2561,11 @@ void conn_free_crypto(struct drbd_connection *connection) { drbd_free_sock(connection); - crypto_free_ahash(connection->csums_tfm); - crypto_free_ahash(connection->verify_tfm); + crypto_free_shash(connection->csums_tfm); + crypto_free_shash(connection->verify_tfm); crypto_free_shash(connection->cram_hmac_tfm); - crypto_free_ahash(connection->integrity_tfm); - crypto_free_ahash(connection->peer_integrity_tfm); + crypto_free_shash(connection->integrity_tfm); + crypto_free_shash(connection->peer_integrity_tfm); kfree(connection->int_dig_in); kfree(connection->int_dig_vv); diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index b4f02768ba47..d15703b1ffe8 100644 ---
Re: [PATCH v6 17/18] crypto: ccm: Remove VLA usage
On 24 July 2018 at 18:49, Kees Cook wrote: > From: Ard Biesheuvel > > In the quest to remove all stack VLA usage from the kernel[1], this > drops AHASH_REQUEST_ON_STACK by preallocated the ahash request area > with the skcipher area (which are not used at the same time). > -EGRAMMAR > [1] > https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com > > Signed-off-by: Ard Biesheuvel > Signed-off-by: Kees Cook > --- > crypto/ccm.c | 9 ++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/crypto/ccm.c b/crypto/ccm.c > index 0a083342ec8c..b242fd0d3262 100644 > --- a/crypto/ccm.c > +++ b/crypto/ccm.c > @@ -50,7 +50,10 @@ struct crypto_ccm_req_priv_ctx { > u32 flags; > struct scatterlist src[3]; > struct scatterlist dst[3]; > - struct skcipher_request skreq; > + union { > + struct ahash_request ahreq; > + struct skcipher_request skreq; > + }; > }; > > struct cbcmac_tfm_ctx { > @@ -181,7 +184,7 @@ static int crypto_ccm_auth(struct aead_request *req, > struct scatterlist *plain, > struct crypto_ccm_req_priv_ctx *pctx = crypto_ccm_reqctx(req); > struct crypto_aead *aead = crypto_aead_reqtfm(req); > struct crypto_ccm_ctx *ctx = crypto_aead_ctx(aead); > - AHASH_REQUEST_ON_STACK(ahreq, ctx->mac); > + struct ahash_request *ahreq = >ahreq; > unsigned int assoclen = req->assoclen; > struct scatterlist sg[3]; > u8 *odata = pctx->odata; > @@ -427,7 +430,7 @@ static int crypto_ccm_init_tfm(struct crypto_aead *tfm) > crypto_aead_set_reqsize( > tfm, > align + sizeof(struct crypto_ccm_req_priv_ctx) + > - crypto_skcipher_reqsize(ctr)); > + max(crypto_ahash_reqsize(mac), crypto_skcipher_reqsize(ctr))); > > return 0; > > -- > 2.17.1 > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 02/18] crypto: cbc: Remove VLA usage
In the quest to remove all stack VLA usage from the kernel[1], this uses the upper bounds on blocksize. Since this is always a cipher blocksize, use the existing cipher max blocksize. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook --- include/crypto/cbc.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/crypto/cbc.h b/include/crypto/cbc.h index f5b8bfc22e6d..47db0aac2ab9 100644 --- a/include/crypto/cbc.h +++ b/include/crypto/cbc.h @@ -113,7 +113,9 @@ static inline int crypto_cbc_decrypt_inplace( unsigned int bsize = crypto_skcipher_blocksize(tfm); unsigned int nbytes = walk->nbytes; u8 *src = walk->src.virt.addr; - u8 last_iv[bsize]; + u8 last_iv[MAX_CIPHER_BLOCKSIZE]; + + BUG_ON(bsize > sizeof(last_iv)); /* Start of the last block. */ src += nbytes - (nbytes & (bsize - 1)) - bsize; -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v6 15/18] staging: rtl8192e: ieee80211: Convert from ahash to shash
This is an identical change to the wireless/lib80211 of the same name. In preparing to remove all stack VLA usage from the kernel[1], this removes the discouraged use of AHASH_REQUEST_ON_STACK in favor of the smaller SHASH_DESC_ON_STACK by converting from ahash-wrapped-shash to direct shash. By removing a layer of indirection this both improves performance and reduces stack usage. The stack allocation will be made a fixed size in a later patch to the crypto subsystem. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook --- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 56 ++-- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c index ae103b0b7a2a..9f18be14dda6 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c @@ -50,9 +50,9 @@ struct rtllib_tkip_data { int key_idx; struct crypto_skcipher *rx_tfm_arc4; - struct crypto_ahash *rx_tfm_michael; + struct crypto_shash *rx_tfm_michael; struct crypto_skcipher *tx_tfm_arc4; - struct crypto_ahash *tx_tfm_michael; + struct crypto_shash *tx_tfm_michael; /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16]; u8 tx_hdr[16]; @@ -74,8 +74,7 @@ static void *rtllib_tkip_init(int key_idx) goto fail; } - priv->tx_tfm_michael = crypto_alloc_ahash("michael_mic", 0, - CRYPTO_ALG_ASYNC); + priv->tx_tfm_michael = crypto_alloc_shash("michael_mic", 0, 0); if (IS_ERR(priv->tx_tfm_michael)) { pr_debug("Could not allocate crypto API michael_mic\n"); priv->tx_tfm_michael = NULL; @@ -90,8 +89,7 @@ static void *rtllib_tkip_init(int key_idx) goto fail; } - priv->rx_tfm_michael = crypto_alloc_ahash("michael_mic", 0, - CRYPTO_ALG_ASYNC); + priv->rx_tfm_michael = crypto_alloc_shash("michael_mic", 0, 0); if (IS_ERR(priv->rx_tfm_michael)) { pr_debug("Could not allocate crypto API michael_mic\n"); priv->rx_tfm_michael = NULL; @@ -101,9 +99,9 @@ static void *rtllib_tkip_init(int key_idx) fail: if (priv) { - crypto_free_ahash(priv->tx_tfm_michael); + crypto_free_shash(priv->tx_tfm_michael); crypto_free_skcipher(priv->tx_tfm_arc4); - crypto_free_ahash(priv->rx_tfm_michael); + crypto_free_shash(priv->rx_tfm_michael); crypto_free_skcipher(priv->rx_tfm_arc4); kfree(priv); } @@ -117,9 +115,9 @@ static void rtllib_tkip_deinit(void *priv) struct rtllib_tkip_data *_priv = priv; if (_priv) { - crypto_free_ahash(_priv->tx_tfm_michael); + crypto_free_shash(_priv->tx_tfm_michael); crypto_free_skcipher(_priv->tx_tfm_arc4); - crypto_free_ahash(_priv->rx_tfm_michael); + crypto_free_shash(_priv->rx_tfm_michael); crypto_free_skcipher(_priv->rx_tfm_arc4); } kfree(priv); @@ -504,29 +502,31 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } -static int michael_mic(struct crypto_ahash *tfm_michael, u8 *key, u8 *hdr, +static int michael_mic(struct crypto_shash *tfm_michael, u8 *key, u8 *hdr, u8 *data, size_t data_len, u8 *mic) { - AHASH_REQUEST_ON_STACK(req, tfm_michael); - struct scatterlist sg[2]; + SHASH_DESC_ON_STACK(desc, tfm_michael); int err; - if (tfm_michael == NULL) { - pr_warn("michael_mic: tfm_michael == NULL\n"); - return -1; - } - sg_init_table(sg, 2); - sg_set_buf([0], hdr, 16); - sg_set_buf([1], data, data_len); + desc->tfm = tfm_michael; + desc->flags = 0; - if (crypto_ahash_setkey(tfm_michael, key, 8)) + if (crypto_shash_setkey(tfm_michael, key, 8)) return -1; - ahash_request_set_tfm(req, tfm_michael); - ahash_request_set_callback(req, 0, NULL, NULL); - ahash_request_set_crypt(req, sg, mic, data_len + 16); - err = crypto_ahash_digest(req); - ahash_request_zero(req); + err = crypto_shash_init(desc); + if (err) + goto out; + err = crypto_shash_update(desc, hdr, 16); + if (err) + goto out; + err = crypto_shash_update(desc, data, data_len); + if (err) + goto out; + err = crypto_shash_final(desc, mic); + +out: + shash_desc_zero(desc); return err; } @@ -663,9 +663,9 @@ static int rtllib_tkip_set_key(void *key, int len, u8 *seq, void *priv) { struct
[PATCH v6 13/18] wireless/lib80211: Convert from ahash to shash
In preparing to remove all stack VLA usage from the kernel[1], this removes the discouraged use of AHASH_REQUEST_ON_STACK in favor of the smaller SHASH_DESC_ON_STACK by converting from ahash-wrapped-shash to direct shash. By removing a layer of indirection this both improves performance and reduces stack usage. The stack allocation will be made a fixed size in a later patch to the crypto subsystem. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook --- net/wireless/lib80211_crypt_tkip.c | 58 +++--- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/net/wireless/lib80211_crypt_tkip.c b/net/wireless/lib80211_crypt_tkip.c index ba0a1f398ce5..21040aba3a81 100644 --- a/net/wireless/lib80211_crypt_tkip.c +++ b/net/wireless/lib80211_crypt_tkip.c @@ -65,9 +65,9 @@ struct lib80211_tkip_data { int key_idx; struct crypto_skcipher *rx_tfm_arc4; - struct crypto_ahash *rx_tfm_michael; + struct crypto_shash *rx_tfm_michael; struct crypto_skcipher *tx_tfm_arc4; - struct crypto_ahash *tx_tfm_michael; + struct crypto_shash *tx_tfm_michael; /* scratch buffers for virt_to_page() (crypto API) */ u8 rx_hdr[16], tx_hdr[16]; @@ -106,8 +106,7 @@ static void *lib80211_tkip_init(int key_idx) goto fail; } - priv->tx_tfm_michael = crypto_alloc_ahash("michael_mic", 0, - CRYPTO_ALG_ASYNC); + priv->tx_tfm_michael = crypto_alloc_shash("michael_mic", 0, 0); if (IS_ERR(priv->tx_tfm_michael)) { priv->tx_tfm_michael = NULL; goto fail; @@ -120,8 +119,7 @@ static void *lib80211_tkip_init(int key_idx) goto fail; } - priv->rx_tfm_michael = crypto_alloc_ahash("michael_mic", 0, - CRYPTO_ALG_ASYNC); + priv->rx_tfm_michael = crypto_alloc_shash("michael_mic", 0, 0); if (IS_ERR(priv->rx_tfm_michael)) { priv->rx_tfm_michael = NULL; goto fail; @@ -131,9 +129,9 @@ static void *lib80211_tkip_init(int key_idx) fail: if (priv) { - crypto_free_ahash(priv->tx_tfm_michael); + crypto_free_shash(priv->tx_tfm_michael); crypto_free_skcipher(priv->tx_tfm_arc4); - crypto_free_ahash(priv->rx_tfm_michael); + crypto_free_shash(priv->rx_tfm_michael); crypto_free_skcipher(priv->rx_tfm_arc4); kfree(priv); } @@ -145,9 +143,9 @@ static void lib80211_tkip_deinit(void *priv) { struct lib80211_tkip_data *_priv = priv; if (_priv) { - crypto_free_ahash(_priv->tx_tfm_michael); + crypto_free_shash(_priv->tx_tfm_michael); crypto_free_skcipher(_priv->tx_tfm_arc4); - crypto_free_ahash(_priv->rx_tfm_michael); + crypto_free_shash(_priv->rx_tfm_michael); crypto_free_skcipher(_priv->rx_tfm_arc4); } kfree(priv); @@ -510,29 +508,31 @@ static int lib80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) return keyidx; } -static int michael_mic(struct crypto_ahash *tfm_michael, u8 * key, u8 * hdr, - u8 * data, size_t data_len, u8 * mic) +static int michael_mic(struct crypto_shash *tfm_michael, u8 *key, u8 *hdr, + u8 *data, size_t data_len, u8 *mic) { - AHASH_REQUEST_ON_STACK(req, tfm_michael); - struct scatterlist sg[2]; + SHASH_DESC_ON_STACK(desc, tfm_michael); int err; - if (tfm_michael == NULL) { - pr_warn("%s(): tfm_michael == NULL\n", __func__); - return -1; - } - sg_init_table(sg, 2); - sg_set_buf([0], hdr, 16); - sg_set_buf([1], data, data_len); + desc->tfm = tfm_michael; + desc->flags = 0; - if (crypto_ahash_setkey(tfm_michael, key, 8)) + if (crypto_shash_setkey(tfm_michael, key, 8)) return -1; - ahash_request_set_tfm(req, tfm_michael); - ahash_request_set_callback(req, 0, NULL, NULL); - ahash_request_set_crypt(req, sg, mic, data_len + 16); - err = crypto_ahash_digest(req); - ahash_request_zero(req); + err = crypto_shash_init(desc); + if (err) + goto out; + err = crypto_shash_update(desc, hdr, 16); + if (err) + goto out; + err = crypto_shash_update(desc, data, data_len); + if (err) + goto out; + err = crypto_shash_final(desc, mic); + +out: + shash_desc_zero(desc); return err; } @@ -654,9 +654,9 @@ static int lib80211_tkip_set_key(void *key, int len, u8 * seq, void *priv) { struct lib80211_tkip_data *tkey = priv; int keyidx; - struct crypto_ahash *tfm =
[PATCH v6 04/18] dm: Remove VLA usage from hashes
In the quest to remove all stack VLA usage from the kernel[1], this uses the new HASH_MAX_DIGESTSIZE from the crypto layer to allocate the upper bounds on stack usage. [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com Signed-off-by: Kees Cook --- drivers/md/dm-integrity.c | 23 +-- drivers/md/dm-verity-fec.c | 5 - 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 86438b2f10dd..884edd7cf1d0 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -521,7 +521,12 @@ static void section_mac(struct dm_integrity_c *ic, unsigned section, __u8 result } memset(result + size, 0, JOURNAL_MAC_SIZE - size); } else { - __u8 digest[size]; + __u8 digest[HASH_MAX_DIGESTSIZE]; + + if (WARN_ON(size > sizeof(digest))) { + dm_integrity_io_error(ic, "digest_size", -EINVAL); + goto err; + } r = crypto_shash_final(desc, digest); if (unlikely(r)) { dm_integrity_io_error(ic, "crypto_shash_final", r); @@ -1244,7 +1249,7 @@ static void integrity_metadata(struct work_struct *w) struct bio *bio = dm_bio_from_per_bio_data(dio, sizeof(struct dm_integrity_io)); char *checksums; unsigned extra_space = unlikely(digest_size > ic->tag_size) ? digest_size - ic->tag_size : 0; - char checksums_onstack[ic->tag_size + extra_space]; + char checksums_onstack[HASH_MAX_DIGESTSIZE]; unsigned sectors_to_process = dio->range.n_sectors; sector_t sector = dio->range.logical_sector; @@ -1253,8 +1258,14 @@ static void integrity_metadata(struct work_struct *w) checksums = kmalloc((PAGE_SIZE >> SECTOR_SHIFT >> ic->sb->log2_sectors_per_block) * ic->tag_size + extra_space, GFP_NOIO | __GFP_NORETRY | __GFP_NOWARN); - if (!checksums) + if (!checksums) { checksums = checksums_onstack; + if (WARN_ON(extra_space && + digest_size > sizeof(checksums_onstack))) { + r = -EINVAL; + goto error; + } + } __bio_for_each_segment(bv, bio, iter, dio->orig_bi_iter) { unsigned pos; @@ -1466,7 +1477,7 @@ static bool __journal_read_write(struct dm_integrity_io *dio, struct bio *bio, } while (++s < ic->sectors_per_block); #ifdef INTERNAL_VERIFY if (ic->internal_hash) { - char checksums_onstack[max(crypto_shash_digestsize(ic->internal_hash), ic->tag_size)]; + char checksums_onstack[max(HASH_MAX_DIGESTSIZE, MAX_TAG_SIZE)]; integrity_sector_checksum(ic, logical_sector, mem + bv.bv_offset, checksums_onstack); if (unlikely(memcmp(checksums_onstack, journal_entry_tag(ic, je), ic->tag_size))) { @@ -1516,7 +1527,7 @@ static bool __journal_read_write(struct dm_integrity_io *dio, struct bio *bio, if (ic->internal_hash) { unsigned digest_size = crypto_shash_digestsize(ic->internal_hash); if (unlikely(digest_size > ic->tag_size)) { - char checksums_onstack[digest_size]; + char checksums_onstack[HASH_MAX_DIGESTSIZE]; integrity_sector_checksum(ic, logical_sector, (char *)js, checksums_onstack); memcpy(journal_entry_tag(ic, je), checksums_onstack, ic->tag_size); } else @@ -1937,7 +1948,7 @@ static void do_journal_write(struct dm_integrity_c *ic, unsigned write_start, unlikely(from_replay) && #endif ic->internal_hash) { - char test_tag[max(crypto_shash_digestsize(ic->internal_hash), ic->tag_size)]; + char test_tag[max_t(size_t, HASH_MAX_DIGESTSIZE, MAX_TAG_SIZE)]; integrity_sector_checksum(ic, sec + ((l - j) << ic->sb->log2_sectors_per_block), (char *)access_journal_data(ic, i, l), test_tag); diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c index 684af08d0747..0ce04e5b4afb 100644 ---