Skip to content

Commit

Permalink
Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…linux/kernel/git/tip/tip

Pull core fixes from Ingo Molnar:
 "A handful of objtool updates, plus a documentation addition for
  __ab_c_size()"

* 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  objtool: Fix whitelist documentation typo
  objtool: Fix function fallthrough detection
  objtool: Don't use ignore flag for fake jumps
  overflow.h: Add comment documenting __ab_c_size()
  • Loading branch information
torvalds committed May 16, 2019
2 parents 8c05f3b + 2decec4 commit b2ca74d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
8 changes: 6 additions & 2 deletions include/linux/overflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,15 @@ static inline __must_check size_t array3_size(size_t a, size_t b, size_t c)
return bytes;
}

static inline __must_check size_t __ab_c_size(size_t n, size_t size, size_t c)
/*
* Compute a*b+c, returning SIZE_MAX on overflow. Internal helper for
* struct_size() below.
*/
static inline __must_check size_t __ab_c_size(size_t a, size_t b, size_t c)
{
size_t bytes;

if (check_mul_overflow(n, size, &bytes))
if (check_mul_overflow(a, b, &bytes))
return SIZE_MAX;
if (check_add_overflow(bytes, c, &bytes))
return SIZE_MAX;
Expand Down
2 changes: 1 addition & 1 deletion tools/objtool/Documentation/stack-validation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ ignore it:

- To skip validation of a file, add

OBJECT_FILES_NON_STANDARD_filename.o := n
OBJECT_FILES_NON_STANDARD_filename.o := y

to the Makefile.

Expand Down
11 changes: 7 additions & 4 deletions tools/objtool/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <linux/hashtable.h>
#include <linux/kernel.h>

#define FAKE_JUMP_OFFSET -1

struct alternative {
struct list_head list;
struct instruction *insn;
Expand Down Expand Up @@ -568,7 +570,7 @@ static int add_jump_destinations(struct objtool_file *file)
insn->type != INSN_JUMP_UNCONDITIONAL)
continue;

if (insn->ignore)
if (insn->ignore || insn->offset == FAKE_JUMP_OFFSET)
continue;

rela = find_rela_by_dest_range(insn->sec, insn->offset,
Expand Down Expand Up @@ -745,10 +747,10 @@ static int handle_group_alt(struct objtool_file *file,
clear_insn_state(&fake_jump->state);

fake_jump->sec = special_alt->new_sec;
fake_jump->offset = -1;
fake_jump->offset = FAKE_JUMP_OFFSET;
fake_jump->type = INSN_JUMP_UNCONDITIONAL;
fake_jump->jump_dest = list_next_entry(last_orig_insn, list);
fake_jump->ignore = true;
fake_jump->func = orig_insn->func;
}

if (!special_alt->new_len) {
Expand Down Expand Up @@ -1957,7 +1959,8 @@ static int validate_branch(struct objtool_file *file, struct instruction *first,
return 1;
}

func = insn->func ? insn->func->pfunc : NULL;
if (insn->func)
func = insn->func->pfunc;

if (func && insn->ignore) {
WARN_FUNC("BUG: why am I validating an ignored function?",
Expand Down

0 comments on commit b2ca74d

Please sign in to comment.