Received: by 10.213.65.68 with SMTP id h4csp33277imn; Mon, 19 Mar 2018 18:36:39 -0700 (PDT) X-Google-Smtp-Source: AG47ELucWhtJUgY4yYCu0ZHOdolr75obDbPXjWbDEGcwPfBoJ4Rh+UeTUPZg4njBnaX3B5VVx8zF X-Received: by 2002:a17:902:6c48:: with SMTP id h8-v6mr9007373pln.33.1521509799848; Mon, 19 Mar 2018 18:36:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521509799; cv=none; d=google.com; s=arc-20160816; b=Q77/F3uIAB4ptl0X29pRbXCsS6HBiJ8HdbJXZpFvUXkf5uicg2i+N5ACmB1LXwy4S1 G+z5Pbny6TgF2k37GlNRiRKiSPmbe7DuzKdQoOfd2321Ov2wGPRqEiFLA/arPuWYjRem yBukYOaWFjwrpCEZdb/xNzsxbTtDCiXKFsg7COtFuNo32Jo1cLvXqq2nbkn/WhHTU4rU apeIpRvOhkoE0cuoZSXqjjmecyiN5wupd65fhm+NuxGq09jn4z2VyxJe14ji5LZZ/6wk dxDEj6TblwaHcGGLGcAbBdmNShMutsDuA+yDG86plvUdq2Z89Z2TxC4042HQrrvfQZr+ 9yEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=CZ8XzUgUuoB1uieydTG+jOS9tM92U1ll6acT9AN6Uls=; b=vc2soKQjFvmBOy8j2W3yqnSMesoxReeumAwQjvw2T+yAQ1CENeIyXKxi0Ep7Vx8kP9 f7P1+Yhg33Xn/F3O7gBmm+upMMBVroYh4akymyV6dK6vGBVUV7r+vYJWRvBy5qbBCZPx xrrcLa1PxLLFWz+CcP8kiVBz0+J4ahKoTUhp5LytasnDj+X/8CDd5mYwIaaYVW7ytsIF YmSpOPy2h/bKC5LFVkKvPMbWlcVD0wFRHOOqPxWNs5MvWYQ+EOBWocemQxgx3Vvu2dN6 4I0wCCr7NNRA8U4SSmW1ppCP8PpqX+Fc9tt7aYlWC4fU9cujZDyDRjsVDFF4VSoEGjW5 kwtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=dTcZryE/; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4-v6si561302plm.660.2018.03.19.18.36.26; Mon, 19 Mar 2018 18:36:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=dTcZryE/; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966759AbeCSQLb (ORCPT + 99 others); Mon, 19 Mar 2018 12:11:31 -0400 Received: from mail-bn3nam01on0110.outbound.protection.outlook.com ([104.47.33.110]:35072 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966536AbeCSQJ4 (ORCPT ); Mon, 19 Mar 2018 12:09:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=CZ8XzUgUuoB1uieydTG+jOS9tM92U1ll6acT9AN6Uls=; b=dTcZryE/DsJkDhXUZiv0hHjGrr+OZarf6LZ+fOc0kAgIos3hJPHiCR+Ylm+nsgGwDVtt/LadrWX4RqskMebbEmFC/N3XuL/gBj7sLcypCCQioRat9E4/7m1EeIWjjn7qIANaDD0hrNAlWiQj4Exv1shtqXaOo9gLp1WHuBJlHBM= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1095.namprd21.prod.outlook.com (52.132.130.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.0; Mon, 19 Mar 2018 16:09:52 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 16:09:52 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Miklos Szeredi , Sasha Levin Subject: [PATCH AUTOSEL for 4.4 099/167] ovl: filter trusted xattr for non-admin Thread-Topic: [PATCH AUTOSEL for 4.4 099/167] ovl: filter trusted xattr for non-admin Thread-Index: AQHTv5xfai/CuIT3CUWUgLLDkcW18g== Date: Mon, 19 Mar 2018 16:07:25 +0000 Message-ID: <20180319160513.16384-99-alexander.levin@microsoft.com> References: <20180319160513.16384-1-alexander.levin@microsoft.com> In-Reply-To: <20180319160513.16384-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1095;7:F3eEosKGinlY2qGY7fcBEoHl+QCYF/Ky2/yJkQeLbx3tP6oxm0HNEQ5FPCI7a5pyRgXSBCoGJMfcBJ92vkbB2Ty+ZiSsP6aGlMF2/dZVRwvpILPdmRyKYiORgNdgH38Sr6kjH9Vp7d9OGG35sdLaieTmwRNJDkBlXAWxU0nkKzfsHbhBnf1Y3HQUX6JK21kEUGu9DqmpkAAohvJOOAGc/tjn7SNMMfLJ+VDH0n2aJ9T1kFh0+vDfsu+qJFg98igi;20:dKl+S3HjEFgbqn4Q1LjIgRICP3DfKQdTptTSUVAx2Nx7IeMH0maUJSkxzqtKzoF2/gc0/2NqCuAnubPAlEPStcWmkOgsnNIiWNFNN3Cvf3qQPy3hxRa/+ms+KrNwnwDMO8ddXo/Y24Jr9fl0HPCg5cpn1PeUPqpVE3mOsYY+aHI= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: e336fb05-f338-4c9e-a512-08d58db3d939 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1095; x-ms-traffictypediagnostic: DM5PR2101MB1095: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501300)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB1095;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1095; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(346002)(366004)(39860400002)(396003)(39380400002)(189003)(199004)(305945005)(316002)(1076002)(7736002)(14454004)(86612001)(25786009)(8936002)(2950100002)(110136005)(66066001)(186003)(10090500001)(6666003)(5250100002)(2501003)(99286004)(76176011)(86362001)(4326008)(68736007)(3660700001)(105586002)(8676002)(81166006)(81156014)(106356001)(3280700002)(72206003)(10290500003)(478600001)(2900100001)(59450400001)(97736004)(54906003)(6512007)(53936002)(6506007)(102836004)(6436002)(5660300001)(6486002)(107886003)(26005)(2906002)(22452003)(6116002)(3846002)(36756003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1095;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: GeAYIATjwaeBSiEbAZUUuNNo8dNsRbh2W29QdM2fT1mAVxBErOmS7JLqpuwKpaGz3Rn4ggUFtTCkssm2byiV5jDE8jHeJK2+xXvnDEpR0tKDeAmkBTTg/f1wDQB9G8g0olnFOly5HxDlmkuqiCQf8arvmz0984ToTfK89/OUDjS4VICU1kK7uu15NfcUCO4r6uT7+KpfMUx9Rv4cqvgx51+fewDYLFf9A4JwW2HZLgFHIIbJZ8WQED2/nRECWzkQ74vO1u1LGVYRljWlI7DvrhaPqkU4E0EujIzJ93WEUigGKRrHNL4R+cBDThst0r9FtT7FMEnNAYvYI89TEktJDg== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: e336fb05-f338-4c9e-a512-08d58db3d939 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 16:07:25.9630 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1095 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miklos Szeredi [ Upstream commit a082c6f680da298cf075886ff032f32ccb7c5e1a ] Filesystems filter out extended attributes in the "trusted." domain for unprivlieged callers. Overlay calls underlying filesystem's method with elevated privs, so need to do the filtering in overlayfs too. Signed-off-by: Miklos Szeredi Signed-off-by: Sasha Levin --- fs/overlayfs/inode.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 220b04f04523..985a4cdae06d 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -272,6 +272,16 @@ ssize_t ovl_getxattr(struct dentry *dentry, const char= *name, return vfs_getxattr(realpath.dentry, name, value, size); } =20 +static bool ovl_can_list(const char *s) +{ + /* List all non-trusted xatts */ + if (strncmp(s, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) !=3D 0) + return true; + + /* Never list trusted.overlay, list other trusted for superuser only */ + return !ovl_is_private_xattr(s) && capable(CAP_SYS_ADMIN); +} + ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size) { struct path realpath; @@ -296,7 +306,7 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list= , size_t size) return -EIO; =20 len -=3D slen; - if (ovl_is_private_xattr(s)) { + if (!ovl_can_list(s)) { res -=3D slen; memmove(s, s + slen, len); } else { --=20 2.14.1