Re: [PATCH -next] kernel/audit: convert comma to semicolon

2021-01-04 Thread Paul Moore
On Mon, Dec 14, 2020 at 9:34 PM Paul Moore  wrote:
> On Fri, Dec 11, 2020 at 10:33 AM Richard Guy Briggs  wrote:
> > On 2020-12-11 16:42, Zheng Yongjun wrote:
> > > Replace a comma between expression statements by a semicolon.
> > >
> > > Signed-off-by: Zheng Yongjun 
> > > ---
> > >  kernel/audit.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/kernel/audit.c b/kernel/audit.c
> > > index 68cee3bc8cfe..c8497115be35 100644
> > > --- a/kernel/audit.c
> > > +++ b/kernel/audit.c
> > > @@ -2282,7 +2282,7 @@ static void audit_log_set_loginuid(kuid_t 
> > > koldloginuid, kuid_t kloginuid,
> > >
> > >   uid = from_kuid(_user_ns, task_uid(current));
> > >   oldloginuid = from_kuid(_user_ns, koldloginuid);
> > > - loginuid = from_kuid(_user_ns, kloginuid),
> > > + loginuid = from_kuid(_user_ns, kloginuid);
> >
> > Nice catch.  That went unnoticed through 3 patches, the last two mine...
>
> Yes, thanks for catching this and submitting a patch.  However, as it
> came very late in the v5.10-rcX release cycle I'm going to wait until
> after this merge window to merge it into audit/next.

This should be in audit/next now, thanks!

-- 
paul moore
www.paul-moore.com


Re: [PATCH -next] kernel/audit: convert comma to semicolon

2020-12-14 Thread Paul Moore
On Fri, Dec 11, 2020 at 10:33 AM Richard Guy Briggs  wrote:
> On 2020-12-11 16:42, Zheng Yongjun wrote:
> > Replace a comma between expression statements by a semicolon.
> >
> > Signed-off-by: Zheng Yongjun 
> > ---
> >  kernel/audit.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/audit.c b/kernel/audit.c
> > index 68cee3bc8cfe..c8497115be35 100644
> > --- a/kernel/audit.c
> > +++ b/kernel/audit.c
> > @@ -2282,7 +2282,7 @@ static void audit_log_set_loginuid(kuid_t 
> > koldloginuid, kuid_t kloginuid,
> >
> >   uid = from_kuid(_user_ns, task_uid(current));
> >   oldloginuid = from_kuid(_user_ns, koldloginuid);
> > - loginuid = from_kuid(_user_ns, kloginuid),
> > + loginuid = from_kuid(_user_ns, kloginuid);
>
> Nice catch.  That went unnoticed through 3 patches, the last two mine...

Yes, thanks for catching this and submitting a patch.  However, as it
came very late in the v5.10-rcX release cycle I'm going to wait until
after this merge window to merge it into audit/next.

> Not quite sure why no compiler complained about it...

Because it is legal; odd, but legal. :)

The comma operator allows multiple expressions to be executed with
only the last expression returned.  Take the example below:

% cat test.c
#include 
#include 

int main(int argc, char *argv[])
{
   int a, b, c;

   a = (b = 1, c = 2);
   printf("a = %d, b = %d, c = %d\n", a, b, c);

   return 0;
}
% gcc -o test test.c
% ./test
a = 2, b = 1, c = 2

... we see both "b=1" and "c=2" are executed, and the last statement
in the comma separated list of expressions is used as the right-hand
value in the "a" assignment.

In the case of this patch, the existing code is actually okay: both
expressions are executed and we don't assign either expression's value
to a variable so it doesn't matter.  However, it definitely looks odd
and is something we should fix.

-- 
paul moore
www.paul-moore.com


Re: [PATCH -next] kernel/audit: convert comma to semicolon

2020-12-11 Thread Richard Guy Briggs
On 2020-12-11 16:42, Zheng Yongjun wrote:
> Replace a comma between expression statements by a semicolon.
> 
> Signed-off-by: Zheng Yongjun 
> ---
>  kernel/audit.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/audit.c b/kernel/audit.c
> index 68cee3bc8cfe..c8497115be35 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -2282,7 +2282,7 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, 
> kuid_t kloginuid,
>  
>   uid = from_kuid(_user_ns, task_uid(current));
>   oldloginuid = from_kuid(_user_ns, koldloginuid);
> - loginuid = from_kuid(_user_ns, kloginuid),
> + loginuid = from_kuid(_user_ns, kloginuid);

Nice catch.  That went unnoticed through 3 patches, the last two mine...
Not quite sure why no compiler complained about it...

Reviewed-by: Richard Guy Briggs 

>   tty = audit_get_tty();
>  
>   audit_log_format(ab, "pid=%d uid=%u", task_tgid_nr(current), uid);

- RGB

--
Richard Guy Briggs 
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635



[PATCH -next] kernel/audit: convert comma to semicolon

2020-12-11 Thread Zheng Yongjun
Replace a comma between expression statements by a semicolon.

Signed-off-by: Zheng Yongjun 
---
 kernel/audit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index 68cee3bc8cfe..c8497115be35 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -2282,7 +2282,7 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, 
kuid_t kloginuid,
 
uid = from_kuid(_user_ns, task_uid(current));
oldloginuid = from_kuid(_user_ns, koldloginuid);
-   loginuid = from_kuid(_user_ns, kloginuid),
+   loginuid = from_kuid(_user_ns, kloginuid);
tty = audit_get_tty();
 
audit_log_format(ab, "pid=%d uid=%u", task_tgid_nr(current), uid);
-- 
2.22.0