Skip to content

Commit d8c0321

Browse files
committed
Merge branch 'for-5.14-vsprintf-scanf' into for-linus
2 parents 80ae552 + d327ea1 commit d8c0321

File tree

11 files changed

+827
-40
lines changed

11 files changed

+827
-40
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19395,6 +19395,7 @@ S: Maintained
1939519395
T: git git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk.git
1939619396
F: Documentation/core-api/printk-formats.rst
1939719397
F: lib/test_printf.c
19398+
F: lib/test_scanf.c
1939819399
F: lib/vsprintf.c
1939919400

1940019401
VT1211 HARDWARE MONITOR DRIVER

include/linux/prandom.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static inline u32 __seed(u32 x, u32 m)
111111
*/
112112
static inline void prandom_seed_state(struct rnd_state *state, u64 seed)
113113
{
114-
u32 i = (seed >> 32) ^ (seed << 10) ^ seed;
114+
u32 i = ((seed >> 32) ^ (seed << 10) ^ seed) & 0xffffffffUL;
115115

116116
state->s1 = __seed(i, 2U);
117117
state->s2 = __seed(i, 8U);

lib/Kconfig.debug

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,6 +2163,9 @@ config TEST_KSTRTOX
21632163
config TEST_PRINTF
21642164
tristate "Test printf() family of functions at runtime"
21652165

2166+
config TEST_SCANF
2167+
tristate "Test scanf() family of functions at runtime"
2168+
21662169
config TEST_BITMAP
21672170
tristate "Test bitmap_*() family of functions at runtime"
21682171
help

lib/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o
8383
obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o
8484
obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o
8585
obj-$(CONFIG_TEST_PRINTF) += test_printf.o
86+
obj-$(CONFIG_TEST_SCANF) += test_scanf.o
8687
obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
8788
obj-$(CONFIG_TEST_STRSCPY) += test_strscpy.o
8889
obj-$(CONFIG_TEST_UUID) += test_uuid.o

lib/kstrtox.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,22 @@ const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
3939

4040
/*
4141
* Convert non-negative integer string representation in explicitly given radix
42-
* to an integer.
42+
* to an integer. A maximum of max_chars characters will be converted.
43+
*
4344
* Return number of characters consumed maybe or-ed with overflow bit.
4445
* If overflow occurs, result integer (incorrect) is still returned.
4546
*
4647
* Don't you dare use this function.
4748
*/
48-
unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *p)
49+
unsigned int _parse_integer_limit(const char *s, unsigned int base, unsigned long long *p,
50+
size_t max_chars)
4951
{
5052
unsigned long long res;
5153
unsigned int rv;
5254

5355
res = 0;
5456
rv = 0;
55-
while (1) {
57+
while (max_chars--) {
5658
unsigned int c = *s;
5759
unsigned int lc = c | 0x20; /* don't tolower() this line */
5860
unsigned int val;
@@ -82,6 +84,11 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long
8284
return rv;
8385
}
8486

87+
unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *p)
88+
{
89+
return _parse_integer_limit(s, base, p, INT_MAX);
90+
}
91+
8592
static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res)
8693
{
8794
unsigned long long _res;

lib/kstrtox.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#define KSTRTOX_OVERFLOW (1U << 31)
66
const char *_parse_integer_fixup_radix(const char *s, unsigned int *base);
7+
unsigned int _parse_integer_limit(const char *s, unsigned int base, unsigned long long *res,
8+
size_t max_chars);
79
unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long *res);
810

911
#endif

0 commit comments

Comments
 (0)