Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp81795ybm; Thu, 28 May 2020 16:40:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLV9d0sv/M/3S/3ECHYNCa4eBzXwrG0yyOzK1JplKL1jQlw4aTHQUZCj6tgsVE1nL8G4vc X-Received: by 2002:a50:eacb:: with SMTP id u11mr5559324edp.162.1590709212889; Thu, 28 May 2020 16:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590709212; cv=none; d=google.com; s=arc-20160816; b=JUCGRnvrva7kxHx0mvvfWJr3zIdp/YLhx4lYrlh+dRoLDnRCBcgoU2C57ndRAPuz0X hgZnqnp6avJrUyC+lywLcN9wDwrJqQHsaef/bFvIk+p2E5rMdsCNoUhShjgdA7roaGen dOgA7fZ67ASdbTV1I3k9UwWwQvHMNp3E/bJrTvLLajYGSszedMWBWbSpb+1T2q4WIEB5 bxrWJE6PK7t5wNGwa75QJVwKhlrunIvenAeId4Rh9Zb3qdtFBa4P8+Z6oiDyr1+Hzga/ GcJJrNT4ngWE1QvcMCqtVjeRKkLrBkSug1GyrfTY/o56EINX5//Fv8+9wyWO6tk21xmL J+rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=lvntbN5poYtMfSoKiCXpDz0H9PHNUtXkgX3txl3QBqg=; b=RxzzFLBSYjIvV217vJ6lnjPNKSOUXOl5oj8vIDj9wSAFdVthFzHNdYw5VwR5PNTtm8 IphPI5Mpns3FkgqKgUtDbY5xD0Sb+n6iY3NI+aHacfOCIVuqQ92I6aHxQ8sr4q+XqUNS 1+wXelFQeXsazun2sCcU7RD3vyEY5SGQNQuj3Gi6ZBLzn8j816RYtUB5OHIsCr8xBIua nhcQHR9RNwzT2pkMaBPjfG50pNB7PtJLSIof+bSZ5XLqMPqZguucg2OU2iw6dtdlz8Rq l/vvHi1klJ9QlxjfF1ioXBCFuJwt0hLTZmczu+YsFisgxoCRsMXMkEjIH7fwJSImNpvm +Pmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Owg3ySC8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z17si4574299ejf.735.2020.05.28.16.39.34; Thu, 28 May 2020 16:40:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Owg3ySC8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437593AbgE1XXu (ORCPT + 99 others); Thu, 28 May 2020 19:23:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437490AbgE1XXs (ORCPT ); Thu, 28 May 2020 19:23:48 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71249C08C5C7 for ; Thu, 28 May 2020 16:23:47 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id r125so147472lff.13 for ; Thu, 28 May 2020 16:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lvntbN5poYtMfSoKiCXpDz0H9PHNUtXkgX3txl3QBqg=; b=Owg3ySC84uxhuGKf6i2dNH2q/RD4VDxW4n+bdjTUEA6SmcwJChlGAG9o1ZFxzpK1Nh nY6SPtEKeisN9g2MeJWXi6V8e9llGjbJu5nh52W1rAF6P824ju3OUk4J4RBFThk0Muul r/SE9uKEOWNO53I3VkXf8ZjvR0cIpy6y6Gck4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lvntbN5poYtMfSoKiCXpDz0H9PHNUtXkgX3txl3QBqg=; b=aIilD3Ry34MTQqcay0WJ+idSUQtjkqnSiD3rF/JCw6ncbzO7qOCU6wjDvaESguukEM xGx1NFQudjhCGgHyHS1OBrvD/54SoVVGhIkKxGLHfJly+sKyLEDrB3stM6+MtO26dst1 1iKTCqtckGPerZC85ogrcpqlB0ak72YXqTiYGcRLiIxwRAcCO9+kihZBZ/b6zdtls60C y8AaeZpMRxnffqvEnRPf28brCAarBS5PDZ7W2qa0+I77ONuM0WtSV1kw4q12nL9h/SmO /3uLZa6qD1RJlXlg0MI0OCygIOmCgnW/7SXhYIoq8YPWctT9A4qnYjrI4FJqE3iXoBqg mOmw== X-Gm-Message-State: AOAM530QyPod/vVyZ69sKf9PUIe+HeM7aj2S617EOW2rT6TS6aKxPwV+ jBrIuZUVRsnpXIFGLblm1ogmWyKG0bc= X-Received: by 2002:a19:6e0e:: with SMTP id j14mr2883386lfc.155.1590708224501; Thu, 28 May 2020 16:23:44 -0700 (PDT) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com. [209.85.208.169]) by smtp.gmail.com with ESMTPSA id v7sm1687787ljv.40.2020.05.28.16.23.42 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 May 2020 16:23:43 -0700 (PDT) Received: by mail-lj1-f169.google.com with SMTP id z13so275627ljn.7 for ; Thu, 28 May 2020 16:23:42 -0700 (PDT) X-Received: by 2002:a2e:b16e:: with SMTP id a14mr2499699ljm.70.1590708222167; Thu, 28 May 2020 16:23:42 -0700 (PDT) MIME-Version: 1.0 References: <20200528135552.GA87103@google.com> <20200528230859.GB225299@google.com> In-Reply-To: <20200528230859.GB225299@google.com> From: Linus Torvalds Date: Thu, 28 May 2020 16:23:26 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] sched/headers: Fix sched_setattr userspace compilation breakage To: Joel Fernandes Cc: Linux Kernel Mailing List , Matthew Blecker , Jesse Barnes , Mike Frysinger , Christian Brauner , vpillai , vineethrp@gmail.com, Peter Zijlstra , stable , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 28, 2020 at 4:09 PM Joel Fernandes wrote: > > > So no, this patch is fundamentally wrong. It negates the whole point > > of having a uapi header at all. > > Sorry, I naively assumed that headers in 'include/uapi/' are safe to include > from userspace. I feel terrible. Well, they "kind of" are safe to include. It's just that normally they are meant for system integrators to include as part of the system header files. So they are designed not to be safe for normal programs, but for library writers. And to make things more confusing, sometimes people _do_ include kernel header files directly, just because they want to get features that either haven't been exposed by the system libraries, or because the system libraries copied the uapi header files for an older version of the kernel, and you want the shiny new feature, so... And some of those header files are easier to do that with than others... > The problem is still does not get us 'struct sched_attr' even > though the manpage of sched_setattr(2) says including is all that's > needed. Ouch. But clearly you get it from -somewhere- since it then complains about the double declaration. Strange. > Also, even if glibc included 'include/uapi/linux/sched/types.h' to get struct > sched_attr's definition, we would run into the same issue I reported right? > The 'struct sched_param' is already defined by glibc, and this header > redefines it. That's kind of the point: glibc sets up whatever system headers it wants. The uapi ones are there to _help_ it, but it's not like glibc _has_ to use them. In fact, traditionally we didn't have any uapi header files at all, and we just expected the system libraries to scrape them and make their own private copies. The uapi headers are _meant_ to make that easier, and to allow system headers to then co-exists with the inevitable "I need to get newer headers because I'm using a bleeding edge feature that glibc isn't exposing" crowd. Put another way: a very non-portable programs _could_ include the uapi headers directly, if the system library headers were set up that way. More commonly, what bleeding edge people do when the system header files don't play nice, is to just build their very own libraries and copy the bleeding-edge features directly from the kernel. So you'll find things like #ifndef __NR_clone3 #define __NR_clone3 435 #endif syscall(__NR_clone3, ...); in user space that wants to use the clone3 system call, but knows that it hasn't made it into the glibc headers yet, so the program just forced the local knowledge of it. That's obviously generally easier to do with macro defines like the above, exactly because you can trivially _test_ whether they've been exposed or not. So yes, this is a horrid mess. But the *intent* is that the uapi header files should be things that system library implementations can just use directly, and then the "special" users could mix-and-match if everything is wonderful. Which it seldom is. But that's why putting those interface declarations inside a #ifdef __KERNEL__ would completely destroy the whole point. Linus