From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68719C3A5A1 for ; Wed, 28 Aug 2019 20:28:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 43FC42189D for ; Wed, 28 Aug 2019 20:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbfH1U2v (ORCPT ); Wed, 28 Aug 2019 16:28:51 -0400 Received: from s3.sipsolutions.net ([144.76.43.62]:42268 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726315AbfH1U2t (ORCPT ); Wed, 28 Aug 2019 16:28:49 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.92.1) (envelope-from ) id 1i34Yf-0000AZ-9X; Wed, 28 Aug 2019 22:28:45 +0200 Message-ID: <8fc1716ca0dd522b7149160be02aed5f8cd1c882.camel@sipsolutions.net> Subject: Re: [PATCH v2] cfg80211: add local BSS receive time to survey information From: Johannes Berg To: Marcel Holtmann Cc: Felix Fietkau , linux-wireless@vger.kernel.org Date: Wed, 28 Aug 2019 22:28:43 +0200 In-Reply-To: References: <20190828102042.58016-1-nbd@nbd.name> <9189B2C1-6E5B-4457-9354-A010F946EE33@holtmann.org> <18c4232675c7b4f13fbfe9e5d8e9364a0908f316.camel@sipsolutions.net> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5 (3.30.5-1.fc29) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Wed, 2019-08-28 at 22:24 +0200, Marcel Holtmann wrote: > Hi Johannes, > > > > > No, as usual, that would break ABI. PAD is a regular attribute, just > > > > empty and ignored for aligning 64-bit values. > > > > > > then I do not grok on how the nla_put_u64_64bit works, but that is > > > fine. > > > > > > I assumed these are similar to the NL80211_SURVEY_INFO_MAX which we > > > also always move, but also not expected to be part of the API as a > > > fixed value. > > > > No no, the _MAX is just the token we use for knowing what we want as the > > maximum when parsing etc. > > > > The _PAD is actually a real attribute, basically nla_put_u64_64bit() > > will do "nla_put_flag(_PAD)" if and only if "offset % 8 == 0", in order > > to actually 64-bit align the 64-bit value in the following attribute. > > > > (Note that offset % 8 can only be 0 or 4, due to the way netlink > > attributes work.) > > I get that part now. So the kernel is inserting a _PAD, but userspace > is still not doing that. Yeah, and I forgot to say - if we renumbered _PAD, then newer userspace would think old kernel's _PAD is really _BSS_RX, so things would break. > So for NL80211_ATTR_WDEV we should be doing the same actually? Not really. The kernel doesn't rely on it, nla_get_u64() uses nla_memcpy() so doesn't care about alignment. Even userspace doesn't (usually) rely on the alignment, it also typically uses nla_get_u64() from libnl which also uses nla_memcpy() or memcpy() (depending on the version), so it's all not really necessary. I think some libraries or tools like maybe iproute2 didn't do it correctly and just dereferenced a pointer there, causing alignment violations, and so basically the decision was to get rid of unaligned 64-bit attributes to prevent that once and for all. johannes