linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
Cc: linux-can <linux-can@vger.kernel.org>
Subject: Re: Breaking UAPI change?
Date: Wed, 24 Mar 2021 20:21:46 +0100 (CET)	[thread overview]
Message-ID: <1135648123.112255.1616613706554.JavaMail.zimbra@nod.at> (raw)
In-Reply-To: <20210324190104.GB3342@x1.vandijck-laurijssen.be>

Kurt,

----- Ursprüngliche Mail -----
>> commit f5223e9eee65 ("can: extend sockaddr_can to include j1939 members")
>> increased the size of
>> struct sockaddr_can.
>> This is a problem for applications which use recvfrom() with addrlen being
>> sizeof(struct sockaddr_can)
>> or sizeof(struct sockaddr).
>> If such an application was built before the change it will no longer function
>> correctly on newer kernels.
> 
> This scenario was identified, and explicitely dealt with.
> This requires a tiny bit different code, i.e. net/can/raw.c should use
> REQUIRED_SIZE() instead of sizeof() for testing the size of the address
> structure.
> 
>> In fact I ran into such a scenario and found the said commit later that day.
> 
> Looking to the v5.10 kernel (which I happen to have checked out),
> your claim indeed seems true, the raw_recvmsg does not (raw_bind and
> raw_sendmsg work correct, but that's not important for your problem).
> 
>> 
>> Is this a known issue?
> 
> It wasn't, until you found it :-)

Thanks for the prompt reply!
 
>> Or is this allowed and application must not use sizeof(struct sockaddr_can) as
>> addrlen?
> 
> sizeof(struct sockaddr_can). As you already mentioned, applications may have
> been built
> before the size increase, and so they should not be recompiled.
> 
> 
>> If so, what is the proposed way to avoid future breakage?
> 
> Your application should not change. Kernel must be fixed.

Feel free to CC me when you submit a patch, I'll happily test it.

Thanks,
//richard

  reply	other threads:[~2021-03-24 19:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24 15:30 Breaking UAPI change? Richard Weinberger
2021-03-24 19:01 ` Kurt Van Dijck
2021-03-24 19:21   ` Richard Weinberger [this message]
2021-03-24 19:27     ` PATCH: " Kurt Van Dijck
2021-03-24 19:47       ` Richard Weinberger
2021-03-24 20:26       ` Oliver Hartkopp
2021-03-24 21:59         ` Oliver Hartkopp
2021-03-25  8:01         ` Kurt Van Dijck

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=1135648123.112255.1616613706554.JavaMail.zimbra@nod.at \
    --to=richard@nod.at \
    --cc=dev.kurt@vandijck-laurijssen.be \
    --cc=linux-can@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).