From: Aleksei Vetrov <vvvvvv@google.com>
To: Andrej Shadura <andrew.shadura@collabora.co.uk>
Cc: linux-bluetooth@vger.kernel.org,
Nathan Chancellor <nathan@kernel.org>,
Justin Stitt <justinstitt@google.com>,
llvm@lists.linux.dev, kernel@collabora.com,
George Burgess <gbiv@chromium.org>,
stable@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: Fix type of len in rfcomm_sock_{bind,getsockopt_old}()
Date: Mon, 7 Oct 2024 19:49:15 +0000 [thread overview]
Message-ID: <ZwQ7OzSSWZHM4XqS@google.com> (raw)
In-Reply-To: <20241002141217.663070-1-andrew.shadura@collabora.co.uk>
Hi Andrej,
On Wed, Oct 02, 2024 at 04:12:17PM +0200, Andrej Shadura wrote:
> Change the type of len to size_t in both rfcomm_sock_bind and
> rfcomm_sock_getsockopt_old and replace min_t() with min().
rfcomm_sock_bind doesn't use copy_to_user, are you sure it has the same
issue?
> @@ -328,14 +328,15 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr
> {
> struct sockaddr_rc sa;
> struct sock *sk = sock->sk;
> - int len, err = 0;
> + int err = 0;
> + size_t len;
>
> if (!addr || addr_len < offsetofend(struct sockaddr, sa_family) ||
> addr->sa_family != AF_BLUETOOTH)
> return -EINVAL;
>
> memset(&sa, 0, sizeof(sa));
> - len = min_t(unsigned int, sizeof(sa), addr_len);
> + len = min(sizeof(sa), addr_len);
> memcpy(&sa, addr, len);
>
> BT_DBG("sk %p %pMR", sk, &sa.rc_bdaddr);
This change produces a compilation error around min expression, as
"kernel test robot" notices below. And I think rfcomm_sock_bind
shouldn't be touched at all, it doesn't use copy_to_user and doesn't
produce compile errors with latest Clang.
> @@ -729,7 +730,8 @@ static int rfcomm_sock_getsockopt_old(struct socket *sock, int optname, char __u
> struct sock *l2cap_sk;
> struct l2cap_conn *conn;
> struct rfcomm_conninfo cinfo;
> - int len, err = 0;
> + int err = 0;
> + size_t len;
> u32 opt;
>
> BT_DBG("sk %p", sk);
> @@ -783,7 +785,7 @@ static int rfcomm_sock_getsockopt_old(struct socket *sock, int optname, char __u
> cinfo.hci_handle = conn->hcon->handle;
> memcpy(cinfo.dev_class, conn->hcon->dev_class, 3);
>
> - len = min_t(unsigned int, len, sizeof(cinfo));
> + len = min(len, sizeof(cinfo));
> if (copy_to_user(optval, (char *) &cinfo, len))
> err = -EFAULT;
>
This looks ok. But there is the same pattern in rfcomm_sock_getsockopt
(without old prefix) and it also uses copy_to_user and produces compile
error with latest Clang.
Could you remove rfcomm_sock_bind patch and apply it to
rfcomm_sock_getsockopt instead? Or I can send my version of the patch:
we've encountered the same compile errors in rfcomm_sock_getsockopt and
rfcomm_sock_getsockopt_old after updating Clang and would like to get it
fixed.
next prev parent reply other threads:[~2024-10-07 19:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-02 14:12 [PATCH] Bluetooth: Fix type of len in rfcomm_sock_{bind,getsockopt_old}() Andrej Shadura
2024-10-02 15:22 ` Nathan Chancellor
2024-10-02 16:29 ` Andrej Shadura
2024-10-02 16:45 ` Nathan Chancellor
2024-10-04 8:41 ` kernel test robot
2024-10-04 15:13 ` kernel test robot
2024-10-07 19:49 ` Aleksei Vetrov [this message]
2024-10-09 12:01 ` Andrej Shadura
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=ZwQ7OzSSWZHM4XqS@google.com \
--to=vvvvvv@google.com \
--cc=andrew.shadura@collabora.co.uk \
--cc=gbiv@chromium.org \
--cc=justinstitt@google.com \
--cc=kernel@collabora.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=stable@vger.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).