[PATCH v2 1/4] crypto: inside-secure - use kfree_sensitive()

2020-08-27 Thread Denis Efremov
Use kfree_sensitive() instead of open-coding it. Signed-off-by: Denis Efremov --- drivers/crypto/inside-secure/safexcel_hash.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c index

[PATCH] crypto: amlogic - use kfree_sensitive()

2020-08-26 Thread Denis Efremov
Use kfree_sensitive() instead of open-coding it. Signed-off-by: Denis Efremov --- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c

[PATCH] crypto: inside-secure - use kfree_sensitive()

2020-08-26 Thread Denis Efremov
Use kfree_sensitive() instead of open-coding it. Signed-off-by: Denis Efremov --- drivers/crypto/inside-secure/safexcel_hash.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c index

Re: [PATCH] coccinelle: api: update kzfree script to kfree_sensitive

2020-08-26 Thread Denis Efremov
Ping? On 8/11/20 10:49 AM, Denis Efremov wrote: > Commit 453431a54934 ("mm, treewide: rename kzfree() to kfree_sensitive()") > renames kzfree to kfree_sensitive and uses memzero_explicit(...) instead of > memset(..., 0, ...) internally. Update cocci script to reflect these >

Re: [PATCH] seccomp: Use current_pt_regs()

2020-08-24 Thread Denis Efremov
On 8/24/20 7:34 PM, Kees Cook wrote: > On Mon, Aug 24, 2020 at 03:59:21PM +0300, Denis Efremov wrote: >> Modify seccomp_do_user_notification(), __seccomp_filter(), >> __secure_computing() to use current_pt_regs(). > > This looks okay. It seems some architectures hav

[PATCH] seccomp: Use current_pt_regs()

2020-08-24 Thread Denis Efremov
Modify seccomp_do_user_notification(), __seccomp_filter(), __secure_computing() to use current_pt_regs(). Signed-off-by: Denis Efremov --- kernel/seccomp.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/seccomp.c b/kernel/seccomp.c index 3ee59ce0a323

[PATCH] namei: use current_fsuid() in may_follow_link()

2020-08-24 Thread Denis Efremov
Modify may_follow_link() to use current_fsuid() Signed-off-by: Denis Efremov --- fs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/namei.c b/fs/namei.c index e99e2a9da0f7..1a47c9d8ce13 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -958,7 +958,7 @@ static inline int

[PATCH] integrity: Use current_uid() in integrity_audit_message()

2020-08-24 Thread Denis Efremov
Modify integrity_audit_message() to use current_uid(). Signed-off-by: Denis Efremov --- security/integrity/integrity_audit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/integrity/integrity_audit.c b/security/integrity/integrity_audit.c index f25e7df099c8

[PATCH] virt: vbox: Use current_uid() in vbg_misc_device_requestor()

2020-08-24 Thread Denis Efremov
Modify vbg_misc_device_requestor() to use current_uid() wrapper. Signed-off-by: Denis Efremov --- drivers/virt/vboxguest/vboxguest_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c

[PATCH] security/commoncap: Use current_user_ns()

2020-08-24 Thread Denis Efremov
Modify cap_inh_is_capped(), cap_task_prctl() to use current_user_ns(). Signed-off-by: Denis Efremov --- security/commoncap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/commoncap.c b/security/commoncap.c index 59bf3c1674c8..82a61f77c07c 100644 --- a/security

[PATCH v2] coccinelle: api: add kobj_to_dev.cocci script

2020-08-21 Thread Denis Efremov
Use kobj_to_dev() instead of container_of(). Signed-off-by: Denis Efremov --- Changes in v2: - "symbol kobj;" added to the rule r scripts/coccinelle/api/kobj_to_dev.cocci | 45 1 file changed, 45 insertions(+) create mode 100644 scripts/cocc

[PATCH] coccinelle: api: add kobj_to_dev.cocci script

2020-08-21 Thread Denis Efremov
Use kobj_to_dev() instead of container_of(). Signed-off-by: Denis Efremov --- Examples of such patches: 893c3d82b425 watchdog: Use kobj_to_dev() API 23fd63a44460 hwmon: (nct6683) Replace container_of() with kobj_to_dev() 224941c9424f power: supply: use kobj_to_dev a9b9b2af40c7 backlight

Re: [PATCH] coccinelle: api: add sprintf() support to device_attr_show

2020-08-14 Thread Denis Efremov
On 8/14/20 3:30 PM, Markus Elfring wrote: >>> You propose to use a nested SmPL disjunction for desired adjustments. >>> I suggest to start a corresponding case distinction behind >>> the key word “return” instead of repeating it three times. >> >> It doesn't work. > > How do you think about to

Re: [PATCH] coccinelle: api: add sprintf() support to device_attr_show

2020-08-14 Thread Denis Efremov
Hi, Markus, I think that CCing new people and spam them with mails they are obviously not interested in doesn't bring an additional value to the discussion. linux-kernel and cocci mailing lists are enough in my opinion. This also will allow us to keep "threaded" mail order. On 8/14/20 11:30 AM,

[PATCH] coccinelle: api: add sprintf() support to device_attr_show

2020-08-13 Thread Denis Efremov
It's safe to use sprintf() for simple cases in device_attr_show type of functions. Add support for sprintf() in patch mode to the device_attr_show.cocci script to print numbers and pointers. Signed-off-by: Denis Efremov --- Interesting enough that with this patch coccinelle starts to skip patch

[RFC PATCH] coccinelle: misc: add uninitialized_var.cocci script

2020-08-11 Thread Denis Efremov
itialized_var(). Cc: Kees Cook Cc: Gustavo A. R. Silva Signed-off-by: Denis Efremov --- List of warnings: ./lib/glob.c:48:31-39: WARNING: this kind of initialization is deprecated ./tools/testing/selftests/vm/userfaultfd.c:349:15-22: WARNING: this kind of initialization is deprecated ./drivers/b

[PATCH] coccinelle: api: update kzfree script to kfree_sensitive

2020-08-11 Thread Denis Efremov
Commit 453431a54934 ("mm, treewide: rename kzfree() to kfree_sensitive()") renames kzfree to kfree_sensitive and uses memzero_explicit(...) instead of memset(..., 0, ...) internally. Update cocci script to reflect these changes. Signed-off-by: Denis Efremov --- Julia, I think you

Re: [PATCH v4] coccinelle: api: add kzfree script

2020-08-11 Thread Denis Efremov
On 8/11/20 2:45 AM, Eric Biggers wrote: > On Fri, Jul 17, 2020 at 10:39:20PM +0200, Julia Lawall wrote: >> >> >> On Fri, 17 Jul 2020, Denis Efremov wrote: >> >>> Check for memset()/memzero_explicit() followed by kfree()/vfree()/kvfree(). >>> &g

[PATCH v2] coccinelle: misc: add flexible_array.cocci script

2020-08-09 Thread Denis Efremov
. Cc: Kees Cook Cc: Gustavo A. R. Silva Signed-off-by: Denis Efremov --- Changes in v2: - all uapi headers are now filtered-out. Unfortunately, coccinelle doesn't provide structure names in Location.current_element. For structures the field is always "something_else". Thus, the

[RFC PATCH] coccinelle: misc: add flexible_array.cocci script

2020-08-06 Thread Denis Efremov
. Cc: Kees Cook Cc: Gustavo A. R. Silva Signed-off-by: Denis Efremov --- Currently, it's just a draft. I've placed a number of questions in the script and marked them as TODO. Kees, Gustavo, if you could help me with my questions I think that this rule will be enough to close: https://github.com/

[PATCH v3] coccinelle: api: add kvmalloc script

2020-08-04 Thread Denis Efremov
Suggest kvmalloc, kvfree instead of opencoded patterns. Signed-off-by: Denis Efremov --- Changes in v2: - binary operator cmp added - NULL comparisions simplified - "T x" case added to !patch mode Changes in v3: - kvfree rules added scripts/coccinelle/api/kvmalloc.c

[PATCH v2] coccinelle: api: add kvmalloc script

2020-08-03 Thread Denis Efremov
Suggest kvmalloc instead of opencoded kmalloc && vmalloc condition. Signed-off-by: Denis Efremov --- Changes in v2: - binary operator cmp added - NULL comparisions simplified - "T x" case added to !patch mode scripts/coccinelle/api/kvmalloc.cocci | 142

[PATCH v7] coccinelle: api: add kfree_mismatch script

2020-08-03 Thread Denis Efremov
Check that alloc and free types of functions match each other. Signed-off-by: Denis Efremov --- Changes in v2: - Lines are limited to 80 characters where possible - Confidence changed from High to Medium because of fs/btrfs/send.c:1119 false-positive - __vmalloc_area_node() explicitly

Re: [PATCH v6] coccinelle: api: add kvfree script

2020-08-03 Thread Denis Efremov
Is there a difference from cocci point of view between: ... when != !is_vmalloc_addr(E) and ... when != is_vmalloc_addr(E) Should the latter one be used in most cases? Thanks, Denis

Re: [PATCH v6] coccinelle: api: add kvfree script

2020-08-03 Thread Denis Efremov
On 8/2/20 11:24 PM, Julia Lawall wrote: >> +@initialize:python@ >> +@@ >> +# low-level memory api >> +filter = frozenset(['__vmalloc_area_node']) >> + >> +def relevant(p): >> +return not (filter & {el.current_element for el in p}) > > Is this used? I'll remove it in v8. Or do you want me

[PATCH] coccinelle: api: add kvmalloc script

2020-08-03 Thread Denis Efremov
Suggest kvmalloc instead of opencoded kmalloc && vmalloc condition. Signed-off-by: Denis Efremov --- If coccinelle fails with "Segmentation fault" during analysis, then one needs to increase stack limit, e.g. ulimit -s 32767. Current, I've sent only one patch for this

[PATCH v2] scsi: libcxgbi: use kvzalloc instead of opencoded kzalloc/vzalloc

2020-08-01 Thread Denis Efremov
Remove cxgbi_alloc_big_mem(), cxgbi_free_big_mem() functions and use kvzalloc/kvfree instead. __GFP_NOWARN added to kvzalloc() call because we already print a warning in case of allocation fail. Signed-off-by: Denis Efremov --- drivers/scsi/cxgbi/libcxgbi.c | 8 drivers/scsi/cxgbi

Re: [PATCH] scsi: libcxgbi: use kvzalloc instead of opencoded kzalloc/vzalloc

2020-08-01 Thread Denis Efremov
On 8/1/20 11:10 AM, Joe Perches wrote: > On Sat, 2020-08-01 at 10:51 +0300, Denis Efremov wrote: >> On 8/1/20 1:24 AM, Joe Perches wrote: >>> On Sat, 2020-08-01 at 01:10 +0300, Denis Efremov wrote: >>>> On 8/1/20 12:58 AM, Joe Perches wrote: >>>>

Re: [PATCH] gfs2: Use kvmalloc instead of opencoded kmalloc/vmalloc

2020-08-01 Thread Denis Efremov
Please, skip this patch. I missed that kvmalloc checks (flags & GFP_KERNEL) == GFP_KERNEL before calling vmalloc. P.S.: previous mail was filtered because of html tags. Thanks, Denis On 8/1/20 12:28 AM, Denis Efremov wrote: > Use kvmalloc instead of opencoded kmalloc/vmalloc co

Re: [PATCH] scsi: libcxgbi: use kvzalloc instead of opencoded kzalloc/vzalloc

2020-08-01 Thread Denis Efremov
On 8/1/20 10:51 AM, Denis Efremov wrote: > > > On 8/1/20 1:24 AM, Joe Perches wrote: >> On Sat, 2020-08-01 at 01:10 +0300, Denis Efremov wrote: >>> >>> On 8/1/20 12:58 AM, Joe Perches wrote: >>>> On Sat, 2020-08-01 at 00:55 +0300, Denis Ef

Re: [PATCH] scsi: libcxgbi: use kvzalloc instead of opencoded kzalloc/vzalloc

2020-08-01 Thread Denis Efremov
On 8/1/20 1:24 AM, Joe Perches wrote: > On Sat, 2020-08-01 at 01:10 +0300, Denis Efremov wrote: >> >> On 8/1/20 12:58 AM, Joe Perches wrote: >>> On Sat, 2020-08-01 at 00:55 +0300, Denis Efremov wrote: >>>> Remove cxgbi_alloc_big_mem(), cxgbi_free_big_mem() fu

Re: [PATCH] scsi: libcxgbi: use kvzalloc instead of opencoded kzalloc/vzalloc

2020-07-31 Thread Denis Efremov
On 8/1/20 12:58 AM, Joe Perches wrote: > On Sat, 2020-08-01 at 00:55 +0300, Denis Efremov wrote: >> Remove cxgbi_alloc_big_mem(), cxgbi_free_big_mem() functions >> and use kvzalloc/kvfree instead. > > Sensible, thanks. > >> diff --git a/drivers/scsi/cxgbi/l

[PATCH] scsi: libcxgbi: use kvzalloc instead of opencoded kzalloc/vzalloc

2020-07-31 Thread Denis Efremov
Remove cxgbi_alloc_big_mem(), cxgbi_free_big_mem() functions and use kvzalloc/kvfree instead. Signed-off-by: Denis Efremov --- drivers/scsi/cxgbi/libcxgbi.c | 8 drivers/scsi/cxgbi/libcxgbi.h | 16 2 files changed, 4 insertions(+), 20 deletions(-) diff --git

[PATCH] gfs2: Use kvmalloc instead of opencoded kmalloc/vmalloc

2020-07-31 Thread Denis Efremov
Use kvmalloc instead of opencoded kmalloc/vmalloc condition. Signed-off-by: Denis Efremov --- fs/gfs2/dir.c | 23 --- fs/gfs2/quota.c | 5 + 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index c0f2875c946c..5d2a708fae9c

[PATCH v6] coccinelle: api: add kvfree script

2020-07-31 Thread Denis Efremov
Check that alloc and free types of functions match each other. Signed-off-by: Denis Efremov --- Changes in v2: - Lines are limited to 80 characters where possible - Confidence changed from High to Medium because of fs/btrfs/send.c:1119 false-positive - __vmalloc_area_node() explicitly

[PATCH v5] coccinelle: api: add kvfree script

2020-07-31 Thread Denis Efremov
Check that alloc and free types of functions match each other. Signed-off-by: Denis Efremov --- Changes in v2: - Lines are limited to 80 characters where possible - Confidence changed from High to Medium because of fs/btrfs/send.c:1119 false-positive - __vmalloc_area_node() explicitly

Re: [PATCH v4] coccinelle: api: add kvfree script

2020-07-31 Thread Denis Efremov
> With the current patch mode, I got some changes in a recent linux-next. > Have you sent patches for these issues? For mellanox, I've sent these patches: https://lkml.org/lkml/2020/6/5/901 https://lkml.org/lkml/2020/6/1/713 They were accepted. I see two new places in mellanox driver in

[PATCH v4] coccinelle: api: add kvfree script

2020-07-30 Thread Denis Efremov
Check that alloc and free types of functions match each other. Signed-off-by: Denis Efremov --- Changes in v2: - Lines are limited to 80 characters where possible - Confidence changed from High to Medium because of fs/btrfs/send.c:1119 false-positive - __vmalloc_area_node() explicitly

Re: [PATCH v3] coccinelle: api: add kvfree script

2020-07-30 Thread Denis Efremov
> + > +@script: python depends on org@ > +v << kfree.v; > +p << kfree.p; > +@@ > + > +msg = "WARNING: vmalloc is used to allocate this memory at line %s" % > (v[0].line) > +coccilib.org.print_todo(p[0], Just noticed this error. I will resend the patch in 5mins. Regards, Denis

[PATCH v3] coccinelle: api: add kvfree script

2020-07-30 Thread Denis Efremov
Check that alloc and free types of functions match each other. Signed-off-by: Denis Efremov --- Changes in v2: - Lines are limited to 80 characters where possible - Confidence changed from High to Medium because of fs/btrfs/send.c:1119 false-positive - __vmalloc_area_node() explicitly

Re: [Linux-kernel-mentees] [PATCH v2] block/floppy: Prevent kernel-infoleak in raw_cmd_copyout()

2020-07-29 Thread Denis Efremov
On 7/29/20 3:58 PM, Dan Carpenter wrote: > Argh... This isn't right still. The "ptr" comes from raw_cmd_copyin() > > ptr = kmalloc(sizeof(struct floppy_raw_cmd), GFP_KERNEL); > copy_from_user overwrites the padding bytes: ptr = kmalloc(sizeof(struct floppy_raw_cmd), GFP_KERNEL);

Re: [Linux-kernel-mentees] [PATCH] block/floppy: Prevent kernel-infoleak in raw_cmd_copyout()

2020-07-29 Thread Denis Efremov
On 7/28/20 5:19 PM, Peilin Ye wrote: > raw_cmd_copyout() is potentially copying uninitialized kernel stack memory > since it is initializing `cmd` by assignment, which may cause the compiler > to leave uninitialized holes in this structure. Fix it by using memcpy() > instead. > > Cc:

Re: [Linux-kernel-mentees] [PATCH] block/floppy: Prevent kernel-infoleak in raw_cmd_copyout()

2020-07-29 Thread Denis Efremov
> > Cc: sta...@vger.kernel.org > Fixes: 2145e15e0557 ("floppy: don't write kernel-only members to FDRAWCMD > ioctl output") > Suggested-by: Dan Carpenter > Suggested-by: Arnd Bergmann > Signed-off-by: Peilin Ye Reviewed-by: Denis Efremov ptr comes from raw_cmd_copy

[PATCH v3 1/3] coccinelle: api: extend memdup_user transformation with GFP_USER

2020-07-20 Thread Denis Efremov
llocations. The motivation behind altering memdup_user() to GFP_USER: https://lkml.org/lkml/2018/1/6/333 Signed-off-by: Denis Efremov --- scripts/coccinelle/api/memdup_user.cocci | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/coccinelle/api/memdup_user.cocci

[PATCH v3 2/3] coccinelle: api: extend memdup_user rule with vmemdup_user()

2020-07-20 Thread Denis Efremov
Add vmemdup_user() transformations to the memdup_user.cocci rule. Commit 50fd2f298bef ("new primitive: vmemdup_user()") introduced vmemdup_user(). The function uses kvmalloc with GPF_USER flag. Signed-off-by: Denis Efremov --- scripts/coccinelle/api/memdup_user.

[PATCH v3 3/3] coccinelle: api: filter out memdup_user definitions

2020-07-20 Thread Denis Efremov
Don't match memdup_user/vmemdup_user. Signed-off-by: Denis Efremov --- scripts/coccinelle/api/memdup_user.cocci | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/coccinelle/api/memdup_user.cocci b/scripts/coccinelle/api/memdup_user.cocci index

[PATCH v3 0/3] Update memdup_user.cocci

2020-07-20 Thread Denis Efremov
Add GFP_USER to the allocation flags and handle vmemdup_user(). Changes in v2: - memdup_user/vmemdup_user matching suppressed - PoC for selfcheck virtual rule Changes in v3: - add missing '-' for patch rule in kmalloc/kzalloc call args - selfcheck rule dropped from patchset Denis Efremov (3

Re: [v2 1/4] coccinelle: api: extend memdup_user transformation with GFP_USER

2020-07-18 Thread Denis Efremov
Hi, On 7/18/20 9:45 AM, Julia Lawall wrote: > This on is indeed a problem. I think it was not detected in testing, > because in the current kernel the rule never applies. But Denis, in > > - to = \(kmalloc\|kzalloc\) > (size,\(GFP_KERNEL\|GFP_USER\| >

Re: [PATCH v2 0/4] Update memdup_user.cocci

2020-07-17 Thread Denis Efremov
Ping? On 6/8/20 6:00 PM, Denis Efremov wrote: > Add GFP_USER to the allocation flags and handle vmemdup_user(). > The third patch supresses memdup_user(), vmemdup_user() functions > detection. Last patch is a proof of concept for the rule selfchecking. > Gives the ability to detect

Re: [PATCH v2] coccinelle: api: add kvfree script

2020-07-17 Thread Denis Efremov
Ping?

[PATCH v4] coccinelle: api: add kzfree script

2020-07-17 Thread Denis Efremov
Check for memset()/memzero_explicit() followed by kfree()/vfree()/kvfree(). Signed-off-by: Denis Efremov --- Changes in v2: - memset_explicit() added - kvfree_sensitive() added - forall added to r1 - ... between memset and kfree added Changes in v3: - Explicit filter for definitions instead

[PATCH v4] coccinelle: misc: add array_size_dup script to detect missed overflow checks

2020-06-22 Thread Denis Efremov
Detect an opencoded expression that is used before or after array_size()/array3_size()/struct_size() to compute the same size. Signed-off-by: Denis Efremov --- Changes in v2: - python rules moved next to SmPL patterns - assignment operator used - struct_size patterns fixed to check only E3

[PATCH] drm/gma500: Fix direction check in psb_accel_2d_copy()

2020-06-22 Thread Denis Efremov
kernel.org Signed-off-by: Denis Efremov --- drivers/gpu/drm/gma500/accel_2d.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/gma500/accel_2d.c b/drivers/gpu/drm/gma500/accel_2d.c index adc0507545bf..8dc86aac54d2 100644 --- a/drivers/gpu/drm/gma500/accel_

[PATCH] drm/radeon: fix fb_div check in ni_init_smc_spll_table()

2020-06-22 Thread Denis Efremov
clk_s is checked twice in a row in ni_init_smc_spll_table(). fb_div should be checked instead. Fixes: 69e0b57a91ad ("drm/radeon/kms: add dpm support for cayman (v5)") Cc: sta...@vger.kernel.org Signed-off-by: Denis Efremov --- drivers/gpu/drm/radeon/ni_dpm.c | 2 +- 1 file changed, 1

[PATCH] btrfs: tests: remove if duplicate in __check_free_space_extents()

2020-06-22 Thread Denis Efremov
num_extents is already checked in the next if condition and can be safely removed. Signed-off-by: Denis Efremov --- fs/btrfs/tests/free-space-tree-tests.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c index

Re: [Cocci] [PATCH v3] coccinelle: misc: add array_size_dup script to detect missed overflow checks

2020-06-22 Thread Denis Efremov
What do you think about removing duplicates warning from the rule? I mean this kind of warnings: "WARNING: same array_size (line {p1[0].line})" As for now, I think it's better to not disturb developers with this kind of things. Thanks, Denis >> +@as_dup@ >> +expression subE1 <= as.E1; >>

Re: [Cocci] [PATCH v3] coccinelle: misc: add array_size_dup script to detect missed overflow checks

2020-06-22 Thread Denis Efremov
On 6/21/20 11:56 PM, Julia Lawall wrote: > Is it a python 2 vs python 3 thing? Yes, python2 is no longer supported and I thought it would be safe to use this syntax. Ok, I will make it portable in v4. Denis

[PATCH] driver core: Use scnprintf() instead of snprintf() in device show functions

2020-06-20 Thread Denis Efremov
nis Efremov --- Actually, I don't know why snprintf() is used here initially. It looks safe to use sprintf(). drivers/base/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 67d39a90b45c..2815deb511fc 100644 --- a/driv

Re: ERROR: modpost: "__mulsi3" undefined!

2020-06-20 Thread Denis Efremov
On 6/19/20 7:17 PM, kernel test robot wrote: > Hi Denis, > > First bad commit (maybe != root cause): > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > master > head: 5e857ce6eae7ca21b2055cca4885545e29228fe2 > commit: e4a42c82e943b97ce124539fcd7a47445b43fa0d

[PATCH] coccinelle: api/kstrdup: fix coccinelle position

2020-06-19 Thread Denis Efremov
There is a typo in rule r2. Position p1 should be attached to kzalloc() call. Fixes: 29a36d4dec6c ("scripts/coccinelle: improve the coverage of some semantic patches") Signed-off-by: Denis Efremov --- scripts/coccinelle/api/kstrdup.cocci | 2 +- 1 file changed, 1 insertion(+),

[PATCH v3] coccinelle: misc: add array_size_dup script to detect missed overflow checks

2020-06-19 Thread Denis Efremov
Detect an opencoded expression that is used before or after array_size()/array3_size()/struct_size() to compute the same size. Cc: Gustavo A. R. Silva Cc: Kees Cook Signed-off-by: Denis Efremov --- Changes in v2: - python rules moved next to SmPL patterns - assignment operator used

Re: [PATCH v2] coccinelle: misc: add array_size_dup script to detect missed overflow checks

2020-06-18 Thread Denis Efremov
Hi, On 6/18/20 2:34 PM, Markus Elfring wrote: > Why did you repeat a typo from the previous patch subject? Where is the typo? I can't handle your suggestions because your mails constantly break the threads. I just can't find them after due to missed/wrong In-Reply-To headers. Again, this mail

[PATCH v2] coccinelle: misc: add array_size_dup script to detect missed overlow checks

2020-06-18 Thread Denis Efremov
Detect an opencoded expression that is used before or after array_size()/array3_size()/struct_size() to compute the same size. Cc: Gustavo A. R. Silva Cc: Kees Cook Signed-off-by: Denis Efremov --- Changes in v2: - python rules moved next to SmPL patterns - assignment operator used

Re: [Cocci] [PATCH v3] coccinelle: api: add kzfree script

2020-06-17 Thread Denis Efremov
>> +@rp_memset depends on patch@ >> +expression E, size; >> +position p : script:python() { relevant(p) }; >> +type T; >> +@@ >> + >> +- memset((T)E, size)@p; > > This is missing a 0 argument. > Thanks, I will send v4. > > >> + ... when != E >> + when strict >> +( >> +- kfree(E); >>

Re: [PATCH v4 0/3] mm, treewide: Rename kzfree() to kfree_sensitive()

2020-06-17 Thread Denis Efremov
On 6/16/20 9:53 PM, Joe Perches wrote: > On Mon, 2020-06-15 at 21:57 -0400, Waiman Long wrote: >> v4: >> - Break out the memzero_explicit() change as suggested by Dan Carpenter >> so that it can be backported to stable. >> - Drop the "crypto: Remove unnecessary memzero_explicit()"

Re: [Cocci] [PATCH] coccinelle: misc: add array_size_dup script to detect missed overlow checks

2020-06-17 Thread Denis Efremov
On 6/17/20 11:30 PM, Julia Lawall wrote: > > > On Mon, 15 Jun 2020, Denis Efremov wrote: > >> Detect an opencoded expression that is used before or after >> array_size()/array3_size()/struct_size() to compute the same size. > > This would benefit from the ass

Re: [Cocci] [PATCH] coccinelle: api: add device_attr_show script

2020-06-17 Thread Denis Efremov
On 6/17/20 11:27 PM, Julia Lawall wrote: > > > On Mon, 15 Jun 2020, Denis Efremov wrote: > >> According to the documentation[1] show() methods of device attributes >> should return the number of bytes printed into the buffer. This is >> the return value of sc

Re: [Cocci] [PATCH] coccinelle: misc: add array_size_dup script to detect missed overlow checks

2020-06-17 Thread Denis Efremov
to check for overflow /// relatively small allocations. /// // Confidence: Low // Copyright: (C) 2020 Denis Efremov ISPRAS // Options: --no-includes --include-headers virtual patch virtual context virtual org virtual report @depends on patch@ expression E1, E2, E3, E4, size; @@ ( - size = E1 * E

Re: [Cocci] [PATCH] coccinelle: misc: add array_size_dup script to detect missed overlow checks

2020-06-17 Thread Denis Efremov
> > > Awesome! I'll take a look into this. :) > It would be helpful to get a feedback from you after. What kind of warnings are helpful and what are not? "duplicate calls" and "opencoded expression after array_size()" look doubtful to me. I think that maintainers will not like these patches.

Re: [PATCH] coccinelle: misc: add array_size_dup script to detect missed overlow checks

2020-06-15 Thread Denis Efremov
On 6/15/20 9:23 PM, Kees Cook wrote: > On Mon, Jun 15, 2020 at 01:20:45PM +0300, Denis Efremov wrote: >> Detect an opencoded expression that is used before or after >> array_size()/array3_size()/struct_size() to compute the same size. >> >> Cc: Kees Cook >

Re: [PATCH] coccinelle: api: add kzfree script

2020-06-15 Thread Denis Efremov
On 6/15/20 3:03 PM, Dan Carpenter wrote: > On Sun, Jun 14, 2020 at 10:42:54PM +0300, Denis Efremov wrote: >> On 6/4/20 7:27 PM, Joe Perches wrote: >>> On Thu, 2020-06-04 at 17:08 +0300, Denis Efremov wrote: >>>> Check for memset() with 0 followed by kfree(). >

[PATCH] coccinelle: api: add device_attr_show script

2020-06-15 Thread Denis Efremov
rintf() confusion" https://lwn.net/Articles/69419/ Signed-off-by: Denis Efremov --- scripts/coccinelle/api/device_attr_show.cocci | 55 +++ 1 file changed, 55 insertions(+) create mode 100644 scripts/coccinelle/api/device_attr_show.cocci diff --git a/scripts/cocc

[PATCH] coccinelle: misc: add array_size_dup script to detect missed overlow checks

2020-06-15 Thread Denis Efremov
Detect an opencoded expression that is used before or after array_size()/array3_size()/struct_size() to compute the same size. Cc: Kees Cook Signed-off-by: Denis Efremov --- scripts/coccinelle/misc/array_size_dup.cocci | 347 +++ 1 file changed, 347 insertions(+) create mode

[PATCH v3] coccinelle: api: add kzfree script

2020-06-14 Thread Denis Efremov
Check for memset()/memzero_explicit() followed by kfree()/vfree()/kvfree(). Signed-off-by: Denis Efremov --- Changes in v2: - memset_explicit() added - kvfree_sensitive() added - forall added to r1 - ... between memset and kfree added Changes in v3: - Explicit filter for definitions instead

Re: [PATCH] coccinelle: api: add kzfree script

2020-06-14 Thread Denis Efremov
On 6/4/20 7:27 PM, Joe Perches wrote: > On Thu, 2020-06-04 at 17:08 +0300, Denis Efremov wrote: >> Check for memset() with 0 followed by kfree(). > > Perhaps those uses should be memzero_explicit or kvfree_sensitive. > Is it safe to suggest to use kzfree instead of memzero

[PATCH v2] coccinelle: api: add kvfree script

2020-06-14 Thread Denis Efremov
Check that alloc and free types of functions match each other. Signed-off-by: Denis Efremov --- Changes in v2: - Lines are limited to 80 characters where possible - Confidence changed from High to Medium because of fs/btrfs/send.c:1119 false-positive - __vmalloc_area_node() explicitly

Re: [Cocci] [PATCH] coccinelle: api: add kvfree script

2020-06-14 Thread Denis Efremov
On 6/14/20 12:17 PM, Julia Lawall wrote: > > > On Sun, 14 Jun 2020, Denis Efremov wrote: > >> >> >> On 6/5/20 11:51 PM, Julia Lawall wrote: >>> Also, there is no need to exceed 80 characters here. You can put a >>> newline in the middle of

Re: [Cocci] [PATCH] coccinelle: api: add kvfree script

2020-06-14 Thread Denis Efremov
On 6/5/20 11:51 PM, Julia Lawall wrote: > Also, there is no need to exceed 80 characters here. You can put a > newline in the middle of a \( ... \) It's required. Looks like it's impossible to break "when" lines. ... when != if (...) { ... E =

Re: [Cocci] [PATCH v2 4/4] coccinelle: api: add selfcheck for memdup_user rule

2020-06-11 Thread Denis Efremov
On 6/9/20 7:22 PM, Julia Lawall wrote: > > > On Mon, 8 Jun 2020, Denis Efremov wrote: > >> Check that the rule matches vmemdup_user implementation. >> memdup_user is out of scope because we are not matching >> kmalloc_track_caller() function. > > Is th

[PATCH v3] f2fs: use kfree() instead of kvfree() to free superblock data

2020-06-09 Thread Denis Efremov
: 5222595d093e ("f2fs: use kvmalloc, if kmalloc is failed") Signed-off-by: Denis Efremov --- Changes in v2: - Single patch instead of two separate patches - kvfree fixed in f2fs_put_super Changes in v3: - raw_super added to the scope, thanks Chao Yu fs/f2fs/super.c | 10 +- 1 file

Re: [PATCH] kbuild: fix broken builds because of GZIP,BZIP2,LZOP variables

2020-06-08 Thread Denis Efremov
On 6/8/20 6:36 PM, Adam Borowski wrote: > On Mon, Jun 08, 2020 at 12:59:44PM +0300, Denis Efremov wrote: >> Redefine GZIP, BZIP2, LZOP variables as KGZIP, KBZIP2, KLZOP resp. >> GZIP, BZIP2, LZOP env variables are reserved by the tools. The original >> attempt to red

[PATCH v2] f2fs: use kfree() instead of kvfree() to free superblock data

2020-06-08 Thread Denis Efremov
;f2fs: use kvmalloc, if kmalloc is failed") Signed-off-by: Denis Efremov --- Changes in v2: - Single patch instead of two separate patches - kvfree fixed in f2fs_put_super fs/f2fs/super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/sup

[PATCH v2] drm/panfrost: Use kvfree() to free bo->sgts

2020-06-08 Thread Denis Efremov
Use kvfree() to free bo->sgts, because the memory is allocated with kvmalloc_array() in panfrost_mmu_map_fault_addr(). Fixes: 187d2929206e ("drm/panfrost: Add support for GPU heap allocations") Cc: sta...@vger.kernel.org Signed-off-by: Denis Efremov --- Change in v2: - k

[PATCH v2 2/4] coccinelle: api: extend memdup_user rule with vmemdup_user()

2020-06-08 Thread Denis Efremov
Add vmemdup_user() transformations to the memdup_user.cocci rule. Commit 50fd2f298bef ("new primitive: vmemdup_user()") introduced vmemdup_user(). The function uses kvmalloc with GPF_USER flag. Signed-off-by: Denis Efremov --- scripts/coccinelle/api/memdup_user.

[PATCH v2 4/4] coccinelle: api: add selfcheck for memdup_user rule

2020-06-08 Thread Denis Efremov
Check that the rule matches vmemdup_user implementation. memdup_user is out of scope because we are not matching kmalloc_track_caller() function. Signed-off-by: Denis Efremov --- scripts/coccinelle/api/memdup_user.cocci | 46 ++-- 1 file changed, 44 insertions(+), 2

[PATCH v2 3/4] coccinelle: api: filter out memdup_user definitions

2020-06-08 Thread Denis Efremov
Don't match original implementations. Signed-off-by: Denis Efremov --- scripts/coccinelle/api/memdup_user.cocci | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/coccinelle/api/memdup_user.cocci b/scripts/coccinelle/api/memdup_user.cocci index

[PATCH v2 1/4] coccinelle: api: extend memdup_user transformation with GFP_USER

2020-06-08 Thread Denis Efremov
llocations. The motivation behind altering memdup_user() to GFP_USER: https://lkml.org/lkml/2018/1/6/333 Signed-off-by: Denis Efremov --- scripts/coccinelle/api/memdup_user.cocci | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/coccinelle/api/memdup_user.cocci

[PATCH v2 0/4] Update memdup_user.cocci

2020-06-08 Thread Denis Efremov
for in the kernel sources changed. Denis Efremov (4): coccinelle: api: extend memdup_user transformation with GFP_USER coccinelle: api: extend memdup_user rule with vmemdup_user() coccinelle: api: filter out memdup_user definitions coccinelle: api: add selfcheck for memdup_user rule scripts

Re: [PATCH v5] kbuild: add variables for compression tools

2020-06-08 Thread Denis Efremov
On 6/8/20 7:59 AM, Masahiro Yamada wrote: > On Mon, Jun 8, 2020 at 10:30 AM Guenter Roeck wrote: >> >> Hi, >> >> On Fri, Jun 05, 2020 at 10:39:55AM +0300, Denis Efremov wrote: >>> Allow user to use alternative implementations of compression tools, >&g

[PATCH] kbuild: fix broken builds because of GZIP,BZIP2,LZOP variables

2020-06-08 Thread Denis Efremov
ken builds. There can be other broken build commands because of this, so the universal solution is to use non-reserved env variables for the compression tools. Fixes: 8dfb61dcbace ("kbuild: add variables for compression tools") Signed-off-by: Denis Efremov --- Makefile

Re: [Cocci] [PATCH 1/2] Coccinelle: extend memdup_user transformation with GFP_USER

2020-06-06 Thread Denis Efremov
On 6/6/20 11:24 AM, Julia Lawall wrote: > > > On Sat, 30 May 2020, Denis Efremov wrote: > >> Match GFP_USER allocations with memdup_user.cocci rule. >> Commit 6c2c97a24f09 ("memdup_user(): switch to GFP_USER") switched >> memdup_user() from GFP_KERNE

Re: [Cocci] [PATCH 1/2] Coccinelle: extend memdup_user transformation with GFP_USER

2020-06-06 Thread Denis Efremov
On 6/6/20 11:24 AM, Julia Lawall wrote: > > > On Sat, 30 May 2020, Denis Efremov wrote: > >> Match GFP_USER allocations with memdup_user.cocci rule. >> Commit 6c2c97a24f09 ("memdup_user(): switch to GFP_USER") switched >> memdup_user() from GFP_KERNE

Re: [Cocci] [PATCH] coccinelle: api: add kvfree script

2020-06-05 Thread Denis Efremov
On 6/5/20 11:51 PM, Julia Lawall wrote: > Is there a strong reason for putting the choice rule first? It may make > things somewhat slower than necessary, if it matches in many places, > because the opportunity rule will have to detect that it doesn't care > about all of those places. No, I

[PATCH] coccinelle: api: add kvfree script

2020-06-05 Thread Denis Efremov
Check that alloc and free types of functions match each other. Signed-off-by: Denis Efremov --- List of patches to stable: - https://lkml.org/lkml/2020/6/1/713 - https://lkml.org/lkml/2020/6/5/200 - https://lkml.org/lkml/2020/6/5/838 - https://lkml.org/lkml/2020/6/5/887 Other patches: - https

[PATCH] net/mlx5: Use kfree(ft->g) in arfs_create_groups()

2020-06-05 Thread Denis Efremov
Use kfree() instead of kvfree() on ft->g in arfs_create_groups() because the memory is allocated with kcalloc(). Signed-off-by: Denis Efremov --- drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mella

[PATCH] cxgb4: Use kfree() instead kvfree() where appropriate

2020-06-05 Thread Denis Efremov
Use kfree(buf) in blocked_fl_read() because the memory is allocated with kzalloc(). Use kfree(t) in blocked_fl_write() because the memory is allocated with kcalloc(). Signed-off-by: Denis Efremov --- drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 6 +++--- 1 file changed, 3 insertions

[PATCH] drm/panfrost: Use kvfree() to free bo->sgts in panfrost_mmu_map_fault_addr()

2020-06-05 Thread Denis Efremov
Use kvfree() to free bo->sgts, because the memory is allocated with kvmalloc_array(). Fixes: 187d2929206e ("drm/panfrost: Add support for GPU heap allocations") Cc: sta...@vger.kernel.org Signed-off-by: Denis Efremov --- drivers/gpu/drm/panfrost/panfrost_mmu.c | 2 +- 1 fi

[PATCH 1/2] f2fs: use kfree() to free super in read_raw_super_block()

2020-06-05 Thread Denis Efremov
Use kfree() instead of kvfree() to free super in read_raw_super_block() because the memory is allocated with kzalloc() in the function. Fixes: 5222595d093e ("f2fs: use kvmalloc, if kmalloc is failed") Signed-off-by: Denis Efremov --- fs/f2fs/super.c | 2 +- 1 file changed, 1 inser

[PATCH 2/2] f2fs: use kfree() to free sbi in f2fs_fill_super()

2020-06-05 Thread Denis Efremov
Use kfree() instead of kvfree() to free sbi in f2fs_fill_super() because the memory is allocated with kzalloc() in the function. Fixes: 5222595d093e ("f2fs: use kvmalloc, if kmalloc is failed") Signed-off-by: Denis Efremov --- fs/f2fs/super.c | 2 +- 1 file changed, 1 insertion(+),

[PATCH 1/2] drm/amd/display: Use kvfree() to free coeff in build_regamma()

2020-06-05 Thread Denis Efremov
Use kvfree() instead of kfree() to free coeff in build_regamma() because the memory is allocated with kvzalloc(). Fixes: e752058b8671 ("drm/amd/display: Optimize gamma calculations") Cc: sta...@vger.kernel.org Signed-off-by: Denis Efremov --- drivers/gpu/drm/amd/display/mod

<    1   2   3   4   5   6   >