Project

General

Profile

Feature #3317

010: Usage of a GFP_ATOMIC flag in functions of memory allocation in a context of interrupt.

Added by Vladimir Gratinskiy over 7 years ago. Updated about 5 years ago.

Status:
Resolved
Priority:
Normal
Start date:
08/01/2012
Due date:
08/08/2012
% Done:

100%

Estimated time:
Published in build:

Description

When calling memory allocation function from the context of interrupt it's required to ensure a non-preemptible execution of the function; but in the case of GFP_KERNEL flag, function execution can be preempted, because a greater number of operations to find and allocate memory blocks is executed.

Verification: If some function is positioned as one that "is executed in a context of interrupt" then it's required to ensure checking for a necessary usage of the GFP_ATOMIC flag in the memory allocation functions for kernel modules.

Example:
void* ptr = kmalloc(size, GFP_ATOMIC);


Related issues

Related to C Instrumentation Framework - Feature #3802: Add ability to refer to function argument by its name specified in aspect fileClosed12/14/2012

Actions

History

#1

Updated by Vladimir Gratinskiy over 7 years ago

  • % Done changed from 10 to 90

I've found 5 unsafes.

#2

Updated by Vladimir Gratinskiy over 7 years ago

  • Due date set to 08/08/2012
  • Status changed from Open to Resolved
  • % Done changed from 90 to 100

I've found 2 true unsafes. Results here:
http://itgdev.intra.ispras.ru/wiki/index.php/Nice_table

Now this rule's name is 10_2a.

#3

Updated by Evgeny Novikov over 7 years ago

Vladimir Gratinskiy wrote:

Now this rule's name is 10_2a.

More correctly, 10_2a is a model identifier (or model name), since the same rule may have different models implementing it. This rule seems to have 2 models for instance.
And another question. What is the difference between 10_1a and 10_2a models? If 10_1a is included into 10_2a model then it should be completely replaced with it.

#4

Updated by Vladimir Gratinskiy over 7 years ago

Rule model 10_1a have been deleted. 10_2a includes functions that was in 10_1a but I've added some new similar functions. So, "10_2a" means that rule 10 wasn't changed, but now its model version is 2.

#5

Updated by Evgeny Novikov over 7 years ago

Vladimir Gratinskiy wrote:

Rule model 10_1a have been deleted. 10_2a includes functions that was in 10_1a but I've added some new similar functions. So, "10_2a" means that rule 10 wasn't changed, but now its model version is 2.

A number used in a model identifier after a rule identifier isn't a model version. That number is intended to distinguish models implementing different approaches for the same rule. For instance, one rule may have a rerouting model and a non rerouting model. This case to distinguish these models one should use different postfixes.
So, to correspond to the common naming scheme you have to use 10_1a identifier instead of 10_2a.

#6

Updated by Evgeny Novikov almost 7 years ago

  • Status changed from Resolved to Open

Please, use ability to refer to function argument by its name specified in aspect file (implemented in #3802).

#7

Updated by Evgeny Novikov almost 7 years ago

  • Assignee changed from Vladimir Gratinskiy to Ilya Shchepetkov
#8

Updated by Ilya Shchepetkov almost 7 years ago

  • Status changed from Open to Resolved

The ability to refer to function argument by its name specified in aspect file was added in the commit b4b7331 of master branch.

Tests passed.

#9

Updated by Evgeny Novikov over 6 years ago

  • Assignee changed from Ilya Shchepetkov to Vladimir Gratinskiy

Ilya just has developed a small part of the rule specification.

#10

Updated by Vitaly Mordan about 5 years ago

Some functions in "before: ALLOC", "around: ALLOC_AROUND" and "before: ALLOC_WITHOUT" (for example, static inline void *kmalloc(.., gfp_t flags, ..) and static inline void *kzalloc(.., gfp_t flags, ..)) will always return 0, which makes some pathes in program infeasible.

Also available in: Atom PDF