linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: David Gow <davidgow@google.com>
Cc: Jeff Dike <jdike@addtoit.com>,
	Richard Weinberger <richard@nod.at>,
	Anton Ivanov <anton.ivanov@cambridgegreys.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	x86@kernel.org, linux-um@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] um: Cleanup syscall_handler_t definition/cast, fix warning
Date: Thu, 17 Feb 2022 09:29:14 -0800	[thread overview]
Message-ID: <202202170928.F02D6F41@keescook> (raw)
In-Reply-To: <20220210034353.1065703-1-davidgow@google.com>

On Thu, Feb 10, 2022 at 11:43:53AM +0800, David Gow wrote:
> The syscall_handler_t type for x86_64 was defined as 'long (*)(void)',
> but always cast to 'long (*)(long, long, long, long, long, long)' before
> use. This now triggers a warning (see below).
> 
> Define syscall_handler_t as the latter instead, and remove the cast.
> This simplifies the code, and fixes the warning.
> 
> Warning:
> In file included from ../arch/um/include/asm/processor-generic.h:13
>                  from ../arch/x86/um/asm/processor.h:41
>                  from ../include/linux/rcupdate.h:30
>                  from ../include/linux/rculist.h:11
>                  from ../include/linux/pid.h:5
>                  from ../include/linux/sched.h:14
>                  from ../include/linux/ptrace.h:6
>                  from ../arch/um/kernel/skas/syscall.c:7:
> ../arch/um/kernel/skas/syscall.c: In function ‘handle_syscall’:
> ../arch/x86/um/shared/sysdep/syscalls_64.h:18:11: warning: cast between incompatible function types from ‘long int (*)(void)’ to ‘long int (*)(long int,  long int,  long int,  long int,  long int,  long int)’ [
> -Wcast-function-type]
>    18 |         (((long (*)(long, long, long, long, long, long)) \
>       |           ^
> ../arch/x86/um/asm/ptrace.h:36:62: note: in definition of macro ‘PT_REGS_SET_SYSCALL_RETURN’
>    36 | #define PT_REGS_SET_SYSCALL_RETURN(r, res) (PT_REGS_AX(r) = (res))
>       |                                                              ^~~
> ../arch/um/kernel/skas/syscall.c:46:33: note: in expansion of macro ‘EXECUTE_SYSCALL’
>    46 |                                 EXECUTE_SYSCALL(syscall, regs));
>       |                                 ^~~~~~~~~~~~~~~
> 
> Signed-off-by: David Gow <davidgow@google.com>

Thanks for this! I was just about to go figure this out too. :)

Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

      reply	other threads:[~2022-02-17 17:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10  3:43 [PATCH] um: Cleanup syscall_handler_t definition/cast, fix warning David Gow
2022-02-17 17:29 ` Kees Cook [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202202170928.F02D6F41@keescook \
    --to=keescook@chromium.org \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=davidgow@google.com \
    --cc=jdike@addtoit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=viro@zeniv.linux.org.uk \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).