Skip to content

Commit 6ccc501

Browse files
aryabininPrasad Sodagudi
authored and
Prasad Sodagudi
committed
lib/ubsan: remove returns-nonnull-attribute checks
Similarly to type mismatch checks, new GCC 8.x and Clang also changed for ABI for returns_nonnull checks. While we can update our code to conform the new ABI it's more reasonable to just remove it. Because it's just dead code, we don't have any single user of returns_nonnull attribute in the whole kernel. And AFAIU the advantage that this attribute could bring would be mitigated by -fno-delete-null-pointer-checks cflag that we use to build the kernel. So it's unlikely we will have a lot of returns_nonnull attribute in future. So let's just remove the code, it has no use. Change-Id: I479d6f1355781017abdee33f5adf8fd3fdbe4304 [[email protected]: fix warning] Link: http://lkml.kernel.org/r/[email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Andrey Ryabinin <[email protected]> Cc: Sodagudi Prasad <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Git-commit: bac7a1fff7926fb9891a18fe33650884b0e13e41 Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git Signed-off-by: Prasad Sodagudi <[email protected]>
1 parent 0eaa11b commit 6ccc501

File tree

3 files changed

+0
-30
lines changed

3 files changed

+0
-30
lines changed

Diff for: lib/ubsan.c

-24
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ static void val_to_string(char *str, size_t size, struct type_descriptor *type,
141141
}
142142
}
143143

144-
static bool location_is_valid(struct source_location *loc)
145-
{
146-
return loc->file_name != NULL;
147-
}
148-
149144
static DEFINE_SPINLOCK(report_lock);
150145

151146
static void ubsan_prologue(struct source_location *location,
@@ -356,25 +351,6 @@ void __ubsan_handle_type_mismatch_v1(struct type_mismatch_data_v1 *data,
356351
}
357352
EXPORT_SYMBOL(__ubsan_handle_type_mismatch_v1);
358353

359-
void __ubsan_handle_nonnull_return(struct nonnull_return_data *data)
360-
{
361-
unsigned long flags;
362-
363-
if (suppress_report(&data->location))
364-
return;
365-
366-
ubsan_prologue(&data->location, &flags);
367-
368-
pr_err("null pointer returned from function declared to never return null\n");
369-
370-
if (location_is_valid(&data->attr_location))
371-
print_source_location("returns_nonnull attribute specified in",
372-
&data->attr_location);
373-
374-
ubsan_epilogue(&flags);
375-
}
376-
EXPORT_SYMBOL(__ubsan_handle_nonnull_return);
377-
378354
void __ubsan_handle_vla_bound_not_positive(struct vla_bound_data *data,
379355
unsigned long bound)
380356
{

Diff for: lib/ubsan.h

-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ struct nonnull_arg_data {
5757
int arg_index;
5858
};
5959

60-
struct nonnull_return_data {
61-
struct source_location location;
62-
struct source_location attr_location;
63-
};
64-
6560
struct vla_bound_data {
6661
struct source_location location;
6762
struct type_descriptor *type;

Diff for: scripts/Makefile.ubsan

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ ifdef CONFIG_UBSAN
77
CFLAGS_UBSAN += $(call cc-option, -fsanitize=signed-integer-overflow)
88
CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds)
99
CFLAGS_UBSAN += $(call cc-option, -fsanitize=object-size)
10-
CFLAGS_UBSAN += $(call cc-option, -fsanitize=returns-nonnull-attribute)
1110
CFLAGS_UBSAN += $(call cc-option, -fsanitize=bool)
1211
CFLAGS_UBSAN += $(call cc-option, -fsanitize=enum)
1312

0 commit comments

Comments
 (0)