Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp64864ybm; Thu, 28 May 2020 16:12:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9aiI476vQrLN/jNC6m4W8PoI+mh+4+R6PS8azg0JQ8pKTiREAWO1lWb6eYveb7cI+V3ZN X-Received: by 2002:a05:6402:1bd9:: with SMTP id ch25mr5400009edb.15.1590707533542; Thu, 28 May 2020 16:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590707533; cv=none; d=google.com; s=arc-20160816; b=XbdPbShZKUoad3KYLlmljZcDFf+CdB9Ar8lN+HYrpvsgD/Dnlziy0BMIymzI69YIQ3 ZTwr1UJZjFqT9cPOqjZT1sNDpesgbJlfLeplkQzdM/iBGBUt8Sb9+ducaC1RyWgGaz3a +rJ5LRNkI4UEk05hsWJCRPXXtcrtVynCS268uOmV9G5UYbOf5h3b0Dqj9a3gv7QVwChS yDQEUnjG+7a3hfuxoruGhbI1Gpa17INABQxTEZdOaMrEoV99o5mHrz/7Yz/NOX0jWDFx xrYonwIi2VEj+nNhMEYnaOUp/wCZFW8bLTrCygUuwUY4BvqfwGGFpCF7AqrnLhzD5Wo/ UuFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=2dnQmLcNwbQCSIJxeSwlgwxT1s89DA1/++ZPTT1pghI=; b=xKYa4idbtJBdRWHRMmrffIUPaPIerD4tlpvANbXxza8TPJzKqF1TXoKxfDyO61GfhA SJCtyz88R0c4GTUt7Bh+jxVsBT+utMgtj/isuydDNgTHl+D+e7viavrKno/zZa/UHuwz 5T+EN7nUWMPvQS1QdiE91PdWnvrn2CPiZCg9K0z3INwRD3k5tkcOhI53l8C/U8INyHul UmJ1VLoTQp320el11LUDDiPMXMYFaZCQ3EteosoRpFSmQhht+Yue14ikz2hayolId+n3 AtJkkeIBz2QlJbnDvQPgxx/x65P1EdMBkyY8RH1/fIKzm82gaXcYvyZlthIpO5JVVf+L /g9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=dNV+oUPb; 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 f25si1938404ejb.695.2020.05.28.16.11.48; Thu, 28 May 2020 16:12:13 -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=@joelfernandes.org header.s=google header.b=dNV+oUPb; 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 S2437428AbgE1XJI (ORCPT + 99 others); Thu, 28 May 2020 19:09:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437333AbgE1XJB (ORCPT ); Thu, 28 May 2020 19:09:01 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E167C08C5C7 for ; Thu, 28 May 2020 16:09:01 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id z80so637840qka.0 for ; Thu, 28 May 2020 16:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2dnQmLcNwbQCSIJxeSwlgwxT1s89DA1/++ZPTT1pghI=; b=dNV+oUPbMYnX3ZVWLV7i45oA5InzscTd+GbDZvrGNuYf/NfzEFogrtiKH0tdUm0cxm LbQUylckxhhhOs8hrestvkZsG8sn1OmP4VJGq/clZ11NSLg5ObOKicUC2wzcC1ySEkY1 UW2ORv4VqdAvZIdt3CwLn/kwDJ8BqfX+dQpc0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2dnQmLcNwbQCSIJxeSwlgwxT1s89DA1/++ZPTT1pghI=; b=MgXHLine9WUMDjJolqXy3GQsecoF9oXw1PGgIIuMm8TlFkSVbIEiDw2SbBZ3TBf98u f9OLmcmMA2UM4m/Pcsx1Juy8IYs0AuoNlN67Obccof5LgIVAij5dnf88bTAB+BVHs1N0 LSxEaWIEqUcfjVMS7Zj8ZevyRd03WqCK9k5CUAOnwIPBmuuz7vD52URgzt78QwHwhlVm 6wfSn4avD42PpX/TnAm8e6EQO9wN0D0dFE129bvFVS/eEYUr6DFpDa18eZ51vYCXwy/1 6xWVmYnFhTEYYbkX9BoBwSR+MIGLsj58u3cONic091YgVFuCf45JBC4rwWcPk6MI5rSt vbjA== X-Gm-Message-State: AOAM531ioRIPF2tNOkad4CxJww2uMSN7+9Lav0auwUvDBDNnRPaC2QiR 9V8+wa2BZDfZflkNT8n3JAcMtg== X-Received: by 2002:a37:46c1:: with SMTP id t184mr5479963qka.192.1590707340169; Thu, 28 May 2020 16:09:00 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id a1sm6383240qtj.65.2020.05.28.16.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2020 16:08:59 -0700 (PDT) Date: Thu, 28 May 2020 19:08:59 -0400 From: Joel Fernandes To: Linus Torvalds Cc: Linux Kernel Mailing List , matthewb@google.com, Jesse Barnes , vapier@google.com, Christian Brauner , vpillai , vineethrp@gmail.com, Peter Zijlstra , stable , Greg Kroah-Hartman Subject: Re: [PATCH] sched/headers: Fix sched_setattr userspace compilation breakage Message-ID: <20200528230859.GB225299@google.com> References: <20200528135552.GA87103@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Linus, On Thu, May 28, 2020 at 03:21:56PM -0700, Linus Torvalds wrote: > On Thu, May 28, 2020 at 6:55 AM Joel Fernandes (Google) > wrote: > > > > On a modern Linux distro, compiling the following program fails: > > #include > > #include > > #include > > #include > > You shouldn't include kernel headers in user space - that's the job of > glibc and friends. Ah, my bad. Sorry I read the docs now and looks like I got it all backwards. > > > --- a/include/uapi/linux/sched/types.h > > +++ b/include/uapi/linux/sched/types.h > > @@ -4,9 +4,11 @@ > > > > #include > > > > +#if defined(__KERNEL__) > > struct sched_param { > > int sched_priority; > > }; > > +#endif > > This makes no sense. > > The point of a 'uapi' header is to export things to user space. Yes, > they sometimes mix kernel-internal thngs in there (because of how they > were created by just moving kernel headers to the uapi directory), but > that ' struct sched_param' is very much part of the very interface > definition that that file is all about exporting. > > 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. > The glibc-provided "" should have been where you got all > these declarations and #defines from, and the point of the uapi file > was always to help glibc (and other library implementations) get them > from the kernel. 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. > > So why are you including kernel header files and mixing them with > system-provided stuff? The include of does not result in availability of the sched_attr header. 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. Sorry that this patch is wrong, I'll try to fix it the right way. Thanks for your help. thanks, - Joel