Hello, On Wed, 24 Mar 2021 16:30:58 +0100, Richard Weinberger wrote: > Hi! > > 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 :-) > 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. Kurt