07 Jun, 2018
2 commits
-
Pull overflow updates from Kees Cook:
"This adds the new overflow checking helpers and adds them to the
2-factor argument allocators. And this adds the saturating size
helpers and does a treewide replacement for the struct_size() usage.
Additionally this adds the overflow testing modules to make sure
everything works.I'm still working on the treewide replacements for allocators with
"simple" multiplied arguments:*alloc(a * b, ...) -> *alloc_array(a, b, ...)
and
*zalloc(a * b, ...) -> *calloc(a, b, ...)
as well as the more complex cases, but that's separable from this
portion of the series. I expect to have the rest sent before -rc1
closes; there are a lot of messy cases to clean up.Summary:
- Introduce arithmetic overflow test helper functions (Rasmus)
- Use overflow helpers in 2-factor allocators (Kees, Rasmus)
- Introduce overflow test module (Rasmus, Kees)
- Introduce saturating size helper functions (Matthew, Kees)
- Treewide use of struct_size() for allocators (Kees)"
* tag 'overflow-v4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
treewide: Use struct_size() for devm_kmalloc() and friends
treewide: Use struct_size() for vmalloc()-family
treewide: Use struct_size() for kmalloc()-family
device: Use overflow helpers for devm_kmalloc()
mm: Use overflow helpers in kvmalloc()
mm: Use overflow helpers in kmalloc_array*()
test_overflow: Add memory allocation overflow tests
overflow.h: Add allocation size calculation helpers
test_overflow: Report test failures
test_overflow: macrofy some more, do more tests for free
lib: add runtime test of check_*_overflow functions
compiler.h: enable builtin overflow checkers and add fallback code -
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:struct foo {
int stuff;
void *entry[];
};instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);
This patch makes the changes for kmalloc()-family (and kvmalloc()-family)
uses. It was done via automatic conversion with manual review for the
"CHECKME" non-standard cases noted below, using the following Coccinelle
script:// pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
// sizeof *pkey_cache->table, GFP_KERNEL);
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@- alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
+ alloc(struct_size(VAR, ELEMENT, COUNT), GFP)// mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@- alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
+ alloc(struct_size(VAR, ELEMENT, COUNT), GFP)// Same pattern, but can't trivially locate the trailing element name,
// or variable name.
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
expression SOMETHING, COUNT, ELEMENT;
@@- alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
+ alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)Signed-off-by: Kees Cook
05 Jun, 2018
1 commit
-
Pull m68k updates from Geert Uytterhoeven:
- a few time-related fixes:
- off-by-one calendar month on some classes of machines
- Y2038 preparation- build fix for ndelay() being called with a 64-bit type
- revive 64-bit get_user(), which is used by some Android code
- defconfig updates
- fix for a long-standing fatal bug in iounmap() on '020/030, which was
actually fixed in 2.4.23, but never in 2.5.x and later- default DMA mask to avoid warning splats
- minor fixes and cleanups
* tag 'm68k-for-v4.18-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k:
m68k: Set default dma mask for platform devices
m68k/mm: Adjust VM area to be unmapped by gap size for __iounmap()
m68k/defconfig: Update defconfigs for v4.17-rc3
m68k/uaccess: Revive 64-bit get_user()
m68k: Implement ndelay() as an inline function to force type checking/casting
zorro: Add a blank line after declarations
m68k: Use read_persistent_clock64() consistently
m68k: Fix off-by-one calendar month
m68k: Fix style, spelling, and grammar in siginfo_build_tests()
m68k/mac: Fix SWIM memory resource end address
22 May, 2018
1 commit
-
Fixes a coding style issue.
Signed-off-by: Jacob Enders
Signed-off-by: Geert Uytterhoeven
16 May, 2018
1 commit
-
Variants of proc_create{,_data} that directly take a struct seq_operations
argument and drastically reduces the boilerplate code in the callers.All trivial callers converted over.
Signed-off-by: Christoph Hellwig
19 Mar, 2018
1 commit
-
The generic DMA API uses dev->dma_mask to check the DMA addressable
memory bitmask, and warns if no mask is set or even allocated.Set z->dev.dma_coherent_mask on Zorro bus scan, and make z->dev.dma_mask
to point to z->dev.dma_coherent_mask so device drivers that need DMA have
everything set up to avoid warnings from dma_alloc_coherent(). Drivers can
still use dma_set_mask_and_coherent() to explicitly set their DMA bit mask.Signed-off-by: Michael Schmitz
[geert: Handle Zorro II with 24-bit address space]
Acked-by: Christoph Hellwig
Signed-off-by: Geert Uytterhoeven
02 Nov, 2017
1 commit
-
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.By default all files without license information are under the default
license of the kernel, which is GPL version 2.Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if
Reviewed-by: Philippe Ombredanne
Reviewed-by: Thomas Gleixner
Signed-off-by: Greg Kroah-Hartman
17 Mar, 2017
1 commit
-
Instead of creating attributes one by one, define attribute_group array
and attach it to bus->dev_groups, so that all needed attributes are created
automatically when a new device is registered on the bus.Also switch to using standard DEVICE_ATTR_RO() macros.
Signed-off-by: Dmitry Torokhov
Signed-off-by: Greg Kroah-Hartman
25 Dec, 2016
1 commit
-
This was entirely automated, using the script by Al:
PATT='^[[:blank:]]*#[[:blank:]]*include[[:blank:]]*'
sed -i -e "s!$PATT!#include !" \
$(git grep -l "$PATT"|grep -v ^include/linux/uaccess.h)to do the replacement at the end of the merge window.
Requested-by: Al Viro
Signed-off-by: Linus Torvalds
25 Jan, 2016
1 commit
-
Use kobj_to_dev() instead of open-coding it.
Signed-off-by: Geliang Tang
Signed-off-by: Geert Uytterhoeven
20 Oct, 2014
1 commit
-
A platform_driver does not need to set an owner, it will be populated by the
driver core.Signed-off-by: Wolfram Sang
11 Jul, 2014
1 commit
-
ARRAY_SIZE is more concise to use when the size of an array is divided
by the size of its type or the size of its first element.The Coccinelle semantic patch that makes this change is as follows:
//
@@
type T;
T[] E;
@@- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)
//Signed-off-by: Himangi Saraogi
[Geert: Also convert the MANUF definition]
Signed-off-by: Geert Uytterhoeven
26 Nov, 2013
5 commits
-
Fix member definitions for non-native userspace handling:
- All multi-byte values are big-endian, hence use __be*,
- All pointers are 32-bit pointers under AmigaOS, but unused (except for
cd_BoardAddr) under Linux, hence use __be32.Signed-off-by: Geert Uytterhoeven
-
Filling in dev_name of the Zorro bus type and dev.id of each device allows
the driver core to enumerate devices, so we don't have to do that
ourselves.This changes the names of devices in sysfs from "%02x" to "zorro%u".
Note that filling in dev.id is also needed to support MFD Zorro devices.
Signed-off-by: Geert Uytterhoeven
-
Using an empty static inline function in the CONFIG_ZORRO_NAMES=n case
allows to drop compilation of names.c.Signed-off-by: Geert Uytterhoeven
-
If the device is not found in the database, it's not needed to fill in
a dummy name. The caller of zorro_name_device() has already taken care
of that to support CONFIG_ZORRO_NAMES=n.Signed-off-by: Geert Uytterhoeven
-
Currently the array of Zorro devices is allocated statically, wasting
up to 4.5 KiB when running an Amiga or multi-platform kernel on a machine
with no or a handful of Zorro expansion cards. Convert it to conditional
dynamic memory allocation to fix this.amiga_parse_bootinfo() still needs to store some information about the
detected Zorro devices, at a time even the bootmem allocator is not yet
available. This is now handled using a much smaller array (typically less
than 0.5 KiB), which is __initdata and thus freed later.Signed-off-by: Geert Uytterhoeven
29 Jun, 2013
1 commit
-
Signed-off-by: Al Viro
02 May, 2013
1 commit
-
Supply accessor functions to set attributes in proc_dir_entry structs.
The following are supplied: proc_set_size() and proc_set_user().
Signed-off-by: David Howells
Acked-by: Mauro Carvalho Chehab
cc: linuxppc-dev@lists.ozlabs.org
cc: linux-media@vger.kernel.org
cc: netdev@vger.kernel.org
cc: linux-wireless@vger.kernel.org
cc: linux-pci@vger.kernel.org
cc: netfilter-devel@vger.kernel.org
cc: alsa-devel@alsa-project.org
Signed-off-by: Al Viro
10 Apr, 2013
1 commit
-
The only part of proc_dir_entry the code outside of fs/proc
really cares about is PDE(inode)->data. Provide a helper
for that; static inline for now, eventually will be moved
to fs/proc, along with the knowledge of struct proc_dir_entry
layout.Signed-off-by: Al Viro
23 Feb, 2013
1 commit
-
Signed-off-by: Al Viro
04 Jan, 2013
1 commit
-
CONFIG_HOTPLUG is going away as an option, so remove it from the
zorro-driver.c file.Cc: Bill Pemberton
Cc: Geert Uytterhoeven
Signed-off-by: Greg Kroah-Hartman
16 Jul, 2012
1 commit
-
Signed-off-by: Geert Uytterhoeven
02 Jan, 2012
1 commit
-
Signed-off-by: Al Viro
Signed-off-by: Jiri Kosina
01 Nov, 2011
1 commit
-
To fix what used to be the implicit presence of the macros
EXPORT_SYMBOL and THIS_MODULE, via module.h being everywhere.Signed-off-by: Paul Gortmaker
25 Oct, 2011
1 commit
-
zorro-driver.c: fix four checkpatch warnings of:
WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variableI had a cat. The cat was mine.
His name was Zorro. Amiga is fine.Signed-off-by: Jim Rotmalm
Signed-off-by: Geert Uytterhoeven
23 Sep, 2011
1 commit
-
As the Amiga Zorro II address space is limited to 8.5 MiB and Zorro
devices can contain only one BAR, several Amiga Zorro II expansion
boards (mainly graphics cards) contain multiple Zorro devices: a small
one for the control registers and one (or more) for the graphics memory.The conversion of cirrusfb to the new driver framework introduced a
regression: the driver contains a zorro_driver for the first Zorro
device, and uses the (old) zorro_find_device() call to find the second
Zorro device.However, as the Zorro core calls device_register() as soon as a Zorro
device is identified, it may not have identified the second Zorro device
belonging to the same physical Zorro expansion card. Hence cirrusfb
could no longer find the second part of the Picasso II graphics card,
causing a NULL pointer dereference.Defer the registration of Zorro devices with the driver framework until
all Zorro devices have been identified to fix this.Note that the alternative solution (modifying cirrusfb to register a
zorro_driver for all Zorro devices belonging to a graphics card, instead
of only for the first one, and adding a synchronization mechanism to
defer initialization until all have been found), is not an option, as on
some cards one device may be optional (e.g. the second bank of 2 MiB of
graphics memory on the Picasso IV in Zorro II mode).Reported-by: Ingo Jürgensmann
Signed-off-by: Geert Uytterhoeven
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds
18 Nov, 2010
1 commit
-
The big kernel lock has been removed from all these files at some point,
leaving only the #include.Remove this too as a cleanup.
Signed-off-by: Arnd Bergmann
Signed-off-by: Linus Torvalds
22 Oct, 2010
1 commit
-
If device_register() fails then call put_device().
See comment to device_register.Signed-off-by: Vasiliy Kulikov
Signed-off-by: Geert Uytterhoeven
10 Aug, 2010
2 commits
-
proc_bus_zorro_read() didn't take into account the current file position,
hence it always read from the start of the ConfigDev.Signed-off-by: Geert Uytterhoeven
-
Remove BKL use from proc_bus_zorro_lseek(), like was done for
proc_bus_pci_lseek() a long time ago.Signed-off-by: Geert Uytterhoeven
Acked-by: Arnd Bergmann
22 May, 2010
1 commit
-
This allows bin_attr->read,write,mmap callbacks to check file specific data
(such as inode owner) as part of any privilege validation.Signed-off-by: Chris Wright
Signed-off-by: Greg Kroah-Hartman
18 May, 2010
2 commits
-
Signed-off-by: Geert Uytterhoeven
-
Add Amiga Zorro bus modalias and uevent support
Signed-off-by: Geert Uytterhoeven
15 Feb, 2010
1 commit
-
Signed-off-by: Uwe Kleine-König
Signed-off-by: Jiri Kosina
06 Dec, 2009
1 commit
-
These now cause errors due to changes present in linux-next:
(__ksymtab_sorted+0x1258): undefined reference to `dio_dev_driver'
(__ksymtab_sorted+0x4d48): undefined reference to `zorro_dev_driver'Signed-off-by: Stephen Rothwell
Signed-off-by: Geert Uytterhoeven
25 Mar, 2009
1 commit
-
Acked-by: Greg Kroah-Hartman
Signed-off-by: Kay Sievers
13 Jan, 2009
3 commits
-
Signed-off-by: Geert Uytterhoeven
-
warning: ignoring return value of 'device_register', declared with attribute
warn_unused_result
warning: ignoring return value of 'device_create_file', declared with
attribute warn_unused_resultSigned-off-by: Geert Uytterhoeven
-
drivers/zorro/.gitignore: Added devlist.h and gen-devlist to .gitignore file
because they shouldn't be tracked.Signed-off-by: Kars de Jong
Signed-off-by: Geert Uytterhoeven