From patchwork Thu Jul 11 13:48:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Szpetkowski, Grzegorz" X-Patchwork-Id: 13730739 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A796B15ECF9 for ; Thu, 11 Jul 2024 13:48:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=192.198.163.15 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720705694; cv=fail; b=h4mDKIIJ/pTAArjM95Eaf/Zjs49nRZFCcf/hF7R7Bmr2eOlgOf886HPyZeXKUZ5SCK6Em7IXHBf6551swrGBTKIP9miZGTFHHm3L53s2LmVIwBi3uvGrSuR/wr4uJQR6dD/7OmjTDJyLofLu4SFy1+3Kqlv3YU64eXMIteaThRM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720705694; c=relaxed/simple; bh=2CnLGt/5Py7MerKhTPvT8kUL9FCYMxnOic7JYL8Cing=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=J7ej5QmpA/5R2rO5FWx88HjZD0iXKsnAa6KjWn1F+V0B9pGd1uOVgsEpMIR6Q35mFlutsPq+ezcTWd32plqXZTGp70CLV16ipuD4A8CbmQhLH+I3zWJx11cGfCKC0mqNodrprGETgbxpounpErH58DWv4FHLctzDt+K4E+LMKfg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bv8j9Nqn; arc=fail smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bv8j9Nqn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1720705693; x=1752241693; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=2CnLGt/5Py7MerKhTPvT8kUL9FCYMxnOic7JYL8Cing=; b=bv8j9NqnXITRroJKy/2KpPU9e4IDIuEufBSkZJaeTSvwZqwU0XpshoIe xeW0/v36QYfQbT1ZbR3ZR30MTQQXgATLbIriTjjNYOPxXwOhcOw0tr/73 U1z1xaVFM5QzYHLUA35/1o8td0ikZ33+kfFAW003ev2t9vXV+2BTqJQRI kbbwvAfnc6pmaY9iQu9DWkyAH05N1WzmD300sSIakrkNKQqBr5gjhOO2N moPT3guFncs6JhJbobiVkzhJT1S9/1z6pXchFe4r73UdyE3UQk+XNnJ2L JDzyLH4dI+mqcEvG1OUNut+/cHycm2poeVEQvzfg+SQT+Uy3b6IEAmtWP w==; X-CSE-ConnectionGUID: SsOYF0JfRNyT1tg5pu4LVg== X-CSE-MsgGUID: gefLFI7uQ3aT2JuVXRmVXA== X-IronPort-AV: E=McAfee;i="6700,10204,11130"; a="18228318" X-IronPort-AV: E=Sophos;i="6.09,200,1716274800"; d="scan'208";a="18228318" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2024 06:48:12 -0700 X-CSE-ConnectionGUID: t0nh+Qr9T7iOEGMNFHD1QA== X-CSE-MsgGUID: md4W+SqmSKeLnQTD/bd5NQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,200,1716274800"; d="scan'208";a="49205356" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orviesa007.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 11 Jul 2024 06:48:12 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 06:48:11 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 11 Jul 2024 06:48:11 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.40) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 11 Jul 2024 06:48:10 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OHSecL6GuKUpVncZhYvd2mWX0waiEW4dID6d9MyshHCemecn9KKFbQu4aRyG2VgBIpmXPMt44rDfH44FIKoaeZpB51z3rKyjOmJ9ZEJQPwpa8yggaEhhvyBfakgHtsugbvlSBPqRPGsLBJr3TAd72gnMM0wHSgefs1TNte9DXOORAvFI9Hy3YHHndk4pBajuAZJVO8pOI8cFzgi9TPmA6eJPJkKPL0c9hpE3cLUbHL01spyeiasCshiU4iOc5Kp9c69GL5PvrQD5sZ/wwtJhHaSqPBZ3BHGNJwyqYz/2lQiuIrnyfLAFk8EgYMsSaoEfstuWlEjHESiLQF93rqVPsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ncyu1A59gE0/yCjIjDqGSxH3bNo8TicUF/FjUfoeuyo=; b=Z3FaWZJcvajHKT6NhjYp+KyONDXVFs2CdvqwI9IKaBOqw3gZeuzz2BvrkoqqLWuKZaV4y2JhhtEW1+VJ3K1oBBk0JyXcKKumCgNHH6QhARPvQWob/lRMB2ti2OgQI0fdk4XBuC1j0f5mv1z+zoIe6zSUgs/5zEkl/oeunaa3jzLkz6vsDbZACxfLpd61Y7a0YJPwS24b4ap5blh3rv0Xt7lB4lvGn4PkkWgqY/dW8OKoVcVaxB5FQEmEYMF4SH2h7TuQLOnbZJsbH3zM5BsCKZdib+lHz1+vjIGs85Vy4vccvp6uspxEc2ZqnVt6CrHDNPwY2yjPld9SJmbVh5Zddw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from CY5PR11MB6186.namprd11.prod.outlook.com (2603:10b6:930:26::13) by IA0PR11MB7861.namprd11.prod.outlook.com (2603:10b6:208:3de::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.20; Thu, 11 Jul 2024 13:48:07 +0000 Received: from CY5PR11MB6186.namprd11.prod.outlook.com ([fe80::a160:7779:5bfe:52a9]) by CY5PR11MB6186.namprd11.prod.outlook.com ([fe80::a160:7779:5bfe:52a9%4]) with mapi id 15.20.7762.016; Thu, 11 Jul 2024 13:48:07 +0000 From: "Szpetkowski, Grzegorz" To: "netdev@vger.kernel.org" Subject: [PATCH net] net: core: sock: add AF_PACKET unsupported binding error Thread-Topic: [PATCH net] net: core: sock: add AF_PACKET unsupported binding error Thread-Index: AdrTmOy3j2HXYBmKTiOYlXlncLPlLg== Date: Thu, 11 Jul 2024 13:48:07 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CY5PR11MB6186:EE_|IA0PR11MB7861:EE_ x-ms-office365-filtering-correlation-id: 00538dda-8d53-4990-ace2-08dca1b0188b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|376014|1800799024|366016|38070700018; x-microsoft-antispam-message-info: lGhbxyAxfuqe+h9rnLZ+PVqrU9rbbS7znmcSEm3yTH7XgHFzdbokVlHniP6rEijkwU3QpRWho77lFVppTQ7mlgARaxJ0FxW9Eq0zfpcGesnG20/sNFrWmz8W5PPuK+4iBdOU8c6Wn93LhxvO+MUuWC4XZL8oK+yjSY97SHObKMX4gFKm2AVrGU34Z9jB5YhB+RdBHWEwywCoF+2HxAnvs9VNB1mzshOL6wUZFA6DdTVIwciJXqhbv7LztaWIGIbLMFOc5zwKGW0Qfx/uVMDmKiW9GoSuGrRwdQaRwAzUA6uhVitessWGXRlr3vdVxf4kQCuOV1nTZpS0BoiqPAzwykDeiFO9ZN76lJ/2RXe/SUMG2g4g5WLr7MWRtR5pRKdi71Fd7It9wpAAHT1u3nz2hf59445bwHA2zgS0N/vKwI9LpRLsTOlEssIsbbT9uWuFMpzFJxmfYEenrsfV0DhtzCqbF6iHw3YVuB/Y8FeNW+vyAjebpYW9/XkFgpokFdxGe9DxiNBTnMHJ0JeXNQVgIyrDHekSfkhqsGMPDQQCXsH0i7DltHxBodKavS0TRO7eJb/yuVzGwM6y7xXKbEfZMd71sf2netBS9wtJKBGqUv/azaJqqbGvWlICe7p6e5kTIwxSGJgsI2YwUOQLHet15qz9EixrsFuNPCtMDGb6a1bZUwuPxr9CTsge0PcJkTrhGVa60Wnj7rDKvGg+yDupkutbguyOkLd8jvzlO8C3Hko2ssue6DYDF5bFIcMujqSoDSnoJK40sMsS2CDTO5XUirzyjqmTSAxmuM9ajoUKHLusma6+p4ldAFe8PPQZzwfa8zoV+6a2GrzjDpM85pBgJG71f5dno0Vea1hDd+z1u4/84T1ZN+HsUFKjnleJLCHf427Xs5kGdltK4NVeoGUkgQ4RW8DqvBL3jn4PJc0RKAGUnQIDdDwgbSUBwqdBLPqQTOUwhPU9AnvzTeKLX4TBRPnPi2zjyok1wHddC/TxjAg37BWAE9YurQMwZ4goSG3W+s8KwSPChR4GCOpBTgS7iQ1QDbLR/LySIRQ4C/eRzry7OFgMT8L8FY3Jq4P3AyXI1G0OQSUgqn5coAfMaY0yIyYL2UAg4XxkqaiNZam+TNPlbpf/1Q6VzGOeJIA9s86cnZkZwqgkxYJm/YTTFoLvGnX6RwDNBELsx3BRosdNAGD/c9QtiHWh2hI/v1jP7G3hPu639Smzd+dRyx/VhynZ/tZTEsFJPc+UyhbMjdqbijZvnijYu6XU2+wCAcPN4t7RVXqZaKrhRPKPPMXD/bufmF7/fCnX9I1vBWJrN6F9mCci22PgrbLKQMgIk8JrZ3ucKc32t7uZ/C59FsyWBX4yukkyoV31/pk8aZi4YYAo1uspBgxPK3E7NrIL/0f3wMMnl7Zle0ZzJULBlr8fsIB/kg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR11MB6186.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: /WAwD+AMaH9fCSCnrqbjurFQzYJSvEd+Y1Ao6QKJk8VOXsV/qlKKmtxoUKmYedpqOcaxAszdwRv7rOOSQ34m6HrtCI4xMqb+UXk1fc80iQmwcRrRakzv7uF8UDw/z5nYpJ3Y5toCWyQuxpfYT+VmLlBURSZAnvfBfZLrR0kgaBzw+FFiScHRPBSXrjUwJh0M9ekXiZuNbESCDXZGUNu8AbGE0jk6InwlhrPiaRI3Q2m9mduD7+CZoBlCwOX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V6FkyM3xfaC+6ZLeEfFK8wNqOkiYN5qbHaH8l10eQLmyHyYBSRRg0WvJ4LZedrTggDKJInwTsrN3DugxG1nb6KURAcK6laA6ahu3QA8EcSIqQhbZuatLoFOSn2Unz8G5QRakfo0w4xbVpP8zNWiIXL862DYGZQZLXMBxxUF6M8DSIoA0HSQLzy9QTnYRUOCA7xH0jPtXTz7S/Dph8nOghcRy/C4xow9LBTXQNKXQgbhlHiTCJx2Z/4RXYqPX5ZofSjR9tkOlwc4GXpkpKeysJevCOmYUPtD3g== Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY5PR11MB6186.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00538dda-8d53-4990-ace2-08dca1b0188b X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jul 2024 13:48:07.7278 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: nte7p3WOEU7kjfcibJ+DMYWzeV6l560+MJmrel8hnTqGO/XrbG8lxUkVhG+2JKUmCTFYUHtSl8+vWjsKaIbBsWQ05IfudK9W6qFPueWoc80= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7861 X-OriginatorOrg: intel.com X-Patchwork-Delegate: kuba@kernel.org Hi All, Currently, when setsockopt() API with SO_BINDTODEVICE option is called over a raw packet socket, then although the function doesn't return an error, the socket is not bound to a specific interface. The limitation itself is explicitly stated in man 7 socket, particularly that SO_BINDTODEVICE is "not supported for packet sockets". The patch below is to align the API, so that it does return failure in case of a packet socket. Signed-off-by: Grzegorz Szpetkowski grzegorz.szpetkowski@intel.com --- net/core/sock.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/core/sock.c b/net/core/sock.c index 100e975073ca..1b77241ac1f7 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -639,6 +639,11 @@ static int sock_bindtoindex_locked(struct sock *sk, int ifindex) if (ifindex < 0) goto out; + /* Not supported for packet sockets, use bind() instead */ + ret = -EOPNOTSUPP; + if (sk->sk_family == PF_PACKET) + goto out; + /* Paired with all READ_ONCE() done locklessly. */ WRITE_ONCE(sk->sk_bound_dev_if, ifindex);